Web: Optional error management and error tightening.
Saves about 6.5K
This commit is contained in:
parent
fb4f2333da
commit
d8834df992
@ -67,6 +67,8 @@ void TParseContextBase::outputMessage(const TSourceLoc& loc, const char* szReaso
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(GLSLANG_WEB) || defined(GLSLANG_WEB_DEVEL)
|
||||
|
||||
void C_DECL TParseContextBase::error(const TSourceLoc& loc, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...)
|
||||
{
|
||||
@ -113,6 +115,8 @@ void C_DECL TParseContextBase::ppWarn(const TSourceLoc& loc, const char* szReaso
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Both test and if necessary, spit out an error, to see if the node is really
|
||||
// an l-value that can be operated on this way.
|
||||
|
||||
@ -5813,6 +5813,7 @@ void TParseContext::layoutQualifierCheck(const TSourceLoc& loc, const TQualifier
|
||||
// output block declarations, and output block member declarations."
|
||||
|
||||
switch (qualifier.storage) {
|
||||
#ifndef GLSLANG_WEB
|
||||
case EvqVaryingIn:
|
||||
{
|
||||
const char* feature = "location qualifier on input";
|
||||
@ -5847,6 +5848,7 @@ void TParseContext::layoutQualifierCheck(const TSourceLoc& loc, const TQualifier
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case EvqUniform:
|
||||
case EvqBuffer:
|
||||
{
|
||||
@ -7243,6 +7245,7 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
|
||||
if (memberQualifier.hasLocation()) {
|
||||
const char* feature = "location on block member";
|
||||
switch (currentBlockQualifier.storage) {
|
||||
#ifndef GLSLANG_WEB
|
||||
case EvqVaryingIn:
|
||||
case EvqVaryingOut:
|
||||
requireProfile(memberLoc, ECoreProfile | ECompatibilityProfile | EEsProfile, feature);
|
||||
@ -7250,6 +7253,7 @@ void TParseContext::declareBlock(const TSourceLoc& loc, TTypeList& typeList, con
|
||||
profileRequires(memberLoc, EEsProfile, 320, Num_AEP_shader_io_blocks, AEP_shader_io_blocks, feature);
|
||||
memberWithLocation = true;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
error(memberLoc, "can only use in an in/out block", feature, "");
|
||||
break;
|
||||
|
||||
@ -97,6 +97,7 @@ public:
|
||||
}
|
||||
virtual ~TParseContextBase() { }
|
||||
|
||||
#if !defined(GLSLANG_WEB) || defined(GLSLANG_WEB_DEVEL)
|
||||
virtual void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
virtual void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
@ -105,6 +106,7 @@ public:
|
||||
const char* szExtraInfoFormat, ...);
|
||||
virtual void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
#endif
|
||||
|
||||
virtual void setLimits(const TBuiltInResource&) = 0;
|
||||
|
||||
|
||||
@ -563,9 +563,8 @@ const char* StageName(EShLanguage stage)
|
||||
void TParseVersions::profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, int numExtensions, const char* const extensions[], const char* featureDesc)
|
||||
{
|
||||
if (profile & profileMask) {
|
||||
bool okay = false;
|
||||
if (minVersion > 0 && version >= minVersion)
|
||||
okay = true;
|
||||
bool okay = minVersion > 0 && version >= minVersion;
|
||||
#ifndef GLSLANG_WEB
|
||||
for (int i = 0; i < numExtensions; ++i) {
|
||||
switch (getExtensionBehavior(extensions[i])) {
|
||||
case EBhWarn:
|
||||
@ -578,7 +577,7 @@ void TParseVersions::profileRequires(const TSourceLoc& loc, int profileMask, int
|
||||
default: break; // some compilers want this
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
if (! okay)
|
||||
error(loc, "not supported for this version or the enabled extensions", featureDesc, "");
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ GLSLANG_WEB_EXCLUDE_OFF
|
||||
%type <interm.intermTypedNode> conditional_expression constant_expression
|
||||
%type <interm.intermTypedNode> logical_or_expression logical_xor_expression logical_and_expression
|
||||
%type <interm.intermTypedNode> shift_expression and_expression exclusive_or_expression inclusive_or_expression
|
||||
%type <interm.intermTypedNode> function_call initializer initializer_list condition conditionopt
|
||||
%type <interm.intermTypedNode> function_call initializer condition conditionopt
|
||||
|
||||
%type <interm.intermNode> translation_unit function_definition
|
||||
%type <interm.intermNode> statement simple_statement
|
||||
@ -342,6 +342,7 @@ GLSLANG_WEB_EXCLUDE_ON
|
||||
%type <interm.typeList> type_name_list
|
||||
%type <interm.attributes> attribute attribute_list single_attribute
|
||||
%type <interm.intermNode> demote_statement
|
||||
%type <interm.intermTypedNode> initializer_list
|
||||
GLSLANG_WEB_EXCLUDE_OFF
|
||||
|
||||
%start translation_unit
|
||||
@ -857,7 +858,6 @@ declaration
|
||||
}
|
||||
| PRECISION precision_qualifier type_specifier SEMICOLON {
|
||||
parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "precision statement");
|
||||
|
||||
// lazy setting of the previous scope's defaults, has effect only the first time it is called in a particular scope
|
||||
parseContext.symbolTable.setPreviousDefaultPrecisions(&parseContext.defaultPrecision[0]);
|
||||
parseContext.setDefaultPrecision($1.loc, $3, $2.qualifier.precision);
|
||||
@ -1137,7 +1137,6 @@ fully_specified_type
|
||||
parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
|
||||
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
|
||||
}
|
||||
|
||||
parseContext.precisionQualifierCheck($$.loc, $$.basicType, $$.qualifier);
|
||||
}
|
||||
| type_qualifier type_specifier {
|
||||
@ -3339,6 +3338,7 @@ initializer
|
||||
: assignment_expression {
|
||||
$$ = $1;
|
||||
}
|
||||
GLSLANG_WEB_EXCLUDE_ON
|
||||
| LEFT_BRACE initializer_list RIGHT_BRACE {
|
||||
const char* initFeature = "{ } style initializers";
|
||||
parseContext.requireProfile($1.loc, ~EEsProfile, initFeature);
|
||||
@ -3351,8 +3351,10 @@ initializer
|
||||
parseContext.profileRequires($1.loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, initFeature);
|
||||
$$ = $2;
|
||||
}
|
||||
GLSLANG_WEB_EXCLUDE_OFF
|
||||
;
|
||||
|
||||
GLSLANG_WEB_EXCLUDE_ON
|
||||
initializer_list
|
||||
: initializer {
|
||||
$$ = parseContext.intermediate.growAggregate(0, $1, $1->getLoc());
|
||||
@ -3361,6 +3363,7 @@ initializer_list
|
||||
$$ = parseContext.intermediate.growAggregate($1, $3);
|
||||
}
|
||||
;
|
||||
GLSLANG_WEB_EXCLUDE_OFF
|
||||
|
||||
declaration_statement
|
||||
: declaration { $$ = $1; }
|
||||
@ -3726,11 +3729,13 @@ external_declaration
|
||||
| declaration {
|
||||
$$ = $1;
|
||||
}
|
||||
GLSLANG_WEB_EXCLUDE_ON
|
||||
| SEMICOLON {
|
||||
parseContext.requireProfile($1.loc, ~EEsProfile, "extraneous semicolon");
|
||||
parseContext.profileRequires($1.loc, ~EEsProfile, 460, nullptr, "extraneous semicolon");
|
||||
$$ = nullptr;
|
||||
}
|
||||
GLSLANG_WEB_EXCLUDE_OFF
|
||||
;
|
||||
|
||||
function_definition
|
||||
|
||||
@ -300,7 +300,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
|
||||
%type <interm.intermTypedNode> conditional_expression constant_expression
|
||||
%type <interm.intermTypedNode> logical_or_expression logical_xor_expression logical_and_expression
|
||||
%type <interm.intermTypedNode> shift_expression and_expression exclusive_or_expression inclusive_or_expression
|
||||
%type <interm.intermTypedNode> function_call initializer initializer_list condition conditionopt
|
||||
%type <interm.intermTypedNode> function_call initializer condition conditionopt
|
||||
|
||||
%type <interm.intermNode> translation_unit function_definition
|
||||
%type <interm.intermNode> statement simple_statement
|
||||
@ -342,6 +342,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
|
||||
%type <interm.typeList> type_name_list
|
||||
%type <interm.attributes> attribute attribute_list single_attribute
|
||||
%type <interm.intermNode> demote_statement
|
||||
%type <interm.intermTypedNode> initializer_list
|
||||
|
||||
|
||||
%start translation_unit
|
||||
@ -857,7 +858,6 @@ declaration
|
||||
}
|
||||
| PRECISION precision_qualifier type_specifier SEMICOLON {
|
||||
parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "precision statement");
|
||||
|
||||
// lazy setting of the previous scope's defaults, has effect only the first time it is called in a particular scope
|
||||
parseContext.symbolTable.setPreviousDefaultPrecisions(&parseContext.defaultPrecision[0]);
|
||||
parseContext.setDefaultPrecision($1.loc, $3, $2.qualifier.precision);
|
||||
@ -1137,7 +1137,6 @@ fully_specified_type
|
||||
parseContext.profileRequires($1.loc, ENoProfile, 120, E_GL_3DL_array_objects, "arrayed type");
|
||||
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
|
||||
}
|
||||
|
||||
parseContext.precisionQualifierCheck($$.loc, $$.basicType, $$.qualifier);
|
||||
}
|
||||
| type_qualifier type_specifier {
|
||||
@ -3339,6 +3338,7 @@ initializer
|
||||
: assignment_expression {
|
||||
$$ = $1;
|
||||
}
|
||||
|
||||
| LEFT_BRACE initializer_list RIGHT_BRACE {
|
||||
const char* initFeature = "{ } style initializers";
|
||||
parseContext.requireProfile($1.loc, ~EEsProfile, initFeature);
|
||||
@ -3351,8 +3351,10 @@ initializer
|
||||
parseContext.profileRequires($1.loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, initFeature);
|
||||
$$ = $2;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
|
||||
initializer_list
|
||||
: initializer {
|
||||
$$ = parseContext.intermediate.growAggregate(0, $1, $1->getLoc());
|
||||
@ -3362,6 +3364,7 @@ initializer_list
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
declaration_statement
|
||||
: declaration { $$ = $1; }
|
||||
;
|
||||
@ -3726,11 +3729,13 @@ external_declaration
|
||||
| declaration {
|
||||
$$ = $1;
|
||||
}
|
||||
|
||||
| SEMICOLON {
|
||||
parseContext.requireProfile($1.loc, ~EEsProfile, "extraneous semicolon");
|
||||
parseContext.profileRequires($1.loc, ~EEsProfile, 460, nullptr, "extraneous semicolon");
|
||||
$$ = nullptr;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
function_definition
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -56,8 +56,10 @@ namespace glslang {
|
||||
//
|
||||
void TIntermediate::error(TInfoSink& infoSink, const char* message)
|
||||
{
|
||||
#ifndef GLSLANG_WEB
|
||||
infoSink.info.prefix(EPrefixError);
|
||||
infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
|
||||
#endif
|
||||
|
||||
++numErrors;
|
||||
}
|
||||
@ -65,8 +67,10 @@ void TIntermediate::error(TInfoSink& infoSink, const char* message)
|
||||
// Link-time warning.
|
||||
void TIntermediate::warn(TInfoSink& infoSink, const char* message)
|
||||
{
|
||||
#ifndef GLSLANG_WEB
|
||||
infoSink.info.prefix(EPrefixWarning);
|
||||
infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: 4.4 offset/align: "Two blocks linked together in the same program with the same block
|
||||
|
||||
@ -137,6 +137,17 @@ public:
|
||||
virtual void requireVulkan(const TSourceLoc&, const char* op);
|
||||
virtual void requireSpv(const TSourceLoc&, const char* op);
|
||||
|
||||
|
||||
#if defined(GLSLANG_WEB) && !defined(GLSLANG_WEB_DEVEL)
|
||||
void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...) { addError(); }
|
||||
void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...) { }
|
||||
void C_DECL ppError(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...) { addError(); }
|
||||
void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...) { }
|
||||
#else
|
||||
virtual void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...) = 0;
|
||||
virtual void C_DECL warn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
@ -145,6 +156,7 @@ public:
|
||||
const char* szExtraInfoFormat, ...) = 0;
|
||||
virtual void C_DECL ppWarn(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...) = 0;
|
||||
#endif
|
||||
|
||||
void addError() { ++numErrors; }
|
||||
int getNumErrors() const { return numErrors; }
|
||||
|
||||
@ -116,6 +116,7 @@ int TPpContext::TokenStream::getToken(TParseContextBase& parseContext, TPpToken
|
||||
int atom = stream[currentPos++].get(*ppToken);
|
||||
ppToken->loc = parseContext.getCurrentLoc();
|
||||
|
||||
#ifndef GLSLANG_WEB
|
||||
// Check for ##, unless the current # is the last character
|
||||
if (atom == '#') {
|
||||
if (peekToken('#')) {
|
||||
@ -125,6 +126,7 @@ int TPpContext::TokenStream::getToken(TParseContextBase& parseContext, TPpToken
|
||||
atom = PpAtomPaste;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return atom;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user