[cfe-commits] r92429 - /cfe/trunk/lib/Sema/SemaExprCXX.cpp
Eli Friedman
eli.friedman at gmail.com
Sat Jan 2 14:56:28 PST 2010
Author: efriedma
Date: Sat Jan 2 16:56:07 2010
New Revision: 92429
URL: http://llvm.org/viewvc/llvm-project?rev=92429&view=rev
Log:
Get rid of more unnecessary code.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=92429&r1=92428&r2=92429&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sat Jan 2 16:56:07 2010
@@ -1790,6 +1790,12 @@
// type and the other is a null pointer constant; pointer conversions
// and qualification conversions are performed to bring them to their
// composite pointer type. The result is of the composite pointer type.
+ // -- The second and third operands have pointer to member type, or one has
+ // pointer to member type and the other is a null pointer constant;
+ // pointer to member conversions and qualification conversions are
+ // performed to bring them to a common type, whose cv-qualification
+ // shall match the cv-qualification of either the second or the third
+ // operand. The result is of the common type.
QualType Composite = FindCompositePointerType(LHS, RHS);
if (!Composite.isNull())
return Composite;
@@ -1799,83 +1805,6 @@
if (!Composite.isNull())
return Composite;
- // Fourth bullet is same for pointers-to-member. However, the possible
- // conversions are far more limited: we have null-to-pointer, upcast of
- // containing class, and second-level cv-ness.
- // cv-ness is not a union, but must match one of the two operands. (Which,
- // frankly, is stupid.)
- const MemberPointerType *LMemPtr = LTy->getAs<MemberPointerType>();
- const MemberPointerType *RMemPtr = RTy->getAs<MemberPointerType>();
- if (LMemPtr &&
- RHS->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) {
- ImpCastExprToType(RHS, LTy, CastExpr::CK_NullToMemberPointer);
- return LTy;
- }
- if (RMemPtr &&
- LHS->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) {
- ImpCastExprToType(LHS, RTy, CastExpr::CK_NullToMemberPointer);
- return RTy;
- }
- if (LMemPtr && RMemPtr) {
- QualType LPointee = LMemPtr->getPointeeType();
- QualType RPointee = RMemPtr->getPointeeType();
-
- QualifierCollector LPQuals, RPQuals;
- const Type *LPCan = LPQuals.strip(Context.getCanonicalType(LPointee));
- const Type *RPCan = RPQuals.strip(Context.getCanonicalType(RPointee));
-
- // First, we check that the unqualified pointee type is the same. If it's
- // not, there's no conversion that will unify the two pointers.
- if (LPCan == RPCan) {
-
- // Second, we take the greater of the two qualifications. If neither
- // is greater than the other, the conversion is not possible.
-
- Qualifiers MergedQuals = LPQuals + RPQuals;
-
- bool CompatibleQuals = true;
- if (MergedQuals.getCVRQualifiers() != LPQuals.getCVRQualifiers() &&
- MergedQuals.getCVRQualifiers() != RPQuals.getCVRQualifiers())
- CompatibleQuals = false;
- else if (LPQuals.getAddressSpace() != RPQuals.getAddressSpace())
- // FIXME:
- // C99 6.5.15 as modified by TR 18037:
- // If the second and third operands are pointers into different
- // address spaces, the address spaces must overlap.
- CompatibleQuals = false;
- // FIXME: GC qualifiers?
-
- if (CompatibleQuals) {
- // Third, we check if either of the container classes is derived from
- // the other.
- QualType LContainer(LMemPtr->getClass(), 0);
- QualType RContainer(RMemPtr->getClass(), 0);
- QualType MoreDerived;
- if (Context.getCanonicalType(LContainer) ==
- Context.getCanonicalType(RContainer))
- MoreDerived = LContainer;
- else if (IsDerivedFrom(LContainer, RContainer))
- MoreDerived = LContainer;
- else if (IsDerivedFrom(RContainer, LContainer))
- MoreDerived = RContainer;
-
- if (!MoreDerived.isNull()) {
- // The type 'Q Pointee (MoreDerived::*)' is the common type.
- // We don't use ImpCastExprToType here because this could still fail
- // for ambiguous or inaccessible conversions.
- LPointee = Context.getQualifiedType(LPointee, MergedQuals);
- QualType Common
- = Context.getMemberPointerType(LPointee, MoreDerived.getTypePtr());
- if (PerformImplicitConversion(LHS, Common, Sema::AA_Converting))
- return QualType();
- if (PerformImplicitConversion(RHS, Common, Sema::AA_Converting))
- return QualType();
- return Common;
- }
- }
- }
- }
-
Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
<< LHS->getType() << RHS->getType()
<< LHS->getSourceRange() << RHS->getSourceRange();
More information about the cfe-commits
mailing list