[llvm-branch-commits] [clang] release/19.x: [AIX] Turn on `#pragma mc_func` check by default (#101336) (PR #101505)
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Aug 2 03:09:52 PDT 2024
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101505
>From 7fa3ba52ba4c918298b67ef74891319464017bf4 Mon Sep 17 00:00:00 2001
From: Qiongsi Wu <274595+qiongsiwu at users.noreply.github.com>
Date: Thu, 1 Aug 2024 09:51:07 -0400
Subject: [PATCH] [AIX] Turn on `#pragma mc_func` check by default (#101336)
https://github.com/llvm/llvm-project/pull/99888 added a check (and
corresponding options) to flag uses of `#pragma mc_func` on AIX.
This PR turns on the check by default.
(cherry picked from commit b9335176db718bf64c72d48107eb9dff28ed979e)
---
clang/include/clang/Driver/Options.td | 4 ++--
clang/include/clang/Lex/PreprocessorOptions.h | 4 ++--
clang/lib/Driver/ToolChains/AIX.cpp | 6 ++----
clang/test/Preprocessor/pragma_mc_func.c | 6 ++++--
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 359a698ea87dd..bed6e7af9dce9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8087,8 +8087,8 @@ def source_date_epoch : Separate<["-"], "source-date-epoch">,
} // let Visibility = [CC1Option]
defm err_pragma_mc_func_aix : BoolFOption<"err-pragma-mc-func-aix",
- PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultFalse,
- PosFlag<SetTrue, [], [ClangOption, CC1Option],
+ PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultTrue,
+ PosFlag<SetTrue, [], [ClangOption],
"Treat uses of #pragma mc_func as errors">,
NegFlag<SetFalse,[], [ClangOption, CC1Option],
"Ignore uses of #pragma mc_func">>;
diff --git a/clang/include/clang/Lex/PreprocessorOptions.h b/clang/include/clang/Lex/PreprocessorOptions.h
index 3f7dd9db18ba7..f48b7ecb90e1e 100644
--- a/clang/include/clang/Lex/PreprocessorOptions.h
+++ b/clang/include/clang/Lex/PreprocessorOptions.h
@@ -213,7 +213,7 @@ class PreprocessorOptions {
/// If set, the preprocessor reports an error when processing #pragma mc_func
/// on AIX.
- bool ErrorOnPragmaMcfuncOnAIX = false;
+ bool ErrorOnPragmaMcfuncOnAIX = true;
public:
PreprocessorOptions() : PrecompiledPreambleBytes(0, false) {}
@@ -252,7 +252,7 @@ class PreprocessorOptions {
PrecompiledPreambleBytes.first = 0;
PrecompiledPreambleBytes.second = false;
RetainExcludedConditionalBlocks = false;
- ErrorOnPragmaMcfuncOnAIX = false;
+ ErrorOnPragmaMcfuncOnAIX = true;
}
};
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index fb780fb75651d..0615a8a9e8d17 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -558,10 +558,8 @@ void AIX::addClangTargetOptions(
options::OPT_fno_sized_deallocation))
CC1Args.push_back("-fno-sized-deallocation");
- if (Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix,
- options::OPT_fno_err_pragma_mc_func_aix, false))
- CC1Args.push_back("-ferr-pragma-mc-func-aix");
- else
+ if (!Args.hasFlag(options::OPT_ferr_pragma_mc_func_aix,
+ options::OPT_fno_err_pragma_mc_func_aix, true))
CC1Args.push_back("-fno-err-pragma-mc-func-aix");
}
diff --git a/clang/test/Preprocessor/pragma_mc_func.c b/clang/test/Preprocessor/pragma_mc_func.c
index f0d3e49e5dddc..bf12f7107ff5c 100644
--- a/clang/test/Preprocessor/pragma_mc_func.c
+++ b/clang/test/Preprocessor/pragma_mc_func.c
@@ -1,5 +1,8 @@
+// RUN: not %clang --target=powerpc64-ibm-aix -fsyntax-only %s 2>&1 | FileCheck %s
// RUN: not %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix -fsyntax-only \
// RUN: %s 2>&1 | FileCheck %s
+// RUN: not %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix \
+// RUN: -ferr-pragma-mc-func-aix -fsyntax-only %s 2>&1 | FileCheck %s
#pragma mc_func asm_barrier {"60000000"}
// CHECK: error: #pragma mc_func is not supported
@@ -8,11 +11,10 @@
// RUN: %clang --target=powerpc64-ibm-aix -fno-err-pragma-mc-func-aix -fsyntax-only %s
// RUN: %clang --target=powerpc64-ibm-aix -ferr-pragma-mc-func-aix -fsyntax-only \
// RUN: -fno-err-pragma-mc-func-aix %s
-// RUN: %clang --target=powerpc64-ibm-aix -fsyntax-only %s
// RUN: %clang --target=powerpc64-ibm-aix -Werror=unknown-pragmas \
// RUN: -fno-err-pragma-mc-func-aix -fsyntax-only %s
-// Cases where we have errors or warnings.
+// Cases on a non-AIX target.
// RUN: not %clang --target=powerpc64le-unknown-linux-gnu \
// RUN: -Werror=unknown-pragmas -fno-err-pragma-mc-func-aix -fsyntax-only %s 2>&1 | \
// RUN: FileCheck --check-prefix=UNUSED %s
More information about the llvm-branch-commits
mailing list