Commit fa55bf1e by Geoff Lang

Track if a non-preprocessor token has been seen and validate #extension with it.

Fixes: dEQP-GLES2.functional.shaders.preprocessor.extensions.after_non_preprocessing_tokens_vertex dEQP-GLES2.functional.shaders.preprocessor.extensions.after_non_preprocessing_tokens_fragment BUG=angleproject:989 Change-Id: Ie0aba80b2fde0160e83fc95f545b62954af2e5fc Reviewed-on: https://chromium-review.googlesource.com/267398Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c185cb8d
......@@ -211,6 +211,7 @@ DirectiveParser::DirectiveParser(Tokenizer *tokenizer,
Diagnostics *diagnostics,
DirectiveHandler *directiveHandler)
: mPastFirstStatement(false),
mSeenNonPreprocessorToken(false),
mTokenizer(tokenizer),
mMacroSet(macroSet),
mDiagnostics(diagnostics),
......@@ -229,6 +230,10 @@ void DirectiveParser::lex(Token *token)
parseDirective(token);
mPastFirstStatement = true;
}
else if (!isEOD(token))
{
mSeenNonPreprocessorToken = true;
}
if (token->type == Token::LAST)
{
......@@ -715,6 +720,12 @@ void DirectiveParser::parseExtension(Token *token)
token->location, token->text);
valid = false;
}
if (valid && mSeenNonPreprocessorToken)
{
mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_DIRECTIVE,
token->location, token->text);
valid = false;
}
if (valid)
mDirectiveHandler->handleExtension(token->location, name, behavior);
}
......
......@@ -70,6 +70,8 @@ class DirectiveParser : public Lexer
}
};
bool mPastFirstStatement;
bool mSeenNonPreprocessorToken; // Tracks if a non-preprocessor token has been seen yet. Some macros, such as
// #extension must be declared before all shader code.
std::vector<ConditionalBlock> mConditionalStack;
Tokenizer *mTokenizer;
MacroSet *mMacroSet;
......
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