OSDN Git Service

2008-03-27 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Mar 2008 16:34:55 +0000 (16:34 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Mar 2008 16:34:55 +0000 (16:34 +0000)
PR c/32511
* c-common.c (handle_weak_attribute): Reject combination of
weak and inline.

* gcc.dg/attr-weak-1.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133646 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/attr-weak-1.c [new file with mode: 0644]

index 215f0b2..19cb567 100644 (file)
@@ -1,5 +1,11 @@
 2008-03-27  Richard Guenther  <rguenther@suse.de>
 
+       PR c/32511
+       * c-common.c (handle_weak_attribute): Reject combination of
+       weak and inline.
+
+2008-03-27  Richard Guenther  <rguenther@suse.de>
+
        PR tree-optimization/32810
        * tree-ssa-ccp.c (get_symbol_constant_value): Strip useless
        conversions from DECL_INITIAL.
index 1b62974..7e609de 100644 (file)
@@ -5518,11 +5518,16 @@ handle_weak_attribute (tree *node, tree name,
                       bool * ARG_UNUSED (no_add_attrs))
 {
   if (TREE_CODE (*node) == FUNCTION_DECL
-      || TREE_CODE (*node) == VAR_DECL)
+      && DECL_DECLARED_INLINE_P (*node))
+    {
+      error ("inline function %q+D cannot be declared weak", *node);
+      *no_add_attrs = true;
+    }
+  else if (TREE_CODE (*node) == FUNCTION_DECL
+          || TREE_CODE (*node) == VAR_DECL)
     declare_weak (*node);
   else
     warning (OPT_Wattributes, "%qE attribute ignored", name);
-       
 
   return NULL_TREE;
 }
index abaed69..1752896 100644 (file)
@@ -1,5 +1,10 @@
 2008-03-27  Richard Guenther  <rguenther@suse.de>
 
+       PR c/32511
+       * gcc.dg/attr-weak-1.c: New testcase.
+
+2008-03-27  Richard Guenther  <rguenther@suse.de>
+
        PR tree-optimization/32810
        * gcc.dg/tree-ssa/ssa-ccp-18.c: New testcase.
 
diff --git a/gcc/testsuite/gcc.dg/attr-weak-1.c b/gcc/testsuite/gcc.dg/attr-weak-1.c
new file mode 100644 (file)
index 0000000..014e37d
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+
+__inline void foo(void) __attribute__((weak));  /* { dg-error "inline.*weak" } */
+