def warn_float_underflow : Warning<
"magnitude of floating-point constant too small for type %0; minimum is %1">,
InGroup<LiteralRange>;
+def warn_double_const_requires_fp64 : Warning<
+ "double precision constant requires cl_khr_fp64, casting to single precision">;
// C99 variable-length arrays
def ext_vla : Extension<
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);
-
+ if (Ty == Context.DoubleTy) {
+ if (getLangOptions().SinglePrecisionConstants) {
+ ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast);
+ } else if (getLangOptions().OpenCL && !getOpenCLOptions().cl_khr_fp64) {
+ Diag(Tok.getLocation(), diag::warn_double_const_requires_fp64);
+ ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast);
+ }
+ }
} else if (!Literal.isIntegerLiteral()) {
return ExprError();
} else {
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
-void f1(double da) { // expected-error {{requires cl_khr_fp64 extension}}
- double d; // expected-error {{requires cl_khr_fp64 extension}}
+void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+ double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+ (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
}
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
void f2(void) {
double d;
+ (void) 1.0;
}
#pragma OPENCL EXTENSION cl_khr_fp64 : disable
void f3(void) {
- double d; // expected-error {{requires cl_khr_fp64 extension}}
+ double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
}