// RUN: rm -rf %t // RUN: mkdir %t // RUN: split-file %s %t // // We need '-fmodules-local-submodule-visibility' to properly test merging when building a module from multiple // headers inside the same TU. C++20 mode would imply this flag, but we need it to set it explicitly for C++14. // // RUN: %clang_cc1 -xc++ -std=c++14 -fmodules -fmodules-local-submodule-visibility -fmodule-name=library \ // RUN: -emit-module %t/modules.map \ // RUN: -o %t/module.pcm // // // RUN: %clang_cc1 -xc++ -std=c++14 -fmodules -fmodules-local-submodule-visibility -fmodule-file=%t/module.pcm \ // RUN: -fmodule-map-file=%t/modules.map \ // RUN: -fsyntax-only -verify %t/use.cpp // //--- use.cpp #include "var1.h" #include "var2.h" auto foo = zero; auto bar = zero; auto baz = zero; template constexpr T zero = 0; // expected-error {{redefinition}} expected-note@* {{previous}} template <> constexpr Int zero = {0}; // expected-error {{redefinition}} expected-note@* {{previous}} template constexpr T* zero = nullptr; // expected-error {{redefinition}} expected-note@* {{previous}} template <> constexpr int** zero = nullptr; // ok, new specialization. template constexpr T** zero = nullptr; // ok, new partial specilization. //--- modules.map module "library" { export * module "var1" { export * header "var1.h" } module "var2" { export * header "var2.h" } } //--- var1.h #ifndef VAR1_H #define VAR1_H template constexpr T zero = 0; struct Int { int value; }; template <> constexpr int zero = {0}; template constexpr T* zero = nullptr; #endif // VAR1_H //--- var2.h #ifndef VAR2_H #define VAR2_H template constexpr T zero = 0; struct Int { int value; }; template <> constexpr int zero = {0}; template constexpr T* zero = nullptr; #endif // VAR2_H