50 lines · plain
1// RUN: rm -rf %t2// RUN: mkdir %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/var_def.cppm -o %t/var_def.pcm6// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/reexport1.cppm -o %t/reexport1.pcm7// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/reexport2.cppm -o %t/reexport2.pcm8// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cppm -fsyntax-only -verify9 10// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/var_def.cppm -o %t/var_def.pcm11// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface -fprebuilt-module-path=%t %t/reexport1.cppm -o %t/reexport1.pcm12// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface -fprebuilt-module-path=%t %t/reexport2.cppm -o %t/reexport2.pcm13// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cppm -fsyntax-only -verify14 15//--- use.cppm16import reexport1;17import reexport2;18 19auto foo = zero<Int>;20auto bar = zero<int*>;21auto baz = zero<int>;22 23template <class T> constexpr T zero = 0; // expected-error-re {{declaration{{.*}}in the global module follows declaration in module var_def}}24 // expected-note@* {{previous}}25template <> constexpr Int zero<Int> = {0}; // expected-error-re {{declaration{{.*}}in the global module follows declaration in module var_def}}26 // expected-note@* {{previous}}27template <class T> constexpr T* zero<T*> = nullptr; // expected-error-re {{declaration{{.*}}in the global module follows declaration in module var_def}}28 // expected-note@* {{previous}}29 30template <> constexpr int** zero<int**> = nullptr; // ok, new specialization.31template <class T> constexpr T** zero<T**> = nullptr; // ok, new partial specilization.32 33//--- var_def.cppm34export module var_def;35 36export template <class T> constexpr T zero = 0;37export struct Int {38 int value;39};40export template <> constexpr Int zero<Int> = {0};41export template <class T> constexpr T* zero<T*> = nullptr;42 43//--- reexport1.cppm44export module reexport1;45export import var_def;46 47//--- reexport2.cppm48export module reexport2;49export import var_def;50