[lex] Don't create a garbage token if parsing of __has_include fails.
It will crash downstream somewhere. Found by afl-fuzz. llvm-svn: 233493
This commit is contained in:
parent
3012e59bc7
commit
18ff02dd51
|
@ -1461,9 +1461,11 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
|
|||
Value = EvaluateHasInclude(Tok, II, *this);
|
||||
else
|
||||
Value = EvaluateHasIncludeNext(Tok, II, *this);
|
||||
|
||||
if (Tok.isNot(tok::r_paren))
|
||||
return;
|
||||
OS << (int)Value;
|
||||
if (Tok.is(tok::r_paren))
|
||||
Tok.setKind(tok::numeric_constant);
|
||||
Tok.setKind(tok::numeric_constant);
|
||||
} else if (II == Ident__has_warning) {
|
||||
// The argument should be a parenthesized string literal.
|
||||
// The argument to these builtins should be a parenthesized identifier.
|
||||
|
|
|
@ -163,6 +163,18 @@ __has_include
|
|||
#if __has_include
|
||||
#endif
|
||||
|
||||
// expected-error@+1 {{missing '(' after '__has_include'}}
|
||||
#if __has_include'x'
|
||||
#endif
|
||||
|
||||
// expected-error@+1 {{expected "FILENAME" or <FILENAME>}}
|
||||
#if __has_include('x'
|
||||
#endif
|
||||
|
||||
// expected-error@+1 {{expected "FILENAME" or <FILENAME}} expected-error@+1 {{expected end of line in preprocessor expression}}
|
||||
#if __has_include('x')
|
||||
#endif
|
||||
|
||||
// expected-error@+1 {{missing ')' after '__has_include'}} // expected-error@+1 {{expected value in expression}} // expected-note@+1 {{to match this '('}}
|
||||
#if __has_include(<stdint.h>
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue