aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseTentative.cpp
diff options
context:
space:
mode:
authorcor3ntin <corentinjabot@gmail.com>2024-07-13 08:53:02 +0200
committerGitHub <noreply@github.com>2024-07-13 08:53:02 +0200
commit1fe406fffe11dad0457a4d214ce67bf492196145 (patch)
treec7d78a3a0899a9cc9e3dcad317218c3804e97229 /clang/lib/Parse/ParseTentative.cpp
parent40ed1946f27ea64916993ea8fab947f2ad804063 (diff)
downloadllvm-1fe406fffe11dad0457a4d214ce67bf492196145.zip
llvm-1fe406fffe11dad0457a4d214ce67bf492196145.tar.gz
llvm-1fe406fffe11dad0457a4d214ce67bf492196145.tar.bz2
[Clang] Fix parsing of reversible type traits in template arguments (#95969)
Constructs like `__is_pointer(Foo)` are never considered to be functions declarations. This matches usages in libstdc++, and we can hope no one else redefine these reserved identifiers. Fixes #95598
Diffstat (limited to 'clang/lib/Parse/ParseTentative.cpp')
-rw-r--r--clang/lib/Parse/ParseTentative.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index ea17c3e3..0142271 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1385,6 +1385,15 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
if (!getLangOpts().ObjC && Next.is(tok::identifier))
return TPResult::True;
+ // If this identifier was reverted from a token ID, and the next token
+ // is a '(', we assume it to be a use of a type trait, so this
+ // can never be a type name.
+ if (Next.is(tok::l_paren) &&
+ Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier() &&
+ isRevertibleTypeTrait(Tok.getIdentifierInfo())) {
+ return TPResult::False;
+ }
+
if (Next.isNot(tok::coloncolon) && Next.isNot(tok::less)) {
// Determine whether this is a valid expression. If not, we will hit
// a parse error one way or another. In that case, tell the caller that