Clang Project

clang_source_code/test/Modules/const-var-init-update.cpp
1// RUN: %clang_cc1 -std=c++1z -fmodules %s -verify
2// expected-no-diagnostics
3
4#pragma clang module build std
5module std { module limits {} module other {} }
6#pragma clang module contents
7#pragma clang module begin std.limits
8template<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
14inline void f() { numeric_limits<int> nl; }
15#pragma clang module end
16#pragma clang module endbuild
17
18#pragma clang module build module_b
19module module_b {}
20#pragma clang module contents
21#pragma clang module begin module_b
22#pragma clang module import std.limits
23constexpr 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
29constexpr int b = a;
30static_assert(b == 5);
31