<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57066>57066</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang crashes due to bool redeclaration
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ivanrodriguez3753
      </td>
    </tr>
</table>

<pre>
    ```
/* Visual Studio < 2013 does not have stdbool.h so here it is a replacement: */
#if defined __STDC__ && defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
/* have a C99 compiler */
typedef _Bool bool;
#else
/* do not have a C99 compiler */
typedef unsigned char bool;
#endif
```

When compiling with OpenMP for an AMDGPU, it seems to automatically include `stdbool.h`. 
```
rodriiva> cat test.c
/* Visual Studio < 2013 does not have stdbool.h so here it is a replacement: */
#if defined __STDC__ && defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
/* have a C99 compiler */
typedef _Bool bool;
#else
/* do not have a C99 compiler */
typedef unsigned char bool;
rodriiva> clang -c -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx908 test.c 
test.c:4:15: error: cannot combine with previous 'bool' declaration specifier
typedef _Bool bool;
              ^
lib/clang/16.0.0/include/stdbool.h:20:14: note: expanded from macro 'bool'
#define bool _Bool
             ^
../test.c:4:1: warning: typedef requires a name [-Wmissing-declarations]
typedef _Bool bool;
^~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.
```
There is no error when compiling for the CPU (leave off all openmp flags).
I also noticed that amdclang does not run into this problem (using amdclang from rocm/5.1.0). Is there special handling going on in amdclang that is not going on upstream? 
amdclang shows the desired behavior. That is, amdclang runs into the problem if you modify the testcase to include stdbool.h, that is, prepend `#include stdbool.h` to the testcase.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVU1zozg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