diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-29 22:55:55 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-29 22:55:55 +0000 |
commit | 342f1f8b0a402c5a7f8c5055db7f60a7808f1687 (patch) | |
tree | 2e506433b126471a0427a727844fe3bd91ccc9c1 | |
parent | b78c0b66481a59dbef7ac2a454e4f89448909749 (diff) |
Don't crash if a GCC binary conditional is used in a constant expression on an
integer-cast pointer value.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143299 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ExprConstant.cpp | 4 | ||||
-rw-r--r-- | test/Sema/const-eval.c | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index e5bff359f8..f33827ff7c 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -1436,6 +1436,10 @@ public: } bool Success(const CCValue &V, const Expr *E) { + if (V.isLValue()) { + Result = V; + return true; + } return Success(V.getInt(), E); } bool Error(const Expr *E) { diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index 6dcc6db765..ee55ca871f 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -88,3 +88,6 @@ void rdar8875946() { } double d = (d = 0.0); // expected-error {{not a compile-time constant}} + +int n = 2; +int intLvalue[*(int*)((long)&n ?: 1)] = { 1, 2 }; // expected-error {{variable length array}} |