Commit 4de340ac by Olli Etuaho Committed by Commit Bot

Remove extraInfo parameter from compiler diagnostic functions

This makes error messages more consistent. It was not clear what was supposed to go to the extraInfo parameter, and previously it was mostly being misused, resulting in poorly formatted error messages. Sometimes the order of parameters to the diagnostic functions like error() and warning() was wrong altogether. The diagnostics API is simpler when there's only the "reason" and "token" parameters that have clear meaning and that are separated by consistent punctuation in the output. Fixes error messages like "redifinition interface block member" to be grammatically reasonable like the rest of the error messages. For other error messages, punctuation is added to make them clearer. Example: "invalid layout qualifier location requires an argument" is changed to "invalid layout qualifier: location requires an argument". Extra spaces are also removed from the beginning of error messages. BUG=angleproject:1670 BUG=angleproject:911 TEST=angle_unittests Change-Id: Id5fb1a1f2892fad2b796aaef47ffb07e9d79759c Reviewed-on: https://chromium-review.googlesource.com/420789Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 08a617ad
...@@ -21,11 +21,11 @@ float CheckedSum(float lhs, float rhs, TDiagnostics *diag, const TSourceLoc &lin ...@@ -21,11 +21,11 @@ float CheckedSum(float lhs, float rhs, TDiagnostics *diag, const TSourceLoc &lin
float result = lhs + rhs; float result = lhs + rhs;
if (gl::isNaN(result) && !gl::isNaN(lhs) && !gl::isNaN(rhs)) if (gl::isNaN(result) && !gl::isNaN(lhs) && !gl::isNaN(rhs))
{ {
diag->warning(line, "Constant folded undefined addition generated NaN", "+", ""); diag->warning(line, "Constant folded undefined addition generated NaN", "+");
} }
else if (gl::isInf(result) && !gl::isInf(lhs) && !gl::isInf(rhs)) else if (gl::isInf(result) && !gl::isInf(lhs) && !gl::isInf(rhs))
{ {
diag->warning(line, "Constant folded addition overflowed to infinity", "+", ""); diag->warning(line, "Constant folded addition overflowed to infinity", "+");
} }
return result; return result;
} }
...@@ -35,11 +35,11 @@ float CheckedDiff(float lhs, float rhs, TDiagnostics *diag, const TSourceLoc &li ...@@ -35,11 +35,11 @@ float CheckedDiff(float lhs, float rhs, TDiagnostics *diag, const TSourceLoc &li
float result = lhs - rhs; float result = lhs - rhs;
if (gl::isNaN(result) && !gl::isNaN(lhs) && !gl::isNaN(rhs)) if (gl::isNaN(result) && !gl::isNaN(lhs) && !gl::isNaN(rhs))
{ {
diag->warning(line, "Constant folded undefined subtraction generated NaN", "-", ""); diag->warning(line, "Constant folded undefined subtraction generated NaN", "-");
} }
else if (gl::isInf(result) && !gl::isInf(lhs) && !gl::isInf(rhs)) else if (gl::isInf(result) && !gl::isInf(lhs) && !gl::isInf(rhs))
{ {
diag->warning(line, "Constant folded subtraction overflowed to infinity", "-", ""); diag->warning(line, "Constant folded subtraction overflowed to infinity", "-");
} }
return result; return result;
} }
...@@ -49,11 +49,11 @@ float CheckedMul(float lhs, float rhs, TDiagnostics *diag, const TSourceLoc &lin ...@@ -49,11 +49,11 @@ float CheckedMul(float lhs, float rhs, TDiagnostics *diag, const TSourceLoc &lin
float result = lhs * rhs; float result = lhs * rhs;
if (gl::isNaN(result) && !gl::isNaN(lhs) && !gl::isNaN(rhs)) if (gl::isNaN(result) && !gl::isNaN(lhs) && !gl::isNaN(rhs))
{ {
diag->warning(line, "Constant folded undefined multiplication generated NaN", "*", ""); diag->warning(line, "Constant folded undefined multiplication generated NaN", "*");
} }
else if (gl::isInf(result) && !gl::isInf(lhs) && !gl::isInf(rhs)) else if (gl::isInf(result) && !gl::isInf(lhs) && !gl::isInf(rhs))
{ {
diag->warning(line, "Constant folded multiplication overflowed to infinity", "*", ""); diag->warning(line, "Constant folded multiplication overflowed to infinity", "*");
} }
return result; return result;
} }
...@@ -380,7 +380,7 @@ TConstantUnion TConstantUnion::rshift(const TConstantUnion &lhs, ...@@ -380,7 +380,7 @@ TConstantUnion TConstantUnion::rshift(const TConstantUnion &lhs,
if ((rhs.type == EbtInt && (rhs.iConst < 0 || rhs.iConst > 31)) || if ((rhs.type == EbtInt && (rhs.iConst < 0 || rhs.iConst > 31)) ||
(rhs.type == EbtUInt && rhs.uConst > 31u)) (rhs.type == EbtUInt && rhs.uConst > 31u))
{ {
diag->error(line, "Undefined shift (operand out of range)", ">>", ""); diag->error(line, "Undefined shift (operand out of range)", ">>");
switch (lhs.type) switch (lhs.type)
{ {
case EbtInt: case EbtInt:
...@@ -487,7 +487,7 @@ TConstantUnion TConstantUnion::lshift(const TConstantUnion &lhs, ...@@ -487,7 +487,7 @@ TConstantUnion TConstantUnion::lshift(const TConstantUnion &lhs,
if ((rhs.type == EbtInt && (rhs.iConst < 0 || rhs.iConst > 31)) || if ((rhs.type == EbtInt && (rhs.iConst < 0 || rhs.iConst > 31)) ||
(rhs.type == EbtUInt && rhs.uConst > 31u)) (rhs.type == EbtUInt && rhs.uConst > 31u))
{ {
diag->error(line, "Undefined shift (operand out of range)", "<<", ""); diag->error(line, "Undefined shift (operand out of range)", "<<");
switch (lhs.type) switch (lhs.type)
{ {
case EbtInt: case EbtInt:
......
...@@ -26,8 +26,7 @@ TDiagnostics::~TDiagnostics() ...@@ -26,8 +26,7 @@ TDiagnostics::~TDiagnostics()
void TDiagnostics::writeInfo(Severity severity, void TDiagnostics::writeInfo(Severity severity,
const pp::SourceLocation &loc, const pp::SourceLocation &loc,
const std::string &reason, const std::string &reason,
const std::string &token, const std::string &token)
const std::string &extra)
{ {
TPrefixType prefix = EPrefixNone; TPrefixType prefix = EPrefixNone;
switch (severity) switch (severity)
...@@ -49,39 +48,28 @@ void TDiagnostics::writeInfo(Severity severity, ...@@ -49,39 +48,28 @@ void TDiagnostics::writeInfo(Severity severity,
/* VC++ format: file(linenum) : error #: 'token' : extrainfo */ /* VC++ format: file(linenum) : error #: 'token' : extrainfo */
sink.prefix(prefix); sink.prefix(prefix);
sink.location(loc.file, loc.line); sink.location(loc.file, loc.line);
sink << "'" << token << "' : " << reason << " " << extra << "\n"; sink << "'" << token << "' : " << reason << "\n";
} }
void TDiagnostics::error(const TSourceLoc &loc, void TDiagnostics::error(const TSourceLoc &loc, const char *reason, const char *token)
const char *reason,
const char *token,
const char *extraInfo)
{ {
pp::SourceLocation srcLoc; pp::SourceLocation srcLoc;
srcLoc.file = loc.first_file; srcLoc.file = loc.first_file;
srcLoc.line = loc.first_line; srcLoc.line = loc.first_line;
writeInfo(pp::Diagnostics::PP_ERROR, srcLoc, reason, token, extraInfo); writeInfo(pp::Diagnostics::PP_ERROR, srcLoc, reason, token);
}
void TDiagnostics::error(const TSourceLoc &loc, const char *reason, const char *token)
{
error(loc, reason, token, "");
} }
void TDiagnostics::warning(const TSourceLoc &loc, void TDiagnostics::warning(const TSourceLoc &loc, const char *reason, const char *token)
const char *reason,
const char *token,
const char *extraInfo)
{ {
pp::SourceLocation srcLoc; pp::SourceLocation srcLoc;
srcLoc.file = loc.first_file; srcLoc.file = loc.first_file;
srcLoc.line = loc.first_line; srcLoc.line = loc.first_line;
writeInfo(pp::Diagnostics::PP_WARNING, srcLoc, reason, token, extraInfo); writeInfo(pp::Diagnostics::PP_WARNING, srcLoc, reason, token);
} }
void TDiagnostics::print(ID id, const pp::SourceLocation &loc, const std::string &text) void TDiagnostics::print(ID id, const pp::SourceLocation &loc, const std::string &text)
{ {
writeInfo(severity(id), loc, message(id), text, ""); writeInfo(severity(id), loc, message(id), text);
} }
} // namespace sh } // namespace sh
...@@ -30,15 +30,10 @@ class TDiagnostics : public pp::Diagnostics, angle::NonCopyable ...@@ -30,15 +30,10 @@ class TDiagnostics : public pp::Diagnostics, angle::NonCopyable
void writeInfo(Severity severity, void writeInfo(Severity severity,
const pp::SourceLocation &loc, const pp::SourceLocation &loc,
const std::string &reason, const std::string &reason,
const std::string &token, const std::string &token);
const std::string &extra);
void error(const TSourceLoc &loc, const char *reason, const char *token, const char *extraInfo);
void error(const TSourceLoc &loc, const char *reason, const char *token); void error(const TSourceLoc &loc, const char *reason, const char *token);
void warning(const TSourceLoc &loc, void warning(const TSourceLoc &loc, const char *reason, const char *token);
const char *reason,
const char *token,
const char *extraInfo);
protected: protected:
void print(ID id, const pp::SourceLocation &loc, const std::string &text) override; void print(ID id, const pp::SourceLocation &loc, const std::string &text) override;
......
...@@ -52,7 +52,7 @@ TDirectiveHandler::~TDirectiveHandler() ...@@ -52,7 +52,7 @@ TDirectiveHandler::~TDirectiveHandler()
void TDirectiveHandler::handleError(const pp::SourceLocation &loc, const std::string &msg) void TDirectiveHandler::handleError(const pp::SourceLocation &loc, const std::string &msg)
{ {
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, msg, "", ""); mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, msg, "");
} }
void TDirectiveHandler::handlePragma(const pp::SourceLocation &loc, void TDirectiveHandler::handlePragma(const pp::SourceLocation &loc,
...@@ -72,7 +72,7 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation &loc, ...@@ -72,7 +72,7 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation &loc,
// ESSL 3.00.4 section 4.6.1 // ESSL 3.00.4 section 4.6.1
mDiagnostics.writeInfo( mDiagnostics.writeInfo(
pp::Diagnostics::PP_ERROR, loc, pp::Diagnostics::PP_ERROR, loc,
"#pragma STDGL invariant(all) can not be used in fragment shader", name, value); "#pragma STDGL invariant(all) can not be used in fragment shader", name);
} }
mPragma.stdgl.invariantAll = true; mPragma.stdgl.invariantAll = true;
} }
...@@ -125,8 +125,8 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation &loc, ...@@ -125,8 +125,8 @@ void TDirectiveHandler::handlePragma(const pp::SourceLocation &loc,
if (invalidValue) if (invalidValue)
{ {
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "invalid pragma value", value, mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"'on' or 'off' expected"); "invalid pragma value - 'on' or 'off' expected", value);
} }
} }
} }
...@@ -140,7 +140,7 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation &loc, ...@@ -140,7 +140,7 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation &loc,
TBehavior behaviorVal = getBehavior(behavior); TBehavior behaviorVal = getBehavior(behavior);
if (behaviorVal == EBhUndefined) if (behaviorVal == EBhUndefined)
{ {
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "behavior", name, "invalid"); mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "behavior invalid", name);
return; return;
} }
...@@ -148,13 +148,13 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation &loc, ...@@ -148,13 +148,13 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation &loc,
{ {
if (behaviorVal == EBhRequire) if (behaviorVal == EBhRequire)
{ {
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "extension", name, mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"cannot have 'require' behavior"); "extension cannot have 'require' behavior", name);
} }
else if (behaviorVal == EBhEnable) else if (behaviorVal == EBhEnable)
{ {
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "extension", name, mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc,
"cannot have 'enable' behavior"); "extension cannot have 'enable' behavior", name);
} }
else else
{ {
...@@ -187,7 +187,7 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation &loc, ...@@ -187,7 +187,7 @@ void TDirectiveHandler::handleExtension(const pp::SourceLocation &loc,
UNREACHABLE(); UNREACHABLE();
break; break;
} }
mDiagnostics.writeInfo(severity, loc, "extension", name, "is not supported"); mDiagnostics.writeInfo(severity, loc, "extension is not supported", name);
} }
void TDirectiveHandler::handleVersion(const pp::SourceLocation &loc, int version) void TDirectiveHandler::handleVersion(const pp::SourceLocation &loc, int version)
...@@ -201,8 +201,7 @@ void TDirectiveHandler::handleVersion(const pp::SourceLocation &loc, int version ...@@ -201,8 +201,7 @@ void TDirectiveHandler::handleVersion(const pp::SourceLocation &loc, int version
std::stringstream stream; std::stringstream stream;
stream << version; stream << version;
std::string str = stream.str(); std::string str = stream.str();
mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "version number", str, mDiagnostics.writeInfo(pp::Diagnostics::PP_ERROR, loc, "version number not supported", str);
"not supported");
} }
} }
......
...@@ -54,7 +54,7 @@ void UndefinedConstantFoldingError(const TSourceLoc &loc, ...@@ -54,7 +54,7 @@ void UndefinedConstantFoldingError(const TSourceLoc &loc,
TConstantUnion *result) TConstantUnion *result)
{ {
diagnostics->warning(loc, "operation result is undefined for the values passed in", diagnostics->warning(loc, "operation result is undefined for the values passed in",
GetOperatorString(op), ""); GetOperatorString(op));
switch (basicType) switch (basicType)
{ {
...@@ -1342,13 +1342,13 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op, ...@@ -1342,13 +1342,13 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op,
diagnostics->warning( diagnostics->warning(
getLine(), getLine(),
"Zero divided by zero during constant folding generated NaN", "Zero divided by zero during constant folding generated NaN",
"/", ""); "/");
resultArray[i].setFConst(std::numeric_limits<float>::quiet_NaN()); resultArray[i].setFConst(std::numeric_limits<float>::quiet_NaN());
} }
else else
{ {
diagnostics->warning( diagnostics->warning(getLine(),
getLine(), "Divide by zero during constant folding", "/", ""); "Divide by zero during constant folding", "/");
bool negativeResult = bool negativeResult =
std::signbit(dividend) != std::signbit(divisor); std::signbit(dividend) != std::signbit(divisor);
resultArray[i].setFConst( resultArray[i].setFConst(
...@@ -1361,7 +1361,7 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op, ...@@ -1361,7 +1361,7 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op,
diagnostics->warning(getLine(), diagnostics->warning(getLine(),
"Infinity divided by infinity during constant " "Infinity divided by infinity during constant "
"folding generated NaN", "folding generated NaN",
"/", ""); "/");
resultArray[i].setFConst(std::numeric_limits<float>::quiet_NaN()); resultArray[i].setFConst(std::numeric_limits<float>::quiet_NaN());
} }
else else
...@@ -1371,7 +1371,7 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op, ...@@ -1371,7 +1371,7 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op,
{ {
diagnostics->warning( diagnostics->warning(
getLine(), "Constant folded division overflowed to infinity", getLine(), "Constant folded division overflowed to infinity",
"/", ""); "/");
} }
resultArray[i].setFConst(result); resultArray[i].setFConst(result);
} }
...@@ -1381,7 +1381,7 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op, ...@@ -1381,7 +1381,7 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op,
if (rightArray[i] == 0) if (rightArray[i] == 0)
{ {
diagnostics->warning( diagnostics->warning(
getLine(), "Divide by zero error during constant folding", "/", ""); getLine(), "Divide by zero error during constant folding", "/");
resultArray[i].setIConst(INT_MAX); resultArray[i].setIConst(INT_MAX);
} }
else else
...@@ -1418,7 +1418,7 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op, ...@@ -1418,7 +1418,7 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op,
diagnostics->warning(getLine(), diagnostics->warning(getLine(),
"Negative modulus operator operand " "Negative modulus operator operand "
"encountered during constant folding", "encountered during constant folding",
"%", ""); "%");
resultArray[i].setIConst(0); resultArray[i].setIConst(0);
} }
else else
...@@ -1433,7 +1433,7 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op, ...@@ -1433,7 +1433,7 @@ TConstantUnion *TIntermConstantUnion::foldBinary(TOperator op,
if (rightArray[i] == 0) if (rightArray[i] == 0)
{ {
diagnostics->warning( diagnostics->warning(
getLine(), "Divide by zero error during constant folding", "/", ""); getLine(), "Divide by zero error during constant folding", "/");
resultArray[i].setUConst(UINT_MAX); resultArray[i].setUConst(UINT_MAX);
} }
else else
......
...@@ -50,21 +50,14 @@ class TParseContext : angle::NonCopyable ...@@ -50,21 +50,14 @@ class TParseContext : angle::NonCopyable
ShShaderSpec getShaderSpec() const { return mShaderSpec; } ShShaderSpec getShaderSpec() const { return mShaderSpec; }
int numErrors() const { return mDiagnostics.numErrors(); } int numErrors() const { return mDiagnostics.numErrors(); }
TInfoSink &infoSink() { return mDiagnostics.infoSink(); } TInfoSink &infoSink() { return mDiagnostics.infoSink(); }
void error(const TSourceLoc &loc, void error(const TSourceLoc &loc, const char *reason, const char *token);
const char *reason, void warning(const TSourceLoc &loc, const char *reason, const char *token);
const char *token,
const char *extraInfo = "");
void warning(const TSourceLoc &loc,
const char *reason,
const char *token,
const char *extraInfo = "");
// If isError is false, a warning will be reported instead. // If isError is false, a warning will be reported instead.
void outOfRangeError(bool isError, void outOfRangeError(bool isError,
const TSourceLoc &loc, const TSourceLoc &loc,
const char *reason, const char *reason,
const char *token, const char *token);
const char *extraInfo = "");
TIntermBlock *getTreeRoot() const { return mTreeRoot; } TIntermBlock *getTreeRoot() const { return mTreeRoot; }
void setTreeRoot(TIntermBlock *treeRoot) { mTreeRoot = treeRoot; } void setTreeRoot(TIntermBlock *treeRoot) { mTreeRoot = treeRoot; }
...@@ -273,6 +266,9 @@ class TParseContext : angle::NonCopyable ...@@ -273,6 +266,9 @@ class TParseContext : angle::NonCopyable
const TString &fieldString, const TString &fieldString,
const TSourceLoc &fieldLocation); const TSourceLoc &fieldLocation);
TFieldList *combineStructFieldLists(TFieldList *processedFields,
const TFieldList *newlyAddedFields,
const TSourceLoc &location);
TFieldList *addStructDeclaratorListWithQualifiers( TFieldList *addStructDeclaratorListWithQualifiers(
const TTypeQualifierBuilder &typeQualifierBuilder, const TTypeQualifierBuilder &typeQualifierBuilder,
TPublicType *typeSpecifier, TPublicType *typeSpecifier,
...@@ -362,13 +358,12 @@ class TParseContext : angle::NonCopyable ...@@ -362,13 +358,12 @@ class TParseContext : angle::NonCopyable
TSymbolTable &symbolTable; // symbol table that goes with the language currently being parsed TSymbolTable &symbolTable; // symbol table that goes with the language currently being parsed
private: private:
// Returns a clamped index. // Returns a clamped index. If it prints out an error message, the token is "[]".
int checkIndexOutOfRange(bool outOfRangeIndexIsError, int checkIndexOutOfRange(bool outOfRangeIndexIsError,
const TSourceLoc &location, const TSourceLoc &location,
int index, int index,
int arraySize, int arraySize,
const char *reason, const char *reason);
const char *token);
bool declareVariable(const TSourceLoc &line, bool declareVariable(const TSourceLoc &line,
const TString &identifier, const TString &identifier,
......
...@@ -476,7 +476,7 @@ TTypeQualifier GetVariableTypeQualifierFromSortedSequence( ...@@ -476,7 +476,7 @@ TTypeQualifier GetVariableTypeQualifierFromSortedSequence(
{ {
const TString &qualifierString = qualifier->getQualifierString(); const TString &qualifierString = qualifier->getQualifierString();
diagnostics->error(qualifier->getLine(), "invalid qualifier combination", diagnostics->error(qualifier->getLine(), "invalid qualifier combination",
qualifierString.c_str(), ""); qualifierString.c_str());
break; break;
} }
} }
...@@ -521,7 +521,7 @@ TTypeQualifier GetParameterTypeQualifierFromSortedSequence( ...@@ -521,7 +521,7 @@ TTypeQualifier GetParameterTypeQualifierFromSortedSequence(
{ {
const TString &qualifierString = qualifier->getQualifierString(); const TString &qualifierString = qualifier->getQualifierString();
diagnostics->error(qualifier->getLine(), "invalid parameter qualifier", diagnostics->error(qualifier->getLine(), "invalid parameter qualifier",
qualifierString.c_str(), ""); qualifierString.c_str());
break; break;
} }
} }
...@@ -542,7 +542,7 @@ TTypeQualifier GetParameterTypeQualifierFromSortedSequence( ...@@ -542,7 +542,7 @@ TTypeQualifier GetParameterTypeQualifierFromSortedSequence(
break; break;
default: default:
diagnostics->error(sortedSequence[0]->getLine(), "Invalid parameter qualifier ", diagnostics->error(sortedSequence[0]->getLine(), "Invalid parameter qualifier ",
getQualifierString(typeQualifier.qualifier), ""); getQualifierString(typeQualifier.qualifier));
} }
return typeQualifier; return typeQualifier;
} }
...@@ -578,7 +578,7 @@ TLayoutQualifier JoinLayoutQualifiers(TLayoutQualifier leftQualifier, ...@@ -578,7 +578,7 @@ TLayoutQualifier JoinLayoutQualifiers(TLayoutQualifier leftQualifier,
{ {
diagnostics->error(rightQualifierLocation, diagnostics->error(rightQualifierLocation,
"Cannot have multiple different work group size specifiers", "Cannot have multiple different work group size specifiers",
getWorkGroupSizeString(i), ""); getWorkGroupSizeString(i));
} }
joinedQualifier.localSize[i] = rightQualifier.localSize[i]; joinedQualifier.localSize[i] = rightQualifier.localSize[i];
} }
...@@ -661,15 +661,13 @@ bool TTypeQualifierBuilder::checkSequenceIsValid(TDiagnostics *diagnostics) cons ...@@ -661,15 +661,13 @@ bool TTypeQualifierBuilder::checkSequenceIsValid(TDiagnostics *diagnostics) cons
std::string errorMessage; std::string errorMessage;
if (HasRepeatingQualifiers(mQualifiers, areQualifierChecksRelaxed, &errorMessage)) if (HasRepeatingQualifiers(mQualifiers, areQualifierChecksRelaxed, &errorMessage))
{ {
diagnostics->error(mQualifiers[0]->getLine(), "qualifier sequence", errorMessage.c_str(), diagnostics->error(mQualifiers[0]->getLine(), errorMessage.c_str(), "qualifier sequence");
"");
return false; return false;
} }
if (!areQualifierChecksRelaxed && !AreQualifiersInOrder(mQualifiers, &errorMessage)) if (!areQualifierChecksRelaxed && !AreQualifiersInOrder(mQualifiers, &errorMessage))
{ {
diagnostics->error(mQualifiers[0]->getLine(), "qualifier sequence", errorMessage.c_str(), diagnostics->error(mQualifiers[0]->getLine(), errorMessage.c_str(), "qualifier sequence");
"");
return false; return false;
} }
......
...@@ -401,7 +401,7 @@ O [0-7] ...@@ -401,7 +401,7 @@ O [0-7]
} }
<FIELDS>[ \t\v\f\r] {} <FIELDS>[ \t\v\f\r] {}
<FIELDS>. { <FIELDS>. {
yyextra->error(*yylloc, "Illegal character at fieldname start", yytext, ""); yyextra->error(*yylloc, "Illegal character at fieldname start", yytext);
return 0; return 0;
} }
...@@ -445,7 +445,7 @@ int check_type(yyscan_t yyscanner) { ...@@ -445,7 +445,7 @@ int check_type(yyscan_t yyscanner) {
int reserved_word(yyscan_t yyscanner) { int reserved_word(yyscan_t yyscanner) {
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
yyextra->error(*yylloc, "Illegal use of reserved word", yytext, ""); yyextra->error(*yylloc, "Illegal use of reserved word", yytext);
return 0; return 0;
} }
...@@ -539,12 +539,12 @@ int uint_constant(TParseContext *context) ...@@ -539,12 +539,12 @@ int uint_constant(TParseContext *context)
if (context->getShaderVersion() < 300) if (context->getShaderVersion() < 300)
{ {
context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext, ""); context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext);
return 0; return 0;
} }
if (!atoi_clamp(yytext, &(yylval->lex.u))) if (!atoi_clamp(yytext, &(yylval->lex.u)))
yyextra->error(*yylloc, "Integer overflow", yytext, ""); yyextra->error(*yylloc, "Integer overflow", yytext);
return UINTCONSTANT; return UINTCONSTANT;
} }
...@@ -562,7 +562,7 @@ int floatsuffix_check(TParseContext* context) ...@@ -562,7 +562,7 @@ int floatsuffix_check(TParseContext* context)
std::string text = yytext; std::string text = yytext;
text.resize(text.size() - 1); text.resize(text.size() - 1);
if (!strtof_clamp(text, &(yylval->lex.f))) if (!strtof_clamp(text, &(yylval->lex.f)))
yyextra->warning(*yylloc, "Float overflow", yytext, ""); yyextra->warning(*yylloc, "Float overflow", yytext);
return(FLOATCONSTANT); return(FLOATCONSTANT);
} }
...@@ -578,9 +578,9 @@ int int_constant(TParseContext *context) { ...@@ -578,9 +578,9 @@ int int_constant(TParseContext *context) {
if (!atoi_clamp(yytext, &u)) if (!atoi_clamp(yytext, &u))
{ {
if (context->getShaderVersion() >= 300) if (context->getShaderVersion() >= 300)
yyextra->error(*yylloc, "Integer overflow", yytext, ""); yyextra->error(*yylloc, "Integer overflow", yytext);
else else
yyextra->warning(*yylloc, "Integer overflow", yytext, ""); yyextra->warning(*yylloc, "Integer overflow", yytext);
} }
yylval->lex.i = static_cast<int>(u); yylval->lex.i = static_cast<int>(u);
return INTCONSTANT; return INTCONSTANT;
...@@ -590,7 +590,7 @@ int float_constant(yyscan_t yyscanner) { ...@@ -590,7 +590,7 @@ int float_constant(yyscan_t yyscanner) {
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
if (!strtof_clamp(yytext, &(yylval->lex.f))) if (!strtof_clamp(yytext, &(yylval->lex.f)))
yyextra->warning(*yylloc, "Float overflow", yytext, ""); yyextra->warning(*yylloc, "Float overflow", yytext);
return FLOATCONSTANT; return FLOATCONSTANT;
} }
......
...@@ -932,7 +932,7 @@ storage_qualifier ...@@ -932,7 +932,7 @@ storage_qualifier
| INOUT_QUAL { | INOUT_QUAL {
if (!context->declaringFunction()) if (!context->declaringFunction())
{ {
context->error(@1, "invalid inout qualifier", "'inout' can be only used with function parameters"); context->error(@1, "invalid qualifier: can be only used with function parameters", "inout");
} }
$$ = new TStorageQualifierWrapper(EvqInOut, @1); $$ = new TStorageQualifierWrapper(EvqInOut, @1);
} }
...@@ -1257,16 +1257,7 @@ struct_declaration_list ...@@ -1257,16 +1257,7 @@ struct_declaration_list
$$ = $1; $$ = $1;
} }
| struct_declaration_list struct_declaration { | struct_declaration_list struct_declaration {
$$ = $1; $$ = context->combineStructFieldLists($1, $2, @2);
for (size_t i = 0; i < $2->size(); ++i) {
TField* field = (*$2)[i];
for (size_t j = 0; j < $$->size(); ++j) {
if ((*$$)[j]->name() == field->name()) {
context->error(@2, "duplicate field name in structure:", "struct", field->name().c_str());
}
}
$$->push_back(field);
}
} }
; ;
......
#line 17 "./glslang.l"
// //
// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
...@@ -221,7 +222,7 @@ typedef size_t yy_size_t; ...@@ -221,7 +222,7 @@ typedef size_t yy_size_t;
#define YY_LESS_LINENO(n) \ #define YY_LESS_LINENO(n) \
do { \ do { \
yy_size_t yyl;\ yy_size_t yyl;\
for ( yyl = n; yyl < static_cast<yy_site_t>(yyleng); ++yyl )\ for ( yyl = n; yyl < yyleng; ++yyl )\
if ( yytext[yyl] == '\n' )\ if ( yytext[yyl] == '\n' )\
--yylineno;\ --yylineno;\
}while(0) }while(0)
...@@ -396,7 +397,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); ...@@ -396,7 +397,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
*/ */
#define YY_DO_BEFORE_ACTION \ #define YY_DO_BEFORE_ACTION \
yyg->yytext_ptr = yy_bp; \ yyg->yytext_ptr = yy_bp; \
yyleng = (size_t) (yy_cp - yy_bp); \ yyleng = (yy_size_t) (yy_cp - yy_bp); \
yyg->yy_hold_char = *yy_cp; \ yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \ *yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp; yyg->yy_c_buf_p = yy_cp;
...@@ -1380,7 +1381,7 @@ yy_find_action: ...@@ -1380,7 +1381,7 @@ yy_find_action:
if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
{ {
yy_size_t yyl; yy_size_t yyl;
for ( yyl = 0; yyl < static_cast<yy_size_t>(yyleng); ++yyl ) for ( yyl = 0; yyl < yyleng; ++yyl )
if ( yytext[yyl] == '\n' ) if ( yytext[yyl] == '\n' )
do{ yylineno++; do{ yylineno++;
...@@ -2141,7 +2142,7 @@ YY_RULE_SETUP ...@@ -2141,7 +2142,7 @@ YY_RULE_SETUP
case 238: case 238:
YY_RULE_SETUP YY_RULE_SETUP
{ {
yyextra->error(*yylloc, "Illegal character at fieldname start", yytext, ""); yyextra->error(*yylloc, "Illegal character at fieldname start", yytext);
return 0; return 0;
} }
YY_BREAK YY_BREAK
...@@ -2384,7 +2385,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) ...@@ -2384,7 +2385,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
static_cast<int>(number_to_move) - 1; number_to_move - 1;
} }
...@@ -2392,10 +2393,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) ...@@ -2392,10 +2393,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
num_to_read = YY_READ_BUF_SIZE; num_to_read = YY_READ_BUF_SIZE;
/* Read in more data. */ /* Read in more data. */
size_t result = 0;
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
result, num_to_read ); yyg->yy_n_chars, num_to_read );
yyg->yy_n_chars = static_cast<int>(result);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
} }
...@@ -2836,7 +2835,7 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) ...@@ -2836,7 +2835,7 @@ static void yyensure_buffer_stack (yyscan_t yyscanner)
/* Increase the buffer to prepare for a possible push. */ /* Increase the buffer to prepare for a possible push. */
int grow_size = 8 /* arbitrary grow size */; int grow_size = 8 /* arbitrary grow size */;
num_to_alloc = static_cast<int>(yyg->yy_buffer_stack_max + grow_size); num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
(yyg->yy_buffer_stack, (yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*) num_to_alloc * sizeof(struct yy_buffer_state*)
...@@ -2870,7 +2869,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscann ...@@ -2870,7 +2869,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscann
if ( ! b ) if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
b->yy_buf_size = static_cast<int>(size) - 2; /* "- 2" to take care of EOB's */ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base; b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0; b->yy_is_our_buffer = 0;
b->yy_input_file = 0; b->yy_input_file = 0;
...@@ -2919,7 +2918,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ...@@ -2919,7 +2918,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
if ( ! buf ) if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
for ( i = 0; i < static_cast<yy_size_t>(_yybytes_len); ++i ) for ( i = 0; i < _yybytes_len; ++i )
buf[i] = yybytes[i]; buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
...@@ -3342,7 +3341,7 @@ int check_type(yyscan_t yyscanner) { ...@@ -3342,7 +3341,7 @@ int check_type(yyscan_t yyscanner) {
int reserved_word(yyscan_t yyscanner) { int reserved_word(yyscan_t yyscanner) {
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
yyextra->error(*yylloc, "Illegal use of reserved word", yytext, ""); yyextra->error(*yylloc, "Illegal use of reserved word", yytext);
return 0; return 0;
} }
...@@ -3436,12 +3435,12 @@ int uint_constant(TParseContext *context) ...@@ -3436,12 +3435,12 @@ int uint_constant(TParseContext *context)
if (context->getShaderVersion() < 300) if (context->getShaderVersion() < 300)
{ {
context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext, ""); context->error(*yylloc, "Unsigned integers are unsupported prior to GLSL ES 3.00", yytext);
return 0; return 0;
} }
if (!atoi_clamp(yytext, &(yylval->lex.u))) if (!atoi_clamp(yytext, &(yylval->lex.u)))
yyextra->error(*yylloc, "Integer overflow", yytext, ""); yyextra->error(*yylloc, "Integer overflow", yytext);
return UINTCONSTANT; return UINTCONSTANT;
} }
...@@ -3459,7 +3458,7 @@ int floatsuffix_check(TParseContext* context) ...@@ -3459,7 +3458,7 @@ int floatsuffix_check(TParseContext* context)
std::string text = yytext; std::string text = yytext;
text.resize(text.size() - 1); text.resize(text.size() - 1);
if (!strtof_clamp(text, &(yylval->lex.f))) if (!strtof_clamp(text, &(yylval->lex.f)))
yyextra->warning(*yylloc, "Float overflow", yytext, ""); yyextra->warning(*yylloc, "Float overflow", yytext);
return(FLOATCONSTANT); return(FLOATCONSTANT);
} }
...@@ -3475,9 +3474,9 @@ int int_constant(TParseContext *context) { ...@@ -3475,9 +3474,9 @@ int int_constant(TParseContext *context) {
if (!atoi_clamp(yytext, &u)) if (!atoi_clamp(yytext, &u))
{ {
if (context->getShaderVersion() >= 300) if (context->getShaderVersion() >= 300)
yyextra->error(*yylloc, "Integer overflow", yytext, ""); yyextra->error(*yylloc, "Integer overflow", yytext);
else else
yyextra->warning(*yylloc, "Integer overflow", yytext, ""); yyextra->warning(*yylloc, "Integer overflow", yytext);
} }
yylval->lex.i = static_cast<int>(u); yylval->lex.i = static_cast<int>(u);
return INTCONSTANT; return INTCONSTANT;
...@@ -3487,7 +3486,7 @@ int float_constant(yyscan_t yyscanner) { ...@@ -3487,7 +3486,7 @@ int float_constant(yyscan_t yyscanner) {
struct yyguts_t* yyg = (struct yyguts_t*) yyscanner; struct yyguts_t* yyg = (struct yyguts_t*) yyscanner;
if (!strtof_clamp(yytext, &(yylval->lex.f))) if (!strtof_clamp(yytext, &(yylval->lex.f)))
yyextra->warning(*yylloc, "Float overflow", yytext, ""); yyextra->warning(*yylloc, "Float overflow", yytext);
return FLOATCONSTANT; return FLOATCONSTANT;
} }
......
...@@ -755,13 +755,13 @@ static const yytype_uint16 yyrline[] = ...@@ -755,13 +755,13 @@ static const yytype_uint16 yyrline[] =
1147, 1150, 1153, 1156, 1159, 1162, 1165, 1168, 1171, 1174, 1147, 1150, 1153, 1156, 1159, 1162, 1165, 1168, 1171, 1174,
1177, 1180, 1183, 1190, 1196, 1199, 1202, 1205, 1208, 1211, 1177, 1180, 1183, 1190, 1196, 1199, 1202, 1205, 1208, 1211,
1214, 1217, 1220, 1223, 1226, 1229, 1232, 1235, 1247, 1247, 1214, 1217, 1220, 1223, 1226, 1229, 1232, 1235, 1247, 1247,
1250, 1250, 1256, 1259, 1274, 1277, 1284, 1288, 1294, 1300, 1250, 1250, 1256, 1259, 1265, 1268, 1275, 1279, 1285, 1291,
1312, 1316, 1320, 1321, 1327, 1328, 1329, 1330, 1331, 1332, 1303, 1307, 1311, 1312, 1318, 1319, 1320, 1321, 1322, 1323,
1333, 1337, 1338, 1338, 1338, 1347, 1348, 1352, 1352, 1353, 1324, 1328, 1329, 1329, 1329, 1338, 1339, 1343, 1343, 1344,
1353, 1358, 1361, 1370, 1375, 1382, 1383, 1387, 1394, 1398, 1344, 1349, 1352, 1361, 1366, 1373, 1374, 1378, 1385, 1389,
1405, 1405, 1412, 1415, 1422, 1426, 1439, 1439, 1444, 1444, 1396, 1396, 1403, 1406, 1413, 1417, 1430, 1430, 1435, 1435,
1450, 1450, 1458, 1461, 1467, 1470, 1476, 1480, 1487, 1490, 1441, 1441, 1449, 1452, 1458, 1461, 1467, 1471, 1478, 1481,
1493, 1496, 1499, 1508, 1514, 1520, 1523, 1529, 1529 1484, 1487, 1490, 1499, 1505, 1511, 1514, 1520, 1520
}; };
#endif #endif
...@@ -3677,7 +3677,7 @@ yyreduce: ...@@ -3677,7 +3677,7 @@ yyreduce:
{ {
if (!context->declaringFunction()) if (!context->declaringFunction())
{ {
context->error((yylsp[0]), "invalid inout qualifier", "'inout' can be only used with function parameters"); context->error((yylsp[0]), "invalid qualifier: can be only used with function parameters", "inout");
} }
(yyval.interm.qualifierWrapper) = new TStorageQualifierWrapper(EvqInOut, (yylsp[0])); (yyval.interm.qualifierWrapper) = new TStorageQualifierWrapper(EvqInOut, (yylsp[0]));
} }
...@@ -4402,16 +4402,7 @@ yyreduce: ...@@ -4402,16 +4402,7 @@ yyreduce:
case 223: case 223:
{ {
(yyval.interm.fieldList) = (yyvsp[-1].interm.fieldList); (yyval.interm.fieldList) = context->combineStructFieldLists((yyvsp[-1].interm.fieldList), (yyvsp[0].interm.fieldList), (yylsp[0]));
for (size_t i = 0; i < (yyvsp[0].interm.fieldList)->size(); ++i) {
TField* field = (*(yyvsp[0].interm.fieldList))[i];
for (size_t j = 0; j < (yyval.interm.fieldList)->size(); ++j) {
if ((*(yyval.interm.fieldList))[j]->name() == field->name()) {
context->error((yylsp[0]), "duplicate field name in structure:", "struct", field->name().c_str());
}
}
(yyval.interm.fieldList)->push_back(field);
}
} }
break; break;
......
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