Check that the incoming type to a default precision qualifier statement is valid.

Fixes new WebGL conformance tests shader-with-illegal-default-precision.frag.html and shader-with-illegal-default-precision.vert.html per http://www.khronos.org/bugzilla/show_bug.cgi?id=781 . Also ran WebGL 1.0.1 conformance tests; no regressions. BUG=none Review URL: https://codereview.appspot.com/7302043 git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1958 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 83065899
......@@ -323,10 +323,16 @@ public:
void dump(TInfoSink &infoSink) const;
void copyTable(const TSymbolTable& copyOf);
void setDefaultPrecision( TBasicType type, TPrecision prec ){
if( type != EbtFloat && type != EbtInt ) return; // Only set default precision for int/float
bool setDefaultPrecision( const TPublicType& type, TPrecision prec ){
if (IsSampler(type.type))
return true; // Skip sampler types for the time being
if (type.type != EbtFloat && type.type != EbtInt)
return false; // Only set default precision for int/float
if (type.size != 1 || type.matrix || type.array)
return false; // Not allowed to set for aggregate types
int indexOfLastElement = static_cast<int>(precisionStack.size()) - 1;
precisionStack[indexOfLastElement][type] = prec; // Uses map operator [], overwrites the current value
precisionStack[indexOfLastElement][type.type] = prec; // Uses map operator [], overwrites the current value
return true;
}
// Searches down the precisionStack for a precision qualifier for the specified TBasicType
......
......@@ -991,7 +991,10 @@ declaration
$$ = $1.intermAggregate;
}
| PRECISION precision_qualifier type_specifier_no_prec SEMICOLON {
context->symbolTable.setDefaultPrecision( $3.type, $2 );
if (!context->symbolTable.setDefaultPrecision( $3, $2 )) {
context->error($1.line, "illegal type argument for default precision qualifier", getBasicString($3.type));
context->recover();
}
$$ = 0;
}
;
......
......@@ -667,20 +667,20 @@ static const yytype_uint16 yyrline[] =
762, 773, 777, 778, 788, 798, 808, 821, 822, 832,
845, 849, 853, 857, 858, 871, 872, 885, 886, 899,
900, 917, 918, 931, 932, 933, 934, 935, 939, 942,
953, 961, 988, 993, 1000, 1038, 1041, 1048, 1056, 1077,
1098, 1109, 1138, 1143, 1153, 1158, 1168, 1171, 1174, 1177,
1183, 1190, 1193, 1215, 1233, 1257, 1280, 1284, 1302, 1310,
1342, 1362, 1451, 1460, 1483, 1486, 1492, 1500, 1508, 1516,
1526, 1533, 1536, 1539, 1545, 1548, 1563, 1567, 1571, 1575,
1584, 1589, 1594, 1599, 1604, 1609, 1614, 1619, 1624, 1629,
1635, 1641, 1647, 1652, 1657, 1666, 1675, 1680, 1693, 1693,
1707, 1707, 1716, 1719, 1734, 1770, 1774, 1780, 1788, 1804,
1808, 1812, 1813, 1819, 1820, 1821, 1822, 1823, 1827, 1828,
1828, 1828, 1838, 1839, 1843, 1843, 1844, 1844, 1849, 1852,
1862, 1865, 1871, 1872, 1876, 1884, 1888, 1898, 1903, 1920,
1920, 1925, 1925, 1932, 1932, 1940, 1943, 1949, 1952, 1958,
1962, 1969, 1976, 1983, 1990, 2001, 2010, 2014, 2021, 2024,
2030, 2030
953, 961, 988, 993, 1003, 1041, 1044, 1051, 1059, 1080,
1101, 1112, 1141, 1146, 1156, 1161, 1171, 1174, 1177, 1180,
1186, 1193, 1196, 1218, 1236, 1260, 1283, 1287, 1305, 1313,
1345, 1365, 1454, 1463, 1486, 1489, 1495, 1503, 1511, 1519,
1529, 1536, 1539, 1542, 1548, 1551, 1566, 1570, 1574, 1578,
1587, 1592, 1597, 1602, 1607, 1612, 1617, 1622, 1627, 1632,
1638, 1644, 1650, 1655, 1660, 1669, 1678, 1683, 1696, 1696,
1710, 1710, 1719, 1722, 1737, 1773, 1777, 1783, 1791, 1807,
1811, 1815, 1816, 1822, 1823, 1824, 1825, 1826, 1830, 1831,
1831, 1831, 1841, 1842, 1846, 1846, 1847, 1847, 1852, 1855,
1865, 1868, 1874, 1875, 1879, 1887, 1891, 1901, 1906, 1923,
1923, 1928, 1928, 1935, 1935, 1943, 1946, 1952, 1955, 1961,
1965, 1972, 1979, 1986, 1993, 2004, 2013, 2017, 2024, 2027,
2033, 2033
};
#endif
......@@ -3088,7 +3088,10 @@ yyreduce:
case 73:
{
context->symbolTable.setDefaultPrecision( (yyvsp[(3) - (4)].interm.type).type, (yyvsp[(2) - (4)].interm.precision) );
if (!context->symbolTable.setDefaultPrecision( (yyvsp[(3) - (4)].interm.type), (yyvsp[(2) - (4)].interm.precision) )) {
context->error((yyvsp[(1) - (4)].lex).line, "illegal type argument for default precision qualifier", getBasicString((yyvsp[(3) - (4)].interm.type).type));
context->recover();
}
(yyval.interm.intermNode) = 0;
}
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