diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -300,8 +300,11 @@ if (ExplicitType == FloatModeKind::Ibm128) return hasIbm128Type() ? FloatModeKind::Ibm128 : FloatModeKind::NoFloat; - if (ExplicitType == FloatModeKind::LongDouble) - return ExplicitType; + if (&getLongDoubleFormat() == &llvm::APFloat::PPCDoubleDouble() || + &getLongDoubleFormat() == &llvm::APFloat::IEEEquad()) + return FloatModeKind::LongDouble; + if (hasFloat128Type()) + return FloatModeKind::Float128; break; } diff --git a/clang/test/CodeGenCXX/complex128.cpp b/clang/test/CodeGenCXX/complex128.cpp new file mode 100644 --- /dev/null +++ b/clang/test/CodeGenCXX/complex128.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s + +// Define __complex128 type corresponding to __float128 (as in GCC headers). +typedef _Complex float __attribute__((mode(TC))) __complex128; + +void check() { + // CHECK: alloca { fp128, fp128 } + __complex128 tmp; +}