This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG13ea238b1e1d: [OpenCL] Allow use of double type without extension pragma. (authored by Anastasia). Herald added a subscriber: ldrumm. Herald added a project: clang.
Changed prior to commit: https://reviews.llvm.org/D100980?vs=341833&id=344360#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D100980/new/ https://reviews.llvm.org/D100980 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaType.cpp clang/test/Misc/warning-flags.c clang/test/SemaOpenCL/extensions.cl
Index: clang/test/SemaOpenCL/extensions.cl =================================================================== --- clang/test/SemaOpenCL/extensions.cl +++ clang/test/SemaOpenCL/extensions.cl @@ -1,5 +1,6 @@ // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1 +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL1.1 -DNOPEDANTIC // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64 // Test with a target not supporting fp64. @@ -43,8 +44,20 @@ #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 f1(double da) { +#ifdef NOFP64 +// expected-error@-2 {{type 'double' requires cl_khr_fp64 support}} +#elif !defined(NOPEDANTIC) +// expected-warning@-4{{Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is supported}} +#endif + double d; +#ifdef NOFP64 +// expected-error@-2 {{type 'double' requires cl_khr_fp64 support}} +#elif !defined(NOPEDANTIC) +// expected-warning@-4{{Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is supported}} +#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 +92,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; - #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 +107,11 @@ #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}} +#elif !defined(NOPEDANTIC) +// expected-warning@-4 {{Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is supported}} +#endif } #endif Index: clang/test/Misc/warning-flags.c =================================================================== --- clang/test/Misc/warning-flags.c +++ clang/test/Misc/warning-flags.c @@ -91,4 +91,4 @@ The list of warnings in -Wpedantic should NEVER grow. -CHECK: Number in -Wpedantic (not covered by other -W flags): 26 +CHECK: Number in -Wpedantic (not covered by other -W flags): 27 Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -1524,6 +1524,13 @@ break; case DeclSpec::TST_float: Result = Context.FloatTy; break; case DeclSpec::TST_double: + if (S.getLangOpts().OpenCL) { + if (!S.getOpenCLOptions().isSupported("cl_khr_fp64", S.getLangOpts())) + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_opencl_requires_extension) + << 0 << Context.DoubleTy << "cl_khr_fp64"; + else if (!S.getOpenCLOptions().isAvailableOption("cl_khr_fp64", S.getLangOpts())) + S.Diag(DS.getTypeSpecTypeLoc(), diag::ext_opencl_double_without_pragma); + } if (DS.getTypeSpecWidth() == TypeSpecifierWidth::Long) Result = Context.LongDoubleTy; else Index: clang/lib/Sema/Sema.cpp =================================================================== --- clang/lib/Sema/Sema.cpp +++ clang/lib/Sema/Sema.cpp @@ -366,7 +366,6 @@ "cl_khr_int64_base_atomics cl_khr_int64_extended_atomics"); } - setOpenCLExtensionForType(Context.DoubleTy, "cl_khr_fp64"); #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ if (getOpenCLOptions().isSupported(#Ext, getLangOpts())) { \ Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -10023,6 +10023,9 @@ "invalid prototype, variadic arguments are not allowed in OpenCL">; def err_opencl_requires_extension : Error< "use of %select{type|declaration}0 %1 requires %2 support">; +def ext_opencl_double_without_pragma : Extension< + "Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is" + " supported">; def warn_opencl_generic_address_space_arg : Warning< "passing non-generic address space pointer to %0" " may cause dynamic conversion affecting performance">,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits