Do not call cp_parser_omp_dispatch directly in cp_parser_pragma

Message ID 20250106152204.218226-1-parras@baylibre.com
State New
Headers
Series Do not call cp_parser_omp_dispatch directly in cp_parser_pragma |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed

Commit Message

Paul-Antoine Arras Jan. 6, 2025, 3:22 p.m. UTC
  This is a followup to
ed49709acda OpenMP: C++ front-end support for dispatch + adjust_args.

The call to cp_parser_omp_dispatch only belongs in cp_parser_omp_construct. In
cp_parser_pragma, handle PRAGMA_OMP_DISPATCH by calling cp_parser_omp_construct.

gcc/cp/ChangeLog:

	* parser.cc (cp_parser_pragma): Replace call to cp_parser_omp_dispatch
	with cp_parser_omp_construct.
---
 gcc/cp/parser.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Tobias Burnus Jan. 7, 2025, 11:13 a.m. UTC | #1
Paul-Antoine Arras wrote:
> This is a followup to
> ed49709acda OpenMP: C++ front-end support for dispatch + adjust_args.
> 
> The call to cp_parser_omp_dispatch only belongs in cp_parser_omp_construct. In
> cp_parser_pragma, handle PRAGMA_OMP_DISPATCH by calling cp_parser_omp_construct.

I think this change is good - but not sufficient. For instance,
the following gives an ICE:

void k();
struct t {
  #pragma omp dispatch
   k();
};

I think that's context == pragma_member.

Tobias
  
Paul-Antoine Arras Jan. 10, 2025, 3:31 p.m. UTC | #2
Hi Tobias,

On 07/01/2025 12:13, Tobias Burnus wrote:
> Paul-Antoine Arras wrote:
>> This is a followup to
>> ed49709acda OpenMP: C++ front-end support for dispatch + adjust_args.
>>
>> The call to cp_parser_omp_dispatch only belongs in 
>> cp_parser_omp_construct. In
>> cp_parser_pragma, handle PRAGMA_OMP_DISPATCH by calling 
>> cp_parser_omp_construct.
> 
> I think this change is good - but not sufficient. For instance,
> the following gives an ICE:
> 
> void k();
> struct t {
>   #pragma omp dispatch
>    k();
> };
> 
> I think that's context == pragma_member.


This amended patch checks the context and adds the suggested testcase.

Thanks,
  
Tobias Burnus Jan. 10, 2025, 5:21 p.m. UTC | #3
Hi PA,

Paul-Antoine Arras wrote:
> This amended patch checks the context and adds the suggested testcase.

LGTM - thanks!

>      Do not call cp_parser_omp_dispatch directly in cp_parser_pragma
>      
>      This is a followup to
>      ed49709acda OpenMP: C++ front-end support for dispatch + adjust_args.
>      
>      The call to cp_parser_omp_dispatch only belongs in cp_parser_omp_construct. In
>      cp_parser_pragma, handle PRAGMA_OMP_DISPATCH by calling cp_parser_omp_construct.
>      
>      gcc/cp/ChangeLog:
>      
>              * parser.cc (cp_parser_pragma): Replace call to cp_parser_omp_dispatch
>              with cp_parser_omp_construct.
>      
>      gcc/testsuite/ChangeLog:
>      
>              * g++.dg/gomp/dispatch-8.C: New test.

Tobias
  

Patch

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index f548dc31c2b..7434c1d91ba 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -53060,7 +53060,7 @@  cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p)
       break;
 
     case PRAGMA_OMP_DISPATCH:
-      cp_parser_omp_dispatch (parser, pragma_tok);
+      cp_parser_omp_construct (parser, pragma_tok, if_p);
       return true;
 
     case PRAGMA_IVDEP: