From 06d4ba388873e6d1cfa9cd715a8935ecc8cd2097 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 18 Jan 2015 16:23:48 +0000 Subject: Vendor import of clang RELEASE_360/rc1 tag r226102 (effectively, 3.6.0 RC1): https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_360/rc1@226102 --- test/SemaTemplate/constructor-template.cpp | 50 +++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'test/SemaTemplate/constructor-template.cpp') diff --git a/test/SemaTemplate/constructor-template.cpp b/test/SemaTemplate/constructor-template.cpp index cf3fdfb7c1ea..c5306a6e32f4 100644 --- a/test/SemaTemplate/constructor-template.cpp +++ b/test/SemaTemplate/constructor-template.cpp @@ -54,7 +54,7 @@ struct B { A x; B(B& a) : x(a.x) {} }; struct X2 { X2(); // expected-note{{candidate constructor}} X2(X2&); // expected-note {{candidate constructor}} - template X2(T); + template X2(T); // expected-note {{candidate template ignored: instantiation would take its own class type by value}} }; X2 test(bool Cond, X2 x2) { @@ -126,3 +126,51 @@ namespace PR8182 { } } + +// Don't blow out the stack trying to call an illegal constructor +// instantiation. We intentionally allow implicit instantiations to +// exist, so make sure they're unusable. +// +// rdar://19199836 +namespace self_by_value { + template struct A { + A() {} + A(const A &o) {} + A(A o) {} + }; + + void helper(A); + + void test1(A a) { + helper(a); + } + void test2() { + helper(A()); + } +} + +namespace self_by_value_2 { + template struct A { + A() {} // expected-note {{not viable: requires 0 arguments}} + A(A &o) {} // expected-note {{not viable: expects an l-value}} + A(A o) {} // expected-note {{ignored: instantiation takes its own class type by value}} + }; + + void helper_A(A); // expected-note {{passing argument to parameter here}} + void test_A() { + helper_A(A()); // expected-error {{no matching constructor}} + } +} + +namespace self_by_value_3 { + template struct A { + A() {} + A(A &o) {} + A(A o) {} + }; + + void helper_A(A); + void test_A(A b) { + helper_A(b); + } +} -- cgit v1.2.3