blob: 79c294b1d92921f169ce9d8750640f9ae152a652 [file] [log] [blame]
Douglas Gregorf1d70ad2010-02-01 23:46:27 +00001// RUN: %clang_cc1 -pedantic -Wall -fixit %s -o - | %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x c++ -
Douglas Gregore3e01a22009-04-01 22:41:11 +00002
3/* This is a test of the various code modification hints that are
Douglas Gregor7e702042009-04-02 03:20:30 +00004 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 Gregore3e01a22009-04-01 22:41:11 +00007
Douglas Gregor170512f2009-04-01 23:51:29 +00008struct C1 {
9 virtual void f();
10 static void g();
11};
Douglas Gregore3e01a22009-04-01 22:41:11 +000012struct C2 : virtual public virtual C1 { }; // expected-error{{duplicate}}
13
Douglas Gregor170512f2009-04-01 23:51:29 +000014virtual void C1::f() { } // expected-error{{'virtual' can only be specified inside the class definition}}
15
16static void C1::g() { } // expected-error{{'static' can only be specified inside the class definition}}
17
18template<int Value> struct CT { }; // expected-note{{previous use is here}}
Douglas Gregore3e01a22009-04-01 22:41:11 +000019
20CT<10 >> 2> ct; // expected-warning{{require parentheses}}
Douglas Gregor170512f2009-04-01 23:51:29 +000021
22class C3 {
23public:
24 C3(C3, int i = 0); // expected-error{{copy constructor must pass its first argument by reference}}
25};
26
27struct CT<0> { }; // expected-error{{'template<>'}}
28
29template<> class CT<1> { }; // expected-error{{tag type}}
Anders Carlsson0b8ea552009-11-10 03:24:44 +000030
Douglas Gregorf1d70ad2010-02-01 23:46:27 +000031// Access declarations
32class A {
33protected:
34 int foo();
35};
Anders Carlsson0b8ea552009-11-10 03:24:44 +000036
Douglas Gregorf1d70ad2010-02-01 23:46:27 +000037class B : public A {
38 A::foo; // expected-warning{{access declarations are deprecated}}
39};
Douglas Gregord6bc5e62010-03-24 07:14:45 +000040
41void f() throw();
42void f(); // expected-warning{{missing exception specification}}