* H. J. Lu:

> @@ -8106,6 +8109,34 @@ grokdeclarator (const struct c_declarator *declarator,
>      else
>        {
>       /* It's a variable.  */
> +
> +     const char *stack_protect_guard_name
> +       = targetm.stack_protect_guard_symbol;
> +     if (stack_protect_guard_name)
> +       {
> +         /* If the variable name is the same as the stack protect
> +            guard, use the stack protect guard decl.  */
> +         tree guard_decl = targetm.stack_protect_guard ();
> +         if (guard_decl
> +             && VAR_P (guard_decl)
> +             && strcmp (stack_protect_guard_name,
> +                        IDENTIFIER_POINTER (declarator->u.id.id)) == 0)
> +           {
> +             /* Allow different types with the same size.  */
> +             tree guard_type = TREE_TYPE (guard_decl);
> +             if (TYPE_PRECISION (type)
> +                 != TYPE_PRECISION (guard_type))
> +               {
> +                 error ("conflicting types for %s; have %qT, "
> +                        "should be %qT",
> +                        stack_protect_guard_name, type,
> +                        guard_type);
> +                 return error_mark_node;
> +               }
> +             return guard_decl;
> +           }
> +       }

It seems to me this goes in the wrong direction: guard_decl doesn't have
proper location information, so any subsequent diagnostics against it
will look wrong.  I would expect this to be more like the re-declaration
of builtins.

But I'm not a GCC expert.

Thanks,
Florian

Reply via email to