Commit 53f076fa by Olli Etuaho

Add basic error checks for switch and case

Check that the case labels have constant scalar integers, and that switch statements are initialized with scalar integers. Also check that case and default labels do not exist outside switch statements. Allow break statements inside switch statements. Tested by manually disabling shading language version checks for switch in a Chromium build and checking that the expected errors are generated. BUG=angle:921 Change-Id: Ibe83d0db52958c493ded5640d4babf670dc02d55 Reviewed-on: https://chromium-review.googlesource.com/251523Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent a3a36664
......@@ -2610,6 +2610,17 @@ TPublicType TParseContext::addStructure(const TSourceLoc& structLine, const TSou
TIntermSwitch *TParseContext::addSwitch(TIntermTyped *init, TIntermAggregate *statementList, const TSourceLoc &loc)
{
TBasicType switchType = init->getBasicType();
if ((switchType != EbtInt && switchType != EbtUInt) ||
init->isMatrix() ||
init->isArray() ||
init->isVector())
{
error(init->getLine(), "init-expression in a switch statement must be a scalar integer", "switch");
recover();
return nullptr;
}
TIntermSwitch *node = intermediate.addSwitch(init, statementList, loc);
if (node == nullptr)
{
......@@ -2622,6 +2633,32 @@ TIntermSwitch *TParseContext::addSwitch(TIntermTyped *init, TIntermAggregate *st
TIntermCase *TParseContext::addCase(TIntermTyped *condition, const TSourceLoc &loc)
{
if (mSwitchNestingLevel == 0)
{
error(loc, "case labels need to be inside switch statements", "case");
recover();
return nullptr;
}
if (condition == nullptr)
{
error(loc, "case label must have a condition", "case");
recover();
return nullptr;
}
if ((condition->getBasicType() != EbtInt && condition->getBasicType() != EbtUInt) ||
condition->isMatrix() ||
condition->isArray() ||
condition->isVector())
{
error(condition->getLine(), "case label must be a scalar integer", "case");
recover();
}
TIntermConstantUnion *conditionConst = condition->getAsConstantUnion();
if (conditionConst == nullptr)
{
error(condition->getLine(), "case label must be constant", "case");
recover();
}
TIntermCase *node = intermediate.addCase(condition, loc);
if (node == nullptr)
{
......@@ -2634,6 +2671,12 @@ TIntermCase *TParseContext::addCase(TIntermTyped *condition, const TSourceLoc &l
TIntermCase *TParseContext::addDefault(const TSourceLoc &loc)
{
if (mSwitchNestingLevel == 0)
{
error(loc, "default labels need to be inside switch statements", "default");
recover();
return nullptr;
}
TIntermCase *node = intermediate.addCase(nullptr, loc);
if (node == nullptr)
{
......@@ -2703,9 +2746,9 @@ TIntermBranch *TParseContext::addBranch(TOperator op, const TSourceLoc &loc)
}
break;
case EOpBreak:
if (mLoopNestingLevel <= 0)
if (mLoopNestingLevel <= 0 && mSwitchNestingLevel <= 0)
{
error(loc, "break statement only allowed in loops", "");
error(loc, "break statement only allowed in loops and switch statements", "");
recover();
}
break;
......
......@@ -34,6 +34,7 @@ struct TParseContext {
treeRoot(0),
mLoopNestingLevel(0),
structNestingLevel(0),
mSwitchNestingLevel(0),
currentFunctionType(NULL),
mFunctionReturnsValue(false),
checksPrecisionErrors(checksPrecErrors),
......@@ -53,6 +54,7 @@ struct TParseContext {
TIntermNode* treeRoot; // root of parse tree being created
int mLoopNestingLevel; // 0 if outside all loops
int structNestingLevel; // incremented while parsing a struct declaration
int mSwitchNestingLevel; // 0 if outside all switch statements
const TType* currentFunctionType; // the return type of the function that's currently being parsed
bool mFunctionReturnsValue; // true if a non-void function has a return
bool checksPrecisionErrors; // true if an error will be generated when a variable is declared without precision, explicit or implicit.
......
......@@ -1606,8 +1606,9 @@ selection_rest_statement
;
switch_statement
: SWITCH LEFT_PAREN expression RIGHT_PAREN compound_statement {
$$ = context->addSwitch($3, $5, @1);
: SWITCH LEFT_PAREN expression RIGHT_PAREN { ++context->mSwitchNestingLevel; } compound_statement {
$$ = context->addSwitch($3, $6, @1);
--context->mSwitchNestingLevel;
}
;
......
......@@ -626,11 +626,11 @@ union yyalloc
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 128
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 93
#define YYNNTS 94
/* YYNRULES -- Number of rules. */
#define YYNRULES 268
#define YYNRULES 269
/* YYNSTATES -- Number of states. */
#define YYNSTATES 404
#define YYNSTATES 405
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
......@@ -713,9 +713,9 @@ static const yytype_uint16 yyrline[] =
1501, 1516, 1520, 1524, 1525, 1531, 1532, 1533, 1534, 1535,
1536, 1537, 1541, 1542, 1542, 1542, 1552, 1553, 1557, 1557,
1558, 1558, 1563, 1566, 1576, 1579, 1585, 1586, 1590, 1598,
1602, 1609, 1615, 1618, 1625, 1630, 1647, 1647, 1652, 1652,
1659, 1659, 1667, 1670, 1676, 1679, 1685, 1689, 1696, 1699,
1702, 1705, 1708, 1717, 1721, 1728, 1731, 1737, 1737
1602, 1609, 1609, 1616, 1619, 1626, 1631, 1648, 1648, 1653,
1653, 1660, 1660, 1668, 1671, 1677, 1680, 1686, 1690, 1697,
1700, 1703, 1706, 1709, 1718, 1722, 1729, 1732, 1738, 1738
};
#endif
......@@ -775,11 +775,11 @@ static const char *const yytname[] =
"compound_statement", "$@3", "$@4", "statement_no_new_scope",
"statement_with_scope", "$@5", "$@6", "compound_statement_no_new_scope",
"statement_list", "expression_statement", "selection_statement",
"selection_rest_statement", "switch_statement", "case_label",
"condition", "iteration_statement", "$@7", "$@8", "$@9",
"selection_rest_statement", "switch_statement", "$@7", "case_label",
"condition", "iteration_statement", "$@8", "$@9", "$@10",
"for_init_statement", "conditionopt", "for_rest_statement",
"jump_statement", "translation_unit", "external_declaration",
"function_definition", "$@10", YY_NULLPTR
"function_definition", "$@11", YY_NULLPTR
};
#endif
......@@ -818,47 +818,47 @@ static const yytype_uint16 yytoknum[] =
STATE-NUM. */
static const yytype_int16 yypact[] =
{
1946, -28, -334, -334, -334, 179, -334, -334, -334, -334,
1946, -28, -334, -334, -334, 183, -334, -334, -334, -334,
-334, -334, -334, -334, -334, -334, -334, -334, -334, -334,
-334, -334, -334, -334, -334, -334, -334, -334, -334, -334,
-334, -334, -334, -334, -334, -334, -334, 91, -334, -334,
-40, -334, -334, -334, -334, -334, -334, -334, -334, -334,
-334, -334, -334, -334, -334, -334, -334, -334, -334, -90,
-334, -334, -88, -62, -64, 10, 5, -334, 117, 14,
1161, -334, -334, 2231, 14, -334, 18, -334, 1871, -334,
-334, -334, -334, 2231, -334, -334, -334, -334, -334, -14,
27, -334, 33, -334, 55, -334, -334, -334, -334, -334,
2095, 147, 127, -334, 73, -34, -334, 87, -334, 2021,
-334, -334, -334, 1424, -334, -334, 67, 2021, -334, 86,
-4, -334, 389, -334, -334, -334, -334, 127, 2095, -21,
-334, 260, 1424, -334, 157, 2095, 127, 1616, -334, 101,
-334, -334, -88, -62, -64, 10, 5, -334, 105, 14,
1161, -334, -334, 2231, 14, -334, -12, -334, 1871, -334,
-334, -334, -334, 2231, -334, -334, -334, -334, -334, -5,
48, -334, 33, -334, 55, -334, -334, -334, -334, -334,
2095, 150, 108, -334, 73, -34, -334, 93, -334, 2021,
-334, -334, -334, 1424, -334, -334, 85, 2021, -334, 92,
-4, -334, 389, -334, -334, -334, -334, 108, 2095, -21,
-334, 260, 1424, -334, 163, 2095, 108, 1616, -334, 125,
-334, -334, -334, -334, 1424, 1424, 1424, -334, -334, -334,
-334, -334, -334, 19, -334, -334, -334, 102, -3, 1519,
107, -334, 1424, 71, -32, 126, -48, 134, 103, 106,
109, 152, 151, -71, -334, 138, -334, -334, 1701, 2021,
146, -334, 27, 133, 135, -334, 144, 154, 136, 1231,
155, 1424, 139, 156, 153, -334, -334, 119, -334, -334,
-334, -334, -334, 19, -334, -334, -334, 104, -3, 1519,
127, -334, 1424, 74, -32, 120, -48, 121, 107, 115,
117, 152, 151, -71, -334, 138, -334, -334, 1701, 2021,
144, -334, 48, 133, 134, -334, 145, 146, 137, 1231,
154, 1424, 143, 155, 147, -334, -334, 119, -334, -334,
29, -334, -88, 17, -334, -334, -334, -334, 505, -334,
-334, -334, -334, -334, -334, 149, -334, -334, 1326, 1424,
-334, 158, -334, -334, 127, 150, 60, -334, -56, -334,
-334, -334, -334, -334, -334, 156, -334, -334, 1326, 1424,
-334, 153, -334, -334, 108, 157, 60, -334, -56, -334,
-334, -334, 1, -334, -334, 1424, 2163, -334, -334, 1424,
159, -334, -334, -334, 1424, 1424, 1424, 1424, 1424, 1424,
161, -334, -334, -334, 1424, 1424, 1424, 1424, 1424, 1424,
1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424, 1424,
1424, 1424, 1424, 1424, -334, -334, 1786, -334, -334, -334,
-334, -334, 160, -334, 1424, -334, -334, 61, 1424, 162,
-334, -334, 159, -334, 1424, -334, -334, 61, 1424, 149,
-334, -334, -334, 621, -334, -334, -334, -334, -334, -334,
-334, -334, -334, -334, -334, 1424, 1424, -334, -334, -334,
1424, -334, 168, -334, -334, 62, 1424, 127, -334, -25,
-334, -334, 169, 166, 101, 165, -334, -334, -334, -334,
-334, -334, 71, 71, -32, -32, 126, 126, 126, 126,
-48, -48, 134, 103, 106, 109, 152, 151, 116, -334,
205, 33, 853, 969, 15, -334, 25, -334, 1066, 621,
-334, -334, 171, -334, -334, 172, -334, 1424, -334, -334,
1424, 176, -334, -334, -334, -334, 1066, 160, 173, 166,
127, 2095, 177, 175, -334, -334, 193, -334, 1424, -334,
187, 197, 287, -334, -334, 198, 737, -334, 199, 28,
1424, 737, 160, 1424, -334, -334, -334, -334, 202, 166,
-334, -334, -334, -334
1424, -334, 162, -334, -334, 62, 1424, 108, -334, -25,
-334, -334, 167, 164, 125, 172, -334, -334, -334, -334,
-334, -334, 74, 74, -32, -32, 120, 120, 120, 120,
-48, -48, 121, 107, 115, 117, 152, 151, 114, -334,
221, 33, 853, 969, 15, -334, 25, -334, 1066, 621,
-334, -334, 171, -334, -334, 173, -334, 1424, -334, -334,
1424, 175, -334, -334, -334, -334, 1066, 159, -334, 164,
108, 2095, 176, 191, -334, -334, 177, -334, 1424, -334,
168, 196, 285, -334, 203, 199, 737, -334, 190, 28,
1424, 737, 159, -334, 1424, -334, -334, -334, -334, 202,
164, -334, -334, -334, -334
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
......@@ -872,19 +872,19 @@ static const yytype_uint16 yydefact[] =
128, 174, 175, 176, 177, 178, 179, 0, 125, 124,
0, 154, 180, 182, 195, 196, 183, 184, 185, 186,
187, 188, 189, 190, 191, 181, 192, 193, 194, 0,
198, 266, 267, 0, 96, 106, 0, 111, 116, 132,
0, 130, 122, 0, 133, 141, 152, 197, 0, 263,
265, 129, 121, 0, 138, 139, 2, 3, 201, 0,
198, 267, 268, 0, 96, 106, 0, 111, 116, 132,
0, 130, 122, 0, 133, 141, 152, 197, 0, 264,
266, 129, 121, 0, 138, 139, 2, 3, 201, 0,
0, 87, 0, 94, 106, 126, 107, 108, 109, 97,
0, 106, 0, 88, 2, 117, 131, 0, 93, 0,
123, 142, 134, 0, 1, 264, 0, 0, 199, 149,
0, 147, 0, 268, 98, 103, 105, 110, 0, 112,
123, 142, 134, 0, 1, 265, 0, 0, 199, 149,
0, 147, 0, 269, 98, 103, 105, 110, 0, 112,
99, 0, 0, 86, 0, 0, 0, 0, 203, 4,
8, 6, 7, 9, 0, 0, 0, 36, 35, 37,
34, 5, 11, 30, 13, 18, 19, 0, 0, 24,
0, 38, 0, 42, 45, 48, 53, 56, 58, 60,
62, 64, 66, 68, 85, 0, 28, 89, 0, 0,
0, 146, 0, 0, 0, 248, 0, 0, 0, 0,
0, 146, 0, 0, 0, 249, 0, 0, 0, 0,
0, 0, 0, 0, 223, 232, 236, 38, 70, 83,
0, 212, 0, 152, 215, 234, 214, 213, 0, 216,
217, 218, 219, 220, 221, 100, 102, 104, 0, 0,
......@@ -893,35 +893,35 @@ static const yytype_uint16 yydefact[] =
23, 25, 27, 33, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 153, 202, 0, 150, 151, 148,
259, 258, 230, 250, 0, 262, 260, 0, 0, 0,
243, 246, 222, 0, 73, 74, 76, 75, 78, 79,
260, 259, 230, 251, 0, 263, 261, 0, 0, 0,
244, 247, 222, 0, 73, 74, 76, 75, 78, 79,
80, 81, 82, 77, 72, 0, 0, 237, 233, 235,
0, 113, 0, 115, 119, 0, 0, 0, 205, 0,
90, 10, 0, 17, 2, 3, 14, 20, 26, 39,
40, 41, 44, 43, 46, 47, 51, 52, 49, 50,
54, 55, 57, 59, 61, 63, 65, 67, 0, 200,
0, 0, 0, 0, 0, 261, 0, 242, 0, 224,
0, 0, 0, 0, 0, 262, 0, 243, 0, 224,
71, 84, 0, 114, 206, 0, 208, 0, 91, 12,
0, 0, 229, 231, 253, 252, 255, 230, 0, 244,
0, 0, 0, 0, 101, 210, 0, 69, 0, 254,
0, 0, 240, 238, 241, 0, 0, 225, 0, 0,
256, 0, 230, 0, 227, 247, 226, 92, 0, 257,
251, 239, 245, 249
0, 0, 229, 231, 254, 253, 256, 230, 241, 245,
0, 0, 0, 0, 101, 210, 0, 69, 0, 255,
0, 0, 240, 238, 0, 0, 0, 225, 0, 0,
257, 0, 230, 242, 0, 227, 248, 226, 92, 0,
258, 252, 239, 246, 250
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int16 yypgoto[] =
{
-334, -39, -334, -334, -334, -334, -334, -334, 76, -334,
-334, -334, -334, -100, -334, -12, -11, -86, -15, 78,
89, 85, 90, 92, 93, -334, -104, -126, -334, -136,
-120, -334, 4, 12, -334, -334, -334, 223, 258, 253,
-334, -39, -334, -334, -334, -334, -334, -334, 77, -334,
-334, -334, -334, -100, -334, -20, -14, -86, -17, 78,
86, 88, 90, 94, 89, -334, -104, -126, -334, -136,
-120, -334, 4, 12, -334, -334, -334, 224, 259, 253,
228, -334, -334, -324, -334, -334, -102, -44, -68, 352,
-334, -334, 178, -45, 0, -334, -334, -334, -99, -132,
137, 51, -211, 16, -186, -325, -6, -334, -334, -26,
135, 51, -211, 18, -186, -325, -22, -334, -334, -26,
-333, -334, -334, -89, 80, 26, -334, -334, -334, -334,
2, -334, -334, -334, -334, -334, -334, -334, -334, -334,
292, -334, -334
-334, 2, -334, -334, -334, -334, -334, -334, -334, -334,
-334, 292, -334, -334
};
/* YYDEFGOTO[NTERM-NUM]. */
......@@ -933,10 +933,10 @@ static const yytype_int16 yydefgoto[] =
175, 109, 201, 202, 63, 64, 65, 125, 99, 100,
126, 66, 67, 68, 69, 101, 70, 71, 72, 73,
74, 120, 121, 75, 176, 77, 179, 117, 137, 138,
226, 227, 223, 204, 205, 206, 207, 283, 373, 395,
340, 341, 342, 396, 208, 209, 210, 383, 211, 212,
372, 213, 348, 272, 343, 366, 380, 381, 214, 78,
79, 80, 92
226, 227, 223, 204, 205, 206, 207, 283, 373, 396,
340, 341, 342, 397, 208, 209, 210, 383, 211, 384,
212, 372, 213, 348, 272, 343, 366, 380, 381, 214,
78, 79, 80, 92
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
......@@ -949,38 +949,38 @@ static const yytype_int16 yytable[] =
309, 262, 299, 7, 370, 106, 91, 174, 111, 105,
112, 161, 127, 241, 382, 135, 86, 87, 116, 251,
252, 136, 370, 93, 230, 231, 229, 94, 82, 136,
96, 97, 98, 277, 27, 28, 263, 29, 310, 401,
127, 394, 243, 129, 95, 37, 394, 224, 88, 136,
96, 97, 98, 277, 27, 28, 263, 29, 310, 402,
127, 395, 243, 129, 95, 37, 395, 224, 88, 136,
76, 279, 131, 76, 253, 254, 135, 135, 76, 132,
266, 357, 61, 76, 247, 218, 248, 174, 215, 358,
62, 161, 219, 222, 118, 96, 97, 98, 302, 313,
76, 181, 238, 119, 233, 234, 311, 182, 239, 76,
62, 161, 219, 222, 113, 96, 97, 98, 302, 313,
76, 181, 238, 118, 233, 234, 311, 182, 239, 76,
136, 136, 296, 318, 174, -95, 102, 76, 161, 103,
367, -28, 203, 113, 113, 235, 296, 338, 76, 236,
368, 84, 85, 398, 229, 76, 296, 76, 344, 296,
367, -28, 203, 113, 119, 235, 296, 338, 76, 236,
368, 84, 85, 399, 229, 76, 296, 76, 344, 296,
296, 122, 346, 297, 319, 320, 321, 161, 161, 161,
161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
161, 161, 161, 299, 135, 326, 327, 328, 329, 350,
351, 307, 296, 307, 308, 345, 354, 130, 76, 76,
352, 177, 402, 2, 3, 4, 355, 96, 97, 98,
244, 245, 246, 104, 87, 133, 174, 316, 136, 180,
161, 81, 174, 86, 87, -29, 161, 237, 203, 249,
250, 242, 369, 284, 285, 286, 287, 288, 289, 290,
291, 292, 293, 255, 256, 267, 268, 296, 360, 257,
369, 258, 294, 259, 377, 322, 323, 376, 324, 325,
330, 331, 389, 260, 261, 264, 371, 270, 273, 271,
275, 280, 362, 174, 399, 300, 306, 161, 274, 278,
281, 361, 282, -154, 371, 304, 76, 222, -228, -198,
8, 9, 10, 11, 347, 353, 359, 296, 374, 375,
378, 194, 386, 203, 387, 12, 13, 14, 15, 16,
352, 104, 87, 403, 86, 87, 355, 2, 3, 4,
96, 97, 98, 244, 245, 246, 174, 316, 136, 177,
161, 133, 174, 249, 250, 180, 161, 81, 203, 237,
255, 256, 369, 284, 285, 286, 287, 288, 289, 290,
291, 292, 293, 267, 268, 296, 360, 322, 323, -29,
369, 242, 294, 257, 377, 324, 325, 376, 330, 331,
258, 259, 389, 260, 261, 264, 371, 270, 271, 273,
274, 275, 362, 174, 400, 280, 282, 161, 278, 281,
304, 347, 300, 306, 371, -154, 76, -228, 222, 353,
8, 9, 10, 11, 359, 296, -198, 361, 374, 378,
375, 386, 390, 203, 388, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
388, 390, 391, 110, 392, 31, 32, 33, 34, 35,
36, 393, 317, 397, 40, 41, 403, 42, 43, 44,
387, 391, 392, 110, 398, 31, 32, 33, 34, 35,
36, 194, 394, 317, 40, 41, 404, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
55, 385, 56, 57, 58, 332, 139, 60, 140, 141,
142, 143, 203, 203, 334, 144, 145, 333, 203, 203,
335, 216, 124, 336, 128, 337, 217, 83, 356, 364,
269, 305, 384, 349, 146, 400, 203, 220, 379, 365,
142, 143, 203, 203, 333, 144, 145, 334, 203, 203,
335, 337, 216, 124, 128, 336, 217, 83, 356, 305,
269, 364, 393, 349, 146, 401, 203, 220, 379, 365,
115, 76, 0, 0, 0, 147, 148, 149, 150, 0,
0, 0, 0, 0, 0, 0, 203, 0, 0, 0,
0, 203, 1, 2, 3, 4, 5, 6, 7, 8,
......@@ -1188,34 +1188,34 @@ static const yytype_int16 yycheck[] =
128, 386, 162, 102, 9, 51, 391, 135, 108, 137,
70, 191, 106, 73, 122, 123, 178, 179, 78, 113,
179, 106, 78, 83, 116, 106, 118, 191, 127, 114,
78, 191, 113, 219, 108, 40, 41, 42, 218, 235,
100, 105, 105, 76, 85, 86, 105, 111, 111, 109,
78, 191, 113, 219, 106, 40, 41, 42, 218, 235,
100, 105, 105, 108, 85, 86, 105, 111, 111, 109,
178, 179, 111, 239, 218, 105, 111, 117, 218, 114,
105, 104, 122, 106, 106, 106, 111, 263, 128, 110,
105, 104, 122, 106, 76, 106, 111, 263, 128, 110,
105, 40, 41, 105, 266, 135, 111, 137, 274, 111,
111, 108, 278, 114, 244, 245, 246, 247, 248, 249,
250, 251, 252, 253, 254, 255, 256, 257, 258, 259,
260, 261, 262, 349, 266, 251, 252, 253, 254, 295,
296, 111, 111, 111, 114, 114, 114, 104, 178, 179,
300, 114, 393, 4, 5, 6, 306, 40, 41, 42,
119, 120, 121, 76, 77, 108, 300, 236, 266, 113,
300, 44, 306, 76, 77, 104, 306, 105, 208, 83,
84, 104, 348, 94, 95, 96, 97, 98, 99, 100,
101, 102, 103, 89, 90, 79, 80, 111, 112, 126,
366, 125, 113, 124, 360, 247, 248, 357, 249, 250,
255, 256, 378, 91, 93, 107, 348, 114, 104, 114,
114, 112, 341, 357, 390, 106, 106, 357, 104, 104,
104, 56, 109, 104, 366, 107, 266, 393, 108, 104,
10, 11, 12, 13, 112, 107, 107, 111, 107, 107,
104, 108, 105, 283, 109, 25, 26, 27, 28, 29,
300, 76, 77, 394, 76, 77, 306, 4, 5, 6,
40, 41, 42, 119, 120, 121, 300, 236, 266, 114,
300, 108, 306, 83, 84, 113, 306, 44, 208, 105,
89, 90, 348, 94, 95, 96, 97, 98, 99, 100,
101, 102, 103, 79, 80, 111, 112, 247, 248, 104,
366, 104, 113, 126, 360, 249, 250, 357, 255, 256,
125, 124, 378, 91, 93, 107, 348, 114, 114, 104,
104, 114, 341, 357, 390, 112, 109, 357, 104, 104,
107, 112, 106, 106, 366, 104, 266, 108, 394, 107,
10, 11, 12, 13, 107, 111, 104, 56, 107, 104,
107, 105, 114, 283, 107, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
107, 114, 105, 371, 17, 45, 46, 47, 48, 49,
50, 113, 236, 114, 54, 55, 114, 57, 58, 59,
109, 105, 17, 371, 114, 45, 46, 47, 48, 49,
50, 108, 113, 236, 54, 55, 114, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
70, 370, 72, 73, 74, 257, 76, 77, 78, 79,
80, 81, 342, 343, 259, 85, 86, 258, 348, 349,
260, 128, 94, 261, 101, 262, 128, 5, 307, 343,
182, 224, 368, 283, 104, 391, 366, 107, 366, 343,
80, 81, 342, 343, 258, 85, 86, 259, 348, 349,
260, 262, 128, 94, 101, 261, 128, 5, 307, 224,
182, 343, 384, 283, 104, 391, 366, 107, 366, 343,
78, 371, -1, -1, -1, 115, 116, 117, 118, -1,
-1, -1, -1, -1, -1, -1, 386, -1, -1, -1,
-1, 391, 3, 4, 5, 6, 7, 8, 9, 10,
......@@ -1423,11 +1423,11 @@ static const yytype_uint8 yystos[] =
54, 55, 57, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 72, 73, 74, 75,
77, 160, 161, 162, 163, 164, 169, 170, 171, 172,
174, 175, 176, 177, 178, 181, 182, 183, 217, 218,
219, 44, 76, 177, 40, 41, 76, 77, 108, 129,
104, 114, 220, 105, 111, 9, 40, 41, 42, 166,
174, 175, 176, 177, 178, 181, 182, 183, 218, 219,
220, 44, 76, 177, 40, 41, 76, 77, 108, 129,
104, 114, 221, 105, 111, 9, 40, 41, 42, 166,
167, 173, 111, 114, 76, 129, 175, 76, 114, 159,
176, 181, 175, 106, 0, 218, 181, 185, 108, 76,
176, 181, 175, 106, 0, 219, 181, 185, 108, 76,
179, 180, 108, 201, 166, 165, 168, 176, 167, 129,
104, 106, 113, 108, 3, 174, 176, 186, 187, 76,
78, 79, 80, 81, 85, 86, 104, 115, 116, 117,
......@@ -1437,26 +1437,26 @@ static const yytype_uint8 yystos[] =
113, 105, 111, 14, 15, 16, 18, 19, 20, 21,
22, 23, 24, 56, 108, 109, 114, 141, 154, 155,
157, 160, 161, 182, 191, 192, 193, 194, 202, 203,
204, 206, 207, 209, 216, 129, 165, 168, 106, 113,
204, 206, 208, 210, 217, 129, 165, 168, 106, 113,
107, 158, 155, 190, 176, 129, 188, 189, 109, 187,
141, 141, 157, 85, 86, 106, 110, 105, 105, 111,
55, 155, 104, 141, 119, 120, 121, 116, 118, 83,
84, 87, 88, 122, 123, 89, 90, 126, 125, 124,
91, 93, 92, 127, 107, 109, 186, 79, 80, 180,
114, 114, 211, 104, 104, 114, 114, 157, 104, 158,
114, 114, 212, 104, 104, 114, 114, 157, 104, 158,
112, 104, 109, 195, 94, 95, 96, 97, 98, 99,
100, 101, 102, 103, 113, 156, 111, 114, 109, 192,
106, 107, 158, 190, 107, 188, 106, 111, 114, 76,
114, 105, 133, 157, 76, 77, 129, 136, 155, 141,
141, 141, 143, 143, 144, 144, 145, 145, 145, 145,
146, 146, 147, 148, 149, 150, 151, 152, 157, 109,
198, 199, 200, 212, 157, 114, 157, 112, 210, 202,
198, 199, 200, 213, 157, 114, 157, 112, 211, 202,
155, 155, 158, 107, 114, 158, 189, 106, 114, 107,
112, 56, 201, 193, 191, 203, 213, 105, 105, 157,
171, 174, 208, 196, 107, 107, 158, 155, 104, 208,
214, 215, 198, 205, 194, 129, 105, 109, 107, 157,
114, 105, 17, 113, 193, 197, 201, 114, 105, 157,
197, 198, 190, 114
112, 56, 201, 193, 191, 203, 214, 105, 105, 157,
171, 174, 209, 196, 107, 107, 158, 155, 104, 209,
215, 216, 198, 205, 207, 129, 105, 109, 107, 157,
114, 105, 17, 194, 113, 193, 197, 201, 114, 105,
157, 197, 198, 190, 114
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
......@@ -1486,9 +1486,9 @@ static const yytype_uint8 yyr1[] =
189, 190, 191, 192, 192, 193, 193, 193, 193, 193,
193, 193, 194, 195, 196, 194, 197, 197, 199, 198,
200, 198, 201, 201, 202, 202, 203, 203, 204, 205,
205, 206, 207, 207, 208, 208, 210, 209, 211, 209,
212, 209, 213, 213, 214, 214, 215, 215, 216, 216,
216, 216, 216, 217, 217, 218, 218, 220, 219
205, 207, 206, 208, 208, 209, 209, 211, 210, 212,
210, 213, 210, 214, 214, 215, 215, 216, 216, 217,
217, 217, 217, 217, 218, 218, 219, 219, 221, 220
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
......@@ -1518,9 +1518,9 @@ static const yytype_uint8 yyr2[] =
4, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 2, 0, 0, 5, 1, 1, 0, 2,
0, 2, 2, 3, 1, 2, 1, 2, 5, 3,
1, 5, 3, 2, 1, 4, 0, 6, 0, 8,
0, 7, 1, 1, 1, 0, 2, 3, 2, 2,
2, 3, 2, 1, 2, 1, 1, 0, 3
1, 0, 6, 3, 2, 1, 4, 0, 6, 0,
8, 0, 7, 1, 1, 1, 0, 2, 3, 2,
2, 2, 3, 2, 1, 2, 1, 1, 0, 3
};
......@@ -4658,13 +4658,20 @@ yyreduce:
case 241:
{ ++context->mSwitchNestingLevel; }
break;
case 242:
{
(yyval.interm.intermSwitch) = context->addSwitch((yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermAggregate), (yylsp[-4]));
(yyval.interm.intermSwitch) = context->addSwitch((yyvsp[-3].interm.intermTypedNode), (yyvsp[0].interm.intermAggregate), (yylsp[-5]));
--context->mSwitchNestingLevel;
}
break;
case 242:
case 243:
{
(yyval.interm.intermCase) = context->addCase((yyvsp[-1].interm.intermTypedNode), (yylsp[-2]));
......@@ -4672,7 +4679,7 @@ yyreduce:
break;
case 243:
case 244:
{
(yyval.interm.intermCase) = context->addDefault((yylsp[-1]));
......@@ -4680,7 +4687,7 @@ yyreduce:
break;
case 244:
case 245:
{
(yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode);
......@@ -4690,7 +4697,7 @@ yyreduce:
break;
case 245:
case 246:
{
TIntermNode* intermNode;
......@@ -4709,13 +4716,13 @@ yyreduce:
break;
case 246:
case 247:
{ context->symbolTable.push(); ++context->mLoopNestingLevel; }
break;
case 247:
case 248:
{
context->symbolTable.pop();
......@@ -4725,13 +4732,13 @@ yyreduce:
break;
case 248:
case 249:
{ ++context->mLoopNestingLevel; }
break;
case 249:
case 250:
{
if (context->boolErrorCheck((yylsp[0]), (yyvsp[-2].interm.intermTypedNode)))
......@@ -4743,13 +4750,13 @@ yyreduce:
break;
case 250:
case 251:
{ context->symbolTable.push(); ++context->mLoopNestingLevel; }
break;
case 251:
case 252:
{
context->symbolTable.pop();
......@@ -4759,7 +4766,7 @@ yyreduce:
break;
case 252:
case 253:
{
(yyval.interm.intermNode) = (yyvsp[0].interm.intermNode);
......@@ -4767,7 +4774,7 @@ yyreduce:
break;
case 253:
case 254:
{
(yyval.interm.intermNode) = (yyvsp[0].interm.intermNode);
......@@ -4775,7 +4782,7 @@ yyreduce:
break;
case 254:
case 255:
{
(yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode);
......@@ -4783,7 +4790,7 @@ yyreduce:
break;
case 255:
case 256:
{
(yyval.interm.intermTypedNode) = 0;
......@@ -4791,7 +4798,7 @@ yyreduce:
break;
case 256:
case 257:
{
(yyval.interm.nodePair).node1 = (yyvsp[-1].interm.intermTypedNode);
......@@ -4800,7 +4807,7 @@ yyreduce:
break;
case 257:
case 258:
{
(yyval.interm.nodePair).node1 = (yyvsp[-2].interm.intermTypedNode);
......@@ -4809,7 +4816,7 @@ yyreduce:
break;
case 258:
case 259:
{
(yyval.interm.intermNode) = context->addBranch(EOpContinue, (yylsp[-1]));
......@@ -4817,7 +4824,7 @@ yyreduce:
break;
case 259:
case 260:
{
(yyval.interm.intermNode) = context->addBranch(EOpBreak, (yylsp[-1]));
......@@ -4825,7 +4832,7 @@ yyreduce:
break;
case 260:
case 261:
{
(yyval.interm.intermNode) = context->addBranch(EOpReturn, (yylsp[-1]));
......@@ -4833,7 +4840,7 @@ yyreduce:
break;
case 261:
case 262:
{
(yyval.interm.intermNode) = context->addBranch(EOpReturn, (yyvsp[-1].interm.intermTypedNode), (yylsp[-2]));
......@@ -4841,7 +4848,7 @@ yyreduce:
break;
case 262:
case 263:
{
FRAG_ONLY("discard", (yylsp[-1]));
......@@ -4850,7 +4857,7 @@ yyreduce:
break;
case 263:
case 264:
{
(yyval.interm.intermNode) = (yyvsp[0].interm.intermNode);
......@@ -4859,7 +4866,7 @@ yyreduce:
break;
case 264:
case 265:
{
(yyval.interm.intermNode) = context->intermediate.growAggregate((yyvsp[-1].interm.intermNode), (yyvsp[0].interm.intermNode), (yyloc));
......@@ -4868,7 +4875,7 @@ yyreduce:
break;
case 265:
case 266:
{
(yyval.interm.intermNode) = (yyvsp[0].interm.intermNode);
......@@ -4876,7 +4883,7 @@ yyreduce:
break;
case 266:
case 267:
{
(yyval.interm.intermNode) = (yyvsp[0].interm.intermNode);
......@@ -4884,7 +4891,7 @@ yyreduce:
break;
case 267:
case 268:
{
TFunction* function = (yyvsp[0].interm).function;
......@@ -4974,7 +4981,7 @@ yyreduce:
break;
case 268:
case 269:
{
//?? Check that all paths return a value if return type != void ?
......
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