[cfe-commits] r144558 - in /cfe/trunk: lib/AST/ASTDiagnostic.cpp test/Misc/diag-aka-types.cpp
Richard Trieu
rtrieu at google.com
Mon Nov 14 11:39:25 PST 2011
Author: rtrieu
Date: Mon Nov 14 13:39:25 2011
New Revision: 144558
URL: http://llvm.org/viewvc/llvm-project?rev=144558&view=rev
Log:
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.
Modified:
cfe/trunk/lib/AST/ASTDiagnostic.cpp
cfe/trunk/test/Misc/diag-aka-types.cpp
Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=144558&r1=144557&r2=144558&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Mon Nov 14 13:39:25 2011
@@ -171,9 +171,16 @@
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
Modified: cfe/trunk/test/Misc/diag-aka-types.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-aka-types.cpp?rev=144558&r1=144557&r2=144558&view=diff
==============================================================================
--- cfe/trunk/test/Misc/diag-aka-types.cpp (original)
+++ cfe/trunk/test/Misc/diag-aka-types.cpp Mon Nov 14 13:39:25 2011
@@ -50,3 +50,19 @@
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'}}
+}
More information about the cfe-commits
mailing list