Error when encountering non-preprocessor tokens before #extension in ESSL3.
BUG=angleproject:1047
Change-Id: I4a548270f651e35b2c8d1ab5d0f46185230c5f74
Reviewed-on: https://chromium-review.googlesource.com/281216
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/compiler/preprocessor/DirectiveParser.cpp b/src/compiler/preprocessor/DirectiveParser.cpp
index e94f1db..fecfdae 100644
--- a/src/compiler/preprocessor/DirectiveParser.cpp
+++ b/src/compiler/preprocessor/DirectiveParser.cpp
@@ -215,7 +215,8 @@
mTokenizer(tokenizer),
mMacroSet(macroSet),
mDiagnostics(diagnostics),
- mDirectiveHandler(directiveHandler)
+ mDirectiveHandler(directiveHandler),
+ mShaderVersion(100)
{
}
@@ -722,8 +723,17 @@
}
if (valid && mSeenNonPreprocessorToken)
{
- mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION,
- token->location, token->text);
+ if (mShaderVersion >= 300)
+ {
+ mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3,
+ token->location, token->text);
+ valid = false;
+ }
+ else
+ {
+ mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
+ token->location, token->text);
+ }
}
if (valid)
mDirectiveHandler->handleExtension(token->location, name, behavior);
@@ -811,6 +821,7 @@
if (valid)
{
mDirectiveHandler->handleVersion(token->location, version);
+ mShaderVersion = version;
}
}