mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-01 20:36:06 +00:00
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:
parent
643e63c40c
commit
cf74da76db
@ -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;
|
||||
}
|
||||
|
@ -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}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user