From 21e771e96e2abfa14a8f49ab50601682a24f7582 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 3 Feb 2010 21:02:30 +0000 Subject: Define two types to be "compatible" in C++ if they are the same, and remove some age-old FIXMEs and C++ workarounds within the type-compatibility logic. llvm-svn: 95249 --- clang/lib/AST/ASTContext.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'clang/lib/AST/ASTContext.cpp') diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 46c5b41f931..d6c9041e3e9 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4244,6 +4244,9 @@ bool ASTContext::areComparableObjCPointerTypes(QualType LHS, QualType RHS) { /// C99 6.2.7p1: Two types have compatible types if their types are the /// same. See 6.7.[2,3,5] for additional rules. bool ASTContext::typesAreCompatible(QualType LHS, QualType RHS) { + if (getLangOptions().CPlusPlus) + return hasSameType(LHS, RHS); + return !mergeTypes(LHS, RHS).isNull(); } @@ -4359,15 +4362,9 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { // designates the object or function denoted by the reference, and the // expression is an lvalue unless the reference is an rvalue reference and // the expression is a function call (possibly inside parentheses). - // FIXME: C++ shouldn't be going through here! The rules are different - // enough that they should be handled separately. - // FIXME: Merging of lvalue and rvalue references is incorrect. C++ *really* - // shouldn't be going through here! - if (const ReferenceType *RT = LHS->getAs()) - LHS = RT->getPointeeType(); - if (const ReferenceType *RT = RHS->getAs()) - RHS = RT->getPointeeType(); - + assert(!LHS->getAs() && "LHS is a reference type?"); + assert(!RHS->getAs() && "RHS is a reference type?"); + QualType LHSCan = getCanonicalType(LHS), RHSCan = getCanonicalType(RHS); -- cgit v1.2.3