Fix PR11385: A pointer constant expression which has been cast via an integer is

not safely derived. Don't allow lvalue-to-rvalue conversions on the result of
dereferencing such a pointer.

llvm-svn: 144783
This commit is contained in:
Richard Smith 2011-11-16 07:18:12 +00:00
parent 643e63c40c
commit cf74da76db
2 changed files with 5 additions and 1 deletions

View File

@ -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;
}

View File

@ -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}}