Author: Oleksandr Tarasiuk Date: 2026-03-24T21:56:09+02:00 New Revision: 0692bd52cb3f7a3c4b27cd788746e8085484792f
URL: https://github.com/llvm/llvm-project/commit/0692bd52cb3f7a3c4b27cd788746e8085484792f DIFF: https://github.com/llvm/llvm-project/commit/0692bd52cb3f7a3c4b27cd788746e8085484792f.diff LOG: [Clang] fix crash in duplicate attribute checking (#188274) Fixes #188259 --- This PR fixes a crash in duplicate attribute checking when arguments have different integer signedness. It changes the check to use `isSameValue` (which uses `compareValues`) instead of `llvm::APSInt` equality. Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaStmtAttr.cpp clang/test/Sema/code_align.c Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a8897c707b9e6..0dbe667e4f07a 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -355,6 +355,7 @@ Bug Fixes in This Version - Fixed a crash when substituting into a non-type template parameter that has a type containing an undeduced placeholder type. - Correctly diagnosing and no longer crashing when ``export module foo`` (without a semicolon) are the final tokens in a module file. (#GH187771) +- Fixed a crash in duplicate attribute checking caused by comparing constant arguments with diff erent integer signedness. (#GH188259) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index 27fd5563cc40e..ef2e900e4dc19 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -422,11 +422,12 @@ static void CheckForDuplicateLoopAttrs(Sema &S, ArrayRef<const Attr *> Attrs) { if (!FirstValue) FirstValue = CAFA->getResultAsAPSInt(); - if (FirstValue != SecondValue) { - S.Diag((*LastFoundItr)->getLocation(), diag::err_loop_attr_conflict) - << *FirstItr; - S.Diag((*FirstItr)->getLocation(), diag::note_previous_attribute); - } + if (llvm::APSInt::isSameValue(*FirstValue, SecondValue)) + continue; + + S.Diag((*LastFoundItr)->getLocation(), diag::err_loop_attr_conflict) + << *FirstItr; + S.Diag((*FirstItr)->getLocation(), diag::note_previous_attribute); } } diff --git a/clang/test/Sema/code_align.c b/clang/test/Sema/code_align.c index 52c5879d3a390..095dcea8cc42e 100644 --- a/clang/test/Sema/code_align.c +++ b/clang/test/Sema/code_align.c @@ -86,6 +86,16 @@ void foo1(int A) [[clang::code_align(9223372036854775808)]] for(int I=0; I<256; ++I) { bar(I); } + // expected-error@+3{{conflicting loop attribute 'clang::code_align}} + // expected-note@+1{{previous attribute is here}} + [[clang::code_align(64)]] + [[clang::code_align(1024ULL)]] + for(int I=0; I<128; ++I) { bar(I); } + + [[clang::code_align(64)]] + [[clang::code_align(64u)]] + for(int I=0; I<128; ++I) { bar(I); } + #ifdef __SIZEOF_INT128__ // expected-error@+1{{'clang::code_align' attribute requires an integer argument which is a constant power of two between 1 and 4096 inclusive; provided argument was '(__int128_t)1311768467294899680ULL << 64'}} [[clang::code_align((__int128_t)0x1234567890abcde0ULL << 64)]] _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
