re PR target/33963 (Dllimport attribute wrongly accepted on typedefs)
authorJoseph Myers <joseph@codesourcery.com>
Thu, 28 Feb 2008 12:34:51 +0000 (12:34 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Thu, 28 Feb 2008 12:34:51 +0000 (12:34 +0000)
PR target/33963
* tree.c (handle_dll_attribute): Disallow TYPE_DECLs for types
other than structures and unions.

From-SVN: r132744

gcc/ChangeLog
gcc/tree.c

index 4d168e35b2fcb1517762450230cd5f7544590ac8..a0663ff0d3ae7a552ec2b114b2a8263e8ec6cdef 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-28  Joseph Myers  <joseph@codesourcery.com>
+
+       PR target/33963
+       * tree.c (handle_dll_attribute): Disallow TYPE_DECLs for types
+       other than structures and unions.
+
 2008-02-28  Richard Guenther  <rguenther@suse.de>
 
        Revert:
index 85b0b1c11c67fa191fef7a893561a2770db06b43..c39bccda0985e37275fae2934f3b1870c9818037 100644 (file)
@@ -3971,6 +3971,16 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags,
       return NULL_TREE;
     }
 
+  if (TREE_CODE (node) == TYPE_DECL
+      && TREE_CODE (TREE_TYPE (node)) != RECORD_TYPE
+      && TREE_CODE (TREE_TYPE (node)) != UNION_TYPE)
+    {
+      *no_add_attrs = true;
+      warning (OPT_Wattributes, "%qs attribute ignored",
+              IDENTIFIER_POINTER (name));
+      return NULL_TREE;
+    }
+
   /* Report error on dllimport ambiguities seen now before they cause
      any damage.  */
   else if (is_attribute_p ("dllimport", name))