diff --git a/clang/test/CodeGenCXX/visibility.cpp b/clang/test/CodeGenCXX/visibility.cpp index 3203d476c45f9..7dd5dc37c2dee 100644 --- a/clang/test/CodeGenCXX/visibility.cpp +++ b/clang/test/CodeGenCXX/visibility.cpp @@ -1560,3 +1560,25 @@ namespace no_pragma_test { // CHECK-LABEL: define void @_ZN14no_pragma_test1SC2Ev( // CHECK-HIDDEN-LABEL: define hidden void @_ZN14no_pragma_test1SC2Ev( } + +namespace FunctionTemplateRedecl1 { + template void f(); + extern template DEFAULT void f(); + template void f() {} + template void f(); + // CHECK-LABEL: define weak_odr void @_ZN23FunctionTemplateRedecl11fIiEEvv( + // CHECK-HIDDEN-LABEL: define weak_odr void @_ZN23FunctionTemplateRedecl11fIiEEvv( +} // namespace FunctionTemplateRedecl1 + +namespace SpecOutOfLine1 { + template struct A { + A f(); + }; + template <> + struct DEFAULT A { + ~A(); + }; + A::~A() {} + // CHECK-LABEL: define void @_ZN14SpecOutOfLine11AIvED1Ev( + // CHECK-HIDDEN-LABEL: define void @_ZN14SpecOutOfLine11AIvED1Ev( +} // namespace SpecOutOfLine1 diff --git a/clang/test/Modules/template-default-args-2.cpp b/clang/test/Modules/template-default-args-2.cpp new file mode 100644 index 0000000000000..29925e4785d9a --- /dev/null +++ b/clang/test/Modules/template-default-args-2.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -fmodules -verify -fno-modules-error-recovery -fno-spell-checking %s + +#pragma clang module build A +module A { + explicit module X {} + explicit module Y {} +} +#pragma clang module contents +#pragma clang module begin A.X +namespace N { + template struct Foo1 {}; + template struct Foo2 {}; +} +#pragma clang module end + +#pragma clang module begin A.Y +#pragma clang module import A.X +namespace N { + template struct Foo1; + template struct Foo2; +} +#pragma clang module end +#pragma clang module endbuild + +#pragma clang module import A.X + +N::Foo1 t1; +N::Foo2 t2; +// expected-error@-1 {{default argument of 'Foo2' must be imported from module 'A.Y' before it is required}} +// expected-note@* {{default argument declared here is not reachable}} diff --git a/clang/test/Modules/template-default-args-3.cpp b/clang/test/Modules/template-default-args-3.cpp new file mode 100644 index 0000000000000..0dbdf7165433e --- /dev/null +++ b/clang/test/Modules/template-default-args-3.cpp @@ -0,0 +1,36 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: split-file %s %t +// RUN: cd %t +// +// RUN: %clang_cc1 -verify -std=c++20 -emit-module -fmodules -fmodule-name=B -fmodules-cache-path=%t -xc++ module.modulemap + +//--- module.modulemap +module A { + header "A.h" +} +module B { + module X { + header "B.h" + } + header "C.h" +} + +//--- A.h +template struct A {}; + +//--- B.h +template struct C; +template void f() { + C a; +} +void g() { + f(); +} + +//--- C.h +// expected-no-diagnostics +#pragma clang module import A +template struct C { + using X = A; +}; diff --git a/clang/test/SemaTemplate/generic-lambda.cpp b/clang/test/SemaTemplate/generic-lambda.cpp index 804eeaa29d6a1..7e7c3419f1b43 100644 --- a/clang/test/SemaTemplate/generic-lambda.cpp +++ b/clang/test/SemaTemplate/generic-lambda.cpp @@ -83,3 +83,10 @@ int foo(auto... fn) { int v = foo(42); } // namespace GH95735 + +namespace ExpectionSpec1 { + template void f() { + [](auto...) noexcept(false) {}(); + } + template void f(); +} // namespace ExceptionSpec1 diff --git a/clang/test/SemaTemplate/partial-spec-instantiate.cpp b/clang/test/SemaTemplate/partial-spec-instantiate.cpp index 44b58008a1d33..ab48050938991 100644 --- a/clang/test/SemaTemplate/partial-spec-instantiate.cpp +++ b/clang/test/SemaTemplate/partial-spec-instantiate.cpp @@ -165,3 +165,10 @@ namespace GH162855 { template struct C>; } // namespace GH162855 #endif + +namespace DependentWithQualifier { + template struct A; + template struct B; + template struct A > {}; + template struct A >; +} // namespace DependentWithQualifier