(glslang) Relaxed errors will never be enabled

This commit is contained in:
LibretroAdmin 2022-07-31 19:26:54 +02:00
parent 819d02ab24
commit 5cb8d34ac8
7 changed files with 19 additions and 58 deletions

View File

@ -2213,14 +2213,8 @@ bool TParseContext::lineContinuationCheck(const TSourceLoc& loc, bool endOfComme
return lineContinuationAllowed;
}
if (relaxedErrors()) {
if (! lineContinuationAllowed)
warn(loc, "not allowed in this version", message, "");
return true;
} else {
profileRequires(loc, EEsProfile, 300, nullptr, message);
profileRequires(loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, message);
}
profileRequires(loc, EEsProfile, 300, nullptr, message);
profileRequires(loc, ~EEsProfile, 420, E_GL_ARB_shading_language_420pack, message);
return lineContinuationAllowed;
}
@ -3001,10 +2995,7 @@ void TParseContext::precisionQualifierCheck(const TSourceLoc& loc, TBasicType ba
if (baseType == EbtFloat || baseType == EbtUint || baseType == EbtInt || baseType == EbtSampler || baseType == EbtAtomicUint) {
if (qualifier.precision == EpqNone) {
if (relaxedErrors())
warn(loc, "type requires declaration of default precision qualifier", TType::getBasicString(baseType), "substituting 'mediump'");
else
error(loc, "type requires declaration of default precision qualifier", TType::getBasicString(baseType), "");
error(loc, "type requires declaration of default precision qualifier", TType::getBasicString(baseType), "");
qualifier.precision = EpqMedium;
defaultPrecision[baseType] = EpqMedium;
}
@ -5585,10 +5576,7 @@ TIntermNode* TParseContext::executeInitializer(const TSourceLoc& loc, TIntermTyp
if (symbolTable.atGlobalLevel() && ! initializer->getType().getQualifier().isConstant()) {
const char* initFeature = "non-constant global initializer (needs GL_EXT_shader_non_constant_global_initializers)";
if (profile == EEsProfile) {
if (relaxedErrors() && ! extensionTurnedOn(E_GL_EXT_shader_non_constant_global_initializers))
warn(loc, "not allowed in this version", initFeature, "");
else
profileRequires(loc, EEsProfile, 0, E_GL_EXT_shader_non_constant_global_initializers, initFeature);
profileRequires(loc, EEsProfile, 0, E_GL_EXT_shader_non_constant_global_initializers, initFeature);
}
}
}
@ -6740,7 +6728,7 @@ TIntermNode* TParseContext::addSwitch(const TSourceLoc& loc, TIntermTyped* expre
// "it is an error to have no statement between a label and the end of the switch statement."
// The specifications were updated to remove this (being ill-defined what a "statement" was),
// so, this became a warning. However, 3.0 tests still check for the error.
if (profile == EEsProfile && version <= 300 && ! relaxedErrors())
if (profile == EEsProfile && version <= 300)
error(loc, "last case/default label not followed by statements", "switch", "");
else
warn(loc, "last case/default label not followed by statements", "switch", "");

View File

@ -1307,12 +1307,8 @@ int TScanContext::tokenizeIdentifier()
afterType = true;
if (_parseContext.profile == EEsProfile)
reservedWord();
else if (_parseContext.version < 140 && ! _parseContext.symbolTable.atBuiltInLevel() && ! _parseContext.extensionTurnedOn(E_GL_ARB_texture_rectangle)) {
if (_parseContext.relaxedErrors())
_parseContext.requireExtensions(loc, 1, &E_GL_ARB_texture_rectangle, "texture-rectangle sampler keyword");
else
reservedWord();
}
else if (_parseContext.version < 140 && ! _parseContext.symbolTable.atBuiltInLevel() && ! _parseContext.extensionTurnedOn(E_GL_ARB_texture_rectangle))
reservedWord();
return keyword;
case SAMPLER1DARRAY:

View File

@ -700,8 +700,6 @@ static void TranslateEnvironment(const TEnvironment* environment, EShMessages& m
// These are the few that are not.
static void RecordProcesses(TIntermediate& intermediate, EShMessages messages, const std::string& sourceEntryPointName)
{
if ((messages & EShMsgRelaxedErrors) != 0)
intermediate.processes.processes.push_back("relaxed-errors");
if ((messages & EShMsgSuppressWarnings) != 0)
intermediate.processes.processes.push_back("suppress-warnings");
if (sourceEntryPointName.size() > 0) {
@ -821,12 +819,8 @@ static bool ProcessDeferred(
versionNotFirst, defaultVersion, source, version, profile, spvVersion);
bool versionWillBeError = (versionNotFound || (profile == EEsProfile && version >= 300 && versionNotFirst));
bool warnVersionNotFirst = false;
if (! versionWillBeError && versionNotFirstToken) {
if (messages & EShMsgRelaxedErrors)
warnVersionNotFirst = true;
else
versionWillBeError = true;
}
if (! versionWillBeError && versionNotFirstToken)
versionWillBeError = true;
intermediate.setSource(source);
intermediate.setVersion(version);

View File

@ -612,13 +612,6 @@ bool TParseVersions::checkExtensionsRequested(const TSourceLoc& loc, int numExte
bool warned = false;
for (int i = 0; i < numExtensions; ++i) {
TExtensionBehavior behavior = getExtensionBehavior(extensions[i]);
if (behavior == EBhDisable && relaxedErrors()) {
infoSink.info.append("WARNING: ");
infoSink.info.location(loc);
infoSink.info.append("The following extension must be enabled to use this feature:");
infoSink.info.append("\n");
behavior = EBhWarn;
}
if (behavior == EBhWarn) {
infoSink.info.append("WARNING: ");
infoSink.info.location(loc);

View File

@ -116,7 +116,6 @@ public:
void setCurrentString(int string) { currentScanner->setString(string); }
void getPreamble(std::string&);
bool relaxedErrors() const { return (messages & EShMsgRelaxedErrors) != 0; }
bool suppressWarnings() const { return (messages & EShMsgSuppressWarnings) != 0; }
bool isReadingHLSL() const { return (messages & EShMsgReadHlsl) == EShMsgReadHlsl; }
bool hlslEnable16BitTypes() const { return (messages & EShMsgHlslEnable16BitTypes) != 0; }

View File

@ -315,10 +315,7 @@ int TPpContext::extraTokenCheck(int contextAtom, TPpToken* ppToken, int token)
else
label = "";
if (_parseContext.relaxedErrors())
_parseContext.ppWarn(ppToken->loc, message, label, "");
else
_parseContext.ppError(ppToken->loc, message, label, "");
_parseContext.ppError(ppToken->loc, message, label, "");
while (token != '\n' && token != EndOfInput)
token = scanToken(ppToken);
@ -400,11 +397,7 @@ int TPpContext::eval(int token, int precedence, bool shortCircuit, int& res, boo
if (token == PpAtomIdentifier) {
if (strcmp("defined", ppToken->name) == 0) {
if (! _parseContext.isReadingHLSL() && isMacroInput()) {
if (_parseContext.relaxedErrors())
_parseContext.ppWarn(ppToken->loc, "nonportable when expanded from macros for preprocessor expression",
"defined", "");
else
_parseContext.ppError(ppToken->loc, "cannot use in preprocessor expression when expanded from macros",
_parseContext.ppError(ppToken->loc, "cannot use in preprocessor expression when expanded from macros",
"defined", "");
}
bool needclose = 0;
@ -526,10 +519,7 @@ int TPpContext::evalToToken(int token, bool shortCircuit, int& res, bool& err, T
if (macroReturn == -1) {
if (! shortCircuit && _parseContext.profile == EEsProfile) {
const char* message = "undefined macro in expression not allowed in es profile";
if (_parseContext.relaxedErrors())
_parseContext.ppWarn(ppToken->loc, message, "preprocessor evaluation", ppToken->name);
else
_parseContext.ppError(ppToken->loc, message, "preprocessor evaluation", ppToken->name);
_parseContext.ppError(ppToken->loc, message, "preprocessor evaluation", ppToken->name);
}
}
token = scanToken(ppToken);

View File

@ -288,12 +288,13 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
}
} else if (ch == 'f' || ch == 'F') {
if (ifdepth == 0)
_parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
if (ifdepth == 0 && !_parseContext.relaxedErrors())
_parseContext.profileRequires(ppToken->loc, ~EEsProfile, 120, nullptr, "floating-point suffix");
if (ifdepth == 0 && !hasDecimalOrExponent)
_parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
saveName(ch);
{
_parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
_parseContext.profileRequires(ppToken->loc, ~EEsProfile, 120, nullptr, "floating-point suffix");
if (!hasDecimalOrExponent)
_parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
saveName(ch);
}
} else
ungetChar();