]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: omp declare variant tweak
authorJason Merrill <jason@redhat.com>
Wed, 12 Feb 2025 17:47:17 +0000 (18:47 +0100)
committerJason Merrill <jason@redhat.com>
Thu, 13 Feb 2025 21:52:57 +0000 (22:52 +0100)
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
gcc/testsuite/g++.dg/gomp/declare-variant-3.C
gcc/testsuite/g++.dg/gomp/declare-variant-5.C

index 7f7f4938f2ce34e4ba4f3dcfbf7e7ef98223ee8e..df4e66798b15fd8b4bdac94e601fdf25ce5b05a2 100644 (file)
@@ -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));
index 8c0cfd218ad4ddd98883a8d056ee19ecb0e62f85..fdf030fc4290b0328ab203746481ff560eb23308 100644 (file)
@@ -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; };
index a4747ac030b984cbb4857f0a22064a6e60c7c5c9..f3697f66aba6c16e03479e4c413222d8e096c471 100644 (file)
@@ -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; };