Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

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.
---
 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 7f7f4938f2c..df4e66798b1 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 8c0cfd218ad..fdf030fc429 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 a4747ac030b..f3697f66aba 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; };

base-commit: cdb4d27a4c2786cf1b1b0eb1872eac6a5f931578
-- 
2.48.1

Reply via email to