Richard Smith | 39d3196 | 2011-11-11 19:29:23 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s |
| 2 | // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Wno-bind-to-temporary-copy -Wno-unnamed-type-template-args -Wno-local-type-template-args -Werror %s |
| 3 | |
| 4 | template<typename T> int TemplateFn(T) { return 0; } |
| 5 | void LocalTemplateArg() { |
| 6 | struct S {}; |
| 7 | TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}} |
| 8 | } |
| 9 | struct {} obj_of_unnamed_type; // expected-note {{here}} |
| 10 | int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}} |
| 11 | |
| 12 | namespace CopyCtorIssues { |
| 13 | struct Private { |
| 14 | Private(); |
| 15 | private: |
| 16 | Private(const Private&); // expected-note {{declared private here}} |
| 17 | }; |
| 18 | struct NoViable { |
| 19 | NoViable(); |
| 20 | NoViable(NoViable&); // expected-note {{not viable}} |
| 21 | }; |
| 22 | struct Ambiguous { |
| 23 | Ambiguous(); |
| 24 | Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}} |
| 25 | Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}} |
| 26 | }; |
| 27 | struct Deleted { // expected-note {{here}} |
| 28 | // Copy ctor implicitly defined as deleted because Private's copy ctor is |
| 29 | // inaccessible. |
| 30 | Private p; |
| 31 | }; |
| 32 | |
| 33 | 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}} |
| 34 | 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}} |
| 35 | 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}} |
| 36 | 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}} |
| 37 | } |