Douglas Gregor | 2848523 | 2010-02-01 23:46:27 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -pedantic -Wall -fixit %s -o - | %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x c++ - |
Douglas Gregor | 9b3064b | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 2 | |
| 3 | /* This is a test of the various code modification hints that are |
Douglas Gregor | fe057ac | 2009-04-02 03:20:30 +0000 | [diff] [blame] | 4 | provided as part of warning or extension diagnostics. All of the |
| 5 | warnings will be fixed by -fixit, and the resulting file should |
| 6 | compile cleanly with -Werror -pedantic. */ |
Douglas Gregor | 9b3064b | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 7 | |
Douglas Gregor | a3a8351 | 2009-04-01 23:51:29 +0000 | [diff] [blame] | 8 | struct C1 { |
| 9 | virtual void f(); |
| 10 | static void g(); |
| 11 | }; |
Douglas Gregor | 9b3064b | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 12 | struct C2 : virtual public virtual C1 { }; // expected-error{{duplicate}} |
| 13 | |
Douglas Gregor | a3a8351 | 2009-04-01 23:51:29 +0000 | [diff] [blame] | 14 | virtual void C1::f() { } // expected-error{{'virtual' can only be specified inside the class definition}} |
| 15 | |
| 16 | static void C1::g() { } // expected-error{{'static' can only be specified inside the class definition}} |
| 17 | |
| 18 | template<int Value> struct CT { }; // expected-note{{previous use is here}} |
Douglas Gregor | 9b3064b | 2009-04-01 22:41:11 +0000 | [diff] [blame] | 19 | |
| 20 | CT<10 >> 2> ct; // expected-warning{{require parentheses}} |
Douglas Gregor | a3a8351 | 2009-04-01 23:51:29 +0000 | [diff] [blame] | 21 | |
| 22 | class C3 { |
| 23 | public: |
| 24 | C3(C3, int i = 0); // expected-error{{copy constructor must pass its first argument by reference}} |
| 25 | }; |
| 26 | |
| 27 | struct CT<0> { }; // expected-error{{'template<>'}} |
| 28 | |
| 29 | template<> class CT<1> { }; // expected-error{{tag type}} |
Anders Carlsson | ad26b73 | 2009-11-10 03:24:44 +0000 | [diff] [blame] | 30 | |
Douglas Gregor | 2848523 | 2010-02-01 23:46:27 +0000 | [diff] [blame^] | 31 | // Access declarations |
| 32 | class A { |
| 33 | protected: |
| 34 | int foo(); |
| 35 | }; |
Anders Carlsson | ad26b73 | 2009-11-10 03:24:44 +0000 | [diff] [blame] | 36 | |
Douglas Gregor | 2848523 | 2010-02-01 23:46:27 +0000 | [diff] [blame^] | 37 | class B : public A { |
| 38 | A::foo; // expected-warning{{access declarations are deprecated}} |
| 39 | }; |