diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -913,6 +913,9 @@ InGroup; def err_pragma_options_align_mac68k_target_unsupported : Error< "mac68k alignment pragma is not supported on this target">; +def warn_pragma_align_not_xl_compatible : Warning< + "#pragma align(packed) may not be compatible with objects generated with AIX XL C/C++">, + InGroup; def warn_pragma_pack_invalid_alignment : Warning< "expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">, InGroup; diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -234,6 +234,8 @@ // Note that '#pragma options align=packed' is not equivalent to attribute // packed, it has a different precedence relative to attribute aligned. case POAK_Packed: + if (this->Context.getTargetInfo().getTriple().isOSAIX()) + Diag(PragmaLoc, diag::warn_pragma_align_not_xl_compatible); Action = Sema::PSK_Push_Set; ModeVal = AlignPackInfo::Packed; break; diff --git a/clang/test/Sema/aix-pragma-align-packed-warn.c b/clang/test/Sema/aix-pragma-align-packed-warn.c new file mode 100644 --- /dev/null +++ b/clang/test/Sema/aix-pragma-align-packed-warn.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -fxl-pragma-pack -verify -fsyntax-only %s +// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -fxl-pragma-pack -verify -fsyntax-only %s + +#pragma align(packed) // expected-warning {{#pragma align(packed) may not be compatible with objects generated with AIX XL C/C++}} +struct A { + int a : 8; + int : 0; + short s; +}; +#pragma align(reset) diff --git a/clang/test/Sema/aix-pragma-pack-and-align.c b/clang/test/Sema/aix-pragma-pack-and-align.c --- a/clang/test/Sema/aix-pragma-pack-and-align.c +++ b/clang/test/Sema/aix-pragma-pack-and-align.c @@ -170,7 +170,7 @@ } // namespace test7 namespace test8 { -#pragma align(packed) +#pragma align(packed) // expected-warning {{#pragma align(packed) may not be compatible with objects generated with AIX XL C/C++}} #pragma pack(2) #pragma pack(show) // expected-warning {{value of #pragma pack(show) == 2}} struct A {