GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
c++

C++: Handle OpenMP/OpenACC array sections with C++26 splicing tokens

GCC now correctly parses OpenMP/OpenACC array sections even when C++26's splicing tokens '[:' and ':]' are used.

This commit adjusts the C++ parser to correctly interpret OpenMP and OpenACC array sections, such as [:n] or [idx:], when compiled with C++26 or later standards. C++26 introduced new splicing tokens (CPP_OPEN_SPLICE, CPP_CLOSE_SPLICE) that conflicted with the existing syntax for array sections. This change ensures that these array sections are parsed as intended, maintaining compatibility with OpenMP/OpenACC array slicing despite the new C++26 parsing rules.

In Details

The C++ parser in GCC now correctly distinguishes OpenMP/OpenACC array sections from C++26's new splicing tokens ([: and :]). Prior to C++26, these were unambiguously part of array section syntax. With C++26 (P2996), [: and :] are lexed as CPP_OPEN_SPLICE and CPP_CLOSE_SPLICE respectively. This commit modifies parser.cc to restore the correct parsing of array sections when these tokens are encountered, ensuring that OpenMP/OpenACC constructs remain functional as specified, even with the introduction of C++26 reflection features.

For Context
array sections
A feature in OpenMP and OpenACC that allows specifying a contiguous sub-range of an array for data manipulation, often used for data parallelism.
splicing tokens
New token types introduced in C++26 (related to P2996) intended for reflection mechanisms, which could be confused with existing syntax like OpenMP/OpenACC array sections.
CPP_OPEN_SPLICE
A preprocessor token representing the opening part of a splicing operation, introduced in C++26.
CPP_CLOSE_SPLICE
A preprocessor token representing the closing part of a splicing operation, introduced in C++26.
Filed Under: c++openmpopenaccparser