For WebGL warn on late extension directive
A previous change based on ESSL 1.00 spec had made it an error in all
cases when an extension directive appeared in a shader after the first
non-preprocessor token. However, this is incorrect for WebGL 1.0 so
adding warning case for WebGL.
BUG=chromium:971660
Change-Id: I026fe60e8b1876de65b001b676f7a0552739a20c
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1648661
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Tobin Ehlis <tobine@google.com>
(cherry picked from commit 35b25fc67349c38cba681491b0cb5b784ae7907b)
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1651081
diff --git a/src/compiler/preprocessor/DiagnosticsBase.cpp b/src/compiler/preprocessor/DiagnosticsBase.cpp
index 575b151..c4832c6 100644
--- a/src/compiler/preprocessor/DiagnosticsBase.cpp
+++ b/src/compiler/preprocessor/DiagnosticsBase.cpp
@@ -115,6 +115,8 @@
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_UNDEFINED_SHIFT:
@@ -129,7 +131,7 @@
return "unexpected token after conditional expression";
case PP_UNRECOGNIZED_PRAGMA:
return "unrecognized pragma";
- case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1:
+ case PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL:
return "extension directive should occur before any non-preprocessor tokens";
case PP_WARNING_MACRO_NAME_RESERVED:
return "macro name with a double underscore is reserved - unintented behavior is "
diff --git a/src/compiler/preprocessor/DiagnosticsBase.h b/src/compiler/preprocessor/DiagnosticsBase.h
index bb90bf0..6be5c72 100644
--- a/src/compiler/preprocessor/DiagnosticsBase.h
+++ b/src/compiler/preprocessor/DiagnosticsBase.h
@@ -73,6 +73,7 @@
PP_WARNING_BEGIN,
PP_EOF_IN_DIRECTIVE,
PP_UNRECOGNIZED_PRAGMA,
+ PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL,
PP_WARNING_MACRO_NAME_RESERVED,
PP_WARNING_END
};
diff --git a/src/compiler/preprocessor/DirectiveParser.cpp b/src/compiler/preprocessor/DirectiveParser.cpp
index e99d843..b7f8d91 100644
--- a/src/compiler/preprocessor/DirectiveParser.cpp
+++ b/src/compiler/preprocessor/DirectiveParser.cpp
@@ -676,8 +676,16 @@
}
else
{
- mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
- token->location, token->text);
+ 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);
+ }
}
}
if (valid)