aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/const-eval.c
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-11-12 09:44:48 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-11-12 09:44:48 +0000
commit4efaa276bc0ce8f7baf6138ead11915f3e3e58d9 (patch)
tree0ed7f53e97397eeda48dcb5fdfda0605a84fe2c0 /test/Sema/const-eval.c
parent9802a5173ffd403d9ede2d4b6b6107fa2e220544 (diff)
Some additions to tryEvaluate I've had sitting around for a while.
This pushes it a lot closer to being able to deal with most of the stuff CodeGen's constant expression evaluator knows how to deal with. This also fixes PR3003. The test could possibly use some improvement, but this'll work for now. Test 6 is inspired by PR3003; the other tests are mostly just designed to exercise the new code. The reason for the funny structure of the tests is that type fixing for arrays inside of structs is the only place in Sema that calls tryEvaluate, at least for the moment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59125 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/const-eval.c')
-rw-r--r--test/Sema/const-eval.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c
new file mode 100644
index 0000000000..f42ed2504b
--- /dev/null
+++ b/test/Sema/const-eval.c
@@ -0,0 +1,13 @@
+// RUN: clang -fsyntax-only -verify %s
+
+#define EVAL_EXPR(testno, expr) int test##testno = sizeof(struct{char qq[expr];});
+int x;
+EVAL_EXPR(1, (_Bool)&x)
+EVAL_EXPR(2, (int)(1.0+(double)4))
+EVAL_EXPR(3, (int)(1.0+(float)4.0))
+EVAL_EXPR(4, (_Bool)(1 ? (void*)&x : 0))
+EVAL_EXPR(5, (_Bool)(int[]){0})
+struct y {int x,y;};
+EVAL_EXPR(6, (int)(1+(struct y*)0))
+EVAL_EXPR(7, (int)&((struct y*)0)->y)
+EVAL_EXPR(8, (_Bool)"asdf")