Commit d7013c03 by Tobin Ehlis Committed by Commit Bot

Merge ESSL pre-processsor token errors

In both the ESSL 1.00 & 3.00 specifications having an extension directive after a pre-processor token is an error. Merging those two enum cases to be a single case. WebGL is handled as a separate warning case for any shader version before 3.00. Also this change now correctly marks 1.00 shaders that break this rule to be invalid so the ExtensionAfterNonPreProcessorTokenESSL1 test no longer expects handleExtension() to be called. BUG=chromium:971660 Change-Id: I37b10cc0fb3a0efd6200a478171e005a96478255 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1661395Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>
parent e962b6a6
......@@ -115,10 +115,8 @@ const char *Diagnostics::message(ID id)
return "invalid file number";
case PP_INVALID_LINE_DIRECTIVE:
return "invalid line directive";
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1:
return "extension directive must occur before any non-preprocessor tokens in ESSL1";
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3:
return "extension directive must occur before any non-preprocessor tokens in ESSL3";
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL:
return "extension directive must occur before any non-preprocessor tokens in ESSL";
case PP_UNDEFINED_SHIFT:
return "shift exponent is negative or undefined";
case PP_TOKENIZER_ERROR:
......
......@@ -64,8 +64,7 @@ class Diagnostics
PP_INVALID_LINE_NUMBER,
PP_INVALID_FILE_NUMBER,
PP_INVALID_LINE_DIRECTIVE,
PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3,
PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL,
PP_UNDEFINED_SHIFT,
PP_TOKENIZER_ERROR,
PP_ERROR_END,
......
......@@ -668,24 +668,16 @@ void DirectiveParser::parseExtension(Token *token)
}
if (valid && mSeenNonPreprocessorToken)
{
if (mShaderVersion >= 300)
if (mSettings.shaderSpec == SH_WEBGL_SPEC && mShaderVersion < 300)
{
mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3,
mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL,
token->location, token->text);
valid = false;
}
else
{
if (mSettings.shaderSpec == SH_WEBGL_SPEC)
{
mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL,
token->location, token->text);
}
else
{
mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
token->location, token->text);
}
mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL,
token->location, token->text);
valid = false;
}
}
if (valid)
......
......@@ -74,10 +74,8 @@ TEST_F(ExtensionTest, ExtensionAfterNonPreProcessorTokenESSL1)
const char *expected = "int baz = 1;\n\n";
using testing::_;
// Directive successfully parsed.
EXPECT_CALL(mDirectiveHandler, handleExtension(pp::SourceLocation(0, 2), "foo", "bar"));
// Expect a warning about extension pragmas after non-preprocessor tokens.
EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1, _, _));
// Expect an error about extension pragmas after non-preprocessor tokens.
EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL, _, _));
preprocess(str, expected);
}
......@@ -93,8 +91,8 @@ TEST_F(ExtensionTest, ExtensionAfterNonPreProcessorTokenESSL3)
using testing::_;
// Directive successfully parsed.
EXPECT_CALL(mDirectiveHandler, handleVersion(pp::SourceLocation(0, 1), 300));
// Expect a error about extension pragmas after non-preprocessor tokens.
EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3, _, _));
// Expect an error about extension pragmas after non-preprocessor tokens.
EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL, _, _));
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