diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-12-18 23:32:47 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-12-18 23:32:47 +0000 |
commit | 1850ac6ae954524c821723a0f87df62d004a7293 (patch) | |
tree | 33162eb82466164e51db1d351bb7490109824764 | |
parent | 0f6ef2879083d3c556b9b74d2df7a07dc0b227d5 (diff) |
Fix a crash in diagnostic printing when a template class type is diff'ed
against itself. PR14489.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170474 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ASTDiagnostic.cpp | 7 | ||||
-rw-r--r-- | test/Misc/diag-template-diffing.cpp | 12 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/AST/ASTDiagnostic.cpp b/lib/AST/ASTDiagnostic.cpp index 31c1fbf1b7..a61abf7e34 100644 --- a/lib/AST/ASTDiagnostic.cpp +++ b/lib/AST/ASTDiagnostic.cpp @@ -1125,7 +1125,12 @@ class TemplateDiff { 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); diff --git a/test/Misc/diag-template-diffing.cpp b/test/Misc/diag-template-diffing.cpp index 7d01f4695b..e7a8048870 100644 --- a/test/Misc/diag-template-diffing.cpp +++ b/test/Misc/diag-template-diffing.cpp @@ -800,6 +800,18 @@ namespace PR14342 { // 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. |