diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -184,6 +184,9 @@ - To match GCC, ``__ppc64__`` is no longer defined on PowerPC64 targets. Use ``__powerpc64__`` instead. +- ``-p`` is rejected for all targets which are not AIX or OpenBSD. ``-p`` led + to an ``-Wunused-command-line-argument`` warning in previous releases. + What's New in Clang |release|? ============================== Some of the major new features and improvements to Clang are listed diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -6214,6 +6214,12 @@ << A->getAsString(Args) << TripleStr; } } + if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) { + if (!TC.getTriple().isOSAIX() && !TC.getTriple().isOSOpenBSD()) { + D.Diag(diag::err_drv_unsupported_opt_for_target) + << A->getAsString(Args) << TripleStr; + } + } if (Args.getLastArg(options::OPT_fapple_kext) || (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType))) diff --git a/clang/test/Driver/p.c b/clang/test/Driver/p.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/p.c @@ -0,0 +1,7 @@ +/// For most targets -p is legacy. We used to report -Wunused-command-line-argument. +// RUN: %clang -### --target=x86_64-unknown-linux-gnu -c -p %s 2>&1 | FileCheck %s --check-prefix=ERR + +// RUN: %clang -### --target=x86_64-unknown-openbsd -c -p %s 2>&1 | FileCheck %s --implicit-check-not=error: +// RUN: %clang -### --target=powerpc64-ibm-aix -c -p %s 2>&1 | FileCheck %s --implicit-check-not=error: + +// ERR: error: unsupported option '-p' for target {{.*}}