[cfe-commits] r143299 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/Sema/const-eval.c

Richard Smith richard-llvm at metafoo.co.uk
Sat Oct 29 15:55:55 PDT 2011


Author: rsmith
Date: Sat Oct 29 17:55:55 2011
New Revision: 143299

URL: http://llvm.org/viewvc/llvm-project?rev=143299&view=rev
Log:
Don't crash if a GCC binary conditional is used in a constant expression on an
integer-cast pointer value.

Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp
    cfe/trunk/test/Sema/const-eval.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=143299&r1=143298&r2=143299&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sat Oct 29 17:55:55 2011
@@ -1436,6 +1436,10 @@
   }
 
   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) {

Modified: cfe/trunk/test/Sema/const-eval.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/const-eval.c?rev=143299&r1=143298&r2=143299&view=diff
==============================================================================
--- cfe/trunk/test/Sema/const-eval.c (original)
+++ cfe/trunk/test/Sema/const-eval.c Sat Oct 29 17:55:55 2011
@@ -88,3 +88,6 @@
 }
 
 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}}





More information about the cfe-commits mailing list