[AArch64][GlobalISel] Add disjoint handling for add_and_or_is_add. (#123594)
[llvm-project.git] / clang / test / Modules / module-local-with-templates.cppm
blob87955bdd3f99ee41904979bd14cd2b23b7196d12
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: split-file %s %t
4 //
5 // RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/use.cc -fmodule-file=a=%t/a.pcm -fsyntax-only -verify
7 // RUN: %clang_cc1 -std=c++20 %t/a-part.cppm -fmodule-file=a=%t/a.pcm -fsyntax-only -verify
8 //
9 // Test again with reduced BMI
10 // RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm
11 // RUN: %clang_cc1 -std=c++20 %t/use.cc -fmodule-file=a=%t/a.pcm -fsyntax-only -verify
12 // RUN: %clang_cc1 -std=c++20 %t/a-part.cppm -fmodule-file=a=%t/a.pcm -fsyntax-only -verify
13 // RUN: %clang_cc1 -std=c++20 %t/a.cc -fmodule-file=a=%t/a.pcm -fsyntax-only -verify
16 //--- a.cppm
17 export module a;
19 constexpr int x = 43;
21 export constexpr int f() { return x; }
23 export template <typename T>
24 constexpr T g() {
25     return x;
28 namespace nn {
30 constexpr int x = 88;
32 export constexpr int f() { return x; }
34 export template <typename T>
35 constexpr T g() {
36     return x;
40 //--- use.cc
41 // expected-no-diagnostics
42 import a;
44 static_assert(f() == 43, "");
46 constexpr int x = 99;
48 static_assert(g<int>() == 43, "");
50 static_assert(x == 99, "");
52 namespace nn {
53 static_assert(f() == 88, "");
55 constexpr int x = 1000;
57 static_assert(g<int>() == 88, "");
59 static_assert(x == 1000, "");
63 //--- a-part.cppm
64 module a:impl;
65 import a;
67 static_assert(x == 43, "");
69 constexpr int x = 1000; // expected-error {{redefinition of 'x'}}
70                         // expected-note@* {{previous definition is here}}
72 //--- a.cc
73 module a;
75 static_assert(x == 43, "");
77 constexpr int x = 1000; // expected-error {{redefinition of 'x'}}
78                         // expected-note@* {{previous definition is here}}