xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/cxx98-compat-flags.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -Wno-bind-to-temporary-copy -Wno-unnamed-type-template-args -Wno-local-type-template-args -Werror %s
3f4a2713aSLionel Sambuc 
TemplateFn(T)4f4a2713aSLionel Sambuc template<typename T> int TemplateFn(T) { return 0; }
LocalTemplateArg()5f4a2713aSLionel Sambuc void LocalTemplateArg() {
6f4a2713aSLionel Sambuc   struct S {};
7f4a2713aSLionel Sambuc   TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}}
8f4a2713aSLionel Sambuc }
9f4a2713aSLionel Sambuc struct {} obj_of_unnamed_type; // expected-note {{here}}
10f4a2713aSLionel Sambuc int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}}
11f4a2713aSLionel Sambuc 
12f4a2713aSLionel Sambuc namespace CopyCtorIssues {
13f4a2713aSLionel Sambuc   struct Private {
14f4a2713aSLionel Sambuc     Private();
15f4a2713aSLionel Sambuc   private:
16f4a2713aSLionel Sambuc     Private(const Private&); // expected-note {{declared private here}}
17f4a2713aSLionel Sambuc   };
18f4a2713aSLionel Sambuc   struct NoViable {
19f4a2713aSLionel Sambuc     NoViable();
20f4a2713aSLionel Sambuc     NoViable(NoViable&); // expected-note {{not viable}}
21f4a2713aSLionel Sambuc   };
22f4a2713aSLionel Sambuc   struct Ambiguous {
23f4a2713aSLionel Sambuc     Ambiguous();
24f4a2713aSLionel Sambuc     Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
25f4a2713aSLionel Sambuc     Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
26f4a2713aSLionel Sambuc   };
27f4a2713aSLionel Sambuc   struct Deleted {
28f4a2713aSLionel Sambuc     Private p; // expected-note {{copy constructor of 'Deleted' is implicitly deleted because field 'p' has an inaccessible copy constructor}}
29f4a2713aSLionel Sambuc   };
30f4a2713aSLionel Sambuc 
31f4a2713aSLionel Sambuc   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}}
32f4a2713aSLionel Sambuc   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}}
33f4a2713aSLionel Sambuc   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}}
34f4a2713aSLionel Sambuc   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}}
35f4a2713aSLionel Sambuc }
36