Skip to content

Commit 324436c

Browse files
authored
[Clang] Fix bugs the way we handle duplicate vs conflicting values with loop attribute 'code_align' (#87372)
#70762 added support for new loop attribute [[clang::code_align()]]. This patch fixes bugs for the test cases below that misses diagnostics due to discontinue to while loop during checking duplicate vs conflicting code_align attribute values in routine CheckForDuplicateLoopAttrs(). [[clang::code_align(4)]] [[clang::code_align(4)]] [[clang::code_align(8)]] for(int I=0; I<128; ++I) { bar(I); } [[clang::code_align(4)]] [[clang::code_align(4)]] [[clang::code_align(8)]] [[clang::code_align(32)]] for(int I=0; I<128; ++I) { bar(I); }
1 parent 83402c3 commit 324436c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

clang/lib/Sema/SemaStmtAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ static void CheckForDuplicateLoopAttrs(Sema &S, ArrayRef<const Attr *> Attrs) {
406406
<< *FirstItr;
407407
S.Diag((*FirstItr)->getLocation(), diag::note_previous_attribute);
408408
}
409-
return;
410409
}
410+
return;
411411
}
412412

413413
static Attr *handleMSConstexprAttr(Sema &S, Stmt *St, const ParsedAttr &A,

clang/test/Sema/code_align.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ void foo1(int A)
6262
[[clang::code_align(64)]] // expected-error{{conflicting loop attribute 'code_align'}}
6363
for(int I=0; I<128; ++I) { bar(I); }
6464

65+
[[clang::code_align(4)]] // expected-note{{previous attribute is here}}
66+
[[clang::code_align(4)]] // OK
67+
[[clang::code_align(8)]] // expected-error{{conflicting loop attribute 'code_align'}}
68+
for(int I=0; I<128; ++I) { bar(I); }
69+
70+
[[clang::code_align(4)]] // expected-note 2{{previous attribute is here}}
71+
[[clang::code_align(4)]] // OK
72+
[[clang::code_align(8)]] // expected-error{{conflicting loop attribute 'code_align'}}
73+
[[clang::code_align(64)]] // expected-error{{conflicting loop attribute 'code_align'}}
74+
for(int I=0; I<128; ++I) { bar(I); }
75+
6576
// expected-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 7}}
6677
[[clang::code_align(7)]]
6778
for(int I=0; I<128; ++I) { bar(I); }
@@ -135,6 +146,17 @@ void code_align_dependent() {
135146
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
136147
for(int I=0; I<128; ++I) { bar(I); }
137148

149+
[[clang::code_align(A)]] // cpp-local-note{{previous attribute is here}}
150+
[[clang::code_align(A)]] // OK
151+
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
152+
for(int I=0; I<128; ++I) { bar(I); }
153+
154+
[[clang::code_align(A)]] // cpp-local-note 2{{previous attribute is here}}
155+
[[clang::code_align(A)]] // OK
156+
[[clang::code_align(C)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
157+
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
158+
for(int I=0; I<128; ++I) { bar(I); }
159+
138160
// cpp-local-error@+1{{'code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was 23}}
139161
[[clang::code_align(B)]]
140162
for(int I=0; I<128; ++I) { bar(I); }

0 commit comments

Comments
 (0)