summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/builtins.c
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2018-11-20 23:24:16 +0000
committerBill Wendling <isanbard@gmail.com>2018-11-20 23:24:16 +0000
commit91549ed15f97f21de8770196e66da3d228820cdc (patch)
treea4a3c5ffe121d9c0fdcce151e96eba612d3c7ded /clang/test/Sema/builtins.c
parent8eb65cb25e67a2b426b94152f9c9bb3c1025b701 (diff)
downloadbcm5719-llvm-91549ed15f97f21de8770196e66da3d228820cdc.tar.gz
bcm5719-llvm-91549ed15f97f21de8770196e66da3d228820cdc.zip
Reinstate 347294 with a fix for the failures.
EvaluateAsInt() is sometimes called in a constant context. When that's the case, we need to specify it as so. llvm-svn: 347364
Diffstat (limited to 'clang/test/Sema/builtins.c')
-rw-r--r--clang/test/Sema/builtins.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/test/Sema/builtins.c b/clang/test/Sema/builtins.c
index e874f598857..7d01e89756c 100644
--- a/clang/test/Sema/builtins.c
+++ b/clang/test/Sema/builtins.c
@@ -122,6 +122,14 @@ int test16() {
__builtin_constant_p(1, 2); // expected-error {{too many arguments}}
}
+// __builtin_constant_p cannot resolve non-constants as a file scoped array.
+int expr;
+char y[__builtin_constant_p(expr) ? -1 : 1]; // no warning, the builtin is false.
+
+// no warning, the builtin is false.
+struct foo { int a; };
+struct foo x = (struct foo) { __builtin_constant_p(42) ? 37 : 927 };
+
const int test17_n = 0;
const char test17_c[] = {1, 2, 3, 0};
const char test17_d[] = {1, 2, 3, 4};
@@ -161,6 +169,7 @@ void test17() {
F(&test17_d);
F((struct Aggregate){0, 1});
F((IntVector){0, 1, 2, 3});
+ F(test17);
// Ensure that a technique used in glibc is handled correctly.
#define OPT(...) (__builtin_constant_p(__VA_ARGS__) && strlen(__VA_ARGS__) < 4)
OpenPOWER on IntegriCloud