aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-03 21:02:30 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-03 21:02:30 +0000
commit0e709abafbd939326850501f795cc7a92c88a354 (patch)
treeeda8927b6992e360437b64284c73a05e49347073
parentc2e1c1af8ffe750b827284f207b9207112c7cc4e (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95249 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/ASTContext.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 46c5b41f93..d6c9041e3e 100644
--- a/lib/AST/ASTContext.cpp
+++ b/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<ReferenceType>())
- LHS = RT->getPointeeType();
- if (const ReferenceType *RT = RHS->getAs<ReferenceType>())
- RHS = RT->getPointeeType();
-
+ assert(!LHS->getAs<ReferenceType>() && "LHS is a reference type?");
+ assert(!RHS->getAs<ReferenceType>() && "RHS is a reference type?");
+
QualType LHSCan = getCanonicalType(LHS),
RHSCan = getCanonicalType(RHS);