blob: 5a28132397006a0b97611ac93c4be50d958545e9 [file] [log] [blame]
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +00001// RUN: cp %s %t
2// RUN: %clang_cc1 -pedantic -Wall -fixit -x c++ %t || true
3// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x c++ %t
Douglas Gregor9b3064b2009-04-01 22:41:11 +00004
5/* This is a test of the various code modification hints that are
Douglas Gregorfe057ac2009-04-02 03:20:30 +00006 provided as part of warning or extension diagnostics. All of the
7 warnings will be fixed by -fixit, and the resulting file should
8 compile cleanly with -Werror -pedantic. */
Douglas Gregor9b3064b2009-04-01 22:41:11 +00009
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +000010struct C1 {
Douglas Gregora3a83512009-04-01 23:51:29 +000011 virtual void f();
12 static void g();
13};
Douglas Gregor9b3064b2009-04-01 22:41:11 +000014struct C2 : virtual public virtual C1 { }; // expected-error{{duplicate}}
15
Douglas Gregora3a83512009-04-01 23:51:29 +000016virtual void C1::f() { } // expected-error{{'virtual' can only be specified inside the class definition}}
17
18static void C1::g() { } // expected-error{{'static' can only be specified inside the class definition}}
19
20template<int Value> struct CT { }; // expected-note{{previous use is here}}
Douglas Gregor9b3064b2009-04-01 22:41:11 +000021
22CT<10 >> 2> ct; // expected-warning{{require parentheses}}
Douglas Gregora3a83512009-04-01 23:51:29 +000023
24class C3 {
25public:
26 C3(C3, int i = 0); // expected-error{{copy constructor must pass its first argument by reference}}
27};
28
29struct CT<0> { }; // expected-error{{'template<>'}}
30
31template<> class CT<1> { }; // expected-error{{tag type}}
Anders Carlssonad26b732009-11-10 03:24:44 +000032
Douglas Gregor28485232010-02-01 23:46:27 +000033// Access declarations
34class A {
35protected:
36 int foo();
37};
Anders Carlssonad26b732009-11-10 03:24:44 +000038
Douglas Gregor28485232010-02-01 23:46:27 +000039class B : public A {
40 A::foo; // expected-warning{{access declarations are deprecated}}
41};
Douglas Gregor2eef8292010-03-24 07:14:45 +000042
43void f() throw();
44void f(); // expected-warning{{missing exception specification}}
Douglas Gregor1aae80b2010-04-14 20:27:54 +000045
46namespace rdar7853795 {
47 struct A {
48 bool getNumComponents() const; // expected-note{{declared here}}
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +000049 void dump() const {
Douglas Gregor1aae80b2010-04-14 20:27:54 +000050 getNumComponenets(); // expected-error{{use of undeclared identifier 'getNumComponenets'; did you mean 'getNumComponents'?}}
51 }
52 };
53}
Douglas Gregorb1f6fa42010-09-07 14:35:10 +000054
55namespace rdar7796492 {
56 class A { int x, y; A(); };
57
58 A::A()
59 : x(1) y(2) { // expected-error{{missing ',' between base or member initializers}}
60 }
61
62}