C PATCH to use is_global_var
Jeff Law
law@redhat.com
Thu Jun 25 16:24:00 GMT 2015
On 06/25/2015 06:44 AM, Marek Polacek wrote:
> On Wed, Jun 24, 2015 at 05:16:33PM +0000, Joseph Myers wrote:
>> On Wed, 24 Jun 2015, Marek Polacek wrote:
>>
>>> diff --git gcc/c/c-decl.c gcc/c/c-decl.c
>>> index fc1fdf9..ab54db9 100644
>>> --- gcc/c/c-decl.c
>>> +++ gcc/c/c-decl.c
>>> @@ -2650,9 +2650,8 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
>>> tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common));
>>> olddecl->decl_with_vis.symtab_node = snode;
>>>
>>> - if ((DECL_EXTERNAL (olddecl)
>>> - || TREE_PUBLIC (olddecl)
>>> - || TREE_STATIC (olddecl))
>>> + if ((is_global_var (olddecl)
>>> + || TREE_PUBLIC (olddecl))
>>> && DECL_SECTION_NAME (newdecl) != NULL)
>>> set_decl_section_name (olddecl, DECL_SECTION_NAME (newdecl));
>>>
>>
>> At least this case covers both FUNCTION_DECL and VAR_DECL. If
>> is_global_var is appropriate for functions as well as variables, I think
>> it should be renamed (and have its comment updated to explain what it
>> means for functions).
>
> You raise a good point. After fair amount of investigating, I don't think
> is_global_var is appropriate for functions. (DECL_EXTERNAL || TREE_STATIC)
> for a function is only false for weird cases such as an inline function
> definition followed by redeclaring this function with noinline attribute, i.e.:
>
> inline void a (void) {}
> void a (void) __attribute__ ((noinline));
>
> void
> b ()
> {
> a ();
> }
>
> is_global_var with a FUNCTION_DECL is only called in tree-ssa-structalias.c
> and it seems like a mistake.
>
> So I propose to commit the following patch, which uses is_global_var only
> at places where we're dealing with a variable.
>
> Ok for trunk?
>
> 2015-06-25 Marek Polacek <polacek@redhat.com>
>
> * cilk.c (extract_free_variables): Use is_global_var.
>
> * c-decl.c: Use is_global_var throughout.
> * c-parser.c: Likewise.
> * c-typeck.c: Likewise.
OK.
jeff
More information about the Gcc-patches
mailing list