c++: templates, attributes, #pragma target [PR114772]

Since r12-5426 apply_late_template_attributes suppresses various global
state to avoid applying active pragmas to earlier declarations; we also
need to override target_option_current_node.

	PR c++/114772
	PR c++/101180

gcc/cp/ChangeLog:

	* pt.cc (apply_late_template_attributes): Also override
	target_option_current_node.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/pragma-target2.C: New test.
This commit is contained in:
Jason Merrill 2025-04-16 12:02:58 -04:00
parent b0d7d644f3
commit 5fdb0145fb
2 changed files with 20 additions and 0 deletions

View file

@ -12429,6 +12429,8 @@ apply_late_template_attributes (tree *decl_p, tree attributes, int attr_flags,
auto o4 = make_temp_override (scope_chain->omp_declare_target_attribute,
NULL);
auto o5 = make_temp_override (scope_chain->omp_begin_assumes, NULL);
auto o6 = make_temp_override (target_option_current_node,
target_option_default_node);
cplus_decl_attributes (decl_p, late_attrs, attr_flags);

View file

@ -0,0 +1,18 @@
// PR c++/114772
// { dg-do compile { target x86_64-*-* } }
template<typename V, bool STREAMING>
inline __attribute__((always_inline))
__attribute__((warn_unused_result))
int walk_document(V visitor) {return 0;}
template<bool STREAMING>
void parse_document() {
int r = walk_document<bool, STREAMING>(false);
}
void stage2_next() {
parse_document<true>();
}
#pragma GCC target("pclmul")