aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-11-05 18:28:37 +0100
committerJakub Jelinek <jakub@redhat.com>2023-11-05 18:28:37 +0100
commit26cf06941631c86200ac9050774072531477ef68 (patch)
tree7ea4e56629c65179277091a7eaa7cf6e8b0edc78 /gcc
parent0e6f3e9175bddb5cada6571744f33af574232c76 (diff)
downloadgcc-26cf06941631c86200ac9050774072531477ef68.zip
gcc-26cf06941631c86200ac9050774072531477ef68.tar.gz
gcc-26cf06941631c86200ac9050774072531477ef68.tar.bz2
openmp: Adjust handling of __has_attribute (omp::directive)/sequence and add omp::decl
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-family/c-lex.cc16
-rw-r--r--gcc/testsuite/c-c++-common/gomp/attrs-1.c132
-rw-r--r--gcc/testsuite/c-c++-common/gomp/attrs-2.c132
-rw-r--r--gcc/testsuite/c-c++-common/gomp/attrs-3.c24
4 files changed, 115 insertions, 189 deletions
diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc
index 5e457b7..37f466c 100644
--- a/gcc/c-family/c-lex.cc
+++ b/gcc/c-family/c-lex.cc
@@ -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
diff --git a/gcc/testsuite/c-c++-common/gomp/attrs-1.c b/gcc/testsuite/c-c++-common/gomp/attrs-1.c
index e3c0fa6..5ac1158 100644
--- a/gcc/testsuite/c-c++-common/gomp/attrs-1.c
+++ b/gcc/testsuite/c-c++-common/gomp/attrs-1.c
@@ -1,144 +1,96 @@
/* { 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)
diff --git a/gcc/testsuite/c-c++-common/gomp/attrs-2.c b/gcc/testsuite/c-c++-common/gomp/attrs-2.c
index 21abcdd..2dc6a53 100644
--- a/gcc/testsuite/c-c++-common/gomp/attrs-2.c
+++ b/gcc/testsuite/c-c++-common/gomp/attrs-2.c
@@ -1,144 +1,96 @@
/* { 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)
diff --git a/gcc/testsuite/c-c++-common/gomp/attrs-3.c b/gcc/testsuite/c-c++-common/gomp/attrs-3.c
index 5900244..ec81b83 100644
--- a/gcc/testsuite/c-c++-common/gomp/attrs-3.c
+++ b/gcc/testsuite/c-c++-common/gomp/attrs-3.c
@@ -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
@@ -21,6 +25,10 @@
#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
@@ -33,6 +41,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
@@ -45,6 +57,10 @@
#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
@@ -57,6 +73,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
@@ -69,6 +89,10 @@
#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