]> granicus.if.org Git - clang/commitdiff
Don't crash if a GCC binary conditional is used in a constant expression on an
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 29 Oct 2011 22:55:55 +0000 (22:55 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 29 Oct 2011 22:55:55 +0000 (22:55 +0000)
integer-cast pointer value.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143299 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/Sema/const-eval.c

index e5bff359f8504d847015f4a85832396504d82d41..f33827ff7c4eec8b1a148cfd0811c7b0ed06cd92 100644 (file)
@@ -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) {
index 6dcc6db7659645ea3a679e6ba23105f2a754f9ef..ee55ca871fea940a3489883eeec8bfc318b7d196 100644 (file)
@@ -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}}