This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix PR c/35434 (invalid alias attribute ICE)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 7 Feb 2009 00:33:21 +0000 (UTC)
- Subject: Fix PR c/35434 (invalid alias attribute ICE)
This patch fixes PR 35434, an ICE-on-invalid regression with an
invalid alias attribute.
Bootstrapped with no regressions on i686-pc-linux-gnu. Applied to
mainline. Will test for 4.3 branch and apply there subject to test
results.
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.
testsuite:
2009-02-06 Joseph Myers <joseph@codesourcery.com>
PR c/35434
* gcc.dg/attr-alias-4.c: New test.
Index: testsuite/gcc.dg/attr-alias-4.c
===================================================================
--- testsuite/gcc.dg/attr-alias-4.c (revision 0)
+++ testsuite/gcc.dg/attr-alias-4.c (revision 0)
@@ -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" } */
Index: c-common.c
===================================================================
--- c-common.c (revision 143984)
+++ c-common.c (working copy)
@@ -6015,7 +6015,12 @@
{
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,
--
Joseph S. Myers
joseph@codesourcery.com