This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PING][C] Fix PR32511, GCC inlines weak function
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 25 Mar 2008 11:24:01 +0100 (CET)
- Subject: [PING][C] Fix PR32511, GCC inlines weak function
Ping!
Thanks,
Richard.
2008-02-18 Richard Guenther <rguenther@suse.de>
PR c/32511
* c-common.c (handle_weak_attribute): Reject combination of
weak and inline.
* gcc.dg/attr-weak-1.c: New testcase.
Index: c-common.c
===================================================================
*** c-common.c (revision 132388)
--- c-common.c (working copy)
*************** handle_weak_attribute (tree *node, tree
*** 5492,5502 ****
bool * ARG_UNUSED (no_add_attrs))
{
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;
}
--- 5492,5507 ----
bool * ARG_UNUSED (no_add_attrs))
{
if (TREE_CODE (*node) == FUNCTION_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: testsuite/gcc.dg/attr-weak-1.c
===================================================================
*** testsuite/gcc.dg/attr-weak-1.c (revision 0)
--- testsuite/gcc.dg/attr-weak-1.c (revision 0)
***************
*** 0 ****
--- 1,4 ----
+ /* { dg-do compile } */
+
+ __inline void foo(void) __attribute__((weak)); /* { dg-error "inline.*weak" } */
+