File tree 3 files changed +81
-0
lines changed
3 files changed +81
-0
lines changed Original file line number Diff line number Diff line change @@ -1173,6 +1173,37 @@ void OmpStructureChecker::Enter(const parser::OpenMPDeclareTargetConstruct &x) {
1173
1173
}
1174
1174
}
1175
1175
1176
+ void OmpStructureChecker::Enter (const parser::OmpDeclareTargetWithList &x) {
1177
+ SymbolSourceMap symbols;
1178
+ GetSymbolsInObjectList (x.v , symbols);
1179
+ for (auto &[symbol, source] : symbols) {
1180
+ const GenericDetails *genericDetails = symbol->detailsIf <GenericDetails>();
1181
+ if (genericDetails) {
1182
+ context_.Say (source,
1183
+ " The procedure '%s' in DECLARE TARGET construct cannot be a generic name." _err_en_US,
1184
+ symbol->name ());
1185
+ genericDetails->specific ();
1186
+ }
1187
+ if (IsProcedurePointer (*symbol)) {
1188
+ context_.Say (source,
1189
+ " The procedure '%s' in DECLARE TARGET construct cannot be a procedure pointer." _err_en_US,
1190
+ symbol->name ());
1191
+ }
1192
+ const SubprogramDetails *entryDetails =
1193
+ symbol->detailsIf <SubprogramDetails>();
1194
+ if (entryDetails && entryDetails->entryScope ()) {
1195
+ context_.Say (source,
1196
+ " The procedure '%s' in DECLARE TARGET construct cannot be an entry name." _err_en_US,
1197
+ symbol->name ());
1198
+ }
1199
+ if (IsStmtFunction (*symbol)) {
1200
+ context_.Say (source,
1201
+ " The procedure '%s' in DECLARE TARGET construct cannot be a statement function." _err_en_US,
1202
+ symbol->name ());
1203
+ }
1204
+ }
1205
+ }
1206
+
1176
1207
void OmpStructureChecker::CheckSymbolNames (
1177
1208
const parser::CharBlock &source, const parser::OmpObjectList &objList) {
1178
1209
for (const auto &ompObject : objList.v ) {
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ class OmpStructureChecker
79
79
void Leave (const parser::OpenMPDeclarativeAllocate &);
80
80
void Enter (const parser::OpenMPDeclareTargetConstruct &);
81
81
void Leave (const parser::OpenMPDeclareTargetConstruct &);
82
+ void Enter (const parser::OmpDeclareTargetWithList &);
82
83
void Enter (const parser::OpenMPExecutableAllocate &);
83
84
void Leave (const parser::OpenMPExecutableAllocate &);
84
85
void Enter (const parser::OpenMPAllocatorsConstruct &);
Original file line number Diff line number Diff line change
1
+ ! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2
+
3
+ module my_module
4
+ interface foo
5
+ subroutine foo_int (a )
6
+ integer :: a
7
+ end subroutine
8
+ subroutine foo_real (a )
9
+ real :: a
10
+ end subroutine
11
+ end interface
12
+ contains
13
+ subroutine bar (N )
14
+ integer :: N
15
+ entry entry1(N)
16
+ end subroutine
17
+ subroutine foobar (N )
18
+ integer :: N
19
+ ! ERROR: The procedure 'entry1' in DECLARE TARGET construct cannot be an entry name.
20
+ ! $omp declare target(bar, entry1)
21
+ call bar(N)
22
+ end subroutine
23
+ end module
24
+
25
+ module other_mod
26
+ abstract interface
27
+ integer function foo (a )
28
+ integer , intent (in ) :: a
29
+ end function
30
+ end interface
31
+ procedure (foo), pointer :: procptr
32
+ ! ERROR: The procedure 'procptr' in DECLARE TARGET construct cannot be a procedure pointer.
33
+ ! $omp declare target(procptr)
34
+ end module
35
+
36
+ subroutine baz (x )
37
+ real , intent (inout ) :: x
38
+ real :: res
39
+ stmtfunc(x) = 4.0 * (x** 3 )
40
+ ! ERROR: The procedure 'stmtfunc' in DECLARE TARGET construct cannot be a statement function.
41
+ ! $omp declare target (stmtfunc)
42
+ res = stmtfunc(x)
43
+ end subroutine
44
+
45
+ program main
46
+ use my_module
47
+ ! ERROR: The procedure 'foo' in DECLARE TARGET construct cannot be a generic name.
48
+ ! $omp declare target(foo)
49
+ end
You can’t perform that action at this time.
0 commit comments