diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index c09a934580f..2775af7701b 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -12393,7 +12393,8 @@ apply_late_template_attributes (tree *decl_p, tree attributes, int attr_flags, to our attributes parameter. */ gcc_assert (*p == attributes); } - else if (FUNC_OR_METHOD_TYPE_P (*decl_p)) + else if (FUNC_OR_METHOD_TYPE_P (*decl_p) + || (attr_flags & ATTR_FLAG_TYPE_IN_PLACE) == 0) p = NULL; else { @@ -16867,7 +16868,8 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) { if (type == TREE_TYPE (t) && TREE_CODE (type) != METHOD_TYPE - && TYPE_ATTRIBUTES (t) == NULL_TREE) + && (TYPE_ATTRIBUTES (t) == NULL_TREE + || !ATTR_IS_DEPENDENT (TYPE_ATTRIBUTES (t)))) return t; /* [temp.deduct] @@ -17029,7 +17031,8 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) it will obviously be the same as T. */ if (type == TREE_TYPE (t) && domain == TYPE_DOMAIN (t) - && TYPE_ATTRIBUTES (t) == NULL_TREE) + && (TYPE_ATTRIBUTES (t) == NULL_TREE + || !ATTR_IS_DEPENDENT (TYPE_ATTRIBUTES (t)))) return t; /* These checks should match the ones in create_array_type_for_decl. diff --git a/gcc/testsuite/g++.dg/template/pr119138.C b/gcc/testsuite/g++.dg/template/pr119138.C new file mode 100644 index 00000000000..b0893872f2c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr119138.C @@ -0,0 +1,16 @@ +// PR c++/119138 +// { dg-do compile } + +#include + +template +void +foo (va_list) +{ +} + +void +bar (va_list ap) +{ + foo (ap); +}