-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang][OpenMP] 6.0: 'allocatable' variable-category is not valid for C/C++ #167735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… C/C++
The variable-category 'allocatable' is explicitly noted as applying only to
Fortran. If specified in C/C++ it should generate an error. NOTE: Issue
will be filed against OpenMP 6.0 specification that restriction is missing
from 'default' clause section.
From the OpenMP 6.0 specification:
Section 7.5.1 default Clause
Semantics, under Fortran only, L18-19, pg. 223
The allocatable variable-category specifies variables with the ALLOCATABLE
attribute.
Section 7.9.9 defaultmap Clause
Semantics, under Fortran only, L9-10, pg. 292
The allocatable variable-category specifies variables with the ALLOCATABLE
attribute.
Restrictions, C/C++
L1, pg. 293
The specified variable-category must not be allocatable.
|
@llvm/pr-subscribers-clang Author: David Pagan (ddpagan) ChangesThe variable-category 'allocatable' is explicitly noted as applying only to Fortran. If specified in C/C++ it should generate an error. NOTE: Issue will be filed against OpenMP 6.0 specification that restriction is missing from 'default' clause section. From the OpenMP 6.0 specification: Section 7.9.9 defaultmap Clause Full diff: https://github.com/llvm/llvm-project/pull/167735.diff 3 Files Affected:
diff --git a/clang/include/clang/Basic/OpenMPKinds.def b/clang/include/clang/Basic/OpenMPKinds.def
index 166b80314f687..da0cbafd05a5b 100644
--- a/clang/include/clang/Basic/OpenMPKinds.def
+++ b/clang/include/clang/Basic/OpenMPKinds.def
@@ -127,7 +127,6 @@ OPENMP_DEVICE_MODIFIER(device_num)
// Variable-category attributes for 'default' clause.
OPENMP_DEFAULT_VARIABLE_CATEGORY(aggregate)
OPENMP_DEFAULT_VARIABLE_CATEGORY(all)
-OPENMP_DEFAULT_VARIABLE_CATEGORY(allocatable)
OPENMP_DEFAULT_VARIABLE_CATEGORY(pointer)
OPENMP_DEFAULT_VARIABLE_CATEGORY(scalar)
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 2ab2fd10a942e..06cc7ec28ae90 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -80,7 +80,6 @@ enum DefaultDataSharingAttributes {
enum DefaultDataSharingVCAttributes {
DSA_VC_all = 0, /// for all variables.
DSA_VC_aggregate, /// for aggregate variables.
- DSA_VC_allocatable, /// for allocatable variables.
DSA_VC_pointer, /// for pointer variables.
DSA_VC_scalar, /// for scalar variables.
};
@@ -760,11 +759,6 @@ class DSAStackTy {
getTopOfStack().DefaultVCAttr = DSA_VC_all;
getTopOfStack().DefaultAttrVCLoc = VCLoc;
}
- /// Set default data sharing variable category attribute to allocatable.
- void setDefaultDSAVCAllocatable(SourceLocation VCLoc) {
- getTopOfStack().DefaultVCAttr = DSA_VC_allocatable;
- getTopOfStack().DefaultAttrVCLoc = VCLoc;
- }
/// Set default data sharing variable category attribute to pointer.
void setDefaultDSAVCPointer(SourceLocation VCLoc) {
getTopOfStack().DefaultVCAttr = DSA_VC_pointer;
@@ -1373,11 +1367,6 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
if (!VD->getType()->isAggregateType())
IterDA = DSA_none;
break;
- case DSA_VC_allocatable:
- if (!(VD->getType()->isPointerType() ||
- VD->getType()->isVariableArrayType()))
- IterDA = DSA_none;
- break;
case DSA_VC_pointer:
if (!VD->getType()->isPointerType())
IterDA = DSA_none;
diff --git a/clang/test/OpenMP/parallel_default_messages.cpp b/clang/test/OpenMP/parallel_default_messages.cpp
index 842b1ac5a96b8..b1d62118e0440 100644
--- a/clang/test/OpenMP/parallel_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_default_messages.cpp
@@ -64,6 +64,11 @@ int main(int argc, char **argv) {
++x;
++y;
}
+#pragma omp parallel default(private: allocatable) private(x,y) // expected-error {{wrong variable category specified with modifier private in the default clause}}
+ {
+ ++x;
+ ++y;
+ }
#endif
return 0;
}
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
The variable-category 'allocatable' is explicitly noted as applying only to Fortran. If specified in C/C++ it should generate an error. NOTE: Issue will be filed against OpenMP 6.0 specification that restriction is missing from 'default' clause section.
From the OpenMP 6.0 specification:
Section 7.5.1 default Clause
Semantics, under Fortran only, L18-19, pg. 223
The allocatable variable-category specifies variables with the ALLOCATABLE
attribute.
Section 7.9.9 defaultmap Clause
Semantics, under Fortran only, L9-10, pg. 292
The allocatable variable-category specifies variables with the ALLOCATABLE
attribute.