https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87526

            Bug ID: 87526
           Summary: attribute alias ignored on a local declaration of an
                    extern function
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

GCC accepts extern declarations of aliases at file scope but complains for such
declarations at local scope:

$ cat x.c && gcc -S -Wall x.c
void f (void) { }

extern __attribute ((alias ("f"))) void f1 (void);

void g (void)
{
  extern __attribute ((alias ("f"))) void f2 (void);
}
x.c: In function ‘g’:
x.c:7:3: warning: ‘alias’ attribute ignored [-Wattributes]
7 |   extern __attribute ((alias ("f"))) void f2 (void);
  |   ^~~~~~


The following comment above the block that normally processes the attribute
suggests that the distinction might be an unintended result of some sort of a
hack that has been perhaps been removed (the function doesn't use
DECL_EXTERNAL).

  /* Note that the very first time we process a nested declaration,
     decl_function_context will not be set.  Indeed, *would* never
     be set except for the DECL_INITIAL/DECL_EXTERNAL frobbery that
     we do below.  After such frobbery, pushdecl would set the context.
     In any case, this is never what we want.  */
  else if (decl_function_context (decl) == 0 && current_function_decl == NULL)

Reply via email to