QualType ResultTy,
ArrayRef<QualType> Args);
+ /// The maximum alignment, same as in llvm::Value. We duplicate them here
+ /// because that allows us not to duplicate the constants in clang code,
+ /// which we must to since we can't directly use the llvm constants.
+ ///
+ /// This is the greatest alignment value supported by load, store, and alloca
+ /// instructions, and global values.
+ static const unsigned MaxAlignmentExponent = 29;
+ static const unsigned MaximumAlignment = 1u << MaxAlignmentExponent;
+
public:
typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy;
typedef OpaquePtr<TemplateName> TemplateTy;
return;
}
- // Alignment calculations can wrap around if it's greater than 2**29.
- unsigned MaximumAlignment = 536870912;
- if (I > MaximumAlignment)
+ if (I > Sema::MaximumAlignment)
Diag(Arg->getExprLoc(), diag::warn_assume_aligned_too_great)
- << Arg->getSourceRange() << MaximumAlignment;
+ << Arg->getSourceRange() << Sema::MaximumAlignment;
}
}
}
return Diag(TheCall->getBeginLoc(), diag::err_alignment_not_power_of_two)
<< Arg->getSourceRange();
- // Alignment calculations can wrap around if it's greater than 2**29.
- unsigned MaximumAlignment = 536870912;
- if (Result > MaximumAlignment)
+ if (Result > Sema::MaximumAlignment)
Diag(TheCall->getBeginLoc(), diag::warn_assume_aligned_too_great)
- << Arg->getSourceRange() << MaximumAlignment;
+ << Arg->getSourceRange() << Sema::MaximumAlignment;
}
if (NumArgs > 2) {
return;
}
- // Alignment calculations can wrap around if it's greater than 2**29.
- unsigned MaximumAlignment = 536870912;
- if (I > MaximumAlignment)
+ if (I > Sema::MaximumAlignment)
Diag(CI.getLoc(), diag::warn_assume_aligned_too_great)
- << CI.getRange() << MaximumAlignment;
+ << CI.getRange() << Sema::MaximumAlignment;
}
if (OE) {
}
}
- // Alignment calculations can wrap around if it's greater than 2**28.
- unsigned MaxValidAlignment =
- Context.getTargetInfo().getTriple().isOSBinFormatCOFF() ? 8192
- : 268435456;
- if (AlignVal > MaxValidAlignment) {
+ unsigned MaximumAlignment = Sema::MaximumAlignment;
+ if (Context.getTargetInfo().getTriple().isOSBinFormatCOFF())
+ MaximumAlignment = std::min(MaximumAlignment, 8192u);
+ if (AlignVal > MaximumAlignment) {
Diag(AttrLoc, diag::err_attribute_aligned_too_great)
- << MaxValidAlignment << E->getSourceRange();
+ << MaximumAlignment << E->getSourceRange();
return;
}
#if __cplusplus >= 201103L
namespace dr649 { // dr649: yes
- alignas(0x20000000) int n; // expected-error {{requested alignment}}
- struct alignas(0x20000000) X {}; // expected-error {{requested alignment}}
- struct Y { int n alignas(0x20000000); }; // expected-error {{requested alignment}}
+ alignas(0x40000000) int n; // expected-error {{requested alignment}}1
+ struct alignas(0x40000000) X {}; // expected-error {{requested alignment}}
+ struct Y { int n alignas(0x40000000); }; // expected-error {{requested alignment}}
struct alignas(256) Z {};
// This part is superseded by dr2130 and eventually by aligned allocation support.
auto *p = new Z;
// RUN: %clang_cc1 -triple i386-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(1 << 29))); // expected-error {{requested alignment must be 268435456 bytes or smaller}}
+int y __attribute__((aligned(1 << 30))); // expected-error {{requested alignment must be 536870912 bytes or smaller}}
// PR26444
+int y __attribute__((aligned(1 << 29)));
int y __attribute__((aligned(1 << 28)));
// PR3254
short g0[3] __attribute__((aligned));
-short g0_chk[__alignof__(g0) == 16 ? 1 : -1];
+short g0_chk[__alignof__(g0) == 16 ? 1 : -1];
// <rdar://problem/6840045>
typedef char ueber_aligned_char __attribute__((aligned(8)));