Skip to content

Commit db5b398

Browse files
authored
[clang][OpenMP] 6.0: 'allocatable' variable-category is not valid for C/C++ (#167735)
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.
1 parent 8ae3ac8 commit db5b398

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

clang/include/clang/Basic/OpenMPKinds.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ OPENMP_DEVICE_MODIFIER(device_num)
127127
// Variable-category attributes for 'default' clause.
128128
OPENMP_DEFAULT_VARIABLE_CATEGORY(aggregate)
129129
OPENMP_DEFAULT_VARIABLE_CATEGORY(all)
130-
OPENMP_DEFAULT_VARIABLE_CATEGORY(allocatable)
131130
OPENMP_DEFAULT_VARIABLE_CATEGORY(pointer)
132131
OPENMP_DEFAULT_VARIABLE_CATEGORY(scalar)
133132

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,10 @@ enum DefaultDataSharingAttributes {
7878
/// Not mentioning any Variable category attribute indicates
7979
/// the modifier (DefaultDataSharingAttributes) is for all variables.
8080
enum DefaultDataSharingVCAttributes {
81-
DSA_VC_all = 0, /// for all variables.
82-
DSA_VC_aggregate, /// for aggregate variables.
83-
DSA_VC_allocatable, /// for allocatable variables.
84-
DSA_VC_pointer, /// for pointer variables.
85-
DSA_VC_scalar, /// for scalar variables.
81+
DSA_VC_all = 0, /// for all variables.
82+
DSA_VC_aggregate, /// for aggregate variables.
83+
DSA_VC_pointer, /// for pointer variables.
84+
DSA_VC_scalar, /// for scalar variables.
8685
};
8786

8887
/// Stack for tracking declarations used in OpenMP directives and
@@ -760,11 +759,6 @@ class DSAStackTy {
760759
getTopOfStack().DefaultVCAttr = DSA_VC_all;
761760
getTopOfStack().DefaultAttrVCLoc = VCLoc;
762761
}
763-
/// Set default data sharing variable category attribute to allocatable.
764-
void setDefaultDSAVCAllocatable(SourceLocation VCLoc) {
765-
getTopOfStack().DefaultVCAttr = DSA_VC_allocatable;
766-
getTopOfStack().DefaultAttrVCLoc = VCLoc;
767-
}
768762
/// Set default data sharing variable category attribute to pointer.
769763
void setDefaultDSAVCPointer(SourceLocation VCLoc) {
770764
getTopOfStack().DefaultVCAttr = DSA_VC_pointer;
@@ -1373,11 +1367,6 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
13731367
if (!VD->getType()->isAggregateType())
13741368
IterDA = DSA_none;
13751369
break;
1376-
case DSA_VC_allocatable:
1377-
if (!(VD->getType()->isPointerType() ||
1378-
VD->getType()->isVariableArrayType()))
1379-
IterDA = DSA_none;
1380-
break;
13811370
case DSA_VC_pointer:
13821371
if (!VD->getType()->isPointerType())
13831372
IterDA = DSA_none;

clang/test/OpenMP/parallel_default_messages.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ int main(int argc, char **argv) {
6464
++x;
6565
++y;
6666
}
67+
#pragma omp parallel default(private: allocatable) private(x,y) // expected-error {{wrong variable category specified with modifier private in the default clause}}
68+
{
69+
++x;
70+
++y;
71+
}
6772
#endif
6873
return 0;
6974
}

0 commit comments

Comments
 (0)