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

            Bug ID: 120118
           Summary: ICE in c and c++ in cpp_spell_token with unterminated
                    macro stringification inside #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: ---

It fails when #pragma message is ended in next after a line break, it happens
in C and C++.

```
#define F(X) #X
#pragma message F(
)
```

Stack dump

```
prueba.cpp:3:1: internal compiler error: unspellable token PRAGMA_EOL
    3 | )
      | ^
0x7f5ea2 c_cpp_diagnostic(cpp_reader*, cpp_diagnostic_level,
cpp_warning_reason, rich_location*, char const*, __va_list_tag (*) [1])
        .././../gcc-13-source/gcc/c-family/c-common.cc:6710
0x1b1214b cpp_diagnostic_at
        .././../gcc-13-source/libcpp/errors.cc:67
0x1b1214b cpp_diagnostic
        .././../gcc-13-source/libcpp/errors.cc:82
0x1b12276 cpp_error(cpp_reader*, cpp_diagnostic_level, char const*, ...)
        .././../gcc-13-source/libcpp/errors.cc:96
0x1b1c5c1 cpp_spell_token(cpp_reader*, cpp_token const*, unsigned char*, bool)
        .././../gcc-13-source/libcpp/lex.cc:4426
0x1b25df2 stringify_arg
        .././../gcc-13-source/libcpp/macro.cc:904
0x1b27fa9 replace_args
        .././../gcc-13-source/libcpp/macro.cc:1933
0x1b27fa9 enter_macro_context
        .././../gcc-13-source/libcpp/macro.cc:1483
0x1b28700 cpp_get_token_1
        .././../gcc-13-source/libcpp/macro.cc:3018
0x80b15e c_lex_with_flags(tree_node**, unsigned int*, unsigned char*, int)
        .././../gcc-13-source/gcc/c-family/c-lex.cc:499
0x782e3f c_lex_one_token
        .././../gcc-13-source/gcc/c/c-parser.cc:294
0x786fbc c_parser_peek_token(c_parser*)
        .././../gcc-13-source/gcc/c/c-parser.cc:498
0x786fbc pragma_lex(tree_node**, unsigned int*)
        .././../gcc-13-source/gcc/c/c-parser.cc:13339
0x816580 handle_pragma_message
        .././../gcc-13-source/gcc/c-family/c-pragma.cc:1380
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
```

It happens since 4.4.7

To reproduce quickly

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

Reply via email to