diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 4349b19119b..51433e7c4ec 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -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); diff --git a/gcc/testsuite/g++.dg/ext/pragma-target2.C b/gcc/testsuite/g++.dg/ext/pragma-target2.C new file mode 100644 index 00000000000..53eb7dd96a2 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pragma-target2.C @@ -0,0 +1,18 @@ +// PR c++/114772 +// { dg-do compile { target x86_64-*-* } } + +template +inline __attribute__((always_inline)) +__attribute__((warn_unused_result)) +int walk_document(V visitor) {return 0;} + +template +void parse_document() { + int r = walk_document(false); +} + +void stage2_next() { + parse_document(); +} + +#pragma GCC target("pclmul")