Skip to content

[Clang] Fix bug the way we handle duplicate vs conflicting values with loop attribute 'code_align' #87372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaStmtAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ static void CheckForDuplicateLoopAttrs(Sema &S, ArrayRef<const Attr *> Attrs) {
<< *FirstItr;
S.Diag((*FirstItr)->getLocation(), diag::note_previous_attribute);
}
return;
}
return;
}

static Attr *handleMSConstexprAttr(Sema &S, Stmt *St, const ParsedAttr &A,
Expand Down
22 changes: 22 additions & 0 deletions clang/test/Sema/code_align.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ void foo1(int A)
[[clang::code_align(64)]] // expected-error{{conflicting loop attribute 'code_align'}}
for(int I=0; I<128; ++I) { bar(I); }

[[clang::code_align(4)]] // expected-note{{previous attribute is here}}
[[clang::code_align(4)]] // OK
[[clang::code_align(8)]] // expected-error{{conflicting loop attribute 'code_align'}}
for(int I=0; I<128; ++I) { bar(I); }

[[clang::code_align(4)]] // expected-note 2{{previous attribute is here}}
[[clang::code_align(4)]] // OK
[[clang::code_align(8)]] // expected-error{{conflicting loop attribute 'code_align'}}
[[clang::code_align(64)]] // expected-error{{conflicting loop attribute 'code_align'}}
for(int I=0; I<128; ++I) { bar(I); }

// 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}}
[[clang::code_align(7)]]
for(int I=0; I<128; ++I) { bar(I); }
Expand Down Expand Up @@ -135,6 +146,17 @@ void code_align_dependent() {
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
for(int I=0; I<128; ++I) { bar(I); }

[[clang::code_align(A)]] // cpp-local-note{{previous attribute is here}}
[[clang::code_align(A)]] // OK
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
for(int I=0; I<128; ++I) { bar(I); }

[[clang::code_align(A)]] // cpp-local-note 2{{previous attribute is here}}
[[clang::code_align(A)]] // OK
[[clang::code_align(C)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
[[clang::code_align(E)]] // cpp-local-error{{conflicting loop attribute 'code_align'}}
for(int I=0; I<128; ++I) { bar(I); }

// 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}}
[[clang::code_align(B)]]
for(int I=0; I<128; ++I) { bar(I); }
Expand Down