[clang] [llvm] [PowerPC][AIX] Support #pragma comment copyright for AIX (PR #178184)
Sean Perry via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 06:59:07 PST 2026
================
@@ -3284,27 +3289,53 @@ void PragmaCommentHandler::HandlePragma(Preprocessor &PP,
return;
}
- // Verify that this is one of the 5 explicitly listed options.
+ // Verify that this is one of the 6 explicitly listed options.
IdentifierInfo *II = Tok.getIdentifierInfo();
PragmaMSCommentKind Kind =
- llvm::StringSwitch<PragmaMSCommentKind>(II->getName())
- .Case("linker", PCK_Linker)
- .Case("lib", PCK_Lib)
- .Case("compiler", PCK_Compiler)
- .Case("exestr", PCK_ExeStr)
- .Case("user", PCK_User)
- .Default(PCK_Unknown);
+ llvm::StringSwitch<PragmaMSCommentKind>(II->getName())
+ .Case("linker", PCK_Linker)
+ .Case("lib", PCK_Lib)
+ .Case("compiler", PCK_Compiler)
+ .Case("exestr", PCK_ExeStr)
+ .Case("user", PCK_User)
+ .Case("copyright", PCK_Copyright)
+ .Default(PCK_Unknown);
+
if (Kind == PCK_Unknown) {
PP.Diag(Tok.getLocation(), diag::err_pragma_comment_unknown_kind);
return;
}
+ if (PP.getTargetInfo().getTriple().isOSAIX() && (Kind != PCK_Copyright)) {
+ // On AIX, pragma comment linker, lib, compiler, exestr and user are
+ // ignored.
+ PP.Diag(Tok.getLocation(), diag::warn_pragma_comment_ignored)
+ << II->getName();
+ return;
+ }
+
if (PP.getTargetInfo().getTriple().isOSBinFormatELF() && Kind != PCK_Lib) {
PP.Diag(Tok.getLocation(), diag::warn_pragma_comment_ignored)
<< II->getName();
return;
}
+ if (Kind == PCK_Copyright) {
+ if (!PP.getTargetInfo().getTriple().isOSAIX()) {
+ // Restrict pragma comment copyright to AIX targets only.
+ PP.Diag(Tok.getLocation(),
----------------
perry-ca wrote:
Why did you create a new message for this case instead of using `warn_pragma_comment_ignored` like in the other cases for pragma being ignored? I'd use the same message for all of these cases.
https://github.com/llvm/llvm-project/pull/178184
More information about the cfe-commits
mailing list