1// RUN: rm -rf %t 2// RUN: mkdir %t 3// RUN: split-file %s %t 4// 5// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/var_def.cppm -o %t/var_def.pcm 6// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/reexport1.cppm -o %t/reexport1.pcm 7// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/reexport2.cppm -o %t/reexport2.pcm 8// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cppm -fsyntax-only -verify 9 10// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/var_def.cppm -o %t/var_def.pcm 11// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface -fprebuilt-module-path=%t %t/reexport1.cppm -o %t/reexport1.pcm 12// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface -fprebuilt-module-path=%t %t/reexport2.cppm -o %t/reexport2.pcm 13// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cppm -fsyntax-only -verify 14 15//--- use.cppm 16import 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.cppm 34export 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.cppm 44export module reexport1; 45export import var_def; 46 47//--- reexport2.cppm 48export module reexport2; 49export import var_def; 50