summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-26 20:59:55 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-26 20:59:55 +0000
commitf9edf80c39cec48906529ca168bc155cd8a0367b (patch)
treea4a2d8f6e62f0a4f980295463436b4f032c18f00 /clang/lib
parent34147278eafdd7f42ac06637c7168af221379772 (diff)
downloadbcm5719-llvm-f9edf80c39cec48906529ca168bc155cd8a0367b.tar.gz
bcm5719-llvm-f9edf80c39cec48906529ca168bc155cd8a0367b.zip
When trying to determine whether one operand of a conditional
expression can be converted to the type of another, only apply the lvalue-to-rvalue conversion to the type of the expression we're converting, *not* the array-to-pointer or function-to-pointer conversions. Fixes PR6595. llvm-svn: 99652
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 52dc6d8fa4f..5a412920415 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1934,7 +1934,8 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
// can be converted to match an operand expression E2 of type T2 is defined
// as follows:
// -- If E2 is an lvalue:
- if (To->isLvalue(Self.Context) == Expr::LV_Valid) {
+ bool ToIsLvalue = (To->isLvalue(Self.Context) == Expr::LV_Valid);
+ if (ToIsLvalue) {
// E1 can be converted to match E2 if E1 can be implicitly converted to
// type "lvalue reference to T2", subject to the constraint that in the
// conversion the reference must bind directly to E1.
@@ -1985,12 +1986,13 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
// -- Otherwise: E1 can be converted to match E2 if E1 can be
// implicitly converted to the type that expression E2 would have
- // if E2 were converted to an rvalue.
- // First find the decayed type.
- if (TTy->isFunctionType())
- TTy = Self.Context.getPointerType(TTy);
- else if (TTy->isArrayType())
- TTy = Self.Context.getArrayDecayedType(TTy);
+ // if E2 were converted to an rvalue (or the type it has, if E2 is
+ // an rvalue).
+ //
+ // This actually refers very narrowly to the lvalue-to-rvalue conversion, not
+ // to the array-to-pointer or function-to-pointer conversions.
+ if (!TTy->getAs<TagType>())
+ TTy = TTy.getUnqualifiedType();
InitializedEntity Entity = InitializedEntity::InitializeTemporary(TTy);
InitializationSequence InitSeq(Self, Entity, Kind, &From, 1);
OpenPOWER on IntegriCloud