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]

Re: PATCH: PR c/26993: fix weakref ICE on malformed input


On Jun 29, 2006, Geoff Keating <geoffk@geoffk.org> wrote:

> Hi Alexandre,
>> PR c/26993
>> * c-common.c (handle_weakref_attribute): Ignore attribute in
>> the same conditions the alias attribute is ignored.

> This patch is OK, except that this comment:

>> +  /* We must ignore the attribute when it is associated with
>> +     local-scoped decls, since attribute alias is ignored and, more
>> +     importantly, such symbols do not have a DECL_WEAK field.  */

> is confusing, because some such symbols will be VAR_DECLs or
> FUNCTION_DECLs and they do have a DECL_WEAK field, it just isn't
> meaningful.

Thanks for the review and sorry that it took me so long to get to
this.  Here's what I'm checking in mainline and 4.1 branch.

for gcc/ChangeLog
from  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.

Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c.orig	2006-07-18 02:52:27.000000000 -0300
+++ gcc/c-common.c	2006-07-18 03:37:49.000000000 -0300
@@ -4828,6 +4828,16 @@ handle_weakref_attribute (tree *node, tr
 {
   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. */
-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Secretary for FSF Latin America        http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

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