From efa898aca21d771802f274df8afd28d73ab9aaa3 Mon Sep 17 00:00:00 2001 From: James Darpinian Date: Wed, 7 Aug 2019 17:05:35 -0700 Subject: [PATCH] Enable some compiler warnings used by WebKit. This will make it easier to roll ANGLE in WebKit. Bug: angleproject:3439 Change-Id: Icd4a5a2d5dcabb6cf13d4b46a7547f49610fa4b3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1743057 Commit-Queue: James Darpinian Reviewed-by: Jamie Madill Reviewed-by: Geoff Lang --- BUILD.gn | 7 ++ .../preprocessor/ExpressionParser.cpp | 9 ++- src/compiler/preprocessor/ExpressionParser.y | 3 + src/compiler/preprocessor/Tokenizer.cpp | 1 + src/compiler/preprocessor/Tokenizer.l | 1 + src/compiler/translator/glslang.l | 1 + src/compiler/translator/glslang.y | 3 + src/compiler/translator/glslang_lex.cpp | 1 + src/compiler/translator/glslang_tab.cpp | 65 ++++++++++--------- src/libANGLE/Program.cpp | 2 +- src/libANGLE/Sampler.cpp | 5 +- .../third_party/android_native_app_glue.c | 2 +- .../third_party/android_native_app_glue.h | 2 +- 13 files changed, 63 insertions(+), 39 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 435ac3eb8..9d18d397d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -131,6 +131,13 @@ config("extra_warnings") { "-Wunneeded-internal-declaration", "-Wglobal-constructors", "-Wexit-time-destructors", + + # The below warnings are used by WebKit. We enable them to make rolling + # ANGLE in WebKit easier. + "-Wparentheses", + "-Wrange-loop-analysis", + "-Wstrict-prototypes", + "-Wunreachable-code", ] } } diff --git a/src/compiler/preprocessor/ExpressionParser.cpp b/src/compiler/preprocessor/ExpressionParser.cpp index 461c2145d..b36124722 100644 --- a/src/compiler/preprocessor/ExpressionParser.cpp +++ b/src/compiler/preprocessor/ExpressionParser.cpp @@ -85,6 +85,9 @@ #elif defined(_MSC_VER) # pragma warning(disable : 4065 4244 4701 4702) #endif +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wunreachable-code" +#endif #include "ExpressionParser.h" @@ -455,9 +458,9 @@ static const yytype_uint8 yytranslate[] = { #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = {0, 108, 108, 115, 116, 127, 127, 148, 148, 169, - 172, 175, 178, 181, 184, 187, 190, 193, 196, 221, - 243, 246, 249, 275, 302, 305, 308, 311, 323, 326}; +static const yytype_uint16 yyrline[] = {0, 111, 111, 118, 119, 130, 130, 151, 151, 172, + 175, 178, 181, 184, 187, 190, 193, 196, 199, 224, + 246, 249, 252, 278, 305, 308, 311, 314, 326, 329}; #endif #if YYDEBUG || YYERROR_VERBOSE || 0 diff --git a/src/compiler/preprocessor/ExpressionParser.y b/src/compiler/preprocessor/ExpressionParser.y index 6ddf9122c..29db3c31d 100644 --- a/src/compiler/preprocessor/ExpressionParser.y +++ b/src/compiler/preprocessor/ExpressionParser.y @@ -30,6 +30,9 @@ WHICH GENERATES THE GLSL ES preprocessor expression parser. #elif defined(_MSC_VER) #pragma warning(disable: 4065 4244 4701 4702) #endif +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif #include "ExpressionParser.h" diff --git a/src/compiler/preprocessor/Tokenizer.cpp b/src/compiler/preprocessor/Tokenizer.cpp index 2ce67b738..e31f6526e 100644 --- a/src/compiler/preprocessor/Tokenizer.cpp +++ b/src/compiler/preprocessor/Tokenizer.cpp @@ -702,6 +702,7 @@ IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh. # pragma GCC diagnostic ignored "-Wimplicit-fallthrough" // Flex isn't semi-colon clean. # pragma clang diagnostic ignored "-Wextra-semi-stmt" +# pragma clang diagnostic ignored "-Wunreachable-code" #endif // Workaround for flex using the register keyword, deprecated in C++11. diff --git a/src/compiler/preprocessor/Tokenizer.l b/src/compiler/preprocessor/Tokenizer.l index 94db185ef..fdbbe5b5e 100644 --- a/src/compiler/preprocessor/Tokenizer.l +++ b/src/compiler/preprocessor/Tokenizer.l @@ -43,6 +43,7 @@ IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh. #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" // Flex isn't semi-colon clean. #pragma clang diagnostic ignored "-Wextra-semi-stmt" +#pragma clang diagnostic ignored "-Wunreachable-code" #endif // Workaround for flex using the register keyword, deprecated in C++11. diff --git a/src/compiler/translator/glslang.l b/src/compiler/translator/glslang.l index 26c2f0060..1a9f7c3aa 100644 --- a/src/compiler/translator/glslang.l +++ b/src/compiler/translator/glslang.l @@ -42,6 +42,7 @@ WHICH GENERATES THE GLSL ES LEXER (glslang_lex.cpp). #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" // Flex isn't semi-colon clean. #pragma clang diagnostic ignored "-Wextra-semi-stmt" +#pragma clang diagnostic ignored "-Wunreachable-code" #endif } diff --git a/src/compiler/translator/glslang.y b/src/compiler/translator/glslang.y index 6a7da3d87..09b7c5c94 100644 --- a/src/compiler/translator/glslang.y +++ b/src/compiler/translator/glslang.y @@ -37,6 +37,9 @@ WHICH GENERATES THE GLSL ES PARSER (glslang_tab.cpp AND glslang_tab.h). #pragma warning(disable: 4701) #pragma warning(disable: 4702) #endif +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif #include "angle_gl.h" #include "compiler/translator/Declarator.h" diff --git a/src/compiler/translator/glslang_lex.cpp b/src/compiler/translator/glslang_lex.cpp index 3a65f1ebc..eebd9d5fc 100644 --- a/src/compiler/translator/glslang_lex.cpp +++ b/src/compiler/translator/glslang_lex.cpp @@ -27,6 +27,7 @@ #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" // Flex isn't semi-colon clean. #pragma clang diagnostic ignored "-Wextra-semi-stmt" +#pragma clang diagnostic ignored "-Wunreachable-code" #endif diff --git a/src/compiler/translator/glslang_tab.cpp b/src/compiler/translator/glslang_tab.cpp index bf4efe8cb..b6e5a67a3 100644 --- a/src/compiler/translator/glslang_tab.cpp +++ b/src/compiler/translator/glslang_tab.cpp @@ -83,6 +83,9 @@ #pragma warning(disable: 4701) #pragma warning(disable: 4702) #endif +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif #include "angle_gl.h" #include "compiler/translator/Declarator.h" @@ -738,37 +741,37 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 248, 248, 249, 252, 259, 262, 267, 272, 277, - 282, 291, 297, 300, 303, 306, 309, 312, 318, 325, - 331, 334, 342, 345, 351, 354, 360, 364, 371, 379, - 382, 385, 391, 394, 397, 400, 407, 408, 409, 410, - 418, 419, 422, 425, 432, 433, 436, 442, 443, 447, - 454, 455, 458, 461, 464, 470, 471, 474, 480, 481, - 488, 489, 496, 497, 504, 505, 511, 512, 518, 519, - 525, 526, 532, 533, 539, 540, 541, 542, 546, 547, - 548, 552, 556, 560, 564, 571, 574, 580, 587, 594, - 597, 600, 604, 608, 612, 616, 620, 627, 634, 637, - 644, 652, 669, 679, 682, 688, 692, 696, 700, 707, - 714, 717, 721, 725, 730, 737, 741, 745, 749, 754, - 761, 765, 771, 774, 780, 784, 791, 797, 801, 805, - 808, 811, 820, 825, 829, 832, 835, 838, 841, 845, - 848, 852, 855, 858, 861, 864, 867, 874, 881, 884, - 887, 893, 900, 903, 909, 912, 915, 918, 924, 927, - 934, 939, 946, 951, 962, 965, 968, 971, 974, 977, - 981, 985, 989, 993, 997, 1001, 1005, 1009, 1013, 1017, - 1021, 1025, 1029, 1033, 1037, 1041, 1045, 1049, 1053, 1057, - 1061, 1068, 1071, 1074, 1077, 1080, 1083, 1086, 1089, 1092, - 1095, 1098, 1101, 1104, 1107, 1110, 1113, 1116, 1119, 1122, - 1125, 1128, 1131, 1141, 1148, 1155, 1158, 1161, 1164, 1167, - 1170, 1173, 1176, 1179, 1182, 1185, 1188, 1191, 1194, 1197, - 1205, 1205, 1208, 1208, 1214, 1217, 1223, 1226, 1233, 1237, - 1243, 1246, 1252, 1256, 1260, 1261, 1267, 1268, 1269, 1270, - 1271, 1272, 1273, 1277, 1281, 1281, 1281, 1288, 1289, 1293, - 1293, 1294, 1294, 1299, 1303, 1310, 1314, 1321, 1322, 1326, - 1332, 1336, 1345, 1345, 1352, 1355, 1361, 1365, 1371, 1371, - 1376, 1376, 1380, 1380, 1388, 1391, 1397, 1400, 1406, 1410, - 1417, 1420, 1423, 1426, 1429, 1437, 1443, 1449, 1452, 1458, - 1458 + 0, 251, 251, 252, 255, 262, 265, 270, 275, 280, + 285, 294, 300, 303, 306, 309, 312, 315, 321, 328, + 334, 337, 345, 348, 354, 357, 363, 367, 374, 382, + 385, 388, 394, 397, 400, 403, 410, 411, 412, 413, + 421, 422, 425, 428, 435, 436, 439, 445, 446, 450, + 457, 458, 461, 464, 467, 473, 474, 477, 483, 484, + 491, 492, 499, 500, 507, 508, 514, 515, 521, 522, + 528, 529, 535, 536, 542, 543, 544, 545, 549, 550, + 551, 555, 559, 563, 567, 574, 577, 583, 590, 597, + 600, 603, 607, 611, 615, 619, 623, 630, 637, 640, + 647, 655, 672, 682, 685, 691, 695, 699, 703, 710, + 717, 720, 724, 728, 733, 740, 744, 748, 752, 757, + 764, 768, 774, 777, 783, 787, 794, 800, 804, 808, + 811, 814, 823, 828, 832, 835, 838, 841, 844, 848, + 851, 855, 858, 861, 864, 867, 870, 877, 884, 887, + 890, 896, 903, 906, 912, 915, 918, 921, 927, 930, + 937, 942, 949, 954, 965, 968, 971, 974, 977, 980, + 984, 988, 992, 996, 1000, 1004, 1008, 1012, 1016, 1020, + 1024, 1028, 1032, 1036, 1040, 1044, 1048, 1052, 1056, 1060, + 1064, 1071, 1074, 1077, 1080, 1083, 1086, 1089, 1092, 1095, + 1098, 1101, 1104, 1107, 1110, 1113, 1116, 1119, 1122, 1125, + 1128, 1131, 1134, 1144, 1151, 1158, 1161, 1164, 1167, 1170, + 1173, 1176, 1179, 1182, 1185, 1188, 1191, 1194, 1197, 1200, + 1208, 1208, 1211, 1211, 1217, 1220, 1226, 1229, 1236, 1240, + 1246, 1249, 1255, 1259, 1263, 1264, 1270, 1271, 1272, 1273, + 1274, 1275, 1276, 1280, 1284, 1284, 1284, 1291, 1292, 1296, + 1296, 1297, 1297, 1302, 1306, 1313, 1317, 1324, 1325, 1329, + 1335, 1339, 1348, 1348, 1355, 1358, 1364, 1368, 1374, 1374, + 1379, 1379, 1383, 1383, 1391, 1394, 1400, 1403, 1409, 1413, + 1420, 1423, 1426, 1429, 1432, 1440, 1446, 1452, 1455, 1461, + 1461 }; #endif diff --git a/src/libANGLE/Program.cpp b/src/libANGLE/Program.cpp index 6dc5e97a7..6081727ae 100644 --- a/src/libANGLE/Program.cpp +++ b/src/libANGLE/Program.cpp @@ -3783,7 +3783,7 @@ bool Program::linkValidateGlobalNames(InfoLog &infoLog) const // to see if there's a conflict or not. std::vector prevBlockFieldPairs = uniformBlockFieldMap[field.name]; - for (const auto prevBlockFieldPair : prevBlockFieldPairs) + for (const auto &prevBlockFieldPair : prevBlockFieldPairs) { const sh::InterfaceBlock *prevUniformBlock = prevBlockFieldPair.first; const sh::InterfaceBlockField *prevUniformBlockField = diff --git a/src/libANGLE/Sampler.cpp b/src/libANGLE/Sampler.cpp index 4d94ed12e..0e0c48180 100644 --- a/src/libANGLE/Sampler.cpp +++ b/src/libANGLE/Sampler.cpp @@ -187,8 +187,9 @@ rx::SamplerImpl *Sampler::getImplementation() const angle::Result Sampler::syncState(const Context *context) { ASSERT(isDirty()); - return mSampler->syncState(context, mDirty); - mDirty = false; + angle::Result result = mSampler->syncState(context, mDirty); + mDirty = result != angle::Result::Continue; + return result; } void Sampler::signalDirtyState() diff --git a/util/android/third_party/android_native_app_glue.c b/util/android/third_party/android_native_app_glue.c index abd51b0cb..ad9c55816 100644 --- a/util/android/third_party/android_native_app_glue.c +++ b/util/android/third_party/android_native_app_glue.c @@ -167,7 +167,7 @@ void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd) { } } -void app_dummy() { +void app_dummy(void) { } diff --git a/util/android/third_party/android_native_app_glue.h b/util/android/third_party/android_native_app_glue.h index 97202e094..c1e4d3cb4 100644 --- a/util/android/third_party/android_native_app_glue.h +++ b/util/android/third_party/android_native_app_glue.h @@ -334,7 +334,7 @@ void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd); /** * Dummy function you can call to ensure glue code isn't stripped. */ -void app_dummy(); +void app_dummy(void); /** * This is the function that application code must implement, representing