def error_cannot_find_suitable_accessor : Error<
"cannot find suitable %select{getter|setter}0 for property %1">;
+def warn_alloca_align_alignof : Warning<
+ "second argument to __builtin_alloca_with_align is supposed to be in bits">;
+
def err_alignment_too_small : Error<
"requested alignment must be %0 or greater">;
def err_alignment_too_big : Error<
return false;
}
-/// Handle __builtin_assume_aligned. This is declared
+/// Handle __builtin_alloca_with_align. This is declared
/// as (size_t, size_t) where the second size_t must be a power of 2 greater
/// than 8.
bool Sema::SemaBuiltinAllocaWithAlign(CallExpr *TheCall) {
// We can't check the value of a dependent argument.
if (!Arg->isTypeDependent() && !Arg->isValueDependent()) {
+ if (const auto *UE =
+ dyn_cast<UnaryExprOrTypeTraitExpr>(Arg->IgnoreParenImpCasts()))
+ if (UE->getKind() == UETT_AlignOf)
+ Diag(TheCall->getLocStart(), diag::warn_alloca_align_alignof)
+ << Arg->getSourceRange();
+
llvm::APSInt Result = Arg->EvaluateKnownConstInt(Context);
if (!Result.isPowerOf2())
void test7(int a) {
__builtin_alloca_with_align(a, 2); // expected-error {{requested alignment must be 8 or greater}}
}
+
+void test8() {
+ __builtin_alloca_with_align(sizeof(__INT64_TYPE__), __alignof__(__INT64_TYPE__)); // expected-warning {{second argument to __builtin_alloca_with_align is supposed to be in bits}}
+}