Skip to content

Commit 4ddd177

Browse files
committed
clean-up
1 parent af72c8e commit 4ddd177

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

flang/lib/Parser/message.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static llvm::raw_ostream::Colors PrefixColor(Severity severity) {
272272
return llvm::raw_ostream::SAVEDCOLOR;
273273
}
274274

275-
// FIXME: Make these configurable, based on verbosity level.
275+
// TODO: Make these configurable, based on verbosity level.
276276
const int MAX_CONTEXTS_EMITTED = 2;
277277
const bool OMIT_SHARED_CONTEXTS = true;
278278

@@ -282,21 +282,23 @@ void Message::Emit(llvm::raw_ostream &o, const AllCookedSources &allCooked,
282282
const AllSources &sources{allCooked.allSources()};
283283
sources.EmitMessage(o, provenanceRange, ToString(), Prefix(severity()),
284284
PrefixColor(severity()), echoSourceLine);
285+
// Always refers to if the attachment in the loop below is a context.
285286
bool isContext{attachmentIsContext_};
286-
int contextsEmitted{isContext ? 1 : 0};
287+
int contextsEmitted{0};
287288
// Emit attachments.
288289
for (const Message *attachment{attachment_.get()}; attachment;
290+
isContext = attachment->attachmentIsContext_,
289291
attachment = attachment->attachment_.get()) {
290292
Severity severity = isContext ? Severity::Context : attachment->severity();
291293
auto emitAttachment = [&]() {
292294
sources.EmitMessage(o, attachment->GetProvenanceRange(allCooked),
293295
attachment->ToString(), Prefix(severity), PrefixColor(severity),
294296
echoSourceLine);
295297
};
296-
// TODO isContext is not used correctly here.
297-
if (attachment->attachmentIsContext_) {
298+
299+
if (isContext) {
298300
// Truncate the number of contexts emitted.
299-
if (contextsEmitted <= MAX_CONTEXTS_EMITTED) {
301+
if (contextsEmitted < MAX_CONTEXTS_EMITTED) {
300302
emitAttachment();
301303
contextsEmitted += 1;
302304
}

flang/test/Parser/acc-data-statement.f90

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@ program acc_data_test
4141

4242
! Negative tests
4343
! Basic data construct in program body
44-
!$acc data copy(a, b) create(d)
44+
!$acc data copy(a, b) create(d) bogus()
45+
!CHECK: acc-data-statement.f90:
46+
!CHECK-SAME: error: expected end of OpenACC directive
47+
!CHECK-NEXT: !$acc data copy(a, b) create(d) bogus()
48+
!CHECK-NEXT: ^
49+
!CHECK-NEXT: in the context: OpenACC construct
50+
!CHECK-NEXT: !$acc data copy(a, b) create(d) bogus()
51+
!CHECK-NEXT: ^
52+
!CHECK-NEXT: in the context: execution part
53+
!CHECK-NEXT: !$acc data copy(a, b) create(c)
54+
!CHECK-NEXT: ^
4555
a = 1
4656
b = 2
4757
d = a + b
@@ -54,7 +64,6 @@ program acc_data_test
5464
a = a + 1
5565
! !$acc end data
5666
print *, "Inside if block"
57-
! First error in the file.
5867
!CHECK: acc-data-statement.f90:
5968
!CHECK-SAME: error: expected OpenACC end block directive
6069
!CHECK-NEXT: end if
@@ -92,19 +101,19 @@ program acc_data_test
92101
s = s + 1
93102
! !$acc end data
94103
print *, "After nested data"
95-
! !$acc end data
96-
97-
print *, "Program finished"
104+
!$acc end data I forgot to comment this out.
98105
!CHECK: acc-data-statement.f90:
99-
!CHECK-SAME: error: expected OpenACC end block directive
100-
!CHECK-NEXT: contains
101-
!CHECK-NEXT: ^
106+
!CHECK-SAME: error: expected end of OpenACC directive
107+
!CHECK-NEXT: !$acc end data I forgot to comment this out.
108+
!CHECK-NEXT: ^
102109
!CHECK-NEXT: in the context: OpenACC construct
103110
!CHECK-NEXT: !$acc data copy(s)
104111
!CHECK-NEXT: ^
105112
!CHECK-NEXT: in the context: OpenACC construct
106113
!CHECK-NEXT: !$acc data copyin(a)
107114
!CHECK-NEXT: ^
115+
print *, "Program finished"
116+
108117
!CHECK: acc-data-statement.f90:
109118
!CHECK-SAME: error: expected OpenACC end block directive
110119
!CHECK-NEXT: contains
@@ -113,14 +122,14 @@ program acc_data_test
113122
!CHECK-NEXT: !$acc data copyin(a)
114123
!CHECK-NEXT: ^
115124
!CHECK-NEXT: in the context: OpenACC construct
116-
!CHECK-NEXT: !$acc data copy(a, b) create(d)
125+
!CHECK-NEXT: !$acc data copy(a, b) create(d) bogus()
117126
!CHECK-NEXT: ^
118127
!CHECK: acc-data-statement.f90:
119128
!CHECK-SAME: error: expected OpenACC end block directive
120129
!CHECK-NEXT: contains
121130
!CHECK-NEXT: ^
122131
!CHECK-NEXT: in the context: OpenACC construct
123-
!CHECK-NEXT: $acc data copy(a, b) create(d)
132+
!CHECK-NEXT: $acc data copy(a, b) create(d) bogus()
124133
!CHECK-NEXT: ^
125134
!CHECK-NEXT: in the context: execution part
126135
!CHECK-NEXT: !$acc data copy(a, b) create(c)

0 commit comments

Comments
 (0)