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

--- Comment #16 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
I think it's clear that __has_c_attribute(gnu::unused) should only return 1 if
the [[gnu::unused]] syntax is actually parsed. (An unavoidable limitation if it
might return 1 in pre-C23 modes is that if it's used with -pedantic /
-pedantic-errors, such a usage of [[gnu::unused]] would then be diagnosed -
since another principle is that -pedantic / -pedantic-errors should not affect
semantics, in particular not change the return value of __has_c_attribute.)

I also think that __has_c_attribute(gnu::unused) should always parse
successfully in #if, even if it returns 0 in some cases.

It's probably reasonable to accept :: in [[]] attributes in pre-C23 standard
modes where those are two consecutive : tokens (the use of the [[]] syntax at
all would result in a pedwarn-if-pedantic).

Ideally there might be a marker on the tokens as suggested to indicate whether
two such tokens would have been :: if in C23 mode, to avoid accepting other
variants where the two tokens are separated in the sources. (The only reason
it's not valid to produce a single preprocessing token in pre-C23 mode is to
deal with corner cases such as ##-concatenating < :: > where the concatenations
are valid in pre-C23 mode, producing digraphs equivalent to [], but invalid in
C23 mode. Once the preprocessing tokens are converted to tokens, pre-C23
doesn't have any valid cases of two consecutive : tokens.)

Reply via email to