https://bugs.llvm.org/show_bug.cgi?id=46273

            Bug ID: 46273
           Summary: [OpenMP5.0] Clang violates OpenMP restrictions on the
                    atomic construct
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Clang Compiler Support
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Hi, I am testing on OpenMP5.0 feature on clang10.0.0, 
and found clang does not conform to the OpenMP5.0 restrictions as below:

Restriction on the atomic Construct(C/C++):
All atomic accesses to the storage locations designated by x throughout the
program are required to have a compatible type.
https://www.openmp.org/spec-html/5.0/openmpsu95.html#x126-4840002.17.7

Test case:
---------------------------
void atomic_wrong ()
{
union {int n; float x;} u;

#pragma omp parallel
{
#pragma omp atomic update
u.n++;

 #pragma omp atomic update
 u.x += 1.0;

 /* Incorrect because the atomic constructs reference the same location
 through incompatible types */
}
}

Test command:
-----------------------------
# clang --version
clang version 10.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
# clang -fopenmp-version=50 -fopenmp -S atomic_restrict.1.c

According to OpenMP5.0 atomic restriction, atomic accesses to the same storage
location required to have a compatible type, clang is expected return an error
message when compile the testcase, but clang compiled success.

I have looked into the clang source code SemaOpenMP.cpp, and found there is no
check about the above OpenMP5.0 atomic restriction in the Class
OpenMPAtomicUpdateChecker, The OpenMP5.0 atomic restriction check should be
implemented by clang for OpenMP5.0 support.

Thanks.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to