aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2011-12-13 23:19:45 +0000
committerRichard Trieu <rtrieu@google.com>2011-12-13 23:19:45 +0000
commita6dc7eff27a8c59bee42809270971931b811dd44 (patch)
treec3d74da244ec16825dd5e2f21f278443cac8b0a7 /lib/Sema/SemaOverload.cpp
parent7209646add692c50503435bcffb13187a3349552 (diff)
Make the diagnostic message more consistant. Update the type comparison to
handle non-pointer types. This is for the extra info printed when function types are compared. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146525 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r--lib/Sema/SemaOverload.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 86181040ce..7ddb151e8a 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -2177,6 +2177,12 @@ enum {
/// parameter types, and different return types.
void Sema::HandleFunctionTypeMismatch(PartialDiagnostic &PDiag,
QualType FromType, QualType ToType) {
+ // If either type is not valid, include no extra info.
+ if (FromType.isNull() || ToType.isNull()) {
+ PDiag << ft_default;
+ return;
+ }
+
// Get the function type from the pointers.
if (FromType->isMemberPointerType() && ToType->isMemberPointerType()) {
const MemberPointerType *FromMember = FromType->getAs<MemberPointerType>(),
@@ -2188,27 +2194,26 @@ void Sema::HandleFunctionTypeMismatch(PartialDiagnostic &PDiag,
}
FromType = FromMember->getPointeeType();
ToType = ToMember->getPointeeType();
- } else if (FromType->isPointerType() && ToType->isPointerType()) {
+ }
+
+ if (FromType->isPointerType())
FromType = FromType->getPointeeType();
+ if (ToType->isPointerType())
ToType = ToType->getPointeeType();
- } else {
- PDiag << ft_default;
- return;
- }
+ // Remove references.
FromType = FromType.getNonReferenceType();
ToType = ToType.getNonReferenceType();
- // If either type is not valid, of the types are the same, no extra info.
- if (FromType.isNull() || ToType.isNull() ||
- Context.hasSameType(FromType, ToType)) {
+ // Don't print extra info for non-specialized template functions.
+ if (FromType->isInstantiationDependentType() &&
+ !FromType->getAs<TemplateSpecializationType>()) {
PDiag << ft_default;
return;
}
- // Don't print extra info for non-specialized template functions.
- if (FromType->isInstantiationDependentType() &&
- !FromType->getAs<TemplateSpecializationType>()) {
+ // No extra info for same types.
+ if (Context.hasSameType(FromType, ToType)) {
PDiag << ft_default;
return;
}