diff options
author | dim <dim@FreeBSD.org> | 2015-05-27 18:47:56 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-05-27 18:47:56 +0000 |
commit | 3191b2b32a96e1a6ee833fcca73e5c8e0c67ba65 (patch) | |
tree | dbbd4047878da71c1a706e26ce05b4e7791b14cc /test/SemaTemplate/instantiate-local-class.cpp | |
parent | 38d6f2e7f2ce51a5b3836d26596c6c34a3288752 (diff) | |
download | FreeBSD-src-3191b2b32a96e1a6ee833fcca73e5c8e0c67ba65.zip FreeBSD-src-3191b2b32a96e1a6ee833fcca73e5c8e0c67ba65.tar.gz |
Vendor import of clang trunk r238337:
https://llvm.org/svn/llvm-project/cfe/trunk@238337
Diffstat (limited to 'test/SemaTemplate/instantiate-local-class.cpp')
-rw-r--r-- | test/SemaTemplate/instantiate-local-class.cpp | 200 |
1 files changed, 200 insertions, 0 deletions
diff --git a/test/SemaTemplate/instantiate-local-class.cpp b/test/SemaTemplate/instantiate-local-class.cpp index c9897b9..f58d7a4 100644 --- a/test/SemaTemplate/instantiate-local-class.cpp +++ b/test/SemaTemplate/instantiate-local-class.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify -std=c++11 %s +// RUN: %clang_cc1 -verify -std=c++11 -fdelayed-template-parsing %s + template<typename T> void f0() { struct X; @@ -194,3 +196,201 @@ struct B { void f() { F<int>(); } }; } + +namespace PR23194 { + struct X { + int operator()() const { return 0; } + }; + struct Y { + Y(int) {} + }; + template <bool = true> int make_seed_pair() noexcept { + struct state_t { + X x; + Y y{x()}; + }; + return 0; + } + int func() { + return make_seed_pair(); + } +} + +namespace PR18653 { + // Forward declarations + + template<typename T> void f1() { + void g1(struct x1); + struct x1 {}; + } + template void f1<int>(); + + template<typename T> void f1a() { + void g1(union x1); + union x1 {}; + } + template void f1a<int>(); + + template<typename T> void f2() { + void g2(enum x2); // expected-error{{ISO C++ forbids forward references to 'enum' types}} + enum x2 { nothing }; + } + template void f2<int>(); + + template<typename T> void f3() { + void g3(enum class x3); + enum class x3 { nothing }; + } + template void f3<int>(); + + + template<typename T> void f4() { + void g4(struct x4 {} x); // expected-error{{'x4' cannot be defined in a parameter type}} + } + template void f4<int>(); + + template<typename T> void f4a() { + void g4(union x4 {} x); // expected-error{{'x4' cannot be defined in a parameter type}} + } + template void f4a<int>(); + + + template <class T> void f(); + template <class T> struct S1 { + void m() { + f<class newclass>(); + f<union newunion>(); + } + }; + template struct S1<int>; + + template <class T> struct S2 { + void m() { + f<enum new_enum>(); // expected-error{{ISO C++ forbids forward references to 'enum' types}} + } + }; + template struct S2<int>; + + template <class T> struct S3 { + void m() { + f<enum class new_enum>(); + } + }; + template struct S3<int>; + + template <class T> struct S4 { + struct local {}; + void m() { + f<local>(); + } + }; + template struct S4<int>; + + template <class T> struct S4a { + union local {}; + void m() { + f<local>(); + } + }; + template struct S4a<int>; + + template <class T> struct S5 { + enum local { nothing }; + void m() { + f<local>(); + } + }; + template struct S5<int>; + + template <class T> struct S7 { + enum class local { nothing }; + void m() { + f<local>(); + } + }; + template struct S7<int>; + + + template <class T> void fff(T *x); + template <class T> struct S01 { + struct local { }; + void m() { + local x; + fff(&x); + } + }; + template struct S01<int>; + + template <class T> struct S01a { + union local { }; + void m() { + local x; + fff(&x); + } + }; + template struct S01a<int>; + + template <class T> struct S02 { + enum local { nothing }; + void m() { + local x; + fff(&x); + } + }; + template struct S02<int>; + + template <class T> struct S03 { + enum class local { nothing }; + void m() { + local x; + fff(&x); + } + }; + template struct S03<int>; + + + template <class T> struct S04 { + void m() { + struct { } x; + fff(&x); + } + }; + template struct S04<int>; + + template <class T> struct S04a { + void m() { + union { } x; + fff(&x); + } + }; + template struct S04a<int>; + + template <class T> struct S05 { + void m() { + enum { nothing } x; + fff(&x); + } + }; + template struct S05<int>; + + template <class T> struct S06 { + void m() { + class { virtual void mmm() {} } x; + fff(&x); + } + }; + template struct S06<int>; +} + +namespace PR20625 { +template <typename T> +void f() { + struct N { + static constexpr int get() { return 42; } + }; + constexpr int n = N::get(); + static_assert(n == 42, "n == 42"); +} + +void g() { f<void>(); } +} |