Skip to content

Diagnose GNU-style attribute differences with GCC #81767

@AaronBallman

Description

@AaronBallman

GCC was the initial implementer of the __attribute__(()) extension, which Clang has copied. However, over the years, Clang has diverged from GCC in terms of where we accept the attribute syntactically (we've also diverged in terms of specific attribute implementations, but this issue is specific to the syntax of __attribute__). It would be nice to issue a diagnostic telling users about those divergences, under the -Wgcc-compat warning (or a new warning grouped under that one).

e.g.,

[[]] __attribute__(()) void func1(); // Both accept
__attribute__(()) [[]] void func2(); // Clang accepts, GCC rejects

struct [[]] __attribute__(()) S1 { // Both accept
};
struct __attribute__(()) [[]] S2 { // Clang accepts, GCC rejects
};

https://godbolt.org/z/oq5T55jfE

(We should try to be exhaustive at finding all the places we've diverged, more may exist than what's listed here.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerenhancementImproving things as opposed to bug fixing, e.g. new or missing featureextension:gnuquality-of-implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions