Bug 111758

Summary: #pragma region/endregion fails between if/else
Product: gcc Reporter: Domen Stangar <domen.stangar>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 13.0   
Target Milestone: ---   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85487
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Domen Stangar 2023-10-10 12:08:02 UTC
#include <stdio.h>
int main() {
    #pragma region test
    if(1){}
    #pragma endregion
    else{}
}

gcc 13.x fails with output

<source>: In function 'main':
<source>:7:5: error: 'else' without a previous 'if'
    7 |     else
      |     ^~~~
Compiler returned: 1

while 12.x works fine.
Comment 1 Andrew Pinski 2023-10-10 12:13:47 UTC
Dup of bug 63326.

*** This bug has been marked as a duplicate of bug 63326 ***
Comment 2 Domen Stangar 2023-10-10 12:21:19 UTC
I don't agree. This works fine with 12.x version and bug report is for version 4.9.1.
And this compiles with 4.9.1 version.
Comment 3 Andrew Pinski 2023-10-10 21:17:03 UTC
(In reply to Domen Stangar from comment #2)
> I don't agree. This works fine with 12.x version and bug report is for
> version 4.9.1.
> And this compiles with 4.9.1 version.

yes it might have "worked" in 12.x but these pragma were not recognized until r13-3887-gd3fe767c16e7c528e4fc71c8a68ac14b4573d880 (PR 85487) so you run into the same issue as PR 63326 after that patch.