Commit 9a1b49f7 by Jamie Madill

Revert "Don't evaluate short-circuited preprocessor expressions"

Build break on Clang: FAILED: /b/build/goma/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/third_party/angle/src/compiler/preprocessor/preprocessor.ExpressionParser.o.d -DV8_DEPRECATION_WARNINGS -DCLD_VERSION=2 -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -DCHROMIUM_BUILD -DCR_CLANG_REVISION=245965-1 -DUSE_LIBJPEG_TURBO=1 -DENABLE_ONE_CLICK_SIGNIN -DENABLE_PRE_SYNC_BACKUP -DENABLE_WEBRTC=1 -DENABLE_MEDIA_ROUTER=1 -DUSE_PROPRIETARY_CODECS -DENABLE_PEPPER_CDMS -DENABLE_CONFIGURATION_POLICY -DENABLE_NOTIFICATIONS -DENABLE_HIDPI=1 -DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE -DDONT_EMBED_BUILD_METADATA -DDCHECK_ALWAYS_ON=1 -DFIELDTRIAL_TESTING_ENABLED -DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 -DENABLE_PDF=1 -DENABLE_PLUGIN_INSTALLATION=1 -DENABLE_PLUGINS=1 -DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_AUTOFILL_DIALOG=1 -DENABLE_BACKGROUND=1 -DENABLE_GOOGLE_NOW=1 -DENABLE_PRINTING=1 -DENABLE_BASIC_PRINTING=1 -DENABLE_PRINT_PREVIEW=1 -DENABLE_SPELLCHECK=1 -DUSE_BROWSER_SPELLCHECKER=1 -DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_APP_LIST=1 -DENABLE_SETTINGS_APP=1 -DENABLE_SUPERVISED_USERS=1 -DENABLE_SERVICE_DISCOVERY=1 -DENABLE_WIFI_BOOTSTRAPPING=1 -DV8_USE_EXTERNAL_STARTUP_DATA -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DSAFE_BROWSING_SERVICE -DUSE_LIBPCI=1 -DUSE_OPENSSL=1 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -Igen -isysroot /Applications/Xcode5.1.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -O2 -gdwarf-2 -fvisibility=hidden -Werror -Wnewline-eof -mmacosx-version-min=10.6 -arch x86_64 -Wendif-labels -Wno-unused-parameter -Wno-missing-field-initializers -Wno-selector-type-mismatch -Wpartial-availability -Wheader-hygiene -Wno-char-subscripts -Wno-unneeded-internal-declaration -Wno-covered-switch-default -Wstring-conversion -Wno-c++11-narrowing -Wno-deprecated-register -Wno-inconsistent-missing-override -Wno-shift-negative-value -Wno-unused-function -Wno-unused-variable -std=c++11 -fno-rtti -fno-exceptions -fvisibility-inlines-hidden -fno-threadsafe-statics -Xclang -load -Xclang /b/build/slave/GPU_Mac_Builder/build/src/third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-templates -fcolor-diagnostics -fno-strict-aliasing -c ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp -o obj/third_party/angle/src/compiler/preprocessor/preprocessor.ExpressionParser.o ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp:1372:35: error: use of logical '||' with constant operand [-Werror,-Wconstant-logical-operand] (yyval) = (yyvsp[-3]) || 0; ^ ~ ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp:1372:35: note: use '|' for a bitwise operation (yyval) = (yyvsp[-3]) || 0; ^~ | ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp:1406:35: error: use of logical '&&' with constant operand [-Werror,-Wconstant-logical-operand] (yyval) = (yyvsp[-3]) && 0; ^ ~ ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp:1406:35: note: use '&' for a bitwise operation (yyval) = (yyvsp[-3]) && 0; ^~ & ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp:1406:35: note: remove constant to silence this warning (yyval) = (yyvsp[-3]) && 0; ~^~~~ BUG=angleproject:347 This reverts commit 6ffe6135. Change-Id: I6d81666cca573f320bfb1164a6c794b6f75f7463 Reviewed-on: https://chromium-review.googlesource.com/298020Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 47f730fa
...@@ -122,13 +122,6 @@ struct Context ...@@ -122,13 +122,6 @@ struct Context
pp::Lexer* lexer; pp::Lexer* lexer;
pp::Token* token; pp::Token* token;
int* result; int* result;
void startIgnoreErrors() { ++ignoreErrors; }
void endIgnoreErrors() { --ignoreErrors; }
bool isIgnoringErrors() { return ignoreErrors > 0; }
int ignoreErrors;
}; };
} // namespace } // namespace
...@@ -169,16 +162,15 @@ extern int ppdebug; ...@@ -169,16 +162,15 @@ extern int ppdebug;
enum yytokentype enum yytokentype
{ {
TOK_CONST_INT = 258, TOK_CONST_INT = 258,
TOK_IDENTIFIER = 259, TOK_OP_OR = 259,
TOK_OP_OR = 260, TOK_OP_AND = 260,
TOK_OP_AND = 261, TOK_OP_EQ = 261,
TOK_OP_EQ = 262, TOK_OP_NE = 262,
TOK_OP_NE = 263, TOK_OP_LE = 263,
TOK_OP_LE = 264, TOK_OP_GE = 264,
TOK_OP_GE = 265, TOK_OP_LEFT = 265,
TOK_OP_LEFT = 266, TOK_OP_RIGHT = 266,
TOK_OP_RIGHT = 267, TOK_UNARY = 267
TOK_UNARY = 268
}; };
#endif #endif
...@@ -437,23 +429,23 @@ union yyalloc ...@@ -437,23 +429,23 @@ union yyalloc
#endif /* !YYCOPY_NEEDED */ #endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */ /* YYFINAL -- State number of the termination state. */
#define YYFINAL 15 #define YYFINAL 14
/* YYLAST -- Last index in YYTABLE. */ /* YYLAST -- Last index in YYTABLE. */
#define YYLAST 176 #define YYLAST 175
/* YYNTOKENS -- Number of terminals. */ /* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 28 #define YYNTOKENS 27
/* YYNNTS -- Number of nonterminals. */ /* YYNNTS -- Number of nonterminals. */
#define YYNNTS 5 #define YYNNTS 3
/* YYNRULES -- Number of rules. */ /* YYNRULES -- Number of rules. */
#define YYNRULES 29 #define YYNRULES 26
/* YYNSTATES -- Number of states. */ /* YYNSTATES -- Number of states. */
#define YYNSTATES 55 #define YYNSTATES 52
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */ by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2 #define YYUNDEFTOK 2
#define YYMAXUTOK 268 #define YYMAXUTOK 267
#define YYTRANSLATE(YYX) \ #define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
...@@ -465,16 +457,16 @@ static const yytype_uint8 yytranslate[] = ...@@ -465,16 +457,16 @@ static const yytype_uint8 yytranslate[] =
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 24, 2, 2, 2, 22, 9, 2, 2, 2, 2, 23, 2, 2, 2, 21, 8, 2,
26, 27, 20, 18, 2, 19, 2, 21, 2, 2, 25, 26, 19, 17, 2, 18, 2, 20, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
12, 2, 13, 2, 2, 2, 2, 2, 2, 2, 11, 2, 12, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 7, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 7, 2, 25, 2, 2, 2, 2, 2, 2, 2, 6, 2, 24, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
...@@ -488,16 +480,16 @@ static const yytype_uint8 yytranslate[] = ...@@ -488,16 +480,16 @@ static const yytype_uint8 yytranslate[] =
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 10, 11, 14, 15, 16, 17, 23 5, 9, 10, 13, 14, 15, 16, 22
}; };
#if YYDEBUG #if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] = static const yytype_uint8 yyrline[] =
{ {
0, 105, 105, 111, 112, 118, 118, 141, 141, 164, 0, 97, 97, 104, 105, 108, 111, 114, 117, 120,
167, 170, 173, 176, 179, 182, 185, 188, 191, 194, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150,
197, 200, 203, 226, 249, 252, 255, 258, 261, 264 163, 176, 179, 182, 185, 188, 191
}; };
#endif #endif
...@@ -506,11 +498,11 @@ static const yytype_uint16 yyrline[] = ...@@ -506,11 +498,11 @@ static const yytype_uint16 yyrline[] =
First, the terminals, then, starting at YYNTOKENS, nonterminals. */ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] = static const char *const yytname[] =
{ {
"$end", "error", "$undefined", "TOK_CONST_INT", "TOK_IDENTIFIER", "$end", "error", "$undefined", "TOK_CONST_INT", "TOK_OP_OR",
"TOK_OP_OR", "TOK_OP_AND", "'|'", "'^'", "'&'", "TOK_OP_EQ", "TOK_OP_NE", "TOK_OP_AND", "'|'", "'^'", "'&'", "TOK_OP_EQ", "TOK_OP_NE", "'<'",
"'<'", "'>'", "TOK_OP_LE", "TOK_OP_GE", "TOK_OP_LEFT", "TOK_OP_RIGHT", "'>'", "TOK_OP_LE", "TOK_OP_GE", "TOK_OP_LEFT", "TOK_OP_RIGHT", "'+'",
"'+'", "'-'", "'*'", "'/'", "'%'", "TOK_UNARY", "'!'", "'~'", "'('", "'-'", "'*'", "'/'", "'%'", "TOK_UNARY", "'!'", "'~'", "'('", "')'",
"')'", "$accept", "input", "expression", "$@1", "$@2", YY_NULLPTR "$accept", "input", "expression", YY_NULLPTR
}; };
#endif #endif
...@@ -519,16 +511,16 @@ static const char *const yytname[] = ...@@ -519,16 +511,16 @@ static const char *const yytname[] =
(internal) symbol number NUM (which must be that of a token). */ (internal) symbol number NUM (which must be that of a token). */
static const yytype_uint16 yytoknum[] = static const yytype_uint16 yytoknum[] =
{ {
0, 256, 257, 258, 259, 260, 261, 124, 94, 38, 0, 256, 257, 258, 259, 260, 124, 94, 38, 261,
262, 263, 60, 62, 264, 265, 266, 267, 43, 45, 262, 60, 62, 263, 264, 265, 266, 43, 45, 42,
42, 47, 37, 268, 33, 126, 40, 41 47, 37, 267, 33, 126, 40, 41
}; };
# endif # endif
#define YYPACT_NINF -12 #define YYPACT_NINF -11
#define yypact_value_is_default(Yystate) \ #define yypact_value_is_default(Yystate) \
(!!((Yystate) == (-12))) (!!((Yystate) == (-11)))
#define YYTABLE_NINF -1 #define YYTABLE_NINF -1
...@@ -539,12 +531,12 @@ static const yytype_uint16 yytoknum[] = ...@@ -539,12 +531,12 @@ static const yytype_uint16 yytoknum[] =
STATE-NUM. */ STATE-NUM. */
static const yytype_int16 yypact[] = static const yytype_int16 yypact[] =
{ {
31, -12, -12, 31, 31, 31, 31, 31, 51, 76, 46, -11, 46, 46, 46, 46, 46, 12, 68, -11,
-12, -12, -12, -12, 53, -12, -12, -12, 31, 31, -11, -11, -11, 27, -11, 46, 46, 46, 46, 46,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
31, 31, 31, 31, -12, 31, 31, 124, 138, 26, 46, 46, 46, -11, 85, 101, 116, 130, 143, 154,
149, 149, -11, -11, -11, -11, 154, 154, -8, -8, 154, -10, -10, -10, -10, 37, 37, 31, 31, -11,
-12, -12, -12, 93, 109 -11, -11
}; };
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
...@@ -552,24 +544,24 @@ static const yytype_int16 yypact[] = ...@@ -552,24 +544,24 @@ static const yytype_int16 yypact[] =
means the default is an error. */ means the default is an error. */
static const yytype_uint8 yydefact[] = static const yytype_uint8 yydefact[] =
{ {
0, 3, 4, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 0, 0, 0, 0, 0, 2, 25,
28, 27, 25, 26, 0, 1, 5, 7, 0, 0, 24, 22, 23, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 29, 0, 0, 9, 10, 11, 0, 0, 0, 26, 4, 5, 6, 7, 8, 10,
13, 12, 17, 16, 15, 14, 19, 18, 21, 20, 9, 14, 13, 12, 11, 16, 15, 18, 17, 21,
24, 23, 22, 6, 8 20, 19
}; };
/* YYPGOTO[NTERM-NUM]. */ /* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] = static const yytype_int8 yypgoto[] =
{ {
-12, -12, -3, -12, -12 -11, -11, -2
}; };
/* YYDEFGOTO[NTERM-NUM]. */ /* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] = static const yytype_int8 yydefgoto[] =
{ {
-1, 8, 9, 35, 36 -1, 7, 8
}; };
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
...@@ -577,74 +569,74 @@ static const yytype_int8 yydefgoto[] = ...@@ -577,74 +569,74 @@ static const yytype_int8 yydefgoto[] =
number is the opposite. If YYTABLE_NINF, syntax error. */ number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_uint8 yytable[] = static const yytype_uint8 yytable[] =
{ {
10, 11, 12, 13, 14, 27, 28, 29, 30, 31, 9, 10, 11, 12, 13, 26, 27, 28, 29, 30,
32, 33, 31, 32, 33, 37, 38, 39, 40, 41, 31, 32, 14, 34, 35, 36, 37, 38, 39, 40,
42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
52, 0, 53, 54, 1, 2, 21, 22, 23, 24, 51, 15, 16, 17, 18, 19, 20, 21, 22, 23,
25, 26, 27, 28, 29, 30, 31, 32, 33, 3, 24, 25, 26, 27, 28, 29, 30, 31, 32, 1,
4, 15, 0, 0, 0, 5, 6, 7, 16, 17, 30, 31, 32, 33, 28, 29, 30, 31, 32, 0,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 0, 0, 2, 3, 0, 0, 0, 0, 4,
28, 29, 30, 31, 32, 33, 0, 0, 0, 0, 5, 6, 15, 16, 17, 18, 19, 20, 21, 22,
34, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 33, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 23, 24, 25, 26, 27, 28, 29, 30, 31, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
32, 33, 29, 30, 31, 32, 33 26, 27, 28, 29, 30, 31, 32, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32
}; };
static const yytype_int8 yycheck[] = static const yytype_int8 yycheck[] =
{ {
3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6, 15, 16, 17, 18, 19,
21, 22, 20, 21, 22, 18, 19, 20, 21, 22, 20, 21, 0, 15, 16, 17, 18, 19, 20, 21,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
33, -1, 35, 36, 3, 4, 10, 11, 12, 13, 32, 4, 5, 6, 7, 8, 9, 10, 11, 12,
14, 15, 16, 17, 18, 19, 20, 21, 22, 18, 13, 14, 15, 16, 17, 18, 19, 20, 21, 3,
19, 0, -1, -1, -1, 24, 25, 26, 5, 6, 19, 20, 21, 26, 17, 18, 19, 20, 21, -1,
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, -1, -1, 17, 18, -1, -1, -1, -1, 23,
17, 18, 19, 20, 21, 22, -1, -1, -1, -1, 24, 25, 4, 5, 6, 7, 8, 9, 10, 11,
27, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 6,
7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 12, 13, 14, 15, 16, 17, 18, 19, 20, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
21, 22, 18, 19, 20, 21, 22 15, 16, 17, 18, 19, 20, 21, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21
}; };
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */ symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] = static const yytype_uint8 yystos[] =
{ {
0, 3, 4, 18, 19, 24, 25, 26, 29, 30, 0, 3, 17, 18, 23, 24, 25, 28, 29, 29,
30, 30, 30, 30, 30, 0, 5, 6, 7, 8, 29, 29, 29, 29, 0, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 27, 31, 32, 30, 30, 30, 19, 20, 21, 26, 29, 29, 29, 29, 29, 29,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
30, 30, 30, 30, 30 29, 29
}; };
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] = static const yytype_uint8 yyr1[] =
{ {
0, 28, 29, 30, 30, 31, 30, 32, 30, 30, 0, 27, 28, 29, 29, 29, 29, 29, 29, 29,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
30, 30, 30, 30, 30, 30, 30, 30, 30, 30 29, 29, 29, 29, 29, 29, 29
}; };
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
static const yytype_uint8 yyr2[] = static const yytype_uint8 yyr2[] =
{ {
0, 2, 1, 1, 1, 0, 4, 0, 4, 3, 0, 2, 1, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 2, 2, 2, 2, 3 3, 3, 2, 2, 2, 2, 3
}; };
...@@ -1330,6 +1322,7 @@ yyreduce: ...@@ -1330,6 +1322,7 @@ yyreduce:
{ {
*(context->result) = static_cast<int>((yyvsp[0])); *(context->result) = static_cast<int>((yyvsp[0]));
YYACCEPT;
} }
break; break;
...@@ -1337,10 +1330,7 @@ yyreduce: ...@@ -1337,10 +1330,7 @@ yyreduce:
case 4: case 4:
{ {
if (!context->isIgnoringErrors()) (yyval) = (yyvsp[-2]) || (yyvsp[0]);
{
YYABORT;
}
} }
break; break;
...@@ -1348,15 +1338,7 @@ yyreduce: ...@@ -1348,15 +1338,7 @@ yyreduce:
case 5: case 5:
{ {
if ((yyvsp[-1]) != 0) (yyval) = (yyvsp[-2]) && (yyvsp[0]);
{
// Ignore errors in the short-circuited part of the expression.
// ESSL3.00 section 3.4:
// If an operand is not evaluated, the presence of undefined identifiers
// in the operand will not cause an error.
// Unevaluated division by zero should not cause an error either.
context->startIgnoreErrors();
}
} }
break; break;
...@@ -1364,64 +1346,12 @@ yyreduce: ...@@ -1364,64 +1346,12 @@ yyreduce:
case 6: case 6:
{ {
if ((yyvsp[-3]) != 0)
{
context->endIgnoreErrors();
// Make sure that short-circuited version of || works consistently
// with the normal version even for values other than 0 and 1.
(yyval) = (yyvsp[-3]) || 0;
}
else
{
(yyval) = (yyvsp[-3]) || (yyvsp[0]);
}
}
break;
case 7:
{
if ((yyvsp[-1]) == 0)
{
// Ignore errors in the short-circuited part of the expression.
// ESSL3.00 section 3.4:
// If an operand is not evaluated, the presence of undefined identifiers
// in the operand will not cause an error.
// Unevaluated division by zero should not cause an error either.
context->startIgnoreErrors();
}
}
break;
case 8:
{
if ((yyvsp[-3]) == 0)
{
context->endIgnoreErrors();
// Make sure that short-circuited version of && works consistently
// with the normal version even for values other than 0 and 1.
(yyval) = (yyvsp[-3]) && 0;
}
else
{
(yyval) = (yyvsp[-3]) && (yyvsp[0]);
}
}
break;
case 9:
{
(yyval) = (yyvsp[-2]) | (yyvsp[0]); (yyval) = (yyvsp[-2]) | (yyvsp[0]);
} }
break; break;
case 10: case 7:
{ {
(yyval) = (yyvsp[-2]) ^ (yyvsp[0]); (yyval) = (yyvsp[-2]) ^ (yyvsp[0]);
...@@ -1429,7 +1359,7 @@ yyreduce: ...@@ -1429,7 +1359,7 @@ yyreduce:
break; break;
case 11: case 8:
{ {
(yyval) = (yyvsp[-2]) & (yyvsp[0]); (yyval) = (yyvsp[-2]) & (yyvsp[0]);
...@@ -1437,7 +1367,7 @@ yyreduce: ...@@ -1437,7 +1367,7 @@ yyreduce:
break; break;
case 12: case 9:
{ {
(yyval) = (yyvsp[-2]) != (yyvsp[0]); (yyval) = (yyvsp[-2]) != (yyvsp[0]);
...@@ -1445,7 +1375,7 @@ yyreduce: ...@@ -1445,7 +1375,7 @@ yyreduce:
break; break;
case 13: case 10:
{ {
(yyval) = (yyvsp[-2]) == (yyvsp[0]); (yyval) = (yyvsp[-2]) == (yyvsp[0]);
...@@ -1453,7 +1383,7 @@ yyreduce: ...@@ -1453,7 +1383,7 @@ yyreduce:
break; break;
case 14: case 11:
{ {
(yyval) = (yyvsp[-2]) >= (yyvsp[0]); (yyval) = (yyvsp[-2]) >= (yyvsp[0]);
...@@ -1461,7 +1391,7 @@ yyreduce: ...@@ -1461,7 +1391,7 @@ yyreduce:
break; break;
case 15: case 12:
{ {
(yyval) = (yyvsp[-2]) <= (yyvsp[0]); (yyval) = (yyvsp[-2]) <= (yyvsp[0]);
...@@ -1469,7 +1399,7 @@ yyreduce: ...@@ -1469,7 +1399,7 @@ yyreduce:
break; break;
case 16: case 13:
{ {
(yyval) = (yyvsp[-2]) > (yyvsp[0]); (yyval) = (yyvsp[-2]) > (yyvsp[0]);
...@@ -1477,7 +1407,7 @@ yyreduce: ...@@ -1477,7 +1407,7 @@ yyreduce:
break; break;
case 17: case 14:
{ {
(yyval) = (yyvsp[-2]) < (yyvsp[0]); (yyval) = (yyvsp[-2]) < (yyvsp[0]);
...@@ -1485,7 +1415,7 @@ yyreduce: ...@@ -1485,7 +1415,7 @@ yyreduce:
break; break;
case 18: case 15:
{ {
(yyval) = (yyvsp[-2]) >> (yyvsp[0]); (yyval) = (yyvsp[-2]) >> (yyvsp[0]);
...@@ -1493,7 +1423,7 @@ yyreduce: ...@@ -1493,7 +1423,7 @@ yyreduce:
break; break;
case 19: case 16:
{ {
(yyval) = (yyvsp[-2]) << (yyvsp[0]); (yyval) = (yyvsp[-2]) << (yyvsp[0]);
...@@ -1501,7 +1431,7 @@ yyreduce: ...@@ -1501,7 +1431,7 @@ yyreduce:
break; break;
case 20: case 17:
{ {
(yyval) = (yyvsp[-2]) - (yyvsp[0]); (yyval) = (yyvsp[-2]) - (yyvsp[0]);
...@@ -1509,7 +1439,7 @@ yyreduce: ...@@ -1509,7 +1439,7 @@ yyreduce:
break; break;
case 21: case 18:
{ {
(yyval) = (yyvsp[-2]) + (yyvsp[0]); (yyval) = (yyvsp[-2]) + (yyvsp[0]);
...@@ -1517,17 +1447,10 @@ yyreduce: ...@@ -1517,17 +1447,10 @@ yyreduce:
break; break;
case 22: case 19:
{ {
if ((yyvsp[0]) == 0) if ((yyvsp[0]) == 0) {
{
if (context->isIgnoringErrors())
{
(yyval) = static_cast<YYSTYPE>(0);
}
else
{
std::ostringstream stream; std::ostringstream stream;
stream << (yyvsp[-2]) << " % " << (yyvsp[0]); stream << (yyvsp[-2]) << " % " << (yyvsp[0]);
std::string text = stream.str(); std::string text = stream.str();
...@@ -1535,27 +1458,17 @@ yyreduce: ...@@ -1535,27 +1458,17 @@ yyreduce:
context->token->location, context->token->location,
text.c_str()); text.c_str());
YYABORT; YYABORT;
} } else {
}
else
{
(yyval) = (yyvsp[-2]) % (yyvsp[0]); (yyval) = (yyvsp[-2]) % (yyvsp[0]);
} }
} }
break; break;
case 23: case 20:
{ {
if ((yyvsp[0]) == 0) if ((yyvsp[0]) == 0) {
{
if (context->isIgnoringErrors())
{
(yyval) = static_cast<YYSTYPE>(0);
}
else
{
std::ostringstream stream; std::ostringstream stream;
stream << (yyvsp[-2]) << " / " << (yyvsp[0]); stream << (yyvsp[-2]) << " / " << (yyvsp[0]);
std::string text = stream.str(); std::string text = stream.str();
...@@ -1563,17 +1476,14 @@ yyreduce: ...@@ -1563,17 +1476,14 @@ yyreduce:
context->token->location, context->token->location,
text.c_str()); text.c_str());
YYABORT; YYABORT;
} } else {
}
else
{
(yyval) = (yyvsp[-2]) / (yyvsp[0]); (yyval) = (yyvsp[-2]) / (yyvsp[0]);
} }
} }
break; break;
case 24: case 21:
{ {
(yyval) = (yyvsp[-2]) * (yyvsp[0]); (yyval) = (yyvsp[-2]) * (yyvsp[0]);
...@@ -1581,7 +1491,7 @@ yyreduce: ...@@ -1581,7 +1491,7 @@ yyreduce:
break; break;
case 25: case 22:
{ {
(yyval) = ! (yyvsp[0]); (yyval) = ! (yyvsp[0]);
...@@ -1589,7 +1499,7 @@ yyreduce: ...@@ -1589,7 +1499,7 @@ yyreduce:
break; break;
case 26: case 23:
{ {
(yyval) = ~ (yyvsp[0]); (yyval) = ~ (yyvsp[0]);
...@@ -1597,7 +1507,7 @@ yyreduce: ...@@ -1597,7 +1507,7 @@ yyreduce:
break; break;
case 27: case 24:
{ {
(yyval) = - (yyvsp[0]); (yyval) = - (yyvsp[0]);
...@@ -1605,7 +1515,7 @@ yyreduce: ...@@ -1605,7 +1515,7 @@ yyreduce:
break; break;
case 28: case 25:
{ {
(yyval) = + (yyvsp[0]); (yyval) = + (yyvsp[0]);
...@@ -1613,7 +1523,7 @@ yyreduce: ...@@ -1613,7 +1523,7 @@ yyreduce:
break; break;
case 29: case 26:
{ {
(yyval) = (yyvsp[-1]); (yyval) = (yyvsp[-1]);
...@@ -1871,15 +1781,6 @@ int yylex(YYSTYPE *lvalp, Context *context) ...@@ -1871,15 +1781,6 @@ int yylex(YYSTYPE *lvalp, Context *context)
type = TOK_CONST_INT; type = TOK_CONST_INT;
break; break;
} }
case pp::Token::IDENTIFIER:
if (!context->isIgnoringErrors())
{
context->diagnostics->report(pp::Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
token->location, token->text);
}
*lvalp = static_cast<YYSTYPE>(-1);
type = TOK_IDENTIFIER;
break;
case pp::Token::OP_OR: case pp::Token::OP_OR:
type = TOK_OP_OR; type = TOK_OP_OR;
break; break;
...@@ -1954,7 +1855,6 @@ bool ExpressionParser::parse(Token *token, int *result) ...@@ -1954,7 +1855,6 @@ bool ExpressionParser::parse(Token *token, int *result)
context.lexer = mLexer; context.lexer = mLexer;
context.token = token; context.token = token;
context.result = result; context.result = result;
context.ignoreErrors = 0;
int ret = yyparse(&context); int ret = yyparse(&context);
switch (ret) switch (ret)
{ {
......
...@@ -64,13 +64,6 @@ struct Context ...@@ -64,13 +64,6 @@ struct Context
pp::Lexer* lexer; pp::Lexer* lexer;
pp::Token* token; pp::Token* token;
int* result; int* result;
void startIgnoreErrors() { ++ignoreErrors; }
void endIgnoreErrors() { --ignoreErrors; }
bool isIgnoringErrors() { return ignoreErrors > 0; }
int ignoreErrors;
}; };
} // namespace } // namespace
%} %}
...@@ -86,7 +79,6 @@ static void yyerror(Context* context, const char* reason); ...@@ -86,7 +79,6 @@ static void yyerror(Context* context, const char* reason);
%} %}
%token TOK_CONST_INT %token TOK_CONST_INT
%token TOK_IDENTIFIER
%left TOK_OP_OR %left TOK_OP_OR
%left TOK_OP_AND %left TOK_OP_AND
%left '|' %left '|'
...@@ -104,62 +96,17 @@ static void yyerror(Context* context, const char* reason); ...@@ -104,62 +96,17 @@ static void yyerror(Context* context, const char* reason);
input input
: expression { : expression {
*(context->result) = static_cast<int>($1); *(context->result) = static_cast<int>($1);
YYACCEPT;
} }
; ;
expression expression
: TOK_CONST_INT : TOK_CONST_INT
| TOK_IDENTIFIER { | expression TOK_OP_OR expression {
if (!context->isIgnoringErrors()) $$ = $1 || $3;
{
YYABORT;
}
}
| expression TOK_OP_OR {
if ($1 != 0)
{
// Ignore errors in the short-circuited part of the expression.
// ESSL3.00 section 3.4:
// If an operand is not evaluated, the presence of undefined identifiers
// in the operand will not cause an error.
// Unevaluated division by zero should not cause an error either.
context->startIgnoreErrors();
}
} expression {
if ($1 != 0)
{
context->endIgnoreErrors();
// Make sure that short-circuited version of || works consistently
// with the normal version even for values other than 0 and 1.
$$ = $1 || 0;
}
else
{
$$ = $1 || $4;
}
}
| expression TOK_OP_AND {
if ($1 == 0)
{
// Ignore errors in the short-circuited part of the expression.
// ESSL3.00 section 3.4:
// If an operand is not evaluated, the presence of undefined identifiers
// in the operand will not cause an error.
// Unevaluated division by zero should not cause an error either.
context->startIgnoreErrors();
}
} expression {
if ($1 == 0)
{
context->endIgnoreErrors();
// Make sure that short-circuited version of && works consistently
// with the normal version even for values other than 0 and 1.
$$ = $1 && 0;
}
else
{
$$ = $1 && $4;
} }
| expression TOK_OP_AND expression {
$$ = $1 && $3;
} }
| expression '|' expression { | expression '|' expression {
$$ = $1 | $3; $$ = $1 | $3;
...@@ -201,14 +148,7 @@ expression ...@@ -201,14 +148,7 @@ expression
$$ = $1 + $3; $$ = $1 + $3;
} }
| expression '%' expression { | expression '%' expression {
if ($3 == 0) if ($3 == 0) {
{
if (context->isIgnoringErrors())
{
$$ = static_cast<YYSTYPE>(0);
}
else
{
std::ostringstream stream; std::ostringstream stream;
stream << $1 << " % " << $3; stream << $1 << " % " << $3;
std::string text = stream.str(); std::string text = stream.str();
...@@ -216,22 +156,12 @@ expression ...@@ -216,22 +156,12 @@ expression
context->token->location, context->token->location,
text.c_str()); text.c_str());
YYABORT; YYABORT;
} } else {
}
else
{
$$ = $1 % $3; $$ = $1 % $3;
} }
} }
| expression '/' expression { | expression '/' expression {
if ($3 == 0) if ($3 == 0) {
{
if (context->isIgnoringErrors())
{
$$ = static_cast<YYSTYPE>(0);
}
else
{
std::ostringstream stream; std::ostringstream stream;
stream << $1 << " / " << $3; stream << $1 << " / " << $3;
std::string text = stream.str(); std::string text = stream.str();
...@@ -239,10 +169,7 @@ expression ...@@ -239,10 +169,7 @@ expression
context->token->location, context->token->location,
text.c_str()); text.c_str());
YYABORT; YYABORT;
} } else {
}
else
{
$$ = $1 / $3; $$ = $1 / $3;
} }
} }
...@@ -286,15 +213,6 @@ int yylex(YYSTYPE *lvalp, Context *context) ...@@ -286,15 +213,6 @@ int yylex(YYSTYPE *lvalp, Context *context)
type = TOK_CONST_INT; type = TOK_CONST_INT;
break; break;
} }
case pp::Token::IDENTIFIER:
if (!context->isIgnoringErrors())
{
context->diagnostics->report(pp::Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
token->location, token->text);
}
*lvalp = static_cast<YYSTYPE>(-1);
type = TOK_IDENTIFIER;
break;
case pp::Token::OP_OR: case pp::Token::OP_OR:
type = TOK_OP_OR; type = TOK_OP_OR;
break; break;
...@@ -369,7 +287,6 @@ bool ExpressionParser::parse(Token *token, int *result) ...@@ -369,7 +287,6 @@ bool ExpressionParser::parse(Token *token, int *result)
context.lexer = mLexer; context.lexer = mLexer;
context.token = token; context.token = token;
context.result = result; context.result = result;
context.ignoreErrors = 0;
int ret = yyparse(&context); int ret = yyparse(&context);
switch (ret) switch (ret)
{ {
......
...@@ -697,6 +697,10 @@ TEST_F(IfTest, UndefinedMacro) ...@@ -697,6 +697,10 @@ TEST_F(IfTest, UndefinedMacro)
ASSERT_TRUE(mPreprocessor.init(1, &str, 0)); ASSERT_TRUE(mPreprocessor.init(1, &str, 0));
EXPECT_CALL(mDiagnostics, EXPECT_CALL(mDiagnostics,
print(pp::Diagnostics::PP_INVALID_EXPRESSION,
pp::SourceLocation(0, 1),
"syntax error"));
EXPECT_CALL(mDiagnostics,
print(pp::Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, print(pp::Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN,
pp::SourceLocation(0, 1), pp::SourceLocation(0, 1),
"UNDEFINED")); "UNDEFINED"));
...@@ -829,65 +833,3 @@ TEST_F(IfTest, UnterminatedIfdef) ...@@ -829,65 +833,3 @@ TEST_F(IfTest, UnterminatedIfdef)
mPreprocessor.lex(&token); mPreprocessor.lex(&token);
} }
// The preprocessor only allows one expression to follow an #if directive.
// Supplying two integer expressions should be an error.
TEST_F(IfTest, ExtraIntExpression)
{
const char *str =
"#if 1 1\n"
"#endif\n";
ASSERT_TRUE(mPreprocessor.init(1, &str, 0));
EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_INVALID_EXPRESSION,
pp::SourceLocation(0, 1), "syntax error"));
pp::Token token;
mPreprocessor.lex(&token);
}
// The preprocessor only allows one expression to follow an #if directive.
// Supplying two expressions where one uses a preprocessor define should be an error.
TEST_F(IfTest, ExtraIdentifierExpression)
{
const char *str =
"#define one 1\n"
"#if 1 one\n"
"#endif\n";
ASSERT_TRUE(mPreprocessor.init(1, &str, 0));
EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_INVALID_EXPRESSION,
pp::SourceLocation(0, 2), "syntax error"));
pp::Token token;
mPreprocessor.lex(&token);
}
// Divide by zero that's not evaluated because of short-circuiting should not cause an error.
TEST_F(IfTest, ShortCircuitedDivideByZero)
{
const char *str =
"#if 1 || (2 / 0)\n"
"pass\n"
"#endif\n";
const char *expected =
"\n"
"pass\n"
"\n";
preprocess(str, expected);
}
// Undefined identifier that's not evaluated because of short-circuiting should not cause an error.
TEST_F(IfTest, ShortCircuitedUndefined)
{
const char *str =
"#if 1 || UNDEFINED\n"
"pass\n"
"#endif\n";
const char *expected =
"\n"
"pass\n"
"\n";
preprocess(str, expected);
}
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