brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 87955bd Raw
80 lines · plain
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm6// RUN: %clang_cc1 -std=c++20 %t/use.cc -fmodule-file=a=%t/a.pcm -fsyntax-only -verify7// RUN: %clang_cc1 -std=c++20 %t/a-part.cppm -fmodule-file=a=%t/a.pcm -fsyntax-only -verify8//9// Test again with reduced BMI10// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm11// RUN: %clang_cc1 -std=c++20 %t/use.cc -fmodule-file=a=%t/a.pcm -fsyntax-only -verify12// RUN: %clang_cc1 -std=c++20 %t/a-part.cppm -fmodule-file=a=%t/a.pcm -fsyntax-only -verify13// RUN: %clang_cc1 -std=c++20 %t/a.cc -fmodule-file=a=%t/a.pcm -fsyntax-only -verify14 15 16//--- a.cppm17export module a;18 19constexpr int x = 43;20 21export constexpr int f() { return x; }22 23export template <typename T>24constexpr T g() {25    return x;26}27 28namespace nn {29 30constexpr int x = 88;31 32export constexpr int f() { return x; }33 34export template <typename T>35constexpr T g() {36    return x;37}38}39 40//--- use.cc41// expected-no-diagnostics42import a;43 44static_assert(f() == 43, "");45 46constexpr int x = 99;47 48static_assert(g<int>() == 43, "");49 50static_assert(x == 99, "");51 52namespace nn {53static_assert(f() == 88, "");54 55constexpr int x = 1000;56 57static_assert(g<int>() == 88, "");58 59static_assert(x == 1000, "");60 61}62 63//--- a-part.cppm64module a:impl;65import a;66 67static_assert(x == 43, "");68 69constexpr int x = 1000; // expected-error {{redefinition of 'x'}}70                        // expected-note@* {{previous definition is here}}71 72//--- a.cc73module a;74 75static_assert(x == 43, "");76 77constexpr int x = 1000; // expected-error {{redefinition of 'x'}}78                        // expected-note@* {{previous definition is here}}79 80