re PR c/35434 (ICE with attribute alias)
authorJoseph Myers <joseph@codesourcery.com>
Sat, 7 Feb 2009 00:32:37 +0000 (00:32 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sat, 7 Feb 2009 00:32:37 +0000 (00:32 +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: r143998

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

index 1e450105874404676dab5d7ab6f03bcc6b09fa85..8befe01fa8ce20f6d2f8b5a17f5f0f3a6702f554 100644 (file)
@@ -1,3 +1,9 @@
+2009-02-06  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-06  Janis Johnson  <janis187@us.ibm.com>
 
        PR c/39035
index dbc9676b099b881083b87ff7d3bc42ebefbe7bad..e7b90674d50a04c12941c4f8e549b9b35210e045 100644 (file)
@@ -6015,7 +6015,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 bf0aca756ee907eb475c5a3c2843c299a31fb598..77e3ff7bd226840182bfdf875d8d822562f46f68 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-06  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/35434
+       * gcc.dg/attr-alias-4.c: New test.
+
 2009-02-06  Janis Johnson  <janis187@us.ibm.com>
 
        PR c/39035
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" } */