Remove warning about unused iterator variable in map clauses.
GCC no longer issues false positive warnings for unused iterator variables in OpenMP map clauses by removing the check from the gimplifier.
This commit removes a warning in OpenMP about unused iterator variables within map clauses, which was previously implemented by a code walk in the gimplifier. This check was too late in the compilation process, leading to false positives when frontends optimized away explicit references or with implicit map clauses in Fortran. Removing the warning prevents confusing and incorrect diagnostic messages for developers.
In Details
The gimplify.cc component, specifically remove_unused_omp_iterator_vars, previously performed a code walk to identify unused iterator variables in OpenMP map clauses. This pass occurs after frontend optimizations, such as fold_build* expression constructors, have already processed the code. This late-stage check, combined with the Fortran frontend's handling of implicit map clauses for array descriptors, resulted in erroneous warnings. The change discontinues this specific warning, recognizing that a more accurate check would need to occur earlier in the compilation pipeline, within the…
For Context
OpenMP is an API that supports multi-platform shared-memory multiprocessing programming in C, C++, and Fortran, allowing programs to use multiple CPU cores for faster execution. When you write OpenMP code, the compiler (GCC in this case) translates your high-level instructions into an intermediate representation (IR) called GIMPLE during a phase known as gimplification. The compiler then performs various checks and optimizations on this IR. This change addresses a situation where the compiler was incorrectly flagging variables as 'unused' in OpenMP's map clauses, which are used to specify how data should be transferred between host and device memory. Because of the way the compiler optimized code or handled certain language features, the compiler's check came too late and produced misleading warnings, even when the variables were functionally used. This update removes that specific problematic warning to avoid programmer confusion.