-Wc++98-compat: diagnose if a reference is bound to a prvalue which does not
have an unambiguous accessible copying constructor; this is ill-formed in C++98.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142533 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/cxx98-compat.cpp b/test/SemaCXX/cxx98-compat.cpp
index 193a418..ddcc1ef 100644
--- a/test/SemaCXX/cxx98-compat.cpp
+++ b/test/SemaCXX/cxx98-compat.cpp
@@ -186,3 +186,30 @@
};
FriendRedefinition<int> FriendRedef1;
FriendRedefinition<char> FriendRedef2; // expected-note {{requested here}}
+
+namespace CopyCtorIssues {
+ struct Private {
+ Private();
+ private:
+ Private(const Private&); // expected-note {{declared private here}}
+ };
+ struct NoViable {
+ NoViable();
+ NoViable(NoViable&); // expected-note {{not viable}}
+ };
+ struct Ambiguous {
+ Ambiguous();
+ Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
+ Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
+ };
+ struct Deleted { // expected-note {{here}}
+ // Copy ctor implicitly defined as deleted because Private's copy ctor is
+ // inaccessible.
+ Private p;
+ };
+
+ const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
+ const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}}
+ const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}}
+ const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}}
+}