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