Commit b98a3d1c by Tobin Ehlis Committed by Kai Ninomiya

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/+/1648661Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarKai Ninomiya <kainino@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com> (cherry picked from commit 35b25fc6) Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1651081
parent 1b6a9ca2
...@@ -115,6 +115,8 @@ const char *Diagnostics::message(ID id) ...@@ -115,6 +115,8 @@ 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_ESSL1:
return "extension directive must occur before any non-preprocessor tokens in ESSL1";
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3: case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3:
return "extension directive must occur before any non-preprocessor tokens in ESSL3"; return "extension directive must occur before any non-preprocessor tokens in ESSL3";
case PP_UNDEFINED_SHIFT: case PP_UNDEFINED_SHIFT:
...@@ -129,7 +131,7 @@ const char *Diagnostics::message(ID id) ...@@ -129,7 +131,7 @@ const char *Diagnostics::message(ID id)
return "unexpected token after conditional expression"; return "unexpected token after conditional expression";
case PP_UNRECOGNIZED_PRAGMA: case PP_UNRECOGNIZED_PRAGMA:
return "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"; return "extension directive should occur before any non-preprocessor tokens";
case PP_WARNING_MACRO_NAME_RESERVED: case PP_WARNING_MACRO_NAME_RESERVED:
return "macro name with a double underscore is reserved - unintented behavior is " return "macro name with a double underscore is reserved - unintented behavior is "
......
...@@ -73,6 +73,7 @@ class Diagnostics ...@@ -73,6 +73,7 @@ class Diagnostics
PP_WARNING_BEGIN, PP_WARNING_BEGIN,
PP_EOF_IN_DIRECTIVE, PP_EOF_IN_DIRECTIVE,
PP_UNRECOGNIZED_PRAGMA, PP_UNRECOGNIZED_PRAGMA,
PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL,
PP_WARNING_MACRO_NAME_RESERVED, PP_WARNING_MACRO_NAME_RESERVED,
PP_WARNING_END PP_WARNING_END
}; };
......
...@@ -676,8 +676,16 @@ void DirectiveParser::parseExtension(Token *token) ...@@ -676,8 +676,16 @@ void DirectiveParser::parseExtension(Token *token)
} }
else else
{ {
mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1, if (mSettings.shaderSpec == SH_WEBGL_SPEC)
token->location, token->text); {
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) if (valid)
......
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