Commit d3c29f57 by Geoff Lang

Add pragma errors for malformed pragmas.

Instead of always warning on invalid pragmas, only warn when the pragma type is not recognized and error when the syntax is invalid. Fixes: dEQP-GLES2.functional.shaders.preprocessor.pragmas.invalid_pragma_invalid_debug_vertex dEQP-GLES2.functional.shaders.preprocessor.pragmas.invalid_pragma_invalid_debug_fragment dEQP-GLES2.functional.shaders.preprocessor.pragmas.invalid_pragma_invalid_token_vertex dEQP-GLES2.functional.shaders.preprocessor.pragmas.invalid_pragma_invalid_token_fragment BUG=angleproject:989 Change-Id: Ibd584dc08a2436e163dfc52eeffdf2dac8a22cb8 Reviewed-on: https://chromium-review.googlesource.com/267639Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent b819d25d
......@@ -109,6 +109,10 @@ std::string Diagnostics::message(ID id)
return "invalid file number";
case PP_INVALID_LINE_DIRECTIVE:
return "invalid line directive";
case PP_INVALID_PRAGMA:
return "invalid pragma";
case PP_INVALID_PRAGMA_VALUE:
return "invalid pragma value, must be 'on' or 'off'";
// Errors end.
// Warnings begin.
case PP_EOF_IN_DIRECTIVE:
......
......@@ -61,6 +61,8 @@ class Diagnostics
PP_INVALID_LINE_NUMBER,
PP_INVALID_FILE_NUMBER,
PP_INVALID_LINE_DIRECTIVE,
PP_INVALID_PRAGMA,
PP_INVALID_PRAGMA_VALUE,
PP_ERROR_END,
PP_WARNING_BEGIN,
......
......@@ -616,7 +616,8 @@ void DirectiveParser::parsePragma(Token *token)
break;
case PRAGMA_VALUE:
value = token->text;
valid = valid && (token->type == Token::IDENTIFIER);
// Pragma value validation is handled in DirectiveHandler::handlePragma
// because the proper pragma value is dependent on the pragma name.
break;
case RIGHT_PAREN:
valid = valid && (token->type == ')');
......@@ -633,7 +634,7 @@ void DirectiveParser::parsePragma(Token *token)
(state == RIGHT_PAREN + 1)); // With value.
if (!valid)
{
mDiagnostics->report(Diagnostics::PP_UNRECOGNIZED_PRAGMA,
mDiagnostics->report(Diagnostics::PP_INVALID_PRAGMA,
token->location, name);
}
else if (state > PRAGMA_NAME) // Do not notify for empty pragma.
......
......@@ -98,9 +98,8 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation& loc,
if (invalidValue)
{
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"invalid pragma value", value,
"'on' or 'off' expected");
mDiagnostics.report(pp::Diagnostics::PP_INVALID_PRAGMA_VALUE, loc, value);
return;
}
}
}
......
......@@ -137,9 +137,9 @@ TEST_P(InvalidPragmaTest, Identified)
using testing::_;
// No handlePragma calls.
EXPECT_CALL(mDirectiveHandler, handlePragma(_, _, _, false)).Times(0);
// Unrecognized pragma warning.
// Invalid pragma error.
EXPECT_CALL(mDiagnostics,
print(pp::Diagnostics::PP_UNRECOGNIZED_PRAGMA,
print(pp::Diagnostics::PP_INVALID_PRAGMA,
pp::SourceLocation(0, 1), _));
preprocess(str, expected);
......
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