re PR c/26993 (ICE on invalid code with weakref)
authorAlexandre Oliva <aoliva@redhat.com>
Tue, 18 Jul 2006 06:41:13 +0000 (06:41 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Tue, 18 Jul 2006 06:41:13 +0000 (06:41 +0000)
PR c/26993
* c-common.c (handle_weakref_attribute): Ignore attribute in
the same conditions the alias attribute is ignored.

From-SVN: r115545

gcc/ChangeLog
gcc/c-common.c

index 320f1631c115c1a5fef34c792d356dc5fd4e59c0..65b6b2f9bd084d59655d4e7ce64865af3cfe5d32 100644 (file)
@@ -1,3 +1,9 @@
+2006-07-18  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR c/26993
+       * c-common.c (handle_weakref_attribute): Ignore attribute in
+       the same conditions the alias attribute is ignored.
+
 2006-07-17  Carlos O'Donell  <carlos@codesourcery.com>
 
        * dbxout.c (dbxout_function_end): Do not increment scope_labelno.
index 61bf12bbb59df8feedf64cc73445bd7adeb3e314..9c260615fd710ce7ca791589b1f78c47229e30c9 100644 (file)
@@ -4828,6 +4828,16 @@ handle_weakref_attribute (tree *node, tree ARG_UNUSED (name), tree args,
 {
   tree attr = NULL_TREE;
 
+  /* We must ignore the attribute when it is associated with
+     local-scoped decls, since attribute alias is ignored and many
+     such symbols do not even have a DECL_WEAK field.  */
+  if (decl_function_context (*node) || current_function_decl)
+    {
+      warning (OPT_Wattributes, "%qE attribute ignored", name);
+      *no_add_attrs = true;
+      return NULL_TREE;
+    }
+
   /* The idea here is that `weakref("name")' mutates into `weakref,
      alias("name")', and weakref without arguments, in turn,
      implicitly adds weak. */