Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 2 | struct A; // expected-note 14 {{forward declaration of 'A'}} |
Anders Carlsson | 11582f5 | 2009-10-09 23:58:25 +0000 | [diff] [blame] | 3 | |
| 4 | A f(); // expected-note {{note: 'f' declared here}} |
| 5 | |
| 6 | struct B { |
Anders Carlsson | eed3e69 | 2009-10-10 00:06:20 +0000 | [diff] [blame] | 7 | A f(); // expected-note {{'f' declared here}} |
Anders Carlsson | 07d68f1 | 2009-10-13 21:49:31 +0000 | [diff] [blame] | 8 | A operator()(); // expected-note 2 {{'operator()' declared here}} |
Anders Carlsson | cee1b54 | 2009-10-13 21:02:07 +0000 | [diff] [blame] | 9 | operator A(); // expected-note {{'operator A' declared here}} |
Anders Carlsson | 26a2a07 | 2009-10-13 21:19:37 +0000 | [diff] [blame] | 10 | A operator!(); // expected-note 2 {{'operator!' declared here}} |
Anders Carlsson | 07d68f1 | 2009-10-13 21:49:31 +0000 | [diff] [blame] | 11 | A operator++(int); // expected-note {{'operator++' declared here}} |
Anders Carlsson | 3a9439f | 2009-10-13 22:22:09 +0000 | [diff] [blame] | 12 | A operator[](int); // expected-note {{'operator[]' declared here}} |
Anders Carlsson | 15ea378 | 2009-10-13 22:43:21 +0000 | [diff] [blame] | 13 | A operator+(int); // expected-note {{'operator+' declared here}} |
| 14 | A operator->(); // expected-note {{'operator->' declared here}} |
Anders Carlsson | 11582f5 | 2009-10-09 23:58:25 +0000 | [diff] [blame] | 15 | }; |
| 16 | |
| 17 | void g() { |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 18 | f(); // expected-error {{calling 'f' with incomplete return type 'A'}} |
Anders Carlsson | 11582f5 | 2009-10-09 23:58:25 +0000 | [diff] [blame] | 19 | |
| 20 | typedef A (*Func)(); |
| 21 | Func fp; |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 22 | fp(); // expected-error {{calling function with incomplete return type 'A'}} |
| 23 | ((Func)0)(); // expected-error {{calling function with incomplete return type 'A'}} |
Anders Carlsson | eed3e69 | 2009-10-10 00:06:20 +0000 | [diff] [blame] | 24 | |
| 25 | B b; |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 26 | b.f(); // expected-error {{calling 'f' with incomplete return type 'A'}} |
Anders Carlsson | cee1b54 | 2009-10-13 21:02:07 +0000 | [diff] [blame] | 27 | |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 28 | b.operator()(); // expected-error {{calling 'operator()' with incomplete return type 'A'}} |
| 29 | b.operator A(); // expected-error {{calling 'operator A' with incomplete return type 'A'}} |
| 30 | b.operator!(); // expected-error {{calling 'operator!' with incomplete return type 'A'}} |
Anders Carlsson | 26a2a07 | 2009-10-13 21:19:37 +0000 | [diff] [blame] | 31 | |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 32 | !b; // expected-error {{calling 'operator!' with incomplete return type 'A'}} |
| 33 | b(); // expected-error {{calling 'operator()' with incomplete return type 'A'}} |
| 34 | b++; // expected-error {{calling 'operator++' with incomplete return type 'A'}} |
| 35 | b[0]; // expected-error {{calling 'operator[]' with incomplete return type 'A'}} |
| 36 | b + 1; // expected-error {{calling 'operator+' with incomplete return type 'A'}} |
| 37 | b->f(); // expected-error {{calling 'operator->' with incomplete return type 'A'}} |
Anders Carlsson | 8d6d90d | 2009-10-15 00:41:48 +0000 | [diff] [blame] | 38 | |
| 39 | A (B::*mfp)() = 0; |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 40 | (b.*mfp)(); // expected-error {{calling function with incomplete return type 'A'}} |
Anders Carlsson | 8d6d90d | 2009-10-15 00:41:48 +0000 | [diff] [blame] | 41 | |
Anders Carlsson | 11582f5 | 2009-10-09 23:58:25 +0000 | [diff] [blame] | 42 | } |
Douglas Gregor | 4a27d70 | 2009-10-21 06:18:39 +0000 | [diff] [blame] | 43 | |
| 44 | |
| 45 | struct C; // expected-note{{forward declaration}} |
| 46 | |
| 47 | void test_incomplete_object_call(C& c) { |
| 48 | c(); // expected-error{{incomplete type in call to object of type}} |
| 49 | } |