Implement the final (hopefully) wrinkle to i-c-e + builtin_constant_p
processing: it allows arbitrary foldable constants as the operand of ?: when
builtin_constant_p is the condition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60954 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/i-c-e.c b/test/Sema/i-c-e.c
index 30cc9e2..8fa840d 100644
--- a/test/Sema/i-c-e.c
+++ b/test/Sema/i-c-e.c
@@ -7,6 +7,19 @@
char w[__builtin_constant_p(expr) ? expr : 1];
+// __builtin_constant_p as the condition of ?: allows arbitrary foldable
+// constants to be transmogrified into i-c-e's.
+char b[__builtin_constant_p((int)(1.0+2.0)) ? (int)(1.0+2.0) : -1];
+
+struct c {
+ int a : ( // expected-error {{expression is not an integer constant expression}}
+ __builtin_constant_p((int)(1.0+2.0)) ? (int)(1.0+
+ expr // expected-note {{subexpression not valid in an integer constant expression}}
+ ) : -1);
+};
+
+
+
void test1(int n, int* p) { *(n ? p : (void *)(7-7)) = 1; }
void test2(int n, int* p) { *(n ? p : (void *)0) = 1; }