Commit 0e3aee3f by Olli Etuaho Committed by Commit Bot

Check precision qualification for all declarations

Precision qualification is now checked properly also for declarations that don't have qualifiers. BUG=angleproject:1574 TEST=angle_unittests Change-Id: I3d186df0763e071614c1da9a355a6f6fefdc8091 Reviewed-on: https://chromium-review.googlesource.com/403949 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 2018c0ba
...@@ -1581,6 +1581,18 @@ bool TParseContext::executeInitializer(const TSourceLoc &line, ...@@ -1581,6 +1581,18 @@ bool TParseContext::executeInitializer(const TSourceLoc &line,
return false; return false;
} }
void TParseContext::addFullySpecifiedType(TPublicType *typeSpecifier)
{
checkPrecisionSpecified(typeSpecifier->getLine(), typeSpecifier->precision,
typeSpecifier->getBasicType());
if (mShaderVersion < 300 && typeSpecifier->array)
{
error(typeSpecifier->getLine(), "not supported", "first-class array");
typeSpecifier->clearArrayness();
}
}
TPublicType TParseContext::addFullySpecifiedType(const TTypeQualifierBuilder &typeQualifierBuilder, TPublicType TParseContext::addFullySpecifiedType(const TTypeQualifierBuilder &typeQualifierBuilder,
const TPublicType &typeSpecifier) const TPublicType &typeSpecifier)
{ {
......
...@@ -204,6 +204,7 @@ class TParseContext : angle::NonCopyable ...@@ -204,6 +204,7 @@ class TParseContext : angle::NonCopyable
TIntermTyped *initializer, TIntermTyped *initializer,
TIntermBinary **initNode); TIntermBinary **initNode);
void addFullySpecifiedType(TPublicType *typeSpecifier);
TPublicType addFullySpecifiedType(const TTypeQualifierBuilder &typeQualifierBuilder, TPublicType addFullySpecifiedType(const TTypeQualifierBuilder &typeQualifierBuilder,
const TPublicType &typeSpecifier); const TPublicType &typeSpecifier);
......
...@@ -813,14 +813,8 @@ single_declaration ...@@ -813,14 +813,8 @@ single_declaration
fully_specified_type fully_specified_type
: type_specifier { : type_specifier {
context->addFullySpecifiedType(&$1);
$$ = $1; $$ = $1;
if ($1.array) {
ES3_OR_NEWER("[]", @1, "first-class-array");
if (context->getShaderVersion() != 300) {
$1.clearArrayness();
}
}
} }
| type_qualifier type_specifier { | type_qualifier type_specifier {
$$ = context->addFullySpecifiedType(*$1, $2); $$ = context->addFullySpecifiedType(*$1, $2);
...@@ -959,10 +953,7 @@ storage_qualifier ...@@ -959,10 +953,7 @@ storage_qualifier
type_specifier type_specifier
: type_specifier_no_prec { : type_specifier_no_prec {
$$ = $1; $$ = $1;
$$.precision = context->symbolTable.getDefaultPrecision($1.getBasicType());
if ($$.precision == EbpUndefined) {
$$.precision = context->symbolTable.getDefaultPrecision($1.getBasicType());
}
} }
; ;
......
...@@ -742,23 +742,23 @@ static const yytype_uint16 yyrline[] = ...@@ -742,23 +742,23 @@ static const yytype_uint16 yyrline[] =
612, 621, 625, 629, 633, 637, 644, 651, 654, 661, 612, 621, 625, 629, 633, 637, 644, 651, 654, 661,
669, 689, 699, 707, 732, 736, 740, 744, 751, 758, 669, 689, 699, 707, 732, 736, 740, 744, 751, 758,
761, 765, 769, 774, 779, 786, 790, 794, 798, 803, 761, 765, 769, 774, 779, 786, 790, 794, 798, 803,
808, 815, 825, 831, 834, 840, 844, 851, 857, 861, 808, 815, 819, 825, 828, 834, 838, 845, 851, 855,
865, 868, 871, 880, 886, 894, 897, 917, 936, 943, 859, 862, 865, 874, 880, 888, 891, 911, 930, 937,
947, 951, 954, 960, 970, 973, 976, 982, 989, 992, 941, 945, 948, 954, 961, 964, 967, 973, 980, 983,
998, 1001, 1004, 1010, 1013, 1018, 1029, 1032, 1035, 1038, 989, 992, 995, 1001, 1004, 1009, 1020, 1023, 1026, 1029,
1041, 1044, 1048, 1052, 1056, 1060, 1064, 1068, 1072, 1076, 1032, 1035, 1039, 1043, 1047, 1051, 1055, 1059, 1063, 1067,
1080, 1084, 1088, 1092, 1096, 1100, 1104, 1108, 1112, 1116, 1071, 1075, 1079, 1083, 1087, 1091, 1095, 1099, 1103, 1107,
1120, 1124, 1128, 1131, 1134, 1137, 1140, 1143, 1146, 1149, 1111, 1115, 1119, 1122, 1125, 1128, 1131, 1134, 1137, 1140,
1152, 1155, 1158, 1161, 1164, 1167, 1170, 1173, 1180, 1186, 1143, 1146, 1149, 1152, 1155, 1158, 1161, 1164, 1171, 1177,
1189, 1192, 1195, 1198, 1201, 1204, 1207, 1210, 1213, 1216, 1180, 1183, 1186, 1189, 1192, 1195, 1198, 1201, 1204, 1207,
1219, 1222, 1225, 1237, 1237, 1240, 1240, 1246, 1249, 1264, 1210, 1213, 1216, 1228, 1228, 1231, 1231, 1237, 1240, 1255,
1267, 1274, 1278, 1284, 1290, 1302, 1306, 1310, 1311, 1317, 1258, 1265, 1269, 1275, 1281, 1293, 1297, 1301, 1302, 1308,
1318, 1319, 1320, 1321, 1322, 1323, 1327, 1328, 1328, 1328, 1309, 1310, 1311, 1312, 1313, 1314, 1318, 1319, 1319, 1319,
1337, 1338, 1342, 1342, 1343, 1343, 1348, 1351, 1360, 1365, 1328, 1329, 1333, 1333, 1334, 1334, 1339, 1342, 1351, 1356,
1372, 1373, 1377, 1384, 1388, 1395, 1395, 1402, 1405, 1412, 1363, 1364, 1368, 1375, 1379, 1386, 1386, 1393, 1396, 1403,
1416, 1429, 1429, 1434, 1434, 1440, 1440, 1448, 1451, 1457, 1407, 1420, 1420, 1425, 1425, 1431, 1431, 1439, 1442, 1448,
1460, 1466, 1470, 1477, 1480, 1483, 1486, 1489, 1498, 1504, 1451, 1457, 1461, 1468, 1471, 1474, 1477, 1480, 1489, 1495,
1510, 1513, 1519, 1519 1501, 1504, 1510, 1510
}; };
#endif #endif
...@@ -3469,14 +3469,8 @@ yyreduce: ...@@ -3469,14 +3469,8 @@ yyreduce:
case 121: case 121:
{ {
context->addFullySpecifiedType(&(yyvsp[0].interm.type));
(yyval.interm.type) = (yyvsp[0].interm.type); (yyval.interm.type) = (yyvsp[0].interm.type);
if ((yyvsp[0].interm.type).array) {
ES3_OR_NEWER("[]", (yylsp[0]), "first-class-array");
if (context->getShaderVersion() != 300) {
(yyvsp[0].interm.type).clearArrayness();
}
}
} }
break; break;
...@@ -3705,10 +3699,7 @@ yyreduce: ...@@ -3705,10 +3699,7 @@ yyreduce:
{ {
(yyval.interm.type) = (yyvsp[0].interm.type); (yyval.interm.type) = (yyvsp[0].interm.type);
(yyval.interm.type).precision = context->symbolTable.getDefaultPrecision((yyvsp[0].interm.type).getBasicType());
if ((yyval.interm.type).precision == EbpUndefined) {
(yyval.interm.type).precision = context->symbolTable.getDefaultPrecision((yyvsp[0].interm.type).getBasicType());
}
} }
break; break;
......
...@@ -3000,3 +3000,21 @@ TEST_F(MalformedShaderTest, SamplerAsTernaryOperand) ...@@ -3000,3 +3000,21 @@ TEST_F(MalformedShaderTest, SamplerAsTernaryOperand)
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog; FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
} }
} }
// ESSL 1.00.17 section 4.5.2.
// ESSL 3.00.6 section 4.5.3.
// Precision must be specified for floats. Test this with a declaration with no qualifiers.
TEST_F(MalformedShaderTest, FloatDeclarationNoQualifiersNoPrecision)
{
const std::string &shaderString =
"vec4 foo = vec4(0.0);\n"
"void main()\n"
"{\n"
" gl_FragColor = foo;\n"
"}\n";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure " << mInfoLog;
}
}
\ No newline at end of file
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