Issue |
130452
|
Summary |
[clang][OpenMP] The include file <omp.h> doesn't compile in C89 mode (it uses the "inline" keyword)
|
Labels |
clang
|
Assignees |
|
Reporter |
quake33
|
Hello,
Clang 14.0.6 fails to compile the following program (`main.c`):
```c
#include <omp.h>
int main(void) {
return 0;
}
```
The command producing the error is:
`clang -std=c89 -fopenmp main.c`
The error message is:
```
In file included from main.c:1:
/usr/lib/llvm-14/lib/clang/14.0.6/include/omp.h:493:12: error: unknown type name 'inline'
static inline int omp_is_initial_device(void) { return 1; }
^
1 error generated.
```
I obtained Clang from the official Debian (stable) package.
I think this issue is still relevant today because the keyword `inline` is still written [in the include file <omp.h>](https://github.com/llvm/llvm-project/blob/1649ca5af07a40948ea409ca055330bec1419e72/openmp/runtime/src/include/omp.h.var#L504).
The problem is that `inline` is not a known keyword in C89. Therefore I propose to change [this](https://github.com/llvm/llvm-project/blob/1649ca5af07a40948ea409ca055330bec1419e72/openmp/runtime/src/include/omp.h.var#L502):
```c
# if defined(_OPENMP) && _OPENMP >= 201811
#pragma omp begin declare variant match(device={kind(host)})
static inline int omp_is_initial_device(void) { return 1; }
#pragma omp end declare variant
#pragma omp begin declare variant match(device={kind(nohost)})
static inline int omp_is_initial_device(void) { return 0; }
#pragma omp end declare variant
# endif
```
into this :
```c
# if defined(_OPENMP) && _OPENMP >= 201811
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#pragma omp begin declare variant match(device={kind(host)})
static inline int omp_is_initial_device(void) { return 1; }
#pragma omp end declare variant
#pragma omp begin declare variant match(device={kind(nohost)})
static inline int omp_is_initial_device(void) { return 0; }
#pragma omp end declare variant
# else
#pragma omp begin declare variant match(device={kind(host)})
static int omp_is_initial_device(void) { return 1; }
#pragma omp end declare variant
#pragma omp begin declare variant match(device={kind(nohost)})
static int omp_is_initial_device(void) { return 0; }
#pragma omp end declare variant
# endif
# endif
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs