[clang] [OpenMP] Support for `nothing` in `metadirective` (PR #73690)

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 28 13:36:26 PST 2023


================
@@ -12,7 +12,6 @@ int mixed() {
     x=d;
   }
 
-// expected-error at +2 {{#pragma omp nothing' cannot be an immediate substatement}}
----------------
alexey-bataev wrote:

@dreachem The problem is, that the compiler has no idea what to do with this code.
`nothing` has no associated structured block, right? If so, then this code is actually this:
```
if (x)
    #pragma omp nothing
f();
```
With OpenMP support, this code represents something like this:
```
if (x)
  ;
f();
```
If we disable OpenMP support, this code will be transformed into this:
```
if (x)
  f();
```
because the directive will be ignored completely.
So, having something like this:
```
if (x)
  #pragma omp nothing
```
should not be allowed, it is not correct program if OpenMP is disabled.
To make it correct, you need to have something like this:
```
if (x) {
  #pragma omp nothing
}
```
This will be correct.
The check, you're trying to remove, checks exactly for such stand-alone directives, which may cause troubles when OpenMP is disabled.

https://github.com/llvm/llvm-project/pull/73690


More information about the cfe-commits mailing list