From c250d23c06bab7a11f97bf362727a098297b4ed8 Mon Sep 17 00:00:00 2001 From: Stepan Dyatkovskiy Date: Tue, 10 Sep 2013 08:37:22 +0000 Subject: [PATCH] Rejected 190391, due to failures on clang-x86_64-darwin11-nobootstrap-RAincremental. llvm-svn: 190393 --- clang/lib/Sema/SemaDeclAttr.cpp | 77 ++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 5eaf073..78640d6 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -3518,24 +3518,77 @@ static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) { // FIXME: Sync this with InitializePredefinedMacros; we need to match int8_t // and friends, at least with glibc. + // FIXME: Make sure 32/64-bit integers don't get defined to types of the wrong + // width on unusual platforms. // FIXME: Make sure floating-point mappings are accurate // FIXME: Support XF and TF types - if (!DestWidth) { + QualType NewTy; + switch (DestWidth) { + case 0: S.Diag(Attr.getLoc(), diag::err_unknown_machine_mode) << Name; return; - } - - QualType NewTy; - - if (IntegerMode) - NewTy = S.Context.getIntTypeForBitwidth(DestWidth, - OldTy->isSignedIntegerType()); - else - NewTy = S.Context.getRealTypeForBitwidth(DestWidth); - - if (NewTy.isNull()) { + default: S.Diag(Attr.getLoc(), diag::err_unsupported_machine_mode) << Name; return; + case 8: + if (!IntegerMode) { + S.Diag(Attr.getLoc(), diag::err_unsupported_machine_mode) << Name; + return; + } + if (OldTy->isSignedIntegerType()) + NewTy = S.Context.SignedCharTy; + else + NewTy = S.Context.UnsignedCharTy; + break; + case 16: + if (!IntegerMode) { + S.Diag(Attr.getLoc(), diag::err_unsupported_machine_mode) << Name; + return; + } + if (OldTy->isSignedIntegerType()) + NewTy = S.Context.ShortTy; + else + NewTy = S.Context.UnsignedShortTy; + break; + case 32: + if (!IntegerMode) + NewTy = S.Context.FloatTy; + else if (OldTy->isSignedIntegerType()) + NewTy = S.Context.IntTy; + else + NewTy = S.Context.UnsignedIntTy; + break; + case 64: + if (!IntegerMode) + NewTy = S.Context.DoubleTy; + else if (OldTy->isSignedIntegerType()) + if (S.Context.getTargetInfo().getLongWidth() == 64) + NewTy = S.Context.LongTy; + else + NewTy = S.Context.LongLongTy; + else + if (S.Context.getTargetInfo().getLongWidth() == 64) + NewTy = S.Context.UnsignedLongTy; + else + NewTy = S.Context.UnsignedLongLongTy; + break; + case 96: + NewTy = S.Context.LongDoubleTy; + break; + case 128: + if (!IntegerMode && &S.Context.getTargetInfo().getLongDoubleFormat() != + &llvm::APFloat::PPCDoubleDouble) { + S.Diag(Attr.getLoc(), diag::err_unsupported_machine_mode) << Name; + return; + } + if (IntegerMode) { + if (OldTy->isSignedIntegerType()) + NewTy = S.Context.Int128Ty; + else + NewTy = S.Context.UnsignedInt128Ty; + } else + NewTy = S.Context.LongDoubleTy; + break; } if (ComplexMode) { -- 2.7.4