From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/SemaTemplate/copy-ctor-assign.cpp | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 clang/test/SemaTemplate/copy-ctor-assign.cpp (limited to 'clang/test/SemaTemplate/copy-ctor-assign.cpp') diff --git a/clang/test/SemaTemplate/copy-ctor-assign.cpp b/clang/test/SemaTemplate/copy-ctor-assign.cpp new file mode 100644 index 0000000..ae6dc9c --- /dev/null +++ b/clang/test/SemaTemplate/copy-ctor-assign.cpp @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// Make sure that copy constructors and assignment operators are properly +// generated when there is a matching + +// PR5072 +template +struct X { + template + X(const X& other) + : value(other.value + 1) { } // expected-error{{binary expression}} + + template + X& operator=(const X& other) { + value = other.value + 1; // expected-error{{binary expression}} + return *this; + } + + T value; +}; + +struct Y {}; + +X test0(X x) { return x; } +X test1(X x) { return x; } + + +X test2(X x) { + return x; // expected-note{{instantiation}} +} + +void test3(X &x, X xi, X xl, X xmptr) { + x = xi; + x = xl; + x = xmptr; // expected-note{{instantiation}} +} + +struct X1 { + X1 &operator=(const X1&); +}; + +template +struct X2 : X1 { + template X2 &operator=(const U&); +}; + +struct X3 : X2 { +}; + +void test_X2(X3 &to, X3 from) { + to = from; +} -- cgit v1.2.3