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

            Bug ID: 87591
           Summary: inconsistent spelling of attribute keyword and
                    attribute names
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

GCC recognizes two spelling of the attribute keyword: 1) with two leading and
two trailing underscores, and 2) with just two leading underscores.  However,
it recognizes only form (1) of attribute names.  The test case below shows the
difference.

I could find only three references to form (2) in the GCC 8 manual.  Two under
the -Wabi option and one under -fvisibility.  None in the documentation of
attribute syntax.  There are plenty of tests that make use of this form but
none appears to be one dedicated to the spelling of the keyword which makes me
wonder if the difference between the support for no trailing underscores in
__attribute vs an attribute name is incidental.

Either way, since form (2) has been supported for eons, not just by GCC but by
other compilers it should be documented and its absence with attribute names
noted in the manual.

$ cat y.c && gcc -S -Wall y.c
__attribute__ ((aligned)) void f (void);     // ok
__attribute ((aligned)) void f (void);       // ok

__attribute ((__aligned__)) void f (void);   // ok
__attribute ((__aligned)) void f (void);     // not ok
y.c:5:1: warning: ‘__aligned’ attribute directive ignored [-Wattributes]
5 | __attribute ((__aligned)) void f (void);     // not ok
  | ^~~~~~~~~~~

Reply via email to