[cfe-commits] r120877 - in /cfe/trunk: include/clang/Basic/LangOptions.h include/clang/Driver/CC1Options.td lib/Frontend/CompilerInvocation.cpp lib/Sema/SemaExpr.cpp test/CodeGen/cl-single-precision-constant.c

Peter Collingbourne peter at pcc.me.uk
Sat Dec 4 11:04:29 PST 2010


On Sat, Dec 04, 2010 at 09:33:10AM +0100, Frits van Bommel wrote:
> On Sat, Dec 4, 2010 at 2:50 AM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> > +def cl_single_precision_constant : Flag<"-cl-single-precision-constant">,
> > +  HelpText<"OpenCL only. Treat double precision floating-point constant as single precision constant.">;
> 
> This claims the option is OpenCL only, but that doesn't seem to be
> checked below:
> 
> > --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Dec  3 19:50:56 2010
> > @@ -2394,6 +2394,9 @@
> >     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 {
> >

Hi Frits,

Using the -cl-* options when compiling non-OpenCL code is undefined
behaviour.  If you're using those options outside of OpenCL then you
should know what you're doing (the options are clearly marked at being
OpenCL only), especially since this is the frontend and not the driver.
Note also that the C++ and Objective C only options are not conditional
on the language.

Thanks,
-- 
Peter



More information about the cfe-commits mailing list