@@ -1627,28 +1627,22 @@ const llvm::fltSemantics &ASTContext::getFloatTypeSemantics(QualType T) const {
1627
1627
CharUnits ASTContext::getDeclAlign(const Decl *D, bool ForAlignof) const {
1628
1628
unsigned Align = Target->getCharWidth();
1629
1629
1630
- bool UseAlignAttrOnly = false ;
1631
- if (unsigned AlignFromAttr = D->getMaxAlignment()) {
1630
+ const unsigned AlignFromAttr = D->getMaxAlignment() ;
1631
+ if (AlignFromAttr)
1632
1632
Align = AlignFromAttr;
1633
1633
1634
- // __attribute__((aligned)) can increase or decrease alignment
1635
- // *except* on a struct or struct member, where it only increases
1636
- // alignment unless 'packed' is also specified.
1637
- //
1638
- // It is an error for alignas to decrease alignment, so we can
1639
- // ignore that possibility; Sema should diagnose it.
1640
- if (isa<FieldDecl>(D)) {
1641
- UseAlignAttrOnly = D->hasAttr<PackedAttr>() ||
1642
- cast<FieldDecl>(D)->getParent()->hasAttr<PackedAttr>();
1643
- } else {
1644
- UseAlignAttrOnly = true;
1645
- }
1646
- }
1647
- else if (isa<FieldDecl>(D))
1648
- UseAlignAttrOnly =
1649
- D->hasAttr<PackedAttr>() ||
1650
- cast<FieldDecl>(D)->getParent()->hasAttr<PackedAttr>();
1651
-
1634
+ // __attribute__((aligned)) can increase or decrease alignment
1635
+ // *except* on a struct or struct member, where it only increases
1636
+ // alignment unless 'packed' is also specified.
1637
+ //
1638
+ // It is an error for alignas to decrease alignment, so we can
1639
+ // ignore that possibility; Sema should diagnose it.
1640
+ bool UseAlignAttrOnly;
1641
+ if (const FieldDecl *FD = dyn_cast<FieldDecl>(D))
1642
+ UseAlignAttrOnly =
1643
+ FD->hasAttr<PackedAttr>() || FD->getParent()->hasAttr<PackedAttr>();
1644
+ else
1645
+ UseAlignAttrOnly = AlignFromAttr != 0;
1652
1646
// If we're using the align attribute only, just ignore everything
1653
1647
// else about the declaration and its type.
1654
1648
if (UseAlignAttrOnly) {
0 commit comments