aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/module.cc20
-rw-r--r--gcc/testsuite/g++.dg/modules/class-10_a.H6
-rw-r--r--gcc/testsuite/g++.dg/modules/class-10_b.C19
-rw-r--r--gcc/tree.h8
4 files changed, 49 insertions, 4 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 90ad67d..297ef85bb 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -12379,8 +12379,12 @@ trees_in::read_class_def (tree defn, tree maybe_template)
/* Core pieces. */
TYPE_MODE_RAW (type) = TYPE_MODE_RAW (type_dup);
+ TYPE_ALIGN_RAW (type) = TYPE_ALIGN_RAW (type_dup);
+ TYPE_WARN_IF_NOT_ALIGN_RAW (type)
+ = TYPE_WARN_IF_NOT_ALIGN_RAW (type_dup);
+ TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (type_dup);
+
SET_DECL_MODE (defn, DECL_MODE (maybe_dup));
- TREE_ADDRESSABLE (type) = TREE_ADDRESSABLE (type_dup);
DECL_SIZE (defn) = DECL_SIZE (maybe_dup);
DECL_SIZE_UNIT (defn) = DECL_SIZE_UNIT (maybe_dup);
DECL_ALIGN_RAW (defn) = DECL_ALIGN_RAW (maybe_dup);
@@ -12388,12 +12392,26 @@ trees_in::read_class_def (tree defn, tree maybe_template)
= DECL_WARN_IF_NOT_ALIGN_RAW (maybe_dup);
DECL_USER_ALIGN (defn) = DECL_USER_ALIGN (maybe_dup);
+ TYPE_TYPELESS_STORAGE (type) = TYPE_TYPELESS_STORAGE (type_dup);
+ TYPE_CXX_ODR_P (type) = TYPE_CXX_ODR_P (type_dup);
+ TYPE_NO_FORCE_BLK (type) = TYPE_NO_FORCE_BLK (type_dup);
+ TYPE_TRANSPARENT_AGGR (type) = TYPE_TRANSPARENT_AGGR (type_dup);
+ TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type)
+ = TYPE_CONTAINS_PLACEHOLDER_INTERNAL (type_dup);
+
+ TYPE_EMPTY_P (type) = TYPE_EMPTY_P (type_dup);
+ TREE_ADDRESSABLE (type) = TREE_ADDRESSABLE (type_dup);
+
/* C++ pieces. */
TYPE_POLYMORPHIC_P (type) = TYPE_POLYMORPHIC_P (type_dup);
+ CLASSTYPE_FINAL (type) = CLASSTYPE_FINAL (type_dup);
+
TYPE_HAS_USER_CONSTRUCTOR (type)
= TYPE_HAS_USER_CONSTRUCTOR (type_dup);
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)
= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type_dup);
+ TYPE_NEEDS_CONSTRUCTING (type)
+ = TYPE_NEEDS_CONSTRUCTING (type_dup);
if (auto ls = TYPE_LANG_SPECIFIC (type_dup))
{
diff --git a/gcc/testsuite/g++.dg/modules/class-10_a.H b/gcc/testsuite/g++.dg/modules/class-10_a.H
new file mode 100644
index 0000000..177cf57
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/class-10_a.H
@@ -0,0 +1,6 @@
+// { dg-additional-options "-fmodule-header" }
+// { dg-module-cmi {} }
+
+struct alignas(16) Align {};
+struct Final final {};
+struct NeedsConstructing { NeedsConstructing(); };
diff --git a/gcc/testsuite/g++.dg/modules/class-10_b.C b/gcc/testsuite/g++.dg/modules/class-10_b.C
new file mode 100644
index 0000000..2f98212
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/class-10_b.C
@@ -0,0 +1,19 @@
+// { dg-additional-options "-fmodules-ts -Wno-pedantic" }
+// Test bits and pieces of merging information
+// from class defs into forward declarations
+
+struct Align;
+struct Final;
+struct NeedsConstructing;
+
+import "class-10_a.H";
+
+static_assert(alignof(Align) == 16);
+
+struct TestFinal : Final {}; // { dg-error "cannot derive" }
+
+struct TestNeedsConstructing {
+ struct {
+ NeedsConstructing a; // { dg-error "with constructor not allowed in anonymous aggregate" }
+ };
+};
diff --git a/gcc/tree.h b/gcc/tree.h
index efda032..66e08793 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2357,13 +2357,15 @@ extern tree vector_element_bits_tree (const_tree);
/* The minimum alignment necessary for objects of this type without
warning. The value is an int, measured in bits. */
+#define TYPE_WARN_IF_NOT_ALIGN_RAW(NODE) \
+ (TYPE_CHECK (NODE)->type_common.warn_if_not_align)
#define TYPE_WARN_IF_NOT_ALIGN(NODE) \
- (TYPE_CHECK (NODE)->type_common.warn_if_not_align \
- ? ((unsigned)1) << ((NODE)->type_common.warn_if_not_align - 1) : 0)
+ (TYPE_WARN_IF_NOT_ALIGN_RAW (NODE) \
+ ? ((unsigned)1) << (TYPE_WARN_IF_NOT_ALIGN_RAW (NODE) - 1) : 0)
/* Specify that TYPE_WARN_IF_NOT_ALIGN(NODE) is X. */
#define SET_TYPE_WARN_IF_NOT_ALIGN(NODE, X) \
- (TYPE_CHECK (NODE)->type_common.warn_if_not_align = ffs_hwi (X))
+ (TYPE_WARN_IF_NOT_ALIGN_RAW (NODE) = ffs_hwi (X))
/* If your language allows you to declare types, and you want debug info
for them, then you need to generate corresponding TYPE_DECL nodes.