PP: Rationalize return values of MacroExpand.

This results in better error recovery, including fewer
crashes on badly formed PP input.
This commit is contained in:
John Kessenich 2018-07-02 13:47:31 -06:00
parent 9cc81de096
commit 802c62bca4
8 changed files with 78 additions and 32 deletions

View file

@ -1061,8 +1061,17 @@ int TPpContext::tokenize(TPpToken& ppToken)
continue;
// expand macros
if (token == PpAtomIdentifier && MacroExpand(&ppToken, false, true) != 0)
continue;
if (token == PpAtomIdentifier) {
switch (MacroExpand(&ppToken, false, true)) {
case MacroExpandNotStarted:
break;
case MacroExpandError:
return EndOfInput;
case MacroExpandStarted:
case MacroExpandUndef:
continue;
}
}
switch (token) {
case PpAtomIdentifier: