/// \brief Write the state of 'pragma pack' at the end of the module.
void ASTWriter::WritePackPragmaOptions(Sema &SemaRef) {
+ // Don't serialize pragma pack state for modules, since it should only take
+ // effect on a per-submodule basis.
+ if (WritingModule)
+ return;
+
RecordData Record;
Record.push_back(SemaRef.PackStack.CurrentValue);
AddSourceLocation(SemaRef.PackStack.CurrentPragmaLocation, Record);
header "diag_pragma.h"
}
-module pragma_pack_set {
- header "pragma_pack_set.h"
-}
-
-module pragma_pack_push {
- header "pragma_pack_push.h"
-}
-
-module pragma_pack_empty {
- header "empty.h"
-}
-
-module pragma_pack_reset_push {
- header "pragma_pack_reset_push.h"
+module pragma_pack {
+ module set { header "pragma_pack_set.h" }
+ module empty { header "empty.h" }
}
module dummy {
+++ /dev/null
-
-#pragma pack (push, 4)
-#pragma pack (push, 2)
-#pragma pack (push, 1)
-#pragma pack (pop)
-
+++ /dev/null
-
-#pragma pack ()
-#pragma pack (push, 4)
-
+++ /dev/null
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules -fimplicit-module-maps -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=pragma_pack_set %S/Inputs/module.map
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules -fimplicit-module-maps -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=pragma_pack_push %S/Inputs/module.map
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules -fimplicit-module-maps -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=pragma_pack_empty %S/Inputs/module.map
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules -fimplicit-module-maps -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=pragma_pack_reset_push %S/Inputs/module.map
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules -fimplicit-module-maps -x objective-c -verify -fmodules-cache-path=%t -I %S/Inputs %s
-// FIXME: When we have a syntax for modules in C, use that.
-
-@import pragma_pack_set;
-
-#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 1}}
-#pragma pack (pop) // expected-warning {{#pragma pack(pop, ...) failed: stack empty}}
-
-@import pragma_pack_push;
-
-#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 2}}
-#pragma pack (pop)
-#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 4}}
-#pragma pack (pop)
-#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 1}}
-#pragma pack (pop) // expected-warning {{#pragma pack(pop, ...) failed: stack empty}}
-
-#pragma pack (16)
-
-@import pragma_pack_empty;
-
-#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 16}}
-#pragma pack (pop) // expected-warning {{#pragma pack(pop, ...) failed: stack empty}}
-
-@import pragma_pack_reset_push;
-
-#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 4}}
-#pragma pack (pop)
-#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 8}}
-
--- /dev/null
+// RUN: rm -rf %t.cache %tlocal.cache
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules \
+// RUN: -fimplicit-module-maps -x c++ -emit-module \
+// RUN: -fmodules-cache-path=%t.cache \
+// RUN: -fmodule-name=pragma_pack %S/Inputs/module.map
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules \
+// RUN: -fimplicit-module-maps -x c++ -verify \
+// RUN: -fmodules-cache-path=%t.cache \
+// RUN: -I%S/Inputs %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules \
+// RUN: -fmodules-local-submodule-visibility \
+// RUN: -fimplicit-module-maps -x c++ -emit-module \
+// RUN: -fmodules-cache-path=%tlocal.cache \
+// RUN: -fmodule-name=pragma_pack %S/Inputs/module.map
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fmodules \
+// RUN: -fmodules-local-submodule-visibility \
+// RUN: -fimplicit-module-maps -x c++ -verify \
+// RUN: -fmodules-cache-path=%tlocal.cache \
+// RUN: -I%S/Inputs %s
+
+// Check that we don't serialize pragma pack state until/unless including an
+// empty file from the same module (but different submodule) has no effect.
+#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 8}}
+#include "empty.h"
+#pragma pack (show) // expected-warning {{value of #pragma pack(show) == 8}}