[PATCH] Fix PR32511

Richard Guenther rguenther@suse.de
Tue Jan 11 10:31:00 GMT 2011


This fixes PR32511, us rejecting inline weak function declarations.
The original problem in the PR was fixed with LTO work.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-10-01  Richard Guenther  <rguenther@suse.de>

	PR middle-end/32511
	* c-common.c (handle_weak_attribute): Warn instead of error
	on declaring an inline function weak.

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

Index: gcc/c-family/c-common.c
===================================================================
*** gcc/c-family/c-common.c	(revision 168626)
--- gcc/c-family/c-common.c	(working copy)
*************** handle_weak_attribute (tree *node, tree
*** 6656,6662 ****
    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 (lookup_attribute ("ifunc", DECL_ATTRIBUTES (*node)))
--- 6656,6662 ----
    if (TREE_CODE (*node) == FUNCTION_DECL
        && DECL_DECLARED_INLINE_P (*node))
      {
!       warning (OPT_Wattributes, "inline function %q+D declared weak", *node);
        *no_add_attrs = true;
      }
    else if (lookup_attribute ("ifunc", DECL_ATTRIBUTES (*node)))
Index: gcc/testsuite/gcc.dg/attr-weak-1.c
===================================================================
*** gcc/testsuite/gcc.dg/attr-weak-1.c	(revision 168626)
--- gcc/testsuite/gcc.dg/attr-weak-1.c	(working copy)
***************
*** 1,4 ****
  /* { dg-do compile } */
  
! __inline void foo(void) __attribute__((weak));  /* { dg-error "inline.*weak" } */
  
--- 1,4 ----
  /* { dg-do compile } */
  
! __inline void foo(void) __attribute__((weak));  /* { dg-warning "inline.*weak" } */
  



More information about the Gcc-patches mailing list