https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120033

            Bug ID: 120033
           Summary: ICE in c_parser_consume_token when using macro with
                    malformed #pragma message
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mario.rodriguezb1 at um dot es
  Target Milestone: ---

The following code causes an internal compiler error (ICE) in GCC when a macro
is improperly passed to #pragma message:

```
#define N(q, r)
#pragma  \
message  " " N(d, \
{
})
#pragma message \
        " " 2 N(e,f)
```

Stack Dump

```
prueba.c:7:9: internal compiler error: in c_parser_consume_token, at
c/c-parser.cc:893
    7 | #pragma message \
      |         ^~~~~~~
0x6eca7a c_parser_consume_token(c_parser*)
        .././../gcc-13-source/gcc/c/c-parser.cc:893
0x786f8a pragma_lex(tree_node**, unsigned int*)
        .././../gcc-13-source/gcc/c/c-parser.cc:13354
0x8165f2 handle_pragma_message
        .././../gcc-13-source/gcc/c-family/c-pragma.cc:1401
0x78dbd7 c_parser_pragma
        .././../gcc-13-source/gcc/c/c-parser.cc:13323
0x7b65e5 c_parser_external_declaration
        .././../gcc-13-source/gcc/c/c-parser.cc:1906
0x7b6f93 c_parser_translation_unit
        .././../gcc-13-source/gcc/c/c-parser.cc:1779
0x7b6f93 c_parse_file()
        .././../gcc-13-source/gcc/c/c-parser.cc:24632
0x814561 c_common_parse_file()
        .././../gcc-13-source/gcc/c-family/c-opts.cc:1248
```

Toquickly reproduce:

https://gcc.godbolt.org/z/anxohrz5W

Reply via email to