diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-07-23 09:50:15 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-07-23 09:50:15 +0200 |
commit | 7f7364108f7441e6bd6f6f79a2d991e4e0f71b28 (patch) | |
tree | 2be09c88daca7fffbe70c1f7dcafa99e168efe23 /gcc/c-family | |
parent | 2c5d803d03209478b4f060785c6f6ba2f0de88ad (diff) | |
download | gcc-7f7364108f7441e6bd6f6f79a2d991e4e0f71b28.zip gcc-7f7364108f7441e6bd6f6f79a2d991e4e0f71b28.tar.gz gcc-7f7364108f7441e6bd6f6f79a2d991e4e0f71b28.tar.bz2 |
openmp: Add support for __has_attribute(omp::directive) and __has_attribute(omp::sequence)
Now that the C++ FE supports these attributes, but not through registering
them in the attributes tables (they work quite differently from other
attributes), this teaches c_common_has_attributes about those.
2021-07-23 Jakub Jelinek <jakub@redhat.com>
* c-lex.c (c_common_has_attribute): Call canonicalize_attr_name also
on attr_id. Return 1 for omp::directive or omp::sequence in C++11
and later.
* c-c++-common/gomp/attrs-1.c: New test.
* c-c++-common/gomp/attrs-2.c: New test.
* c-c++-common/gomp/attrs-3.c: New test.
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/c-lex.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index c44e7a1..4b04e71 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -338,7 +338,20 @@ c_common_has_attribute (cpp_reader *pfile, bool std_syntax) tree attr_id = get_identifier ((const char *) cpp_token_as_text (pfile, nxt_token)); - attr_name = build_tree_list (attr_ns, attr_id); + 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; + } + if (result) + attr_name = NULL_TREE; + else + attr_name = build_tree_list (attr_ns, attr_id); } else { |