forked from OSchip/llvm-project
Diagnose non-power-of-2 arguments to attribute aligned.
llvm-svn: 64700
This commit is contained in:
parent
2a4553ba5f
commit
6e8c07d0ea
|
@ -356,6 +356,8 @@ DIAG(err_as_qualified_auto_decl, ERROR,
|
|||
"automatic variable qualified with an address space")
|
||||
DIAG(err_attribute_annotate_no_string, ERROR,
|
||||
"argument to annotate attribute was not a string literal")
|
||||
DIAG(err_attribute_aligned_not_power_of_two, ERROR,
|
||||
"requested alignment is not a power of 2")
|
||||
DIAG(warn_redeclaration_without_attribute_prev_attribute_ignored, WARNING,
|
||||
"'%0' redeclared without %1 attribute: previous %1 ignored")
|
||||
DIAG(warn_attribute_ignored, WARNING,
|
||||
|
|
|
@ -1218,6 +1218,12 @@ static void HandleAlignedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
|
|||
<< "aligned" << alignmentExpr->getSourceRange();
|
||||
return;
|
||||
}
|
||||
if (!llvm::isPowerOf2_64(Alignment.getZExtValue())) {
|
||||
S.Diag(Attr.getLoc(), diag::err_attribute_aligned_not_power_of_two)
|
||||
<< alignmentExpr->getSourceRange();
|
||||
return;
|
||||
}
|
||||
|
||||
d->addAttr(new AlignedAttr(Alignment.getZExtValue() * 8));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
// RUN: clang -fsyntax-only -verify %s
|
||||
|
||||
int x __attribute__((aligned(3))); // expected-error {{requested alignment is not a power of 2}}
|
Loading…
Reference in New Issue