aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Modules/added-visible-decls.cppm
blob: 28df3bf6f85437404a9a06b64813cc70d34b1fd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// RUN: rm -rf %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -o %t/b.pcm -fprebuilt-module-path=%t
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-reduced-module-interface -o %t/c.pcm -fprebuilt-module-path=%t
// RUN: %clang_cc1 -std=c++20 %t/d.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
// RUN: %clang_cc1 -std=c++20 %t/d.cpp -fprebuilt-module-path=%t -fsyntax-only -verify -fexperimental-new-constant-interpreter

//--- a.h
template <typename T>
struct A {
  static const T value0;
  static const T value1;

  constexpr T get0() {
    return value0;
  }

  constexpr T get1() {
    return value1;
  }
};

template <typename T>
const T A<T>::value0 = T(43);
template <typename T>
const T A<T>::value1 = T(44);

//--- a.cppm
module;
#include "a.h"
export module a;
export using ::A;

//--- b.cppm
export module b;
export import a;

export constexpr int bar() {
    return A<int>().get0();
}

//--- c.cppm
export module c;
export import b;

export constexpr int foo() {
    return A<int>().get1() + A<int>().get0();
}

//--- d.cpp
// expected-no-diagnostics

import c;

static_assert(bar() + foo() == 130);