From 342f1f8b0a402c5a7f8c5055db7f60a7808f1687 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 29 Oct 2011 22:55:55 +0000 Subject: [PATCH] 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 --- lib/AST/ExprConstant.cpp | 4 ++++ test/Sema/const-eval.c | 3 +++ 2 files changed, 7 insertions(+) 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}} -- 2.40.0