diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2010-12-04 01:50:56 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2010-12-04 01:50:56 +0000 |
commit | 0982136cb748f4a842141bf199d133126d6be882 (patch) | |
tree | 30ee87d2a35c1d37c6c1eed58671c20cbce241e4 /lib | |
parent | 61e07861dd3a70c31f658bad8c4b911994e4933b (diff) |
Implement -cl-single-precision-constant
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120877 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 1 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 8795b38a41..7f9d4a560e 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1418,6 +1418,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.DumpVTableLayouts = Args.hasArg(OPT_fdump_vtable_layouts); Opts.SpellChecking = !Args.hasArg(OPT_fno_spell_checking); Opts.NoBitFieldTypeAlign = Args.hasArg(OPT_fno_bitfield_type_align); + Opts.SinglePrecisionConstants = Args.hasArg(OPT_cl_single_precision_constant); Opts.OptimizeSize = 0; // FIXME: Eliminate this dependency. diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 270aa3e06b..177d61cc82 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2394,6 +2394,9 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok) { bool isExact = (result == APFloat::opOK); Res = FloatingLiteral::Create(Context, Val, isExact, Ty, Tok.getLocation()); + if (getLangOptions().SinglePrecisionConstants && Ty == Context.DoubleTy) + ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast); + } else if (!Literal.isIntegerLiteral()) { return ExprError(); } else { |