c++: visibility of local extern [PR103291]

When setting up the hidden namespace-scope decl for a local extern, we also
need to set its visibility.

	PR c++/103291

gcc/cp/ChangeLog:

	* name-lookup.cc (push_local_extern_decl_alias): Call
	determine_visibility.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/visibility/visibility-local-extern1.C: New test.
This commit is contained in:
Jason Merrill 2022-03-27 09:44:59 -04:00
parent b854ce130e
commit 8796eb27e2
2 changed files with 13 additions and 0 deletions

View File

@ -3476,6 +3476,9 @@ push_local_extern_decl_alias (tree decl)
&& CP_DECL_THREAD_LOCAL_P (decl)
&& alias != error_mark_node)
set_decl_tls_model (alias, DECL_TLS_MODEL (decl));
/* Adjust visibility. */
determine_visibility (alias);
}
}

View File

@ -0,0 +1,10 @@
// PR c++/103291
// { dg-additional-options -fpic }
// { dg-final { scan-assembler-not "@GOTPCREL" } }
#pragma GCC visibility push(hidden)
int hidden_fetch(void) {
extern const int hidden_global;
return hidden_global;
}