diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 22e37c4f809ab..a5673931fdbc0 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -454,6 +454,9 @@ def warn_drv_object_size_disabled_O0 : Warning< InGroup, DefaultWarnNoWerror; def warn_drv_deprecated_option : Warning< "option '%0' is deprecated, use '%1' directly instead">, InGroup; +def warn_drv_deprecated_option_release : Warning< + "option '%0' is deprecated and will be removed in a future release">, + InGroup; def warn_ignoring_verify_debuginfo_preserve_export : Warning< "ignoring -fverify-debuginfo-preserve-export=%0 because " "-fverify-debuginfo-preserve wasn't enabled">, diff --git a/clang/include/clang/Driver/Options.h b/clang/include/clang/Driver/Options.h index f9b9632ee7cbe..462fdc2811d9c 100644 --- a/clang/include/clang/Driver/Options.h +++ b/clang/include/clang/Driver/Options.h @@ -37,6 +37,7 @@ enum ClangFlags { FlangOnlyOption = (1 << 16), DXCOption = (1 << 17), Ignored = (1 << 18), + Deprecated = (1 << 19), }; enum ID { diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index ff002553937d4..15ec13a9b992f 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -71,6 +71,11 @@ def FlangOnlyOption : OptionFlag; // FC1Option - This option should be accepted by flang -fc1. def FC1Option : OptionFlag; +// Deprecated - The option is deprecated, but still supported. A +// diagnostic is emitted about the potential for the option to be removed +// in an upcoming release. +def Deprecated : OptionFlag; + // A short name to show in documentation. The name will be interpreted as rST. class DocName { string DocName = name; } @@ -2783,10 +2788,14 @@ def fsycl_device_only : Flag<["-"], "fsycl-device-only">, Flags<[CoreOption]>, HelpText<"Compile SYCL kernels for device">; def fsycl_targets_EQ : CommaJoined<["-"], "fsycl-targets=">, Flags<[NoXarchOption, CC1Option, CoreOption]>, HelpText<"Specify comma-separated list of triples SYCL offloading targets to be supported">; -def fsycl_add_targets_EQ : CommaJoined<["-"], "fsycl-add-targets=">, Flags<[NoXarchOption, CoreOption]>, - HelpText<"Specify comma-separated list of triple and device binary image pairs to add to the final SYCL binary">; -def fsycl_link_targets_EQ : CommaJoined<["-"], "fsycl-link-targets=">, Flags<[NoXarchOption, CC1Option, CoreOption]>, - HelpText<"Specify comma-separated list of triples SYCL offloading targets to produce linked device images">; +def fsycl_add_targets_EQ : CommaJoined<["-"], "fsycl-add-targets=">, + Flags<[NoXarchOption, CoreOption, Deprecated]>, + HelpText<"Specify comma-separated list of triple and device binary image " + "pairs to add to the final SYCL binary (deprecated)">; +def fsycl_link_targets_EQ : CommaJoined<["-"], "fsycl-link-targets=">, + Flags<[NoXarchOption, CC1Option, CoreOption, Deprecated]>, + HelpText<"Specify comma-separated list of triples SYCL offloading targets " + "to produce linked device images (deprecated)">; def fsycl_device_code_split_EQ : Joined<["-"], "fsycl-device-code-split=">, Flags<[CC1Option, CoreOption]>, HelpText<"Perform SYCL device code split: per_kernel (device code module is " "created for each SYCL kernel) | per_source (device code module is created for each source (translation unit)) | off (no device code split). | auto (use heuristic to select the best way of splitting device code). " @@ -4894,9 +4903,12 @@ def fsycl : Flag<["-"], "fsycl">, Flags<[NoXarchOption, CoreOption]>, Group, Flags<[NoXarchOption, CoreOption]>, Group, HelpText<"Disables SYCL kernels compilation for device">; // FIXME: -fsycl-explicit-simd is deprecated. remove it when support is dropped. -def : Flag<["-"], "fsycl-explicit-simd">, Flags<[CoreOption]>, Group, +def : Flag<["-"], "fsycl-explicit-simd">, Flags<[CoreOption, Deprecated]>, + Group, HelpText<"Enable SYCL explicit SIMD extension. (deprecated)">; -def : Flag<["-"], "fno-sycl-explicit-simd">, Flags<[CoreOption]>, Group, +def : Flag<["-"], "fno-sycl-explicit-simd">, + Flags<[CoreOption, Deprecated]>, + Group, HelpText<"Disable SYCL explicit SIMD extension. (deprecated)">; defm sycl_early_optimizations : OptOutCC1FFlag<"sycl-early-optimizations", "Enable", "Disable", " standard optimization pipeline for SYCL device compiler", [CoreOption]>; def fsycl_dead_args_optimization : Flag<["-"], "fsycl-dead-args-optimization">, diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 057c7d3e79689..eb5344b2bedf2 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -293,6 +293,15 @@ InputArgList Driver::ParseArgStrings(ArrayRef ArgStrings, continue; } + // Deprecated options emit a diagnostic about deprecation, but are still + // supported until removed. + if (A->getOption().hasFlag(options::Deprecated)) { + Diag(diag::warn_drv_deprecated_option_release) << A->getAsString(Args); + ContainsError |= Diags.getDiagnosticLevel( + diag::warn_drv_deprecated_option_release, + SourceLocation()) > DiagnosticsEngine::Warning; + } + // Warn about -mcpu= without an argument. if (A->getOption().matches(options::OPT_mcpu_EQ) && A->containsValue("")) { Diag(diag::warn_drv_empty_joined_argument) << A->getAsString(Args); diff --git a/clang/test/Driver/sycl-deprecated.cpp b/clang/test/Driver/sycl-deprecated.cpp new file mode 100644 index 0000000000000..d372e3c6f24b3 --- /dev/null +++ b/clang/test/Driver/sycl-deprecated.cpp @@ -0,0 +1,4 @@ +/// Test for any deprecated options +// RUN: %clangxx -fsycl-explicit-simd %s -### 2>&1 | FileCheck %s -DOPTION=-fsycl-explicit-simd +// RUN: %clangxx -fno-sycl-explicit-simd %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-explicit-simd +// CHECK: option '[[OPTION]]' is deprecated and will be removed in a future release