Index: clang/lib/Sema/Sema.cpp =================================================================== --- clang/lib/Sema/Sema.cpp +++ clang/lib/Sema/Sema.cpp @@ -363,7 +363,6 @@ } } - setOpenCLExtensionForType(Context.DoubleTy, "cl_khr_fp64"); #define GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext) \ setOpenCLExtensionForType(Context.Id, Ext); Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -1524,6 +1524,10 @@ break; case DeclSpec::TST_float: Result = Context.FloatTy; break; case DeclSpec::TST_double: + if (S.getLangOpts().OpenCL && + !S.getOpenCLOptions().isSupported("cl_khr_fp64", S.getLangOpts())) + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension) + << 0 << Context.DoubleTy << "cl_khr_fp64"; if (DS.getTypeSpecWidth() == TypeSpecifierWidth::Long) Result = Context.LongDoubleTy; else Index: clang/test/SemaOpenCL/extensions.cl =================================================================== --- clang/test/SemaOpenCL/extensions.cl +++ clang/test/SemaOpenCL/extensions.cl @@ -43,9 +43,17 @@ #endif #if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120) -void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 support}} - double d; // expected-error {{type 'double' requires cl_khr_fp64 support}} - (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}} +void f1(double da) { +#ifdef NOFP64 +// expected-error@-2 {{type 'double' requires cl_khr_fp64 support}} +#endif + double d; +#ifdef NOFP64 +// expected-error@-2 {{type 'double' requires cl_khr_fp64 support}} +#endif + // FIXME: this diagnostic depends on the extension pragma in the earlier versions. + // There is no indication that this behavior is expected. + (void)1.0; // expected-warning {{double precision constant requires cl_khr_fp64}} } #endif @@ -79,13 +87,11 @@ double4 d4 = {0.0f, 2.0f, 3.0f, 1.0f}; #ifdef NOFP64 // expected-error@-3 {{use of type 'double' requires cl_khr_fp64 support}} -// expected-error@-3 {{use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 support}} #endif - (void) 1.0; - + (void)1.0; #ifdef NOFP64 -// expected-warning@-3{{double precision constant requires cl_khr_fp64, casting to single precision}} +// expected-warning@-2{{double precision constant requires cl_khr_fp64, casting to single precision}} #endif } @@ -96,6 +102,9 @@ #if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 120) void f3(void) { - double d; // expected-error {{type 'double' requires cl_khr_fp64 support}} + double d; +#ifdef NOFP64 +// expected-error@-2 {{type 'double' requires cl_khr_fp64 support}} +#endif } #endif