]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Adjust handling of __has_attribute (omp::directive)/sequence and add omp...
authorJakub Jelinek <jakub@redhat.com>
Sun, 5 Nov 2023 17:28:37 +0000 (18:28 +0100)
committerJakub Jelinek <jakub@redhat.com>
Sun, 5 Nov 2023 17:28:37 +0000 (18:28 +0100)
I forgot to tweak c_common_has_attribute for the C++ omp::decl addition and now
also for the C omp::{directive,sequence,decl} addition.

2023-11-05  Jakub Jelinek  <jakub@redhat.com>

* c-lex.cc (c_common_has_attribute): Return 1 for omp::directive
and omp::sequence with -fopenmp or -fopenmp-simd also for C, not
just for C++.  Return 1 for omp::decl with -fopenmp or -fopenmp-simd
for both C and C++.

* c-c++-common/gomp/attrs-1.c: Adjust for omp::directive and
omp::sequence being supported also in C and add tests for omp::decl.
* c-c++-common/gomp/attrs-2.c: Likewise.
* c-c++-common/gomp/attrs-3.c: Add tests for omp::decl.

gcc/c-family/c-lex.cc
gcc/testsuite/c-c++-common/gomp/attrs-1.c
gcc/testsuite/c-c++-common/gomp/attrs-2.c
gcc/testsuite/c-c++-common/gomp/attrs-3.c

index 5e457b78cdd2920a10c61fc0c55bcac0cf398827..37f466c671040f1b9394b8d276e7f178dc0e5010 100644 (file)
@@ -367,15 +367,13 @@ c_common_has_attribute (cpp_reader *pfile, bool std_syntax)
                = get_identifier ((const char *)
                                  cpp_token_as_text (pfile, nxt_token));
              attr_id = canonicalize_attr_name (attr_id);
-             if (c_dialect_cxx ())
-               {
-                 /* OpenMP attributes need special handling.  */
-                 if ((flag_openmp || flag_openmp_simd)
-                     && is_attribute_p ("omp", attr_ns)
-                     && (is_attribute_p ("directive", attr_id)
-                         || is_attribute_p ("sequence", attr_id)))
-                   result = 1;
-               }
+             /* OpenMP attributes need special handling.  */
+             if ((flag_openmp || flag_openmp_simd)
+                 && is_attribute_p ("omp", attr_ns)
+                 && (is_attribute_p ("directive", attr_id)
+                     || is_attribute_p ("sequence", attr_id)
+                     || is_attribute_p ("decl", attr_id)))
+               result = 1;
              if (result)
                attr_name = NULL_TREE;
              else
index e3c0fa6379429a01022f99732fd015760bf696b2..5ac115812250f201208614e66ab947c22f30accf 100644 (file)
 /* { dg-do compile } */
 /* { dg-options "-fopenmp" } */
 
-#if __has_attribute(omp::directive)
-#ifndef __cplusplus
-#error omp::directive supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::directive not supported in C++
-#endif
+#if !__has_attribute(omp::directive)
+#error omp::directive not supported in C/C++
 #endif
 
-#if __has_attribute(omp::sequence)
-#ifndef __cplusplus
-#error omp::sequence supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::sequence not supported in C++
+#if !__has_attribute(omp::sequence)
+#error omp::sequence not supported in C/C++
 #endif
+
+#if !__has_attribute(omp::decl)
+#error omp::decl not supported in C/C++
 #endif
 
 #if __has_attribute(omp::unknown)
 #error omp::unknown supported
 #endif
 
-#if __has_cpp_attribute(omp::directive)
-#ifndef __cplusplus
-#error omp::directive supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::directive not supported in C++
-#endif
+#if !__has_cpp_attribute(omp::directive)
+#error omp::directive not supported in C/C++
 #endif
 
-#if __has_cpp_attribute(omp::sequence)
-#ifndef __cplusplus
-#error omp::sequence supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::sequence not supported in C++
+#if !__has_cpp_attribute(omp::sequence)
+#error omp::sequence not supported in C/C++
 #endif
+
+#if !__has_cpp_attribute(omp::decl)
+#error omp::sequence not supported in C/C++
 #endif
 
 #if __has_cpp_attribute(omp::unknown)
 #error omp::unknown supported
 #endif
 
-#if __has_attribute(__omp__::__directive__)
-#ifndef __cplusplus
-#error __omp__::__directive__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::__directive__ not supported in C++
-#endif
+#if !__has_attribute(__omp__::__directive__)
+#error __omp__::__directive__ not supported in C/C++
 #endif
 
-#if __has_attribute(__omp__::__sequence__)
-#ifndef __cplusplus
-#error __omp__::__sequence__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::__sequence__ not supported in C++
+#if !__has_attribute(__omp__::__sequence__)
+#error __omp__::__sequence__ not supported in C/C++
 #endif
+
+#if !__has_attribute(__omp__::__decl__)
+#error __omp__::__decl__ not supported in C/C++
 #endif
 
 #if __has_attribute(__omp__::__unknown__)
 #error __omp__::__unknown__ supported
 #endif
 
-#if __has_cpp_attribute(__omp__::__directive__)
-#ifndef __cplusplus
-#error __omp__::__directive__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::__directive__ not supported in C++
-#endif
+#if !__has_cpp_attribute(__omp__::__directive__)
+#error __omp__::__directive__ not supported in C/C++
 #endif
 
-#if __has_cpp_attribute(__omp__::__sequence__)
-#ifndef __cplusplus
-#error __omp__::__sequence__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::__sequence__ not supported in C++
+#if !__has_cpp_attribute(__omp__::__sequence__)
+#error __omp__::__sequence__ not supported in C/C++
 #endif
+
+#if !__has_cpp_attribute(__omp__::__decl__)
+#error __omp__::__decl__ not supported in C/C++
 #endif
 
 #if __has_cpp_attribute(__omp__::__unknown__)
 #error __omp__::__unknown__ supported
 #endif
 
-#if __has_attribute(omp::__directive__)
-#ifndef __cplusplus
-#error omp::__directive__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::__directive__ not supported in C++
-#endif
+#if !__has_attribute(omp::__directive__)
+#error omp::__directive__ not supported in C/C++
 #endif
 
-#if __has_attribute(__omp__::sequence)
-#ifndef __cplusplus
-#error __omp__::sequence supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::sequence not supported in C++
+#if !__has_attribute(__omp__::sequence)
+#error __omp__::sequence not supported in C/C++
 #endif
+
+#if !__has_attribute(omp::__decl__)
+#error omp::__decl__ not supported in C/C++
 #endif
 
 #if __has_attribute(omp::__unknown__)
 #error omp::__unknown__ supported
 #endif
 
-#if __has_cpp_attribute(__omp__::directive)
-#ifndef __cplusplus
-#error __omp__::directive supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::directive not supported in C++
-#endif
+#if !__has_cpp_attribute(__omp__::directive)
+#error __omp__::directive not supported in C/C++
 #endif
 
-#if __has_cpp_attribute(omp::__sequence__)
-#ifndef __cplusplus
-#error omp::__sequence__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::__sequence__ not supported in C++
+#if !__has_cpp_attribute(omp::__sequence__)
+#error omp::__sequence__ not supported in C/C++
 #endif
+
+#if !__has_cpp_attribute(__omp__::decl)
+#error __omp__::decl not supported in C/C++
 #endif
 
 #if __has_cpp_attribute(__omp__::unknown)
index 21abcddcd34e4cd9421ca76239e36088ca623938..2dc6a531f20b056c8976477139065a22b12dec7e 100644 (file)
 /* { dg-do compile } */
 /* { dg-options "-fno-openmp -fopenmp-simd" } */
 
-#if __has_attribute(omp::directive)
-#ifndef __cplusplus
-#error omp::directive supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::directive not supported in C++
-#endif
+#if !__has_attribute(omp::directive)
+#error omp::directive not supported in C/C++
 #endif
 
-#if __has_attribute(omp::sequence)
-#ifndef __cplusplus
-#error omp::sequence supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::sequence not supported in C++
+#if !__has_attribute(omp::sequence)
+#error omp::sequence not supported in C/C++
 #endif
+
+#if !__has_attribute(omp::decl)
+#error omp::decl not supported in C/C++
 #endif
 
 #if __has_attribute(omp::unknown)
 #error omp::unknown supported
 #endif
 
-#if __has_cpp_attribute(omp::directive)
-#ifndef __cplusplus
-#error omp::directive supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::directive not supported in C++
-#endif
+#if !__has_cpp_attribute(omp::directive)
+#error omp::directive not supported in C/C++
 #endif
 
-#if __has_cpp_attribute(omp::sequence)
-#ifndef __cplusplus
-#error omp::sequence supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::sequence not supported in C++
+#if !__has_cpp_attribute(omp::sequence)
+#error omp::sequence not supported in C/C++
 #endif
+
+#if !__has_cpp_attribute(omp::decl)
+#error omp::sequence not supported in C/C++
 #endif
 
 #if __has_cpp_attribute(omp::unknown)
 #error omp::unknown supported
 #endif
 
-#if __has_attribute(__omp__::__directive__)
-#ifndef __cplusplus
-#error __omp__::__directive__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::__directive__ not supported in C++
-#endif
+#if !__has_attribute(__omp__::__directive__)
+#error __omp__::__directive__ not supported in C/C++
 #endif
 
-#if __has_attribute(__omp__::__sequence__)
-#ifndef __cplusplus
-#error __omp__::__sequence__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::__sequence__ not supported in C++
+#if !__has_attribute(__omp__::__sequence__)
+#error __omp__::__sequence__ not supported in C/C++
 #endif
+
+#if !__has_attribute(__omp__::__decl__)
+#error __omp__::__decl__ not supported in C/C++
 #endif
 
 #if __has_attribute(__omp__::__unknown__)
 #error __omp__::__unknown__ supported
 #endif
 
-#if __has_cpp_attribute(__omp__::__directive__)
-#ifndef __cplusplus
-#error __omp__::__directive__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::__directive__ not supported in C++
-#endif
+#if !__has_cpp_attribute(__omp__::__directive__)
+#error __omp__::__directive__ not supported in C/C++
 #endif
 
-#if __has_cpp_attribute(__omp__::__sequence__)
-#ifndef __cplusplus
-#error __omp__::__sequence__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::__sequence__ not supported in C++
+#if !__has_cpp_attribute(__omp__::__sequence__)
+#error __omp__::__sequence__ not supported in C/C++
 #endif
+
+#if !__has_cpp_attribute(__omp__::__decl__)
+#error __omp__::__decl__ not supported in C/C++
 #endif
 
 #if __has_cpp_attribute(__omp__::__unknown__)
 #error __omp__::__unknown__ supported
 #endif
 
-#if __has_attribute(omp::__directive__)
-#ifndef __cplusplus
-#error omp::__directive__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::__directive__ not supported in C++
-#endif
+#if !__has_attribute(omp::__directive__)
+#error omp::__directive__ not supported in C/C++
 #endif
 
-#if __has_attribute(__omp__::sequence)
-#ifndef __cplusplus
-#error __omp__::sequence supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::sequence not supported in C++
+#if !__has_attribute(__omp__::sequence)
+#error __omp__::sequence not supported in C/C++
 #endif
+
+#if !__has_attribute(omp::__decl__)
+#error omp::__decl__ not supported in C/C++
 #endif
 
 #if __has_attribute(omp::__unknown__)
 #error omp::__unknown__ supported
 #endif
 
-#if __has_cpp_attribute(__omp__::directive)
-#ifndef __cplusplus
-#error __omp__::directive supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error __omp__::directive not supported in C++
-#endif
+#if !__has_cpp_attribute(__omp__::directive)
+#error __omp__::directive not supported in C/C++
 #endif
 
-#if __has_cpp_attribute(omp::__sequence__)
-#ifndef __cplusplus
-#error omp::__sequence__ supported in C
-#endif
-#else
-#ifdef __cplusplus
-#error omp::__sequence__ not supported in C++
+#if !__has_cpp_attribute(omp::__sequence__)
+#error omp::__sequence__ not supported in C/C++
 #endif
+
+#if !__has_cpp_attribute(__omp__::decl)
+#error __omp__::decl not supported in C/C++
 #endif
 
 #if __has_cpp_attribute(__omp__::unknown)
index 5900244b9f7e8003d88085d586e41990d5c31e5f..ec81b8301006d5eb73d6eccb075113849ff3d89d 100644 (file)
@@ -9,6 +9,10 @@
 #error omp::sequence supported even when -fno-openmp{,-simd}
 #endif
 
+#if __has_attribute(omp::decl)
+#error omp::decl supported even when -fno-openmp{,-simd}
+#endif
+
 #if __has_attribute(omp::unknown)
 #error omp::unknown supported
 #endif
 #error omp::sequence supported even when -fno-openmp{,-simd}
 #endif
 
+#if __has_cpp_attribute(omp::decl)
+#error omp::decl supported even when -fno-openmp{,-simd}
+#endif
+
 #if __has_cpp_attribute(omp::unknown)
 #error omp::unknown supported
 #endif
 #error __omp__::__sequence__ supported even when -fno-openmp{,-simd}
 #endif
 
+#if __has_attribute(__omp__::__decl__)
+#error __omp__::__decl__ supported even when -fno-openmp{,-simd}
+#endif
+
 #if __has_attribute(__omp__::__unknown__)
 #error __omp__::__unknown__ supported
 #endif
 #error __omp__::__sequence__ supported even when -fno-openmp{,-simd}
 #endif
 
+#if __has_cpp_attribute(__omp__::__decl__)
+#error __omp__::__decl__ supported even when -fno-openmp{,-simd}
+#endif
+
 #if __has_cpp_attribute(__omp__::__unknown__)
 #error __omp__::__unknown__ supported
 #endif
 #error __omp__::sequence supported even when -fno-openmp{,-simd}
 #endif
 
+#if __has_attribute(omp::__decl__)
+#error omp::__decl__ supported even when -fno-openmp{,-simd}
+#endif
+
 #if __has_attribute(omp::__unknown__)
 #error omp::__unknown__ supported
 #endif
 #error omp::__sequence__ supported even when -fno-openmp{,-simd}
 #endif
 
+#if __has_cpp_attribute(__omp__::decl)
+#error __omp__::decl supported even when -fno-openmp{,-simd}
+#endif
+
 #if __has_cpp_attribute(__omp__::unknown)
 #error __omp__::unknown supported
 #endif