r173747 - Don't crash while printing APValues that are lvalues casted to a
Douglas Gregor
dgregor at apple.com
Mon Jan 28 17:26:44 PST 2013
Author: dgregor
Date: Mon Jan 28 19:26:43 2013
New Revision: 173747
URL: http://llvm.org/viewvc/llvm-project?rev=173747&view=rev
Log:
Don't crash while printing APValues that are lvalues casted to a
decidedly non-reference, non-pointer type. Fixes <rdar://problem/13090123>.
Modified:
cfe/trunk/lib/AST/APValue.cpp
cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
Modified: cfe/trunk/lib/AST/APValue.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/APValue.cpp?rev=173747&r1=173746&r2=173747&view=diff
==============================================================================
--- cfe/trunk/lib/AST/APValue.cpp (original)
+++ cfe/trunk/lib/AST/APValue.cpp Mon Jan 28 19:26:43 2013
@@ -348,6 +348,8 @@ void APValue::printPretty(raw_ostream &O
bool IsReference = Ty->isReferenceType();
QualType InnerTy
= IsReference ? Ty.getNonReferenceType() : Ty->getPointeeType();
+ if (InnerTy.isNull())
+ InnerTy = Ty;
if (!hasLValuePath()) {
// No lvalue path: just print the offset.
Modified: cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp?rev=173747&r1=173746&r2=173747&view=diff
==============================================================================
--- cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp (original)
+++ cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp Mon Jan 28 19:26:43 2013
@@ -594,3 +594,16 @@ static const bool or_value = and_or<true
static_assert(and_value == false, "");
static_assert(or_value == true, "");
+
+namespace rdar13090123 {
+ typedef __INTPTR_TYPE__ intptr_t;
+
+ constexpr intptr_t f(intptr_t x) {
+ return (((x) >> 21) * 8); // expected-note{{subexpression not valid in a constant expression}}
+ }
+
+ extern "C" int foo;
+
+ constexpr intptr_t i = f((intptr_t)&foo - 10); // expected-error{{constexpr variable 'i' must be initialized by a constant expression}} \
+ // expected-note{{in call to 'f((char*)&foo + -10)'}}
+}
More information about the cfe-commits
mailing list