This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]