Skip to content

Commit 55154d6

Browse files
committed
[OpenACC] Enable 'no_create' sema for data construct
Adds tests and enables the 'no_create' clause semantic analysis for the 'data' constuct, so it will no longer report 'not yet implemented'.
1 parent 4eec286 commit 55154d6

File tree

4 files changed

+140
-7
lines changed

4 files changed

+140
-7
lines changed

clang/lib/Sema/SemaOpenACC.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -915,12 +915,6 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitFirstPrivateClause(
915915

916916
OpenACCClause *SemaOpenACCClauseVisitor::VisitNoCreateClause(
917917
SemaOpenACC::OpenACCParsedClause &Clause) {
918-
// Restrictions only properly implemented on 'compute'/'combined' constructs,
919-
// and 'compute'/'combined' constructs are the only construct that can do
920-
// anything with this yet, so skip/treat as unimplemented in this case.
921-
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()) &&
922-
!isOpenACCCombinedDirectiveKind(Clause.getDirectiveKind()))
923-
return isNotImplemented();
924918
// ActOnVar ensured that everything is a valid variable reference, so there
925919
// really isn't anything to do here. GCC does some duplicate-finding, though
926920
// it isn't apparent in the standard where this is justified.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// RUN: %clang_cc1 %s -fopenacc -ast-dump | FileCheck %s
2+
3+
// Test this with PCH.
4+
// RUN: %clang_cc1 %s -fopenacc -emit-pch -o %t %s
5+
// RUN: %clang_cc1 %s -fopenacc -include-pch %t -ast-dump-all | FileCheck %s
6+
7+
#ifndef PCH_HELPER
8+
#define PCH_HELPER
9+
10+
int Global;
11+
short GlobalArray[5];
12+
void NormalUses(float *PointerParam) {
13+
// CHECK: FunctionDecl{{.*}}NormalUses
14+
// CHECK: ParmVarDecl
15+
// CHECK-NEXT: CompoundStmt
16+
17+
#pragma acc data no_create(GlobalArray, PointerParam[Global])
18+
;
19+
// CHECK-NEXT: OpenACCDataConstruct{{.*}} data
20+
// CHECK-NEXT: no_create clause
21+
// CHECK-NEXT: DeclRefExpr{{.*}}'short[5]' lvalue Var{{.*}}'GlobalArray' 'short[5]'
22+
// CHECK-NEXT: ArraySubscriptExpr{{.*}}'float' lvalue
23+
// CHECK-NEXT: ImplicitCastExpr{{.*}} 'float *' <LValueToRValue>
24+
// CHECK-NEXT: DeclRefExpr{{.*}}'float *' lvalue ParmVar{{.*}}'PointerParam' 'float *'
25+
// CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue>
26+
// CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'Global' 'int'
27+
// CHECK-NEXT: NullStmt
28+
}
29+
30+
template<auto &NTTP, typename T, typename U>
31+
void TemplUses(T t, U u) {
32+
// CHECK-NEXT: FunctionTemplateDecl
33+
// CHECK-NEXT: NonTypeTemplateParmDecl {{.*}}referenced 'auto &' depth 0 index 0 NTTP
34+
// CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 1 T
35+
// CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 2 U
36+
// CHECK-NEXT: FunctionDecl{{.*}} TemplUses 'void (T, U)'
37+
// CHECK-NEXT: ParmVarDecl{{.*}} referenced t 'T'
38+
// CHECK-NEXT: ParmVarDecl{{.*}} referenced u 'U'
39+
// CHECK-NEXT: CompoundStmt
40+
41+
42+
#pragma acc data no_create(t) present(NTTP, u)
43+
;
44+
// CHECK-NEXT: OpenACCDataConstruct{{.*}} data
45+
// CHECK-NEXT: no_create clause
46+
// CHECK-NEXT: DeclRefExpr{{.*}}'T' lvalue ParmVar{{.*}} 't' 'T'
47+
// TODO_CHECK-NEXT: present clause
48+
// TODO_CHECK-NEXT: DeclRefExpr{{.*}}'auto' lvalue NonTypeTemplateParm{{.*}} 'NTTP' 'auto &'
49+
// TODO_CHECK-NEXT: DeclRefExpr{{.*}}'U' lvalue ParmVar{{.*}} 'u' 'U'
50+
// CHECK-NEXT: NullStmt
51+
52+
// Check the instantiated versions of the above.
53+
// CHECK-NEXT: FunctionDecl{{.*}} used TemplUses 'void (int, int *)' implicit_instantiation
54+
// CHECK-NEXT: TemplateArgument decl
55+
// CHECK-NEXT: Var{{.*}} 'CEVar' 'const unsigned int'
56+
// CHECK-NEXT: TemplateArgument type 'int'
57+
// CHECK-NEXT: BuiltinType{{.*}} 'int'
58+
// CHECK-NEXT: TemplateArgument type 'int *'
59+
// CHECK-NEXT: PointerType{{.*}} 'int *'
60+
// CHECK-NEXT: BuiltinType{{.*}} 'int'
61+
// CHECK-NEXT: ParmVarDecl{{.*}} used t 'int'
62+
// CHECK-NEXT: ParmVarDecl{{.*}} u 'int *'
63+
// CHECK-NEXT: CompoundStmt
64+
65+
// #pragma acc data no_create(t) present(NTTP, u)
66+
// CHECK-NEXT: OpenACCDataConstruct{{.*}} data
67+
// CHECK-NEXT: no_create clause
68+
// CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue ParmVar{{.*}} 't' 'int'
69+
// TODO_CHECK-NEXT: present clause
70+
// TODO_CHECK-NEXT: SubstNonTypeTemplateParmExpr{{.*}}'const unsigned int' lvalue
71+
// TODO_CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} referenced 'auto &' depth 0 index 0 NTTP
72+
// TODO_CHECK-NEXT: DeclRefExpr{{.*}}'const unsigned int' lvalue Var{{.*}} 'CEVar' 'const unsigned int'
73+
// TODO_CHECK-NEXT: DeclRefExpr{{.*}}'int *' lvalue ParmVar{{.*}} 'u' 'int *'
74+
// CHECK-NEXT: NullStmt
75+
}
76+
77+
void Inst() {
78+
static constexpr unsigned CEVar = 1;
79+
int i;
80+
TemplUses<CEVar>(i, &i);
81+
}
82+
#endif
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// RUN: %clang_cc1 %s -fopenacc -verify
2+
3+
typedef struct IsComplete {
4+
struct S { int A; } CompositeMember;
5+
int ScalarMember;
6+
float ArrayMember[5];
7+
void *PointerMember;
8+
} Complete;
9+
void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete CompositeParam) {
10+
int LocalInt;
11+
short *LocalPointer;
12+
float LocalArray[5];
13+
Complete LocalComposite;
14+
// Check Appertainment:
15+
#pragma acc data no_create(LocalInt)
16+
;
17+
18+
// Valid cases:
19+
#pragma acc data no_create(LocalInt, LocalPointer, LocalArray)
20+
;
21+
#pragma acc data no_create(LocalArray[2:1])
22+
;
23+
24+
#pragma acc data no_create(LocalComposite.ScalarMember, LocalComposite.ScalarMember)
25+
;
26+
27+
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
28+
#pragma acc data no_create(1 + IntParam)
29+
;
30+
31+
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
32+
#pragma acc data no_create(+IntParam)
33+
;
34+
35+
// expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
36+
#pragma acc data no_create(PointerParam[2:])
37+
;
38+
39+
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
40+
#pragma acc data no_create(ArrayParam[2:5])
41+
;
42+
43+
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
44+
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
45+
#pragma acc data no_create((float*)ArrayParam[2:5])
46+
;
47+
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
48+
#pragma acc data no_create((float)ArrayParam[2])
49+
;
50+
51+
// expected-error@+1{{OpenACC 'no_create' clause is not valid on 'exit data' directive}}
52+
#pragma acc exit data no_create(LocalInt)
53+
// expected-error@+1{{OpenACC 'no_create' clause is not valid on 'enter data' directive}}
54+
#pragma acc enter data no_create(LocalInt)
55+
// expected-error@+1{{OpenACC 'no_create' clause is not valid on 'host_data' directive}}
56+
#pragma acc host_data no_create(LocalInt)
57+
;
58+
}

clang/test/SemaOpenACC/data-construct.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ void AtLeastOneOf() {
3232
// expected-warning@+1{{OpenACC clause 'create' not yet implemented}}
3333
#pragma acc data create(Var)
3434
;
35-
// expected-warning@+1{{OpenACC clause 'no_create' not yet implemented}}
3635
#pragma acc data no_create(Var)
3736
;
3837
// expected-warning@+1{{OpenACC clause 'present' not yet implemented}}

0 commit comments

Comments
 (0)