aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseTentative.cpp
diff options
context:
space:
mode:
authorShafik Yaghmour <shafik.yaghmour@intel.com>2023-06-29 15:38:14 -0700
committerShafik Yaghmour <shafik.yaghmour@intel.com>2023-06-29 15:42:18 -0700
commitd1fcce97a6af872e64b365d80d5b85eb94487dc8 (patch)
tree15e5da2586266bd5232811da98c799ab0aa8b5c7 /clang/lib/Parse/ParseTentative.cpp
parent40cdb220f5af63160679def0aee23aa1cbd49b60 (diff)
downloadllvm-d1fcce97a6af872e64b365d80d5b85eb94487dc8.zip
llvm-d1fcce97a6af872e64b365d80d5b85eb94487dc8.tar.gz
llvm-d1fcce97a6af872e64b365d80d5b85eb94487dc8.tar.bz2
[Clang] Fix crash in isCXXDeclarationSpecifier when attempting to annotate template name
When attempting to decide if in C++17 a type template for class template argument deduction and the code is ill-formed the condition to break is checking the current token is an identifier when it should be checking if the next token is not ::. This fixes: https://github.com/llvm/llvm-project/issues/57495 https://github.com/llvm/llvm-project/issues/63052 Differential Revision: https://reviews.llvm.org/D134334
Diffstat (limited to 'clang/lib/Parse/ParseTentative.cpp')
-rw-r--r--clang/lib/Parse/ParseTentative.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index 89e543f..b7c83bb 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1656,7 +1656,10 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
if (getLangOpts().CPlusPlus17) {
if (TryAnnotateTypeOrScopeToken())
return TPResult::Error;
- if (Tok.isNot(tok::identifier))
+ // If we annotated then the current token should not still be ::
+ // FIXME we may want to also check for tok::annot_typename but
+ // currently don't have a test case.
+ if (Tok.isNot(tok::annot_cxxscope))
break;
}