Commit d2b1d2f9 by Nicolas Capens Committed by Nicolas Capens

Remove literal string from error message.

The lexer doesn't actually keep the string for literals. Bug chromium:939239 Change-Id: Ib8b28e75e36d1c6beff8afa580fc4c29c23b6eb0 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/26428Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 62033406
...@@ -2828,7 +2828,7 @@ TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierTyp ...@@ -2828,7 +2828,7 @@ TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierTyp
return qualifier; return qualifier;
} }
TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine, const TString &intValueString, int intValue, const TSourceLoc& intValueLine) TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine, int intValue, const TSourceLoc& intValueLine)
{ {
TLayoutQualifier qualifier; TLayoutQualifier qualifier;
...@@ -2846,7 +2846,7 @@ TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierTyp ...@@ -2846,7 +2846,7 @@ TLayoutQualifier TParseContext::parseLayoutQualifier(const TString &qualifierTyp
// must check that location is non-negative // must check that location is non-negative
if (intValue < 0) if (intValue < 0)
{ {
error(intValueLine, "out of range:", intValueString.c_str(), "location must be non-negative"); error(intValueLine, "out of range:", "", "location must be non-negative");
recover(); recover();
} }
else else
......
...@@ -209,7 +209,7 @@ public: ...@@ -209,7 +209,7 @@ public:
const TString* instanceName, const TSourceLoc& instanceLine, TIntermTyped* arrayIndex, const TSourceLoc& arrayIndexLine); const TString* instanceName, const TSourceLoc& instanceLine, TIntermTyped* arrayIndex, const TSourceLoc& arrayIndexLine);
TLayoutQualifier parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine); TLayoutQualifier parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine);
TLayoutQualifier parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine, const TString &intValueString, int intValue, const TSourceLoc& intValueLine); TLayoutQualifier parseLayoutQualifier(const TString &qualifierType, const TSourceLoc& qualifierTypeLine, int intValue, const TSourceLoc& intValueLine);
TLayoutQualifier joinLayoutQualifiers(TLayoutQualifier leftQualifier, TLayoutQualifier rightQualifier); TLayoutQualifier joinLayoutQualifiers(TLayoutQualifier leftQualifier, TLayoutQualifier rightQualifier);
TPublicType joinInterpolationQualifiers(const TSourceLoc &interpolationLoc, TQualifier interpolationQualifier, const TSourceLoc &storageLoc, TQualifier storageQualifier); TPublicType joinInterpolationQualifiers(const TSourceLoc &interpolationLoc, TQualifier interpolationQualifier, const TSourceLoc &storageLoc, TQualifier storageQualifier);
......
...@@ -1047,10 +1047,10 @@ layout_qualifier_id ...@@ -1047,10 +1047,10 @@ layout_qualifier_id
$$ = context->parseLayoutQualifier(*$1.string, @1); $$ = context->parseLayoutQualifier(*$1.string, @1);
} }
| IDENTIFIER EQUAL INTCONSTANT { | IDENTIFIER EQUAL INTCONSTANT {
$$ = context->parseLayoutQualifier(*$1.string, @1, *$3.string, $3.i, @3); $$ = context->parseLayoutQualifier(*$1.string, @1, $3.i, @3);
} }
| IDENTIFIER EQUAL UINTCONSTANT { | IDENTIFIER EQUAL UINTCONSTANT {
$$ = context->parseLayoutQualifier(*$1.string, @1, *$3.string, $3.i, @3); $$ = context->parseLayoutQualifier(*$1.string, @1, $3.i, @3);
} }
; ;
......
...@@ -3777,7 +3777,7 @@ yyreduce: ...@@ -3777,7 +3777,7 @@ yyreduce:
case 153: case 153:
{ {
(yyval.interm.layoutQualifier) = context->parseLayoutQualifier(*(yyvsp[-2].lex).string, (yylsp[-2]), *(yyvsp[0].lex).string, (yyvsp[0].lex).i, (yylsp[0])); (yyval.interm.layoutQualifier) = context->parseLayoutQualifier(*(yyvsp[-2].lex).string, (yylsp[-2]), (yyvsp[0].lex).i, (yylsp[0]));
} }
break; break;
...@@ -3785,7 +3785,7 @@ yyreduce: ...@@ -3785,7 +3785,7 @@ yyreduce:
case 154: case 154:
{ {
(yyval.interm.layoutQualifier) = context->parseLayoutQualifier(*(yyvsp[-2].lex).string, (yylsp[-2]), *(yyvsp[0].lex).string, (yyvsp[0].lex).i, (yylsp[0])); (yyval.interm.layoutQualifier) = context->parseLayoutQualifier(*(yyvsp[-2].lex).string, (yylsp[-2]), (yyvsp[0].lex).i, (yylsp[0]));
} }
break; break;
......
...@@ -775,6 +775,98 @@ TEST_F(SwiftShaderTest, AttributeLocation) ...@@ -775,6 +775,98 @@ TEST_F(SwiftShaderTest, AttributeLocation)
Uninitialize(); Uninitialize();
} }
// Test negative layout locations
TEST_F(SwiftShaderTest, NegativeLocation)
{
Initialize(3, false);
const std::string vs =
"#version 300 es\n"
"layout(location = 0x86868686u) in vec4 a0;\n" // Explicitly bound in GLSL
"layout(location = 0x96969696u) in vec4 a2;\n" // Explicitly bound in GLSL
"in vec4 a5;\n" // Bound to location 5 by API
"in mat2 a3;\n" // Implicit location
"in vec4 a1;\n" // Implicit location
"in vec4 a6;\n" // Implicit location
"out vec4 color;\n"
"void main()\n"
"{\n"
" vec4 a34 = vec4(a3[0], a3[1]);\n"
" gl_Position = a0;\n"
" color = (a2 == vec4(1.0, 2.0, 3.0, 4.0) &&\n"
" a34 == vec4(5.0, 6.0, 7.0, 8.0) &&\n"
" a5 == vec4(9.0, 10.0, 11.0, 12.0) &&\n"
" a1 == vec4(13.0, 14.0, 15.0, 16.0) &&\n"
" a6 == vec4(17.0, 18.0, 19.0, 20.0)) ?\n"
" vec4(0.0, 1.0, 0.0, 1.0) :\n"
" vec4(1.0, 0.0, 0.0, 1.0);"
"}\n";
const std::string fs =
"#version 300 es\n"
"precision mediump float;\n"
"in vec4 color;\n"
"layout(location = 0xA6A6A6A6u) out vec4 fragColor;\n"
"void main()\n"
"{\n"
" fragColor = color;\n"
"}\n";
{
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
const char* vsSource[1] = { vs.c_str() };
glShaderSource(vertexShader, 1, vsSource, nullptr);
glCompileShader(vertexShader);
EXPECT_GLENUM_EQ(GL_NONE, glGetError());
GLint vsCompileStatus = 0;
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &vsCompileStatus);
EXPECT_EQ(vsCompileStatus, GL_FALSE);
// Expect the info log to contain "out of range: location must be non-negative". This is not a spec requirement.
GLsizei length = 0;
glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &length);
EXPECT_GLENUM_EQ(GL_NONE, glGetError());
EXPECT_NE(length, 0);
char *log = new char[length];
GLsizei written = 0;
glGetShaderInfoLog(vertexShader, length, &written, log);
EXPECT_GLENUM_EQ(GL_NONE, glGetError());
EXPECT_EQ(length, written + 1);
EXPECT_NE(strstr(log, "out of range: location must be non-negative"), nullptr);
delete[] log;
glDeleteShader(vertexShader);
}
{
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
const char* fsSource[1] = { fs.c_str() };
glShaderSource(fragmentShader, 1, fsSource, nullptr);
glCompileShader(fragmentShader);
EXPECT_GLENUM_EQ(GL_NONE, glGetError());
GLint fsCompileStatus = 0;
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &fsCompileStatus);
EXPECT_EQ(fsCompileStatus, GL_FALSE);
// Expect the info log to contain "out of range: location must be non-negative". This is not a spec requirement.
GLsizei length = 0;
glGetShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &length);
EXPECT_GLENUM_EQ(GL_NONE, glGetError());
EXPECT_NE(length, 0);
char *log = new char[length];
GLsizei written = 0;
glGetShaderInfoLog(fragmentShader, length, &written, log);
EXPECT_GLENUM_EQ(GL_NONE, glGetError());
EXPECT_EQ(length, written + 1);
EXPECT_NE(strstr(log, "out of range: location must be non-negative"), nullptr);
delete[] log;
glDeleteShader(fragmentShader);
}
Uninitialize();
}
// Tests clearing of a texture with 'dirty' content. // Tests clearing of a texture with 'dirty' content.
TEST_F(SwiftShaderTest, ClearDirtyTexture) TEST_F(SwiftShaderTest, ClearDirtyTexture)
{ {
......
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