]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/35434 (ICE with attribute alias)
authorJoseph Myers <joseph@codesourcery.com>
Sun, 8 Feb 2009 19:02:56 +0000 (19:02 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sun, 8 Feb 2009 19:02:56 +0000 (19:02 +0000)
PR c/35434
* c-common.c (handle_alias_attribute): Disallow attribute for
anything not a FUNCTION_DECL or VAR_DECL.

testsuite:
* gcc.dg/attr-alias-4.c: New test.

From-SVN: r144019

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/attr-alias-4.c [new file with mode: 0644]

index f00b0185336ef133973cc4d94cf06200cb8d15a3..c3f1b7e2dc883d9dfa3076b99306f6f75a078221 100644 (file)
@@ -1,3 +1,9 @@
+2009-02-08  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/35434
+       * c-common.c (handle_alias_attribute): Disallow attribute for
+       anything not a FUNCTION_DECL or VAR_DECL.
+
 2009-02-08  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/36432
index 18b55c2e208aa06591f753586f3ca33da01fb0f3..4cafe05a0b5c8d1771627746cba90447dc843d99 100644 (file)
@@ -5534,7 +5534,12 @@ handle_alias_attribute (tree *node, tree name, tree args,
 {
   tree decl = *node;
 
-  if ((TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
+  if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL)
+    {
+      warning (OPT_Wattributes, "%qE attribute ignored", name);
+      *no_add_attrs = true;
+    }
+  else if ((TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
       || (TREE_CODE (decl) != FUNCTION_DECL 
          && TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl))
       /* A static variable declaration is always a tentative definition,
index 386d75a9e8703c4609cfd9cdbab4bfbedc1b6aa6..b24427b167686ef07ce40115e678a1d0c5d2c038 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-08  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/35434
+       * gcc.dg/attr-alias-4.c: New test.
+
 2009-02-08  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/36432
diff --git a/gcc/testsuite/gcc.dg/attr-alias-4.c b/gcc/testsuite/gcc.dg/attr-alias-4.c
new file mode 100644 (file)
index 0000000..fb15a20
--- /dev/null
@@ -0,0 +1,4 @@
+/* ICE on invalid alias attribute: PR 35434.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+typedef int i __attribute__((alias("j"))); /* { dg-warning "ignored" } */