Track if a non-preprocessor token has been seen and validate #extension with it.
Reland: Only report a warning instead of an error.
BUG=angleproject:989
BUG=483252
Change-Id: Ife3e7759cdef6bc0f41cae3c58c307682b608279
Reviewed-on: https://chromium-review.googlesource.com/269404
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 b38f332..1fdece2 100644
--- a/src/compiler/preprocessor/DirectiveParser.cpp
+++ b/src/compiler/preprocessor/DirectiveParser.cpp
@@ -211,6 +211,7 @@
Diagnostics *diagnostics,
DirectiveHandler *directiveHandler)
: mPastFirstStatement(false),
+ mSeenNonPreprocessorToken(false),
mTokenizer(tokenizer),
mMacroSet(macroSet),
mDiagnostics(diagnostics),
@@ -229,6 +230,10 @@
parseDirective(token);
mPastFirstStatement = true;
}
+ else if (!isEOD(token))
+ {
+ mSeenNonPreprocessorToken = true;
+ }
if (token->type == Token::LAST)
{
@@ -715,6 +720,11 @@
token->location, token->text);
valid = false;
}
+ if (valid && mSeenNonPreprocessorToken)
+ {
+ mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION,
+ token->location, token->text);
+ }
if (valid)
mDirectiveHandler->handleExtension(token->location, name, behavior);
}