]> gcc.gnu.org Git - gcc.git/commit
c: Handle scoped attributes in __has*attribute and scoped attribute parsing changes...
authorJakub Jelinek <jakub@redhat.com>
Thu, 22 Feb 2024 18:32:02 +0000 (19:32 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 11 Jun 2024 10:35:32 +0000 (12:35 +0200)
commitc2cd5eefccf54074ea9f8dc677a9a05b8a880ae4
tree6aa9237151a9001f4820dc2b80b83eac17922f9c
parentfda7a897d037ff1c59630f0a741eb20e68f45848
c: Handle scoped attributes in __has*attribute and scoped attribute parsing changes in -std=c11 etc. modes [PR114007]

We aren't able to parse __has_attribute (vendor::attr) (and __has_c_attribute
and __has_cpp_attribute) in strict C < C23 modes.  While in -std=gnu* modes
or in -std=c23 there is CPP_SCOPE token, in -std=c* (except for -std=c23)
there are is just a pair of CPP_COLON tokens.
The c-lex.cc hunk adds support for that, but always returns 0 in that case
unlike the GCC 14+ version.

2024-02-22  Jakub Jelinek  <jakub@redhat.com>

PR c/114007
gcc/c-family/
* c-lex.cc (c_common_has_attribute): Parse 2 CPP_COLONs with
the first one with COLON_SCOPE flag the same as CPP_SCOPE but
ensure 0 is returned then.
gcc/testsuite/
* gcc.dg/c23-attr-syntax-8.c: New test.
libcpp/
* include/cpplib.h (COLON_SCOPE): Define to PURE_ZERO.
* lex.cc (_cpp_lex_direct): When lexing CPP_COLON with another
colon after it, if !CPP_OPTION (pfile, scope) set COLON_SCOPE
flag on the first CPP_COLON token.

(cherry picked from commit 37127ed975e09813eaa2d1cf1062055fce45dd16)
gcc/c-family/c-lex.cc
gcc/testsuite/gcc.dg/c23-attr-syntax-8.c [new file with mode: 0644]
libcpp/include/cpplib.h
libcpp/lex.cc
This page took 0.07098 seconds and 6 git commands to generate.