https://gcc.gnu.org/g:32d3e63ebb2aac4208a522fcd3477932d72eacfc
commit r15-7510-g32d3e63ebb2aac4208a522fcd3477932d72eacfc Author: Jason Merrill <ja...@redhat.com> Date: Wed Feb 12 18:47:17 2025 +0100 c++: omp declare variant tweak In r15-6707 I changed this function to use build_stub_object to more simply produce the right type, but it occurs to me that forward_parm would be even better, specifically for the diagnostic. This changes nothing with respect to PR118791. gcc/cp/ChangeLog: * decl.cc (omp_declare_variant_finalize_one): Use forward_parm. gcc/testsuite/ChangeLog: * g++.dg/gomp/declare-variant-3.C: Adjust diagnostic. * g++.dg/gomp/declare-variant-5.C: Adjust diagnostic. Diff: --- gcc/cp/decl.cc | 2 +- gcc/testsuite/g++.dg/gomp/declare-variant-3.C | 8 ++++---- gcc/testsuite/g++.dg/gomp/declare-variant-5.C | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 7f7f4938f2ce..df4e66798b15 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -8462,7 +8462,7 @@ omp_declare_variant_finalize_one (tree decl, tree attr) if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE) parm = DECL_CHAIN (parm); for (; parm; parm = DECL_CHAIN (parm)) - vec_safe_push (args, build_stub_object (TREE_TYPE (parm))); + vec_safe_push (args, forward_parm (parm)); unsigned nappend_args = 0; tree append_args_list = TREE_CHAIN (TREE_CHAIN (chain)); diff --git a/gcc/testsuite/g++.dg/gomp/declare-variant-3.C b/gcc/testsuite/g++.dg/gomp/declare-variant-3.C index 8c0cfd218ad4..fdf030fc4290 100644 --- a/gcc/testsuite/g++.dg/gomp/declare-variant-3.C +++ b/gcc/testsuite/g++.dg/gomp/declare-variant-3.C @@ -86,8 +86,8 @@ struct E { int e; }; void fn19 (E, int); -#pragma omp declare variant (fn19)match(user={condition(0)}) // { dg-error {could not convert 'std::declval<int>\(\)' from 'int' to 'E'} } -void fn20 (int, E); +#pragma omp declare variant (fn19)match(user={condition(0)}) // { dg-error {could not convert 'i' from 'int' to 'E'} } +void fn20 (int i, E e); struct F { operator int () const { return 42; } int f; }; void fn21 (int, F); @@ -95,8 +95,8 @@ void fn21 (int, F); #pragma omp declare variant ( fn21 ) match (user = { condition ( 1 - 1 ) } ) // { dg-error "variant 'void fn21\\\(int, F\\\)' and base 'void fn22\\\(F, F\\\)' have incompatible types" } void fn22 (F, F); -#pragma omp declare variant (fn19) match (user={condition(0)}) // { dg-error {could not convert 'std::declval<F>\(\)' from 'F' to 'E'} } -void fn23 (F, int); +#pragma omp declare variant (fn19) match (user={condition(0)}) // { dg-error {could not convert 'f' from 'F' to 'E'} } +void fn23 (F f, int i); void fn24 (int); struct U { int u; }; diff --git a/gcc/testsuite/g++.dg/gomp/declare-variant-5.C b/gcc/testsuite/g++.dg/gomp/declare-variant-5.C index a4747ac030b9..f3697f66aba6 100644 --- a/gcc/testsuite/g++.dg/gomp/declare-variant-5.C +++ b/gcc/testsuite/g++.dg/gomp/declare-variant-5.C @@ -74,8 +74,8 @@ struct E { int e; }; void fn19 (E, int) {} -#pragma omp declare variant (fn19)match(user={condition(0)}) // { dg-error {could not convert 'std::declval<int>\(\)' from 'int' to 'E'} } -void fn20 (int, E) {} +#pragma omp declare variant (fn19)match(user={condition(0)}) // { dg-error {could not convert 'i' from 'int' to 'E'} } +void fn20 (int i, E e) {} struct F { operator int () const { return 42; } int f; }; void fn21 (int, F) {} @@ -83,8 +83,8 @@ void fn21 (int, F) {} #pragma omp declare variant ( fn21 ) match (user = { condition ( 1 - 1 ) } ) // { dg-error "variant 'void fn21\\\(int, F\\\)' and base 'void fn22\\\(F, F\\\)' have incompatible types" } void fn22 (F, F) {} -#pragma omp declare variant (fn19) match (user={condition(0)}) // { dg-error {could not convert 'std::declval<F>\(\)' from 'F' to 'E'} } -void fn23 (F, int) {} +#pragma omp declare variant (fn19) match (user={condition(0)}) // { dg-error {could not convert 'f' from 'F' to 'E'} } +void fn23 (F f, int i) {} void fn24 (int); struct U { int u; };