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(D); if (VD) { unsigned MaxTLSAlign = 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)));