Commit 93121f36 by Tobin Ehlis Committed by Commit Bot

Make invalid extension directive a CHROMEOS warning

This change allows extension directive after ESSL1.0 non-preprocessor tokens on CHROMEOS. CHROMEOS kiosks have a video player that violates this spec requirement so just flagging as a warning to prevent failed video playback. Added ANGLE_PLATFORM_CHROMEOS define to build config in order to only make this a warning on CHROMEOS. Split the ESSL1 & ESSL3 cases back out as ESSL3 had always been an error on all platforms in the past and so want to keep it that way. Bug: 1003005 Bug: angleproject:4023 Change-Id: Ia931b3a8dad82dbda4c9c9e49a9c1090116397b5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1866464Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>
parent 01cfefef
...@@ -106,6 +106,10 @@ config("internal_config") { ...@@ -106,6 +106,10 @@ config("internal_config") {
if (angle_enable_trace) { if (angle_enable_trace) {
defines += [ "ANGLE_ENABLE_DEBUG_TRACE=1" ] defines += [ "ANGLE_ENABLE_DEBUG_TRACE=1" ]
} }
if (is_chromeos) {
defines += [ "ANGLE_PLATFORM_CHROMEOS" ]
}
} }
config("extra_warnings") { config("extra_warnings") {
......
...@@ -115,8 +115,10 @@ const char *Diagnostics::message(ID id) ...@@ -115,8 +115,10 @@ const char *Diagnostics::message(ID id)
return "invalid file number"; return "invalid file number";
case PP_INVALID_LINE_DIRECTIVE: case PP_INVALID_LINE_DIRECTIVE:
return "invalid line directive"; return "invalid line directive";
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL: case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1:
return "extension directive must occur before any non-preprocessor tokens in ESSL"; 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_UNDEFINED_SHIFT: case PP_UNDEFINED_SHIFT:
return "shift exponent is negative or undefined"; return "shift exponent is negative or undefined";
case PP_TOKENIZER_ERROR: case PP_TOKENIZER_ERROR:
......
...@@ -64,7 +64,11 @@ class Diagnostics ...@@ -64,7 +64,11 @@ class Diagnostics
PP_INVALID_LINE_NUMBER, PP_INVALID_LINE_NUMBER,
PP_INVALID_FILE_NUMBER, PP_INVALID_FILE_NUMBER,
PP_INVALID_LINE_DIRECTIVE, PP_INVALID_LINE_DIRECTIVE,
PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL, // This is just a warning on CHROME OS http://anglebug.com/4023
#if !defined(ANGLE_PLATFORM_CHROMEOS)
PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
#endif
PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3,
PP_UNDEFINED_SHIFT, PP_UNDEFINED_SHIFT,
PP_TOKENIZER_ERROR, PP_TOKENIZER_ERROR,
PP_ERROR_END, PP_ERROR_END,
...@@ -72,6 +76,9 @@ class Diagnostics ...@@ -72,6 +76,9 @@ class Diagnostics
PP_WARNING_BEGIN, PP_WARNING_BEGIN,
PP_EOF_IN_DIRECTIVE, PP_EOF_IN_DIRECTIVE,
PP_UNRECOGNIZED_PRAGMA, PP_UNRECOGNIZED_PRAGMA,
#if defined(ANGLE_PLATFORM_CHROMEOS)
PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
#endif
PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL, PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL,
PP_WARNING_MACRO_NAME_RESERVED, PP_WARNING_MACRO_NAME_RESERVED,
PP_WARNING_END PP_WARNING_END
......
...@@ -669,16 +669,28 @@ void DirectiveParser::parseExtension(Token *token) ...@@ -669,16 +669,28 @@ void DirectiveParser::parseExtension(Token *token)
} }
if (valid && mSeenNonPreprocessorToken) if (valid && mSeenNonPreprocessorToken)
{ {
if (mSettings.shaderSpec == SH_WEBGL_SPEC && mShaderVersion < 300) if (mShaderVersion >= 300)
{ {
mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL, mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3,
token->location, token->text); token->location, token->text);
valid = false;
} }
else else
{ {
mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL, if (mSettings.shaderSpec == SH_WEBGL_SPEC)
token->location, token->text); {
valid = false; 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);
// This is just a warning on CHROME OS http://anglebug.com/4023
#if !defined(ANGLE_PLATFORM_CHROMEOS)
valid = false;
#endif
}
} }
} }
if (valid) if (valid)
......
...@@ -74,8 +74,12 @@ TEST_F(ExtensionTest, ExtensionAfterNonPreProcessorTokenESSL1) ...@@ -74,8 +74,12 @@ TEST_F(ExtensionTest, ExtensionAfterNonPreProcessorTokenESSL1)
const char *expected = "int baz = 1;\n\n"; const char *expected = "int baz = 1;\n\n";
using testing::_; using testing::_;
// Expect an error about extension pragmas after non-preprocessor tokens. #if defined(ANGLE_PLATFORM_CHROMEOS)
EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL, _, _)); // Directive successfully parsed.
EXPECT_CALL(mDirectiveHandler, handleExtension(pp::SourceLocation(0, 2), "foo", "bar"));
#endif
// Expect an error (chromeos warning) about extension pragmas after non-preprocessor tokens.
EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1, _, _));
preprocess(str, expected); preprocess(str, expected);
} }
...@@ -92,7 +96,7 @@ TEST_F(ExtensionTest, ExtensionAfterNonPreProcessorTokenESSL3) ...@@ -92,7 +96,7 @@ TEST_F(ExtensionTest, ExtensionAfterNonPreProcessorTokenESSL3)
// Directive successfully parsed. // Directive successfully parsed.
EXPECT_CALL(mDirectiveHandler, handleVersion(pp::SourceLocation(0, 1), 300, SH_GLES2_SPEC)); EXPECT_CALL(mDirectiveHandler, handleVersion(pp::SourceLocation(0, 1), 300, SH_GLES2_SPEC));
// Expect an error about extension pragmas after non-preprocessor tokens. // Expect an error about extension pragmas after non-preprocessor tokens.
EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL, _, _)); EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3, _, _));
preprocess(str, expected); 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