shafik updated this revision to Diff 529714. shafik added a comment. - Add release note
CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152335/new/ https://reviews.llvm.org/D152335 Files: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaDeclAttr.cpp clang/test/Sema/attr-aligned.c Index: clang/test/Sema/attr-aligned.c =================================================================== --- clang/test/Sema/attr-aligned.c +++ clang/test/Sema/attr-aligned.c @@ -1,8 +1,10 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -verify %s int x __attribute__((aligned(3))); // expected-error {{requested alignment is not a power of 2}} int y __attribute__((aligned(1ull << 33))); // expected-error {{requested alignment must be 4294967296 bytes or smaller}} int y __attribute__((aligned(1ull << 32))); +// GH50534 +int z __attribute__((aligned((__int128_t)0x1234567890abcde0ULL << 64))); // expected-error {{requested alignment must be 4294967296 bytes or smaller}} // PR26444 int y __attribute__((aligned(1 << 29))); Index: clang/lib/Sema/SemaDeclAttr.cpp =================================================================== --- clang/lib/Sema/SemaDeclAttr.cpp +++ clang/lib/Sema/SemaDeclAttr.cpp @@ -4473,6 +4473,15 @@ if (ICE.isInvalid()) return; + uint64_t MaximumAlignment = Sema::MaximumAlignment; + if (Context.getTargetInfo().getTriple().isOSBinFormatCOFF()) + MaximumAlignment = std::min(MaximumAlignment, uint64_t(8192)); + if (Alignment > MaximumAlignment) { + Diag(AttrLoc, diag::err_attribute_aligned_too_great) + << MaximumAlignment << E->getSourceRange(); + return; + } + uint64_t AlignVal = Alignment.getZExtValue(); // C++11 [dcl.align]p2: // -- if the constant expression evaluates to zero, the alignment @@ -4487,15 +4496,6 @@ } } - uint64_t MaximumAlignment = Sema::MaximumAlignment; - if (Context.getTargetInfo().getTriple().isOSBinFormatCOFF()) - MaximumAlignment = std::min(MaximumAlignment, uint64_t(8192)); - if (AlignVal > MaximumAlignment) { - Diag(AttrLoc, diag::err_attribute_aligned_too_great) - << MaximumAlignment << E->getSourceRange(); - return; - } - const auto *VD = dyn_cast<VarDecl>(D); if (VD) { unsigned MaxTLSAlign = Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -488,6 +488,8 @@ (`#63010 <https://github.com/llvm/llvm-project/issues/63010>`_). - Fix rejects-valid when consteval operator appears inside of a template. (`#62886 <https://github.com/llvm/llvm-project/issues/62886>`_). +- Fix crash when passing a value larger then 64 bits to the aligned attribute. + (`#50534 <https://github.com/llvm/llvm-project/issues/50534>`_). Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Index: clang/test/Sema/attr-aligned.c =================================================================== --- clang/test/Sema/attr-aligned.c +++ clang/test/Sema/attr-aligned.c @@ -1,8 +1,10 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -verify %s int x __attribute__((aligned(3))); // expected-error {{requested alignment is not a power of 2}} int y __attribute__((aligned(1ull << 33))); // expected-error {{requested alignment must be 4294967296 bytes or smaller}} int y __attribute__((aligned(1ull << 32))); +// GH50534 +int z __attribute__((aligned((__int128_t)0x1234567890abcde0ULL << 64))); // expected-error {{requested alignment must be 4294967296 bytes or smaller}} // PR26444 int y __attribute__((aligned(1 << 29))); Index: clang/lib/Sema/SemaDeclAttr.cpp =================================================================== --- clang/lib/Sema/SemaDeclAttr.cpp +++ clang/lib/Sema/SemaDeclAttr.cpp @@ -4473,6 +4473,15 @@ if (ICE.isInvalid()) return; + uint64_t MaximumAlignment = Sema::MaximumAlignment; + if (Context.getTargetInfo().getTriple().isOSBinFormatCOFF()) + MaximumAlignment = std::min(MaximumAlignment, uint64_t(8192)); + if (Alignment > MaximumAlignment) { + Diag(AttrLoc, diag::err_attribute_aligned_too_great) + << MaximumAlignment << E->getSourceRange(); + return; + } + uint64_t AlignVal = Alignment.getZExtValue(); // C++11 [dcl.align]p2: // -- if the constant expression evaluates to zero, the alignment @@ -4487,15 +4496,6 @@ } } - uint64_t MaximumAlignment = Sema::MaximumAlignment; - if (Context.getTargetInfo().getTriple().isOSBinFormatCOFF()) - MaximumAlignment = std::min(MaximumAlignment, uint64_t(8192)); - if (AlignVal > MaximumAlignment) { - Diag(AttrLoc, diag::err_attribute_aligned_too_great) - << MaximumAlignment << E->getSourceRange(); - return; - } - const auto *VD = dyn_cast<VarDecl>(D); if (VD) { unsigned MaxTLSAlign = Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -488,6 +488,8 @@ (`#63010 <https://github.com/llvm/llvm-project/issues/63010>`_). - Fix rejects-valid when consteval operator appears inside of a template. (`#62886 <https://github.com/llvm/llvm-project/issues/62886>`_). +- Fix crash when passing a value larger then 64 bits to the aligned attribute. + (`#50534 <https://github.com/llvm/llvm-project/issues/50534>`_). Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits