diff options
| author | Vassil Vassilev <v.g.vassilev@gmail.com> | 2017-01-12 09:16:26 +0000 |
|---|---|---|
| committer | Vassil Vassilev <v.g.vassilev@gmail.com> | 2017-01-12 09:16:26 +0000 |
| commit | 352e4412e19d909b9fd9de4d19a192bc2540d818 (patch) | |
| tree | 2140f4cfeb84d63ef46af4ed76874eae6d0696af /clang/test | |
| parent | 1743e55e3477e9c389f1cff913be4964bbb8c9c0 (diff) | |
| download | bcm5719-llvm-352e4412e19d909b9fd9de4d19a192bc2540d818.tar.gz bcm5719-llvm-352e4412e19d909b9fd9de4d19a192bc2540d818.zip | |
PR31469: Don't add friend template class decls to redecl chain in dependent contexts.
Fixes a crash in modules where the template class decl becomes the most recent
decl in the redeclaration chain and forcing the template instantiator try to
instantiate the friend declaration, rather than the template definition.
In practice, A::list<int> produces a TemplateSpecializationType
A::__1::list<int, allocator<type-parameter-0-0> >' failing to replace to
subsitute the default argument to allocator<int>.
Kudos Richard Smith (D28399).
llvm-svn: 291753
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Misc/ast-dump-decl.cpp | 1 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/PR31469/empty.h | 1 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/PR31469/module.modulemap | 5 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/PR31469/textual.h | 17 | ||||
| -rw-r--r-- | clang/test/Modules/Inputs/PR31469/textual_file_shadow.h | 2 | ||||
| -rw-r--r-- | clang/test/Modules/pr31469.cpp | 15 |
6 files changed, 40 insertions, 1 deletions
diff --git a/clang/test/Misc/ast-dump-decl.cpp b/clang/test/Misc/ast-dump-decl.cpp index 1cfcd509efa..c966e133eb5 100644 --- a/clang/test/Misc/ast-dump-decl.cpp +++ b/clang/test/Misc/ast-dump-decl.cpp @@ -336,7 +336,6 @@ namespace testCanonicalTemplate { // CHECK-NEXT: ClassTemplateDecl{{.*}} TestClassTemplate // CHECK-NEXT: TemplateTypeParmDecl // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate - // CHECK-NEXT: ClassTemplateSpecialization{{.*}} 'TestClassTemplate' // CHECK-NEXT: ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate // CHECK-NEXT: TemplateArgument{{.*}}A // CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate diff --git a/clang/test/Modules/Inputs/PR31469/empty.h b/clang/test/Modules/Inputs/PR31469/empty.h new file mode 100644 index 00000000000..51e115f57fc --- /dev/null +++ b/clang/test/Modules/Inputs/PR31469/empty.h @@ -0,0 +1 @@ +// This file is triggers loading of module M. diff --git a/clang/test/Modules/Inputs/PR31469/module.modulemap b/clang/test/Modules/Inputs/PR31469/module.modulemap new file mode 100644 index 00000000000..bada81d04ee --- /dev/null +++ b/clang/test/Modules/Inputs/PR31469/module.modulemap @@ -0,0 +1,5 @@ +module M { + module "textual_shadow" { header "textual_file_shadow.h" export *} + module "trigger" { header "empty.h" export * } + export * +} diff --git a/clang/test/Modules/Inputs/PR31469/textual.h b/clang/test/Modules/Inputs/PR31469/textual.h new file mode 100644 index 00000000000..abdc662fb5e --- /dev/null +++ b/clang/test/Modules/Inputs/PR31469/textual.h @@ -0,0 +1,17 @@ +namespace A { +inline +namespace __1 { + template <class _Tp> class allocator; + template <class _Tp, class _Alloc = allocator<_Tp>> class list; + template <class _VoidPtr> class __list_iterator { + //template <class> friend class list; // causes another crash in ASTDeclReader::attachPreviousDecl + template <class, class> friend class list; + }; + template <class _Tp, class _Alloc> class __list_imp {}; + template <class _Tp, class _Alloc> class list : __list_imp<_Tp, _Alloc> { + public: + list() {} + }; + template <class _Tp> void f(list<_Tp>); +} +} diff --git a/clang/test/Modules/Inputs/PR31469/textual_file_shadow.h b/clang/test/Modules/Inputs/PR31469/textual_file_shadow.h new file mode 100644 index 00000000000..48a53dd4a83 --- /dev/null +++ b/clang/test/Modules/Inputs/PR31469/textual_file_shadow.h @@ -0,0 +1,2 @@ +#include "textual.h" + diff --git a/clang/test/Modules/pr31469.cpp b/clang/test/Modules/pr31469.cpp new file mode 100644 index 00000000000..8f7d52285c8 --- /dev/null +++ b/clang/test/Modules/pr31469.cpp @@ -0,0 +1,15 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR31469 -verify %s +// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR31469 -fmodules -fmodules-local-submodule-visibility \ +// RUN: -fimplicit-module-maps -fmodules-cache-path=%t -verify %s + +#include "textual.h" +#include "empty.h" + +namespace A { + template <class _Tp> void f(); +} + +A::list<int> use; + +// expected-no-diagnostics |

