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 @@ -6324,7 +6324,7 @@ << A->getAsString(Args) << TripleStr; } } - if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) { + if (Arg *A = Args.getLastArg(options::OPT_p)) { if (TC.getTriple().isOSAIX()) { CmdArgs.push_back("-pg"); } else if (!TC.getTriple().isOSOpenBSD()) { diff --git a/clang/test/Driver/ibm-profiling.c b/clang/test/Driver/ibm-profiling.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/ibm-profiling.c @@ -0,0 +1,11 @@ +// Check that -pg is disabled on z/OS. +// RUN: %clang 2>&1 -### --target=s390x-none-zos -pg -S %s | FileCheck -check-prefix=FAIL-PG-NAME %s +// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos' + +// Check that -p does not claim to be unused when not linking on AIX. +// RUN: %clang %s -### 2>&1 \ +// RUN: -p \ +// RUN: -S \ +// RUN: --target=powerpc-ibm-aix7.1.0.0 \ +// RUN: | FileCheck --check-prefix=UNUSED %s +// UNUSED-NOT: warning: argument unused during compilation: '-p' diff --git a/clang/test/Driver/zos-profiling-error.c b/clang/test/Driver/zos-profiling-error.c deleted file mode 100644 --- a/clang/test/Driver/zos-profiling-error.c +++ /dev/null @@ -1,2 +0,0 @@ -// RUN: %clang 2>&1 -### --target=s390x-none-zos -pg -S %s | FileCheck -check-prefix=FAIL-PG-NAME %s -// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'