[cfe-commits] r144783 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/Sema/const-eval.c
Richard Smith
richard-llvm at metafoo.co.uk
Tue Nov 15 23:18:12 PST 2011
Author: rsmith
Date: Wed Nov 16 01:18:12 2011
New Revision: 144783
URL: http://llvm.org/viewvc/llvm-project?rev=144783&view=rev
Log:
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.
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=144783&r1=144782&r2=144783&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Nov 16 01:18:12 2011
@@ -3197,6 +3197,7 @@
if (Info.Ctx.getTypeSize(DestType) != Info.Ctx.getTypeSize(SrcType))
return false;
+ LV.Designator.setInvalid();
LV.moveInto(Result);
return true;
}
Modified: cfe/trunk/test/Sema/const-eval.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/const-eval.c?rev=144783&r1=144782&r2=144783&view=diff
==============================================================================
--- cfe/trunk/test/Sema/const-eval.c (original)
+++ cfe/trunk/test/Sema/const-eval.c Wed Nov 16 01:18:12 2011
@@ -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 literalVsNull1 = "foo" == 0;
int literalVsNull2 = 0 == "foo";
+
+// PR11385.
+int castViaInt[*(int*)(unsigned long)"test"]; // expected-error {{variable length array}}
More information about the cfe-commits
mailing list