Clang Project

clang_source_code/test/Modules/merge-deduced-return.cpp
1// RUN: %clang_cc1 -fmodules -std=c++17 -verify %s
2// RUN: %clang_cc1 -fmodules -std=c++17 -verify %s -DLOCAL
3// expected-no-diagnostics
4
5#pragma clang module build A
6module A {}
7#pragma clang module contents
8#pragma clang module begin A
9inline auto f() { struct X {}; return X(); }
10inline auto a = f();
11auto g(int);
12template<typename T> auto h(T t) { return g(t); }
13#pragma clang module end
14#pragma clang module endbuild
15
16#pragma clang module build B
17module B {}
18#pragma clang module contents
19#pragma clang module begin B
20inline auto f() { struct X {}; return X(); }
21inline auto b = f();
22auto g(int) { return 0; }
23#pragma clang module end
24#pragma clang module endbuild
25
26#ifdef LOCAL
27inline auto f() { struct X {}; return X(); }
28inline auto b = f();
29auto g(int) { return 0; }
30#else
31#pragma clang module import B
32#endif
33
34#pragma clang module import A
35
36using T = decltype(a);
37using T = decltype(b);
38
39int test_g = h(0);
40