re PR tree-optimization/47190 (ICE: in function_and_variable_visibility, at ipa.c...
authorRichard Guenther <rguenther@suse.de>
Wed, 26 Jan 2011 14:03:54 +0000 (14:03 +0000)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 26 Jan 2011 14:03:54 +0000 (14:03 +0000)
PR tree-optimization/47190
 * cgraphunit.c (process_common_attributes): New function.
        (process_function_and_variable_attributes): Use it.
* gcc.dg/attr-weakref-3.c: New testcase.

From-SVN: r169288

gcc/ChangeLog
gcc/cgraphunit.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/attr-weakref-3.c [new file with mode: 0644]

index dd7e7530047615447f45a42769f43eec02583a5d..a358ec7e4359205c60be37340275c275cc5b487e 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-26  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/47190
+        * cgraphunit.c (process_common_attributes): New function.
+        (process_function_and_variable_attributes): Use it.
+
 2011-01-26  Richard Guenther  <rguenther@suse.de>
 
        PR lto/47423
index 92e5aa9546120c60b2b9b176a593162aa9007dbf..2eb3285290b77dc0e3c862c08648c3fc45461ef1 100644 (file)
@@ -791,6 +791,23 @@ cgraph_analyze_function (struct cgraph_node *node)
   current_function_decl = save;
 }
 
+/* Process attributes common for vars and functions.  */
+
+static void
+process_common_attributes (tree decl)
+{
+  tree weakref = lookup_attribute ("weakref", DECL_ATTRIBUTES (decl));
+
+  if (weakref && !lookup_attribute ("alias", DECL_ATTRIBUTES (decl)))
+    {
+      warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
+                 "%<weakref%> attribute should be accompanied with"
+                 " an %<alias%> attribute");
+      DECL_WEAK (decl) = 0;
+      remove_attribute ("weakref", DECL_ATTRIBUTES (decl));
+    }
+}
+
 /* Look for externally_visible and used attributes and mark cgraph nodes
    accordingly.
 
@@ -843,6 +860,7 @@ process_function_and_variable_attributes (struct cgraph_node *first,
          else if (node->local.finalized)
             cgraph_mark_needed_node (node);
        }
+      process_common_attributes (decl);
     }
   for (vnode = varpool_nodes; vnode != first_var; vnode = vnode->next)
     {
@@ -869,6 +887,7 @@ process_function_and_variable_attributes (struct cgraph_node *first,
          else if (vnode->finalized)
            varpool_mark_needed_node (vnode);
        }
+      process_common_attributes (decl);
     }
 }
 
index 284d6509c442583139e131a90f929a68fe726330..2d7d765dc15fb13496950bd0ded4371c2366807f 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-26  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/47190
+       * gcc.dg/attr-weakref-3.c: New testcase.
+
 2011-01-26  Dave Korn  <dave.korn.cygwin@gmail.com>
 
        PR c++/43601
diff --git a/gcc/testsuite/gcc.dg/attr-weakref-3.c b/gcc/testsuite/gcc.dg/attr-weakref-3.c
new file mode 100644 (file)
index 0000000..fe4462a
--- /dev/null
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-require-weak "" } */
+static int i __attribute__ ((weakref)); /* { dg-warning "attribute should be accompanied" } */