Diagnose non-power-of-2 arguments to attribute aligned.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64700 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index a28d0a6..1d83605 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -1218,6 +1218,12 @@
       << "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));
 }