ExpandBuiltinMacro would strip the identifier and downstream users crash
when they encounter an identifier token with nullptr identifier info.
Found by afl-fuzz.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233497
91177308-0d34-0410-b5e6-
96231b3b80d8
// These expressions are only allowed within a preprocessor directive.
if (!PP.isParsingIfOrElifDirective()) {
PP.Diag(LParenLoc, diag::err_pp_directive_required) << II->getName();
+ // Return a valid identifier token.
+ assert(Tok.is(tok::identifier));
+ Tok.setIdentifierInfo(II);
return false;
}
}
};
}
+
+namespace crash_has_include {
+int has_include(int); // expected-note {{'has_include' declared here}}
+// expected-error@+1 {{__has_include must be used within a preprocessing directive}}
+int foo = __has_include(42); // expected-error {{use of undeclared identifier '__has_include'; did you mean 'has_include'?}}
+}