@@ -2126,6 +2126,7 @@ void PragmaGCCVisibilityHandler::HandlePragma(Preprocessor &PP,
21262126// pack '(' [integer] ')'
21272127// pack '(' 'show' ')'
21282128// pack '(' ('push' | 'pop') [',' identifier] [, integer] ')'
2129+ // pack '(' 'packed' | 'full' | 'twobyte' | 'reset' ')' with -fzos-extensions
21292130void PragmaPackHandler::HandlePragma (Preprocessor &PP,
21302131 PragmaIntroducer Introducer,
21312132 Token &PackTok) {
@@ -2155,10 +2156,35 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP,
21552156 ? Sema::PSK_Push_Set
21562157 : Sema::PSK_Set;
21572158 } else if (Tok.is (tok::identifier)) {
2159+ // Map pragma pack options to pack (integer).
2160+ auto MapPack = [&](const char *Literal) {
2161+ Action = Sema::PSK_Push_Set;
2162+ Alignment = Tok;
2163+ Alignment.setKind (tok::numeric_constant);
2164+ Alignment.setLiteralData (Literal);
2165+ Alignment.setLength (1 );
2166+ };
2167+
21582168 const IdentifierInfo *II = Tok.getIdentifierInfo ();
21592169 if (II->isStr (" show" )) {
21602170 Action = Sema::PSK_Show;
21612171 PP.Lex (Tok);
2172+ } else if (II->isStr (" packed" ) && PP.getLangOpts ().ZOSExt ) {
2173+ // #pragma pack(packed) is the same as #pragma pack(1)
2174+ MapPack (" 1" );
2175+ PP.Lex (Tok);
2176+ } else if (II->isStr (" full" ) && PP.getLangOpts ().ZOSExt ) {
2177+ // #pragma pack(full) is the same as #pragma pack(4)
2178+ MapPack (" 4" );
2179+ PP.Lex (Tok);
2180+ } else if (II->isStr (" twobyte" ) && PP.getLangOpts ().ZOSExt ) {
2181+ // #pragma pack(twobyte) is the same as #pragma pack(2)
2182+ MapPack (" 2" );
2183+ PP.Lex (Tok);
2184+ } else if (II->isStr (" reset" ) && PP.getLangOpts ().ZOSExt ) {
2185+ // #pragma pack(reset) is the same as #pragma pack(pop) on XL
2186+ Action = Sema::PSK_Pop;
2187+ PP.Lex (Tok);
21622188 } else {
21632189 if (II->isStr (" push" )) {
21642190 Action = Sema::PSK_Push;
0 commit comments