Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 35b25fc

Browse files
tobineCommit Bot
authored andcommitted
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>
1 parent e7e808a commit 35b25fc

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/compiler/preprocessor/DiagnosticsBase.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ const char *Diagnostics::message(ID id)
115115
return "invalid file number";
116116
case PP_INVALID_LINE_DIRECTIVE:
117117
return "invalid line directive";
118+
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1:
119+
return "extension directive must occur before any non-preprocessor tokens in ESSL1";
118120
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3:
119121
return "extension directive must occur before any non-preprocessor tokens in ESSL3";
120122
case PP_UNDEFINED_SHIFT:
@@ -129,7 +131,7 @@ const char *Diagnostics::message(ID id)
129131
return "unexpected token after conditional expression";
130132
case PP_UNRECOGNIZED_PRAGMA:
131133
return "unrecognized pragma";
132-
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1:
134+
case PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL:
133135
return "extension directive should occur before any non-preprocessor tokens";
134136
case PP_WARNING_MACRO_NAME_RESERVED:
135137
return "macro name with a double underscore is reserved - unintented behavior is "

src/compiler/preprocessor/DiagnosticsBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class Diagnostics
7373
PP_WARNING_BEGIN,
7474
PP_EOF_IN_DIRECTIVE,
7575
PP_UNRECOGNIZED_PRAGMA,
76+
PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL,
7677
PP_WARNING_MACRO_NAME_RESERVED,
7778
PP_WARNING_END
7879
};

src/compiler/preprocessor/DirectiveParser.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,16 @@ void DirectiveParser::parseExtension(Token *token)
676676
}
677677
else
678678
{
679-
mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
680-
token->location, token->text);
679+
if (mSettings.shaderSpec == SH_WEBGL_SPEC)
680+
{
681+
mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL,
682+
token->location, token->text);
683+
}
684+
else
685+
{
686+
mDiagnostics->report(Diagnostics::PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
687+
token->location, token->text);
688+
}
681689
}
682690
}
683691
if (valid)

0 commit comments

Comments
 (0)