Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -16448,7 +16448,22 @@ bool MSBitfieldViolation = Value.ugt(TypeStorageSize) && (IsMsStruct || Context.getTargetInfo().getCXXABI().isMicrosoft()); - if (CStdConstraintViolation || MSBitfieldViolation) { + + bool AIXBitfieldViolation = false; + if (const BuiltinType *BTy = FieldTy.getTypePtr()->getAs()) { + if ((BTy->getKind() == BuiltinType::ULongLong || + BTy->getKind() == BuiltinType::LongLong) && + (unsigned)Value.getZExtValue() > 32 && + Context.getTargetInfo().getTriple().isArch32Bit() && + Context.getTargetInfo().getTriple().getOS() == llvm::Triple::AIX) { + AIXBitfieldViolation = true; + TypeStorageSize = 32; + TypeWidth = 32; + } + } + + if (CStdConstraintViolation || MSBitfieldViolation || + AIXBitfieldViolation) { unsigned DiagWidth = CStdConstraintViolation ? TypeWidth : TypeStorageSize; if (FieldName) Index: clang/test/Layout/aix-oversized-bitfield.cpp =================================================================== --- /dev/null +++ clang/test/Layout/aix-oversized-bitfield.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fsyntax-only -verify -x c++ %s + +// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \ +// RUN: -fsyntax-only %s | \ +// RUN: FileCheck --check-prefix=CHECK64 %s +// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fdump-record-layouts \ +// RUN: -fsyntax-only -x c++ %s | \ +// RUN: FileCheck --check-prefix=CHECK64 %s + +struct A { + long long l : 64; // expected-error{{width of bit-field 'l' (64 bits) exceeds size of its type (32 bits)}} +}; + +int a = sizeof(A); + +// CHECK64: *** Dumping AST Record Layout +// CHECK64-NEXT: 0 | struct A +// CHECK64-NEXT: 0:0-63 | long long l +// CHECK64-NEXT: | [sizeof=8, dsize=8, align=8, preferredalign=8, +// CHECK64-NEXT: | nvsize=8, nvalign=8, preferrednvalign=8]