-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix off-by-one error in PPCaching.cpp token annotation assertion
This assert is intended to defend against backtracking into the middle of a sequence of tokens that is being replaced with an annotation, but it's OK if we backtrack to the exact position of the start of the annotation sequence. Use a <= comparison instead of <. Fixes PR25946 llvm-svn: 284777
- Loading branch information
Showing
2 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: %clang_cc1 -verify %s | ||
|
||
// PR25946 | ||
// We had an off-by-one error in an assertion when annotating A<int> below. Our | ||
// error recovery checks if A<int> is a constructor declarator, and opens a | ||
// TentativeParsingAction. Then we attempt to annotate the token at the exact | ||
// position that we want to possibly backtrack to, and this used to crash. | ||
|
||
template <typename T> class A {}; | ||
|
||
// expected-error@+1 {{expected '{' after base class list}} | ||
template <typename T> class B : T // not ',' or '{' | ||
// expected-error@+3 {{C++ requires a type specifier for all declarations}} | ||
// expected-error@+2 {{expected ';' after top level declarator}} | ||
// expected-error@+1 {{expected ';' after class}} | ||
A<int> { | ||
}; |