[cfe-commits] r170474 - in /cfe/trunk: lib/AST/ASTDiagnostic.cpp test/Misc/diag-template-diffing.cpp
Eli Friedman
eli.friedman at gmail.com
Tue Dec 18 15:32:47 PST 2012
Author: efriedma
Date: Tue Dec 18 17:32:47 2012
New Revision: 170474
URL: http://llvm.org/viewvc/llvm-project?rev=170474&view=rev
Log:
Fix a crash in diagnostic printing when a template class type is diff'ed
against itself. PR14489.
Modified:
cfe/trunk/lib/AST/ASTDiagnostic.cpp
cfe/trunk/test/Misc/diag-template-diffing.cpp
Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=170474&r1=170473&r2=170474&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Tue Dec 18 17:32:47 2012
@@ -1125,7 +1125,12 @@
TemplateDecl *FromTD, *ToTD;
Tree.GetNode(FromTD, ToTD);
- assert(Tree.HasChildren() && "Template difference not found in diff tree.");
+ if (!Tree.HasChildren()) {
+ // If we're dealing with a template specialization with zero
+ // arguments, there are no children; special-case this.
+ OS << FromTD->getNameAsString() << "<>";
+ return;
+ }
Qualifiers FromQual, ToQual;
Tree.GetNode(FromQual, ToQual);
Modified: cfe/trunk/test/Misc/diag-template-diffing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-template-diffing.cpp?rev=170474&r1=170473&r2=170474&view=diff
==============================================================================
--- cfe/trunk/test/Misc/diag-template-diffing.cpp (original)
+++ cfe/trunk/test/Misc/diag-template-diffing.cpp Tue Dec 18 17:32:47 2012
@@ -800,6 +800,18 @@
// CHECK-ELIDE-NOTREE: error: no viable conversion from 'X<[...], 2>' to 'X<[...], 3UL>'
}
+namespace PR14489 {
+ // The important thing here is that the diagnostic diffs a template specialization
+ // with no arguments against itself. (We might need a different test if this
+ // diagnostic changes).
+ template<class ...V>
+ struct VariableList {
+ void ConnectAllToAll(VariableList<>& params = VariableList<>()) {
+ }
+ };
+ // CHECK-ELIDE-NOTREE: non-const lvalue reference to type 'VariableList<>' cannot bind to a temporary of type 'VariableList<>'
+}
+
// CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
// CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
// CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.
More information about the cfe-commits
mailing list