diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 1451fd111953..699d81715e3c 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -3197,6 +3197,7 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) { if (Info.Ctx.getTypeSize(DestType) != Info.Ctx.getTypeSize(SrcType)) return false; + LV.Designator.setInvalid(); LV.moveInto(Result); return true; } diff --git a/clang/test/Sema/const-eval.c b/clang/test/Sema/const-eval.c index 632457da0916..094d1ce71608 100644 --- a/clang/test/Sema/const-eval.c +++ b/clang/test/Sema/const-eval.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux %s #define EVAL_EXPR(testno, expr) int test##testno = sizeof(struct{char qq[expr];}); int x; @@ -105,3 +105,6 @@ int weak_int_test = weak_int; // expected-error {{not a compile-time constant}} int literalVsNull1 = "foo" == 0; int literalVsNull2 = 0 == "foo"; + +// PR11385. +int castViaInt[*(int*)(unsigned long)"test"]; // expected-error {{variable length array}}