OpenMP/C++: Enhance diagnostics of 'omp allocate' directive
Compiler provides more detailed and accurate error messages for various issues related to the OpenMP ALLOCATE directive.
This commit significantly improves the diagnostics for the OpenMP allocate directive in C++. It introduces checks and provides clearer error messages for several problematic scenarios, including multiple uses of the same variable within a single directive, using parameters as variables, referencing variables in different scopes, and using reference types. These enhancements ensure that developers receive more precise feedback about incorrect usage, facilitating faster debugging and correct implementation of OpenMP features.
In Details
This patch enhances the diagnostics within cp_parser_omp_allocate and finish_omp_allocate for the omp allocate directive. It adds checks for duplicate variable uses within a single directive, validates the use of parameters, enforces correct scope for variables, and handles reference types. The implementation improves error reporting by wrapping location information into allocator and alignment clause expressions, providing more precise error messages and locations for various semantic issues.
- omp allocate directive
- An OpenMP directive used to control memory allocation for data, allowing specification of memory spaces or strategies.
- diagnostics
- Error messages or warnings issued by the compiler to inform the user about issues in their code.
- variable scope
- The region of a program where a declared variable is valid and can be accessed.
- reference type
- A type that represents an alias to another variable, allowing indirect access and modification.
- parser
- The component of the compiler responsible for analyzing the syntactic structure of the source code according to a given grammar.
- gimplification
- A compiler phase where the code is transformed into an intermediate representation called GIMPLE, which is suitable for optimization.