Skip to content

Commit 656d022

Browse files
committed
Stop emit incomplete type error for a variable in a map clause
where should not. Currently we are using QTy->isIncompleteType(&ND) to check incomplete type. But before doing that, need to instantiate for a class template specialization or a class member of a class template specialization, or an array with known size of such..., so that we know it is really incomplete type. To fix this using RequireCompleteType instead. The new test is added into "test/OpenMP/target_update_messages.cpp" The different of using RequireCompleteType is when emit incomplete type, an additional note is also emitted to point to where incomplete type is declared. Because this change, many tests are needed to be fixed by adding additional note. This is to fix https://bugs.llvm.org/show_bug.cgi?id=50508 Differential Revision: https://reviews.llvm.org/D107200
1 parent 033ca45 commit 656d022

File tree

53 files changed

+76
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+76
-56
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18443,11 +18443,8 @@ OMPClause *Sema::ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier,
1844318443
static bool checkTypeMappable(SourceLocation SL, SourceRange SR, Sema &SemaRef,
1844418444
DSAStackTy *Stack, QualType QTy,
1844518445
bool FullCheck = true) {
18446-
NamedDecl *ND;
18447-
if (QTy->isIncompleteType(&ND)) {
18448-
SemaRef.Diag(SL, diag::err_incomplete_type) << QTy << SR;
18446+
if (SemaRef.RequireCompleteType(SL, QTy, diag::err_incomplete_type))
1844918447
return false;
18450-
}
1845118448
if (FullCheck && !SemaRef.CurContext->isDependentContext() &&
1845218449
!QTy.isTriviallyCopyableType(SemaRef.Context))
1845318450
SemaRef.Diag(SL, diag::warn_omp_non_trivial_type_mapped) << QTy << SR;

clang/test/OpenMP/distribute_firstprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ bool foobool(int argc) {
99
return argc;
1010
}
1111

12-
struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
12+
struct S1; // expected-note {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
1313
extern S1 a;
1414
class S2 {
1515
mutable int a;

clang/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void xxx(int argc) {
1818

1919
extern int omp_default_mem_alloc;
2020

21-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
21+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
2222
extern S1 a;
2323
class S2 {
2424
mutable int a;

clang/test/OpenMP/distribute_parallel_for_lastprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ bool foobool(int argc) {
1111
return argc;
1212
}
1313
extern int omp_default_mem_alloc;
14-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
14+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
1515
extern S1 a;
1616
class S2 {
1717
mutable int a;

clang/test/OpenMP/distribute_parallel_for_reduction_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void foobar(int &ref) {
3636
foo();
3737
}
3838

39-
struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
39+
struct S1; // expected-note {{declared here}} expected-note 6 {{forward declaration of 'S1'}}
4040
extern S1 a;
4141
class S2 {
4242
mutable int a;

clang/test/OpenMP/distribute_parallel_for_shared_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
44

55

6-
struct S1; // expected-note 2 {{declared here}}
6+
struct S1; // expected-note 2 {{declared here}} // expected-note 2 {{forward declaration of 'S1'}}
77
extern S1 a;
88
class S2 {
99
mutable int a;

clang/test/OpenMP/distribute_parallel_for_simd_aligned_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ template<int LEN> int test_warn() {
102102
return 0;
103103
}
104104

105-
struct S1; // expected-note 2 {{declared here}}
105+
struct S1; // expected-note 2 {{declared here}} // expected-note {{forward declaration of 'S1'}}
106106
extern S1 a; // expected-note {{'a' declared here}}
107107
class S2 {
108108
mutable int a;

clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void xxx(int argc) {
1717
;
1818
}
1919

20-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
20+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
2121
extern S1 a;
2222
class S2 {
2323
mutable int a;

clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bool foobool(int argc) {
1212
return argc;
1313
}
1414

15-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
15+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
1616
extern S1 a;
1717
class S2 {
1818
mutable int a;

clang/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ template<int LEN> int test_warn() {
116116
return ind2;
117117
}
118118

119-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
119+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
120120
extern S1 a;
121121
class S2 {
122122
mutable int a;

clang/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void foobar(int &ref) {
3535
foo();
3636
}
3737

38-
struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
38+
struct S1; // expected-note {{declared here}} expected-note 6 {{forward declaration of 'S1'}}
3939
extern S1 a;
4040
class S2 {
4141
mutable int a;

clang/test/OpenMP/distribute_parallel_for_simd_shared_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
44

55

6-
struct S1; // expected-note 2 {{declared here}}
6+
struct S1; // expected-note 2 {{declared here}} // expected-note 2 {{forward declaration of 'S1'}}
77
extern S1 a;
88
class S2 {
99
mutable int a;

clang/test/OpenMP/distribute_simd_aligned_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ template<int LEN> int test_warn() {
102102
return 0;
103103
}
104104

105-
struct S1; // expected-note 2 {{declared here}}
105+
struct S1; // expected-note 2 {{declared here}} // expected-note {{forward declaration of 'S1'}}
106106
extern S1 a; // expected-note {{'a' declared here}}
107107
class S2 {
108108
mutable int a;

clang/test/OpenMP/distribute_simd_firstprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ bool foobool(int argc) {
1010
return argc;
1111
}
1212

13-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
13+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
1414
extern S1 a;
1515
class S2 {
1616
mutable int a;

clang/test/OpenMP/distribute_simd_lastprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bool foobool(int argc) {
1212
return argc;
1313
}
1414

15-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
15+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
1616
extern S1 a;
1717
class S2 {
1818
mutable int a;

clang/test/OpenMP/distribute_simd_linear_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ template<int LEN> int test_warn() {
116116
return ind2;
117117
}
118118

119-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
119+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
120120
extern S1 a;
121121
class S2 {
122122
mutable int a;

clang/test/OpenMP/distribute_simd_reduction_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void foobar(int &ref) {
3535
foo();
3636
}
3737

38-
struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
38+
struct S1; // expected-note {{declared here}} expected-note 6 {{forward declaration of 'S1'}}
3939
extern S1 a;
4040
class S2 {
4141
mutable int a;

clang/test/OpenMP/target_map_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ bool foobool(int argc) {
448448
return argc;
449449
}
450450

451-
struct S1; // expected-note 2 {{declared here}}
451+
struct S1; // expected-note 2 {{declared here}} // expected-note 3 {{forward declaration of 'S1'}}
452452
extern S1 a;
453453
class S2 {
454454
mutable int a;

clang/test/OpenMP/target_parallel_for_map_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void xxx(int argc) {
2020
;
2121
}
2222

23-
struct S1; // expected-note 2 {{declared here}}
23+
struct S1; // expected-note 2 {{declared here}} // expected-note 3 {{forward declaration of 'S1'}}
2424
extern S1 a;
2525
class S2 {
2626
mutable int a;

clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void xxx(int argc) {
2020
;
2121
}
2222

23-
struct S1; // expected-note 2 {{declared here}}
23+
struct S1; // expected-note 2 {{declared here}} // expected-note 3 {{forward declaration of 'S1'}}
2424
extern S1 a;
2525
class S2 {
2626
mutable int a;

clang/test/OpenMP/target_parallel_map_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void xxx(int argc) {
2020
;
2121
}
2222

23-
struct S1; // expected-note 2 {{declared here}}
23+
struct S1; // expected-note 2 {{declared here}} // expected-note 3 {{forward declaration of 'S1'}}
2424
extern S1 a;
2525
class S2 {
2626
mutable int a;

clang/test/OpenMP/target_simd_map_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void xxx(int argc) {
2020
;
2121
}
2222

23-
struct S1; // expected-note 2 {{declared here}}
23+
struct S1; // expected-note 2 {{declared here}} // expected-note 3 {{forward declaration of 'S1'}}
2424
extern S1 a;
2525
class S2 {
2626
mutable int a;

clang/test/OpenMP/target_teams_distribute_map_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void xxx(int argc) {
2020
;
2121
}
2222

23-
struct S1; // expected-note 2 {{declared here}}
23+
struct S1; // expected-note 2 {{declared here}} // expected-note 3 {{forward declaration of 'S1'}}
2424
extern S1 a;
2525
class S2 {
2626
mutable int a;

clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void xxx(int argc) {
1818
;
1919
}
2020

21-
struct S1; // expected-note 2 {{declared here}}
21+
struct S1; // expected-note 2 {{declared here}} // expected-note 3 {{forward declaration of 'S1'}}
2222
extern S1 a;
2323
class S2 {
2424
mutable int a;

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void xxx(int argc) {
2020
;
2121
}
2222

23-
struct S1; // expected-note 2 {{declared here}}
23+
struct S1; // expected-note 2 {{declared here}} // expected-note 3 {{forward declaration of 'S1'}}
2424
extern S1 a;
2525
class S2 {
2626
mutable int a;

clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void xxx(int argc) {
2020
;
2121
}
2222

23-
struct S1; // expected-note 2 {{declared here}}
23+
struct S1; // expected-note 2 {{declared here}} // expected-note 3 {{forward declaration of 'S1'}}
2424
extern S1 a;
2525
class S2 {
2626
mutable int a;

clang/test/OpenMP/target_teams_map_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ bool foobool(int argc) {
335335
return argc;
336336
}
337337

338-
struct S1; // expected-note 2 {{declared here}}
338+
struct S1; // expected-note 2 {{declared here}} // expected-note 3 {{forward declaration of 'S1'}}
339339
extern S1 a;
340340
class S2 {
341341
mutable int a;

clang/test/OpenMP/target_update_from_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bool foobool(int argc) {
1212
return argc;
1313
}
1414

15-
struct S1; // expected-note 2 {{declared here}}
15+
struct S1; // expected-note 2 {{declared here}} // expected-note 2 {{forward declaration of 'S1'}}
1616
extern S1 a;
1717
class S2 {
1818
mutable int a;

clang/test/OpenMP/target_update_messages.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,27 @@ int main(int argc, char **argv) {
185185

186186
return tmain(argc, argv);
187187
}
188+
189+
template<typename _Tp, int _Nm> struct array {
190+
_Tp & operator[](int __n) noexcept;
191+
};
192+
193+
#pragma omp declare target
194+
extern array<double, 4> arr;
195+
#pragma omp end declare target
196+
197+
void copy_host_to_device()
198+
{
199+
#pragma omp target update from(arr) // expected-no-error
200+
arr[0] = 0;
201+
}
202+
203+
struct FOO; // expected-note {{forward declaration of 'FOO'}}
204+
extern FOO a;
205+
template <typename T, int I>
206+
struct bar {
207+
void func() {
208+
#pragma omp target map(to: a) // expected-error {{incomplete type 'FOO' where a complete type is required}}
209+
foo();
210+
}
211+
};

clang/test/OpenMP/target_update_to_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bool foobool(int argc) {
1515
return argc;
1616
}
1717

18-
struct S1; // expected-note 2 {{declared here}}
18+
struct S1; // expected-note 2 {{declared here}} // expected-note 2 {{forward declaration of 'S1'}}
1919
extern S1 a;
2020
class S2 {
2121
mutable int a;

clang/test/OpenMP/teams_distribute_firstprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void xxx(int argc) {
1818
;
1919
}
2020

21-
struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
21+
struct S1; // expected-note {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
2222
extern S1 a;
2323
class S2 {
2424
mutable int a;

clang/test/OpenMP/teams_distribute_lastprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bool foobool(int argc) {
1212
return argc;
1313
}
1414

15-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
15+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
1616
extern S1 a;
1717
class S2 {
1818
mutable int a;

clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void xxx(int argc) {
1818
;
1919
}
2020

21-
struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
21+
struct S1; // expected-note {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
2222
extern S1 a;
2323
class S2 {
2424
mutable int a;

clang/test/OpenMP/teams_distribute_parallel_for_lastprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bool foobool(int argc) {
1212
return argc;
1313
}
1414

15-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
15+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
1616
extern S1 a;
1717
class S2 {
1818
mutable int a;

clang/test/OpenMP/teams_distribute_parallel_for_reduction_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bool foobool(int argc) {
2828
return argc;
2929
}
3030

31-
struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
31+
struct S1; // expected-note {{declared here}} expected-note 6 {{forward declaration of 'S1'}}
3232
extern S1 a;
3333
class S2 {
3434
mutable int a;

clang/test/OpenMP/teams_distribute_parallel_for_shared_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ bool foobool(int argc) {
99
return argc;
1010
}
1111

12-
struct S1; // expected-note {{declared here}}
12+
struct S1; // expected-note {{declared here}} // expected-note {{forward declaration of 'S1'}}
1313
extern S1 a;
1414
class S2 {
1515
mutable int a;

clang/test/OpenMP/teams_distribute_parallel_for_simd_aligned_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ template<int LEN> int test_warn() {
9191
return 0;
9292
}
9393

94-
struct S1; // expected-note 2 {{declared here}}
94+
struct S1; // expected-note 2 {{declared here}} // expected-note {{forward declaration of 'S1'}}
9595
extern S1 a; // expected-note {{'a' declared here}}
9696
class S2 {
9797
mutable int a;

clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void xxx(int argc) {
1919
;
2020
}
2121

22-
struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
22+
struct S1; // expected-note {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
2323
extern S1 a;
2424
class S2 {
2525
mutable int a;

clang/test/OpenMP/teams_distribute_parallel_for_simd_lastprivate_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bool foobool(int argc) {
1212
return argc;
1313
}
1414

15-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
15+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
1616
extern S1 a;
1717
class S2 {
1818
mutable int a;

clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ template<int LEN> int test_warn() {
105105
return ind2;
106106
}
107107

108-
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
108+
struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}}
109109
extern S1 a;
110110
class S2 {
111111
mutable int a;

clang/test/OpenMP/teams_distribute_parallel_for_simd_reduction_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bool foobool(int argc) {
2828
return argc;
2929
}
3030

31-
struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
31+
struct S1; // expected-note {{declared here}} expected-note 6 {{forward declaration of 'S1'}}
3232
extern S1 a;
3333
class S2 {
3434
mutable int a;

0 commit comments

Comments
 (0)