diff --git a/clang/test/CodeGenCXX/visibility.cpp b/clang/test/CodeGenCXX/visibility.cpp index 841813009cd4f..d3e3fb341c572 100644 --- a/clang/test/CodeGenCXX/visibility.cpp +++ b/clang/test/CodeGenCXX/visibility.cpp @@ -957,13 +957,17 @@ namespace test51 { struct HIDDEN foo { }; - DEFAULT foo x; + DEFAULT foo x, y; template void DEFAULT zed() { } template void zed<&x>(); // CHECK-LABEL: define weak_odr hidden void @_ZN6test513zedIXadL_ZNS_1xEEEEEvv // CHECK-HIDDEN-LABEL: define weak_odr hidden void @_ZN6test513zedIXadL_ZNS_1xEEEEEvv + + template void HIDDEN zed<&y>(); + // CHECK-LABEL: define weak_odr hidden void @_ZN6test513zedIXadL_ZNS_1yEEEEEvv( + // CHECK-HIDDEN-LABEL: define weak_odr hidden void @_ZN6test513zedIXadL_ZNS_1yEEEEEvv( } namespace test52 { @@ -1332,3 +1336,28 @@ namespace test70 { B::~B() {} // Check lines at top of file. } + +// https://github.com/llvm/llvm-project/issues/31462 +namespace test71 { + template + struct foo { + static HIDDEN T zed(); + template HIDDEN U bar(); + }; + template + T foo::zed() { return {}; } + template template + U foo::bar() { return {}; } + + extern template struct DEFAULT foo; + + int use() { + foo o; + return o.zed() + o.bar(); + } + /// FIXME: foo::bar is hidden in GCC w/ or w/o -fvisibility=hidden. + // CHECK-LABEL: declare hidden noundef i32 @_ZN6test713fooIiE3zedEv( + // CHECK-LABEL: define linkonce_odr noundef i32 @_ZN6test713fooIiE3barIiEET_v( + // CHECK-HIDDEN-LABEL: declare hidden noundef i32 @_ZN6test713fooIiE3zedEv( + // CHECK-HIDDEN-LABEL: define linkonce_odr noundef i32 @_ZN6test713fooIiE3barIiEET_v( +}