Commit d0e6f680 by Nicolas Capens

Unexpected tokens after conditionals should be an error instead of a warning.

Change-Id: I49d6d36ecf9a5f0d3d333422b3e4970192617c05 Reviewed-on: https://swiftshader-review.googlesource.com/5180Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent ab4505a2
...@@ -53,6 +53,7 @@ class Diagnostics ...@@ -53,6 +53,7 @@ class Diagnostics
CONDITIONAL_ELIF_WITHOUT_IF, CONDITIONAL_ELIF_WITHOUT_IF,
CONDITIONAL_ELIF_AFTER_ELSE, CONDITIONAL_ELIF_AFTER_ELSE,
CONDITIONAL_UNTERMINATED, CONDITIONAL_UNTERMINATED,
CONDITIONAL_UNEXPECTED_TOKEN,
INVALID_EXTENSION_NAME, INVALID_EXTENSION_NAME,
INVALID_EXTENSION_BEHAVIOR, INVALID_EXTENSION_BEHAVIOR,
INVALID_EXTENSION_DIRECTIVE, INVALID_EXTENSION_DIRECTIVE,
...@@ -67,7 +68,6 @@ class Diagnostics ...@@ -67,7 +68,6 @@ class Diagnostics
WARNING_BEGIN, WARNING_BEGIN,
EOF_IN_DIRECTIVE, EOF_IN_DIRECTIVE,
CONDITIONAL_UNEXPECTED_TOKEN,
UNRECOGNIZED_PRAGMA, UNRECOGNIZED_PRAGMA,
WARNING_END WARNING_END
}; };
......
...@@ -490,7 +490,7 @@ void DirectiveParser::parseElse(Token* token) ...@@ -490,7 +490,7 @@ void DirectiveParser::parseElse(Token* token)
block.skipGroup = block.foundValidGroup; block.skipGroup = block.foundValidGroup;
block.foundValidGroup = true; block.foundValidGroup = true;
// Warn if there are extra tokens after #else. // Check if there are extra tokens after #else.
mTokenizer->lex(token); mTokenizer->lex(token);
if (!isEOD(token)) if (!isEOD(token))
{ {
...@@ -554,7 +554,7 @@ void DirectiveParser::parseEndif(Token* token) ...@@ -554,7 +554,7 @@ void DirectiveParser::parseEndif(Token* token)
mConditionalStack.pop_back(); mConditionalStack.pop_back();
// Warn if there are tokens after #endif. // Check if there are tokens after #endif.
mTokenizer->lex(token); mTokenizer->lex(token);
if (!isEOD(token)) if (!isEOD(token))
{ {
...@@ -915,7 +915,7 @@ int DirectiveParser::parseExpressionIf(Token* token) ...@@ -915,7 +915,7 @@ int DirectiveParser::parseExpressionIf(Token* token)
macroExpander.lex(token); macroExpander.lex(token);
expressionParser.parse(token, &expression); expressionParser.parse(token, &expression);
// Warn if there are tokens after #if expression. // Check if there are tokens after #if expression.
if (!isEOD(token)) if (!isEOD(token))
{ {
mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN, mDiagnostics->report(Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN,
...@@ -943,7 +943,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token) ...@@ -943,7 +943,7 @@ int DirectiveParser::parseExpressionIfdef(Token* token)
MacroSet::const_iterator iter = mMacroSet->find(token->text); MacroSet::const_iterator iter = mMacroSet->find(token->text);
int expression = iter != mMacroSet->end() ? 1 : 0; int expression = iter != mMacroSet->end() ? 1 : 0;
// Warn if there are tokens after #ifdef expression. // Check if there are tokens after #ifdef expression.
mTokenizer->lex(token); mTokenizer->lex(token);
if (!isEOD(token)) if (!isEOD(token))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment