diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index d431c0263666ea..cad63fee45703f 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -93,7 +93,8 @@ llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T, bool ForBitField) { // If this is a bool type, or an ExtIntType in a bitfield representation, // map this integer to the target-specified size. - if ((ForBitField && T->isExtIntType()) || R->isIntegerTy(1)) + if ((ForBitField && T->isExtIntType()) || + (!T->isExtIntType() && R->isIntegerTy(1))) return llvm::IntegerType::get(getLLVMContext(), (unsigned)Context.getTypeSize(T)); diff --git a/clang/test/CodeGen/ext-int.c b/clang/test/CodeGen/ext-int.c index 196bb810b61ab5..d8e763283bfd95 100644 --- a/clang/test/CodeGen/ext-int.c +++ b/clang/test/CodeGen/ext-int.c @@ -45,3 +45,16 @@ void OffsetOfTest() { // LIN32: store i32 2097156, i32* %{{.+}} // WIN32: store i32 2097160, i32* %{{.+}} } + +void Size1ExtIntParam(unsigned _ExtInt(1) A) { + // CHECK: define {{.*}}void @Size1ExtIntParam(i1{{.*}} %[[PARAM:.+]]) + // CHECK: %[[PARAM_ADDR:.+]] = alloca i1 + // CHECK: %[[B:.+]] = alloca [5 x i1] + // CHECK: store i1 %[[PARAM]], i1* %[[PARAM_ADDR]] + unsigned _ExtInt(1) B[5]; + + // CHECK: %[[PARAM_LOAD:.+]] = load i1, i1* %[[PARAM_ADDR]] + // CHECK: %[[IDX:.+]] = getelementptr inbounds [5 x i1], [5 x i1]* %[[B]] + // CHECK: store i1 %[[PARAM_LOAD]], i1* %[[IDX]] + B[2] = A; +}