This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PING][C] Fix PR32511, GCC inlines weak function
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: "Richard Guenther" <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 27 Mar 2008 08:48:35 -0700
- Subject: Re: [PING][C] Fix PR32511, GCC inlines weak function
- References: <Pine.LNX.4.64.0803251122590.4133@zhemvz.fhfr.qr>
Hi,
A similar bug for weak and hidden function:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32219
H.J.
On Tue, Mar 25, 2008 at 3:24 AM, Richard Guenther <rguenther@suse.de> wrote:
>
> 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" } */
> +
>