@@ -4449,6 +4449,8 @@ static Token *validate_defer_statement(Token *tok, bool in_loop, bool in_switch,
44494449 if (act && match_ch (act , ';' ))
44504450 error_tok (s , "expected statement after 'orelse'" );
44514451 validate_defer_control_flow (act , in_loop , in_switch );
4452+ if (act && match_ch (act , '{' ))
4453+ validate_defer_statement (act , in_loop , in_switch , depth + 1 );
44524454 break ;
44534455 }
44544456 }
@@ -5453,11 +5455,11 @@ static void collect_source_defines(const char *input_file) {
54535455 char * rd = NULL ;
54545456 if (has_unclosed_block_comment (p , & rd )) {
54555457 in_block_comment = true;
5456- } else if (rd ) {
5458+ } else if (rd && cond_depth == 0 ) {
54575459 in_raw_string = true;
54585460 raw_delim = rd ;
54595461 raw_delim_len = (int )strlen (rd );
5460- }
5462+ } else free ( rd );
54615463 }
54625464 continue ;
54635465 }
@@ -5484,18 +5486,23 @@ static void collect_source_defines(const char *input_file) {
54845486 char * rd = NULL ;
54855487 if (has_unclosed_block_comment (p , & rd ))
54865488 in_block_comment = true;
5487- else if (rd ) { in_raw_string = true; raw_delim = rd ; raw_delim_len = (int )strlen (rd ); }
5489+ else if (rd && cond_depth == 0 ) { in_raw_string = true; raw_delim = rd ; raw_delim_len = (int )strlen (rd ); }
5490+ else free (rd );
54885491 goto check_continuation ;
54895492 }
54905493 goto have_hash ;
54915494 }
54925495 // Non-preprocessor, non-blank line — scan for mid-line
54935496 // block comment or raw string that spans subsequent lines.
5497+ // Raw string detection suppressed inside #if/#ifdef blocks:
5498+ // the C preprocessor doesn't lex tokens in dead branches,
5499+ // so R"(...)" containing #endif would desync nesting.
54945500 {
54955501 char * rd = NULL ;
54965502 if (has_unclosed_block_comment (p , & rd ))
54975503 in_block_comment = true;
5498- else if (rd ) { in_raw_string = true; raw_delim = rd ; raw_delim_len = (int )strlen (rd ); }
5504+ else if (rd && cond_depth == 0 ) { in_raw_string = true; raw_delim = rd ; raw_delim_len = (int )strlen (rd ); }
5505+ else free (rd );
54995506 }
55005507 goto check_continuation ;
55015508 }
@@ -5729,7 +5736,8 @@ static void collect_source_defines(const char *input_file) {
57295736 char * rd = NULL ;
57305737 if (has_unclosed_block_comment (line , & rd ))
57315738 in_block_comment = true;
5732- else if (rd ) { in_raw_string = true; raw_delim = rd ; raw_delim_len = (int )strlen (rd ); }
5739+ else if (rd && cond_depth == 0 ) { in_raw_string = true; raw_delim = rd ; raw_delim_len = (int )strlen (rd ); }
5740+ else free (rd );
57335741 }
57345742 }
57355743 }
0 commit comments