https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/199467
These are extracted from my current and future PRs. They don't have much to do with the PRs themselves except that they were regressions our test suite missed catching. >From 248d1e88cd374ef1002dd513610c221336d0e865 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov <[email protected]> Date: Sun, 24 May 2026 21:13:19 -0300 Subject: [PATCH] [clang] NFC: add some new test cases These are extracted from my current and future PRs. They don't have much to do with the PRs themselves except that they were regressions our test suite missed catching. --- clang/test/CodeGenCXX/visibility.cpp | 22 ++++++++++++ .../test/Modules/template-default-args-2.cpp | 30 ++++++++++++++++ .../test/Modules/template-default-args-3.cpp | 36 +++++++++++++++++++ clang/test/SemaTemplate/generic-lambda.cpp | 7 ++++ .../SemaTemplate/partial-spec-instantiate.cpp | 7 ++++ 5 files changed, 102 insertions(+) create mode 100644 clang/test/Modules/template-default-args-2.cpp create mode 100644 clang/test/Modules/template-default-args-3.cpp 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 <class> void f(); + extern template DEFAULT void f<int>(); + template <class> void f() {} + template void f<int>(); + // CHECK-LABEL: define weak_odr void @_ZN23FunctionTemplateRedecl11fIiEEvv( + // CHECK-HIDDEN-LABEL: define weak_odr void @_ZN23FunctionTemplateRedecl11fIiEEvv( +} // namespace FunctionTemplateRedecl1 + +namespace SpecOutOfLine1 { + template <class> struct A { + A<void> f(); + }; + template <> + struct DEFAULT A<void> { + ~A(); + }; + A<void>::~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<class, class = void> struct Foo1 {}; + template<class, class> struct Foo2 {}; +} +#pragma clang module end + +#pragma clang module begin A.Y +#pragma clang module import A.X +namespace N { + template<class, class> struct Foo1; + template<class, class = void> struct Foo2; +} +#pragma clang module end +#pragma clang module endbuild + +#pragma clang module import A.X + +N::Foo1<int> t1; +N::Foo2<int> 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 <class _Tp, class = void> struct A {}; + +//--- B.h +template <class> struct C; +template <class T> void f() { + C<T> a; +} +void g() { + f<int>(); +} + +//--- C.h +// expected-no-diagnostics +#pragma clang module import A +template <class T> struct C { + using X = A<T>; +}; 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 <class> void f() { + [](auto...) noexcept(false) {}(); + } + template void f<int>(); +} // 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<D<int>>; } // namespace GH162855 #endif + +namespace DependentWithQualifier { + template <class> struct A; + template <class> struct B; + template <class T> struct A<const B<T> > {}; + template struct A<const B<int> >; +} // namespace DependentWithQualifier _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
