1 // Based on C++20 10.2 example 5.
5 // RUN: split-file %s %t
7 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std-10-2-ex5-tu1.cpp \
10 // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std-10-2-ex5-tu2.cpp \
11 // RUN: -fmodule-file=M=%t/M.pcm -o %t/tu-2.o
13 // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std-10-2-ex5-tu3.cpp \
14 // RUN: -fmodule-file=M=%t/M.pcm -verify -o %t/main.o
16 //--- std-10-2-ex5-tu1.cpp
25 export
void f(S
); // OK
28 export
struct A
; // A exported as incomplete
30 export
auto rootFinder(double a
) {
31 return [=](double x
) { return (x
+ a
/ x
) / 2; };
33 export
const int n
= 5; // OK, n has external linkage
35 //--- std-10-2-ex5-tu2.cpp
42 //--- std-10-2-ex5-tu3.cpp
47 X::f(); // OK, X is exported and definition of X is reachable
48 X::Y y
; // OK, X::Y is exported as a complete type
49 auto f
= rootFinder(2); // OK
50 // error: A is incomplete
51 return A
{45}.value
; // expected-error {{invalid use of incomplete type 'A'}}
52 // expected-error@-1 {{member access into incomplete type 'A'}}
53 // expected-note@std-10-2-ex5-tu1.cpp:12 2{{forward declaration of 'A'}}