brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 113a1fb Raw
91 lines · cpp
1// RUN: %clang_cc1 -std=c++14 -fmodules -verify %s -emit-llvm-only2// expected-no-diagnostics3 4#pragma clang module build A5module A {}6#pragma clang module contents7#pragma clang module begin A8template<typename T> auto f() { return []{}; }9#pragma clang module end10#pragma clang module endbuild11 12#pragma clang module build B13module B {}14#pragma clang module contents15#pragma clang module begin B16#pragma clang module import A17inline auto x1() { return f<int>(); }18inline auto z() { return []{}; }19inline auto x2() { return z(); }20 21struct Function {22  template<typename T>23  Function(T t) : p(new T((T&&)t)) {}24 25  void *p;26};27 28struct Outer {29  struct Inner {30    Inner() {}31    Function f = []{};32  };33  Outer(Inner = Inner());34};35 36inline void use_nested_1() { Outer o; }37#pragma clang module end38#pragma clang module endbuild39 40#pragma clang module build C41module C {}42#pragma clang module contents43#pragma clang module begin C44#pragma clang module import A45inline auto y1() { return f<int>(); }46inline auto z() { return []{}; }47inline auto y2() { return z(); }48inline auto q() { return []{}; }49inline auto y3() { return q(); }50 51struct Function {52  template<typename T>53  Function(T t) : p(new T((T&&)t)) {}54 55  void *p;56};57 58struct Outer {59  struct Inner {60    Inner() {}61    Function f = []{};62  };63  Outer(Inner = Inner());64};65 66inline void use_nested_2() { Outer o; }67#pragma clang module end68#pragma clang module endbuild69 70inline auto q() { return []{}; }71inline auto x3() { return q(); }72 73#pragma clang module import B74#pragma clang module import C75using T = decltype(x1);76using T = decltype(y1);77 78using U = decltype(x2);79using U = decltype(y2);80 81using V = decltype(x3);82using V = decltype(y3);83 84#pragma clang module import A85void (*p)() = f<int>();86 87void use_nested() {88  use_nested_1();89  use_nested_2();90}91