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