https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120563
Bug ID: 120563 Summary: ICE: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in c_parser_omp_clause_reduction, at c/c-parser.cc:18549 Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: iamanonymous.cs at gmail dot com Target Milestone: --- Target: x86_64 ******************************************************************************* The compiler produces an internal error during tree_class_check_failed when compiling the provided code with the specified options. The issue can also be reproduced on Compiler Explorer. ******************************************************************************* OS and Platform: # uname -a Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ******************************************************************************* # g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/root/gdbtest/gcc/gcc-250601/libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --prefix=/root/gdbtest/gcc/gcc-250601 --enable-languages=c,c++ --disable-multilib --disable-bootstrap Thread model: posix Supported LTO compression algorithms: zlib gcc version 16.0.0 20250601 (experimental) (GCC) ******************************************************************************* Program: #cat code.c #pragma omp declare reduction (+: struct S : merge (&omp_out, &omp_in)) initializer (init (&omp_priv)) void foo (struct S x) { #pragma omp taskgroup task_reduction (+: x) { #pragma omp task in_reduction (+: x) { x.a++; x.b++; } #pragma omp task in_reduction (+: x) { x.a += 4; x.b += 14; } #pragma omp task in_reduction (+: x) { x.a += 9; x.b += 19; } } if (x.a != 56 || x.b != 86) __builtin_abort (); } ******************************************************************************* Command Lines: gcc code.c -pipe -MMD -MP -MQ ./ -MT test.o -MF test.d -c -o code_0.o <source>: In function 'omp declare reduction +': <source>:1:46: error: implicit declaration of function 'merge' [-Wimplicit-function-declaration] 1 | #pragma omp declare reduction (+: struct S : merge (&omp_out, &omp_in)) initializer (init (&omp_priv)) | ^~~~~ <source>:1:86: error: implicit declaration of function 'init' [-Wimplicit-function-declaration] 1 | #pragma omp declare reduction (+: struct S : merge (&omp_out, &omp_in)) initializer (init (&omp_priv)) | ^~~~ <source>: At top level: <source>:4:15: error: parameter 1 ('x') has incomplete type 4 | foo (struct S x) | ~~~~~~~~~^ <source>: In function 'foo': <source>:6:11: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in c_parser_omp_clause_reduction, at c/c-parser.cc:18685 6 | #pragma omp taskgroup task_reduction (+: x) | ^~~ 0x2505575 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x2526e26 internal_error(char const*, ...) ???:0 0x8fdebb tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ???:0 0xac1cbe c_parse_file() ???:0 0xb433d9 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Compiler returned: 1 ******************************************************************************* Also ICE on trunk, compiler explorer:https://gcc.godbolt.org/z/d6h3n1KKn *******************************************************************************