xref: /llvm-project/clang/test/Modules/const-var-init-update.cpp (revision 05a21351d68c2656e49798fe5789d92a203971a9)
1 // RUN: %clang_cc1 -std=c++1z -fmodules %s -verify
2 // expected-no-diagnostics
3 
4 #pragma clang module build std
5 module std { module limits {} module other {} }
6 #pragma clang module contents
7 #pragma clang module begin std.limits
8 template<typename T> struct numeric_limits {
9   static constexpr T __max = 5;
10   static constexpr T max() { return __max; }
11 };
12 #pragma clang module end
13 #pragma clang module begin std.other
f()14 inline void f() { numeric_limits<int> nl; }
15 #pragma clang module end
16 #pragma clang module endbuild
17 
18 #pragma clang module build module_b
19 module module_b {}
20 #pragma clang module contents
21 #pragma clang module begin module_b
22 #pragma clang module import std.limits
23 constexpr int a = numeric_limits<int>::max();
24 #pragma clang module end
25 #pragma clang module endbuild
26 
27 #pragma clang module import std.limits
28 #pragma clang module import module_b
29 constexpr int b = a;
30 static_assert(b == 5);
31