Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -3266,7 +3266,9 @@ if (Ty == Context.DoubleTy) { if (getLangOpts().SinglePrecisionConstants) { Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get(); - } else if (getLangOpts().OpenCL && !getOpenCLOptions().cl_khr_fp64) { + } else if (getLangOpts().OpenCL && + !((getLangOpts().OpenCLVersion >= 120) || + getOpenCLOptions().cl_khr_fp64)) { Diag(Tok.getLocation(), diag::warn_double_const_requires_fp64); Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get(); } Index: lib/Sema/SemaType.cpp =================================================================== --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -868,7 +868,9 @@ else Result = Context.DoubleTy; - if (S.getLangOpts().OpenCL && !S.getOpenCLOptions().cl_khr_fp64) { + if (S.getLangOpts().OpenCL && + !((S.getLangOpts().OpenCLVersion >= 120) || + S.getOpenCLOptions().cl_khr_fp64)) { S.Diag(DS.getTypeSpecTypeLoc(), diag::err_double_requires_fp64); declarator.setInvalidType(true); } Index: test/SemaOpenCL/extension-fp64-cl1.1.cl =================================================================== --- /dev/null +++ test/SemaOpenCL/extension-fp64-cl1.1.cl @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1 + +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 {{type 'double' requires cl_khr_fp64 extension}} +} Index: test/SemaOpenCL/optional-core-fp64-cl1.2.cl =================================================================== --- /dev/null +++ test/SemaOpenCL/optional-core-fp64-cl1.2.cl @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 +// expected-no-diagnostics + +void f1(double da) { + double d; + (void) 1.0; +} + +#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; +} Index: test/SemaOpenCL/optional-core-fp64-cl2.0.cl =================================================================== --- /dev/null +++ test/SemaOpenCL/optional-core-fp64-cl2.0.cl @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 +// expected-no-diagnostics + +void f1(double da) { + double d; + (void) 1.0; +} + +#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; +}