aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2011-11-14 19:39:25 +0000
committerRichard Trieu <rtrieu@google.com>2011-11-14 19:39:25 +0000
commitecb912e8a2a683a2e1db1743a862ee21e788eea6 (patch)
treee22bd7416ea11e1242bb933a2022fa5122530cef
parentccf1bfde160c03c677ba530c9dcb77365a9c2d7b (diff)
Change the checks in the type aka printing. A confusing case where the string
of the first type is the same as the aka string of the second type, but both types are different. Update the logic to print an aka for the first type to show that they are different. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144558 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/ASTDiagnostic.cpp13
-rw-r--r--test/Misc/diag-aka-types.cpp16
2 files changed, 26 insertions, 3 deletions
diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp
index 07820dc3cc..dd3be44a1f 100644
--- a/lib/AST/ASTDiagnostic.cpp
+++ b/lib/AST/ASTDiagnostic.cpp
@@ -171,9 +171,16 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty,
if (CompareCanTy == CanTy)
continue; // Same canonical types
std::string CompareS = CompareTy.getAsString(Context.getPrintingPolicy());
- if (CompareS != S)
- continue; // Original strings are different
- std::string CompareCanS = CompareCanTy.getAsString(Context.getPrintingPolicy());
+ bool aka;
+ QualType CompareDesugar = Desugar(Context, CompareTy, aka);
+ std::string CompareDesugarStr =
+ CompareDesugar.getAsString(Context.getPrintingPolicy());
+ if (CompareS != S && CompareDesugarStr != S)
+ continue; // The type string is different than the comparison string
+ // and the desugared comparison string.
+ std::string CompareCanS =
+ CompareCanTy.getAsString(Context.getPrintingPolicy());
+
if (CompareCanS == CanS)
continue; // No new info from canonical type
diff --git a/test/Misc/diag-aka-types.cpp b/test/Misc/diag-aka-types.cpp
index 0339b7b63e..7459bc5c65 100644
--- a/test/Misc/diag-aka-types.cpp
+++ b/test/Misc/diag-aka-types.cpp
@@ -50,3 +50,19 @@ namespace std {
f(v); // expected-error{{no matching function for call to 'f'}}
}
}
+
+namespace ns {
+ struct str {
+ static void method(struct data *) {}
+ };
+}
+
+struct data { int i; };
+
+typedef void (*callback)(struct data *);
+
+void helper(callback cb) {} // expected-note{{candidate function not viable: no known conversion from 'void (*)(struct data *)' (aka 'void (*)(ns::data *)') to 'callback' (aka 'void (*)(struct data *)') for 1st argument;}}
+
+void test() {
+ helper(&ns::str::method); // expected-error{{no matching function for call to 'helper'}}
+}