[clang] [Clang] Fix bug the way we handle duplicate vs conflicting values wit… (PR #87372)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 2 10:07:49 PDT 2024
https://github.com/smanna12 created https://github.com/llvm/llvm-project/pull/87372
…h loop attribute 'code_align'
https://github.com/llvm/llvm-project/pull/70762 added support for new loop attribute [[clang::code_align()]].
This patch fixes bug for the test case below that misses diagnostic due to discontinue to loop while checking duplicate vs conflicting code_align attribute values.
[[clang::code_align(4)]]
[[clang::code_align(4)]]
[[clang::code_align(8)]]
for(int I=0; I<128; ++I) { bar(I); }
>From 871cc24e5a0ed50665b73847db455d186d5a1ac9 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" <soumi.manna at intel.com>
Date: Tue, 2 Apr 2024 09:55:29 -0700
Subject: [PATCH] [Clang] Fix bug the way we handle duplicate vs conflicting
values with loop attribute 'code_align'
https://github.com/llvm/llvm-project/pull/70762 added support for new loop attribute [[clang::code_align()]].
This patch fixes bug for the test case below that misses diagnostic due to discontinue to loop while checking duplicate vs conflicting code_align attribute values.
[[clang::code_align(4)]]
[[clang::code_align(4)]]
[[clang::code_align(8)]]
for(int I=0; I<128; ++I) { bar(I); }
---
clang/lib/Sema/SemaStmtAttr.cpp | 2 +-
clang/test/Sema/code_align.c | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp
index 691857e88beb49..b6df4ccf9400c7 100644
--- a/clang/lib/Sema/SemaStmtAttr.cpp
+++ b/clang/lib/Sema/SemaStmtAttr.cpp
@@ -405,8 +405,8 @@ static void CheckForDuplicateLoopAttrs(Sema &S, ArrayRef<const Attr *> Attrs) {
S.Diag((*LastFoundItr)->getLocation(), diag::err_loop_attr_conflict)
<< *FirstItr;
S.Diag((*FirstItr)->getLocation(), diag::note_previous_attribute);
+ return;
}
- return;
}
}
diff --git a/clang/test/Sema/code_align.c b/clang/test/Sema/code_align.c
index d494d5ea1558f0..0656358dc367b9 100644
--- a/clang/test/Sema/code_align.c
+++ b/clang/test/Sema/code_align.c
@@ -62,6 +62,11 @@ 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); }
+
// expected-error at +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); }
@@ -135,6 +140,11 @@ 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); }
+
// cpp-local-error at +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); }
More information about the cfe-commits
mailing list