Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -8097,7 +8097,7 @@ 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,
PreprocessorOpts<"ErrorOnPragmaMcfuncOnAIX">, DefaultTrue,
PosFlag<SetTrue, [], [ClangOption, CC1Option],
"Treat uses of #pragma mc_func as errors">,
NegFlag<SetFalse,[], [ClangOption, CC1Option],
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Lex/PreprocessorOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down Expand Up @@ -252,7 +252,7 @@ class PreprocessorOptions {
PrecompiledPreambleBytes.first = 0;
PrecompiledPreambleBytes.second = false;
RetainExcludedConditionalBlocks = false;
ErrorOnPragmaMcfuncOnAIX = false;
ErrorOnPragmaMcfuncOnAIX = true;
}
};

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/AIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ void AIX::addClangTargetOptions(
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))
options::OPT_fno_err_pragma_mc_func_aix, true))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the preprocessor has a default value, can we avoid the cc1 option if the value here matches the default value inside the preprocessor, like:

if (Args.hasArg(options::OPT_fno_err_pragma_mc_func_aix))
   CC1Args.push_back("-fno-err-pragma-mc-func-aix");

(no need to pass -ferr-pragma-mc-func-aix as it is the default inside preprocessor.)

Copy link
Contributor Author

@qiongsiwu qiongsiwu Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Code is revised.

I tried the suggested change

if (Args.hasArg(options::OPT_fno_err_pragma_mc_func_aix))
   CC1Args.push_back("-fno-err-pragma-mc-func-aix");

But it does not handle situations like -fno-err-pragma-mc-func-aix -ferr-pragma-mc-func-aix correctly (or a single -ferr-pragma-mc-func-aix). I think we still need to process both flags in the driver, but we only need to pass -fno-err-pragma-mc-func-aix to CC1. Did I miss something?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code is the correct one. Thanks for pointing this out.

CC1Args.push_back("-ferr-pragma-mc-func-aix");
else
CC1Args.push_back("-fno-err-pragma-mc-func-aix");
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Preprocessor/pragma_mc_func.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// 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
#pragma mc_func asm_barrier {"60000000"}
Expand All @@ -8,11 +9,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
Expand Down