| 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | struct A; // expected-note 14 {{forward declaration of 'A'}} |
| 3 | |
| 4 | A f(); // expected-note {{'f' declared here}} |
| 5 | |
| 6 | struct B { |
| 7 | A f(); // expected-note {{'f' declared here}} |
| 8 | A operator()(); // expected-note 2 {{'operator()' declared here}} |
| 9 | operator A(); // expected-note {{'operator A' declared here}} |
| 10 | A operator!(); // expected-note 2 {{'operator!' declared here}} |
| 11 | A operator++(int); // expected-note {{'operator++' declared here}} |
| 12 | A operator[](int); // expected-note {{'operator[]' declared here}} |
| 13 | A operator+(int); // expected-note {{'operator+' declared here}} |
| 14 | A operator->(); // expected-note {{'operator->' declared here}} |
| 15 | }; |
| 16 | |
| 17 | void g() { |
| 18 | f(); // expected-error {{calling 'f' with incomplete return type 'A'}} |
| 19 | |
| 20 | typedef A (*Func)(); |
| 21 | Func fp; |
| 22 | fp(); // expected-error {{calling function with incomplete return type 'A'}} |
| 23 | ((Func)0)(); // expected-error {{calling function with incomplete return type 'A'}} |
| 24 | |
| 25 | B b; |
| 26 | b.f(); // expected-error {{calling 'f' with incomplete return type 'A'}} |
| 27 | |
| 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'}} |
| 31 | |
| 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'}} |
| 38 | |
| 39 | A (B::*mfp)() = 0; |
| 40 | (b.*mfp)(); // expected-error {{calling function with incomplete return type 'A'}} |
| 41 | |
| 42 | } |
| 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 | } |
| 50 | |
| 51 | void test_incomplete_object_dtor(C *p) { |
| 52 | p.~C(); // expected-error{{member reference type 'C *' is a pointer; did you mean to use '->'?}} |
| 53 | } |
| 54 | |
| 55 | namespace pr18542 { |
| 56 | struct X { |
| 57 | int count; |
| 58 | template<typename CharT> class basic_istream; |
| 59 | template<typename CharT> |
| 60 | void basic_istream<CharT>::read() { // expected-error{{out-of-line definition of 'read' from class 'basic_istream<CharT>' without definition}} |
| 61 | count = 0; |
| 62 | } |
| 63 | }; |
| 64 | } |
| 65 | |
| 66 | |