[gcc/devel/c++-modules] Aligned type support
Nathan Sidwell
nathan@gcc.gnu.org
Tue Oct 27 17:24:30 GMT 2020
https://gcc.gnu.org/g:2bd8a7ca3d1e690bdbd73fb1825af7585d971e8f
commit 2bd8a7ca3d1e690bdbd73fb1825af7585d971e8f
Author: Nathan Sidwell <nathan@acm.org>
Date: Mon Oct 26 10:52:21 2020 -0700
Aligned type support
gcc/cp/
* module.cc (trees_out::type_node): Stream alignment.
(trees_in::type_node): Alignment is a log.
gcc/testsuite/
* g++.dg/modules/align-type-1_[ab].C: New.
Diff:
---
ChangeLog.modules | 6 ++++++
gcc/cp/module.cc | 13 +++++++------
gcc/testsuite/g++.dg/modules/align-type-1_a.C | 8 ++++++++
gcc/testsuite/g++.dg/modules/align-type-1_b.C | 10 ++++++++++
4 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/ChangeLog.modules b/ChangeLog.modules
index 6e62ea6cf6a..0161674e8db 100644
--- a/ChangeLog.modules
+++ b/ChangeLog.modules
@@ -1,5 +1,11 @@
2020-10-26 Nathan Sidwell <nathan@acm.org>
+ gcc/cp/
+ * module.cc (trees_out::type_node): Stream alignment.
+ (trees_in::type_node): Alignment is a log.
+ gcc/testsuite/
+ * g++.dg/modules/align-type-1_[ab].C: New.
+
gcc/cp/
* module.cc (trees_{in,out}::tree_list): Address more Fixmes,
either by obsoleting them, or coding around their confusion.
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 9d2c7cb3059..6656b56887c 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -2824,7 +2824,7 @@ enum tree_tag {
tt_tinfo_typedef, /* Typeinfo typedef. */
tt_ptrmem_type, /* Pointer to member type. */
- tt_parm, /* Function paramter or result. */
+ tt_parm, /* Function parameter or result. */
tt_enum_value, /* An enum value. */
tt_enum_decl, /* An enum decl. */
tt_data_member, /* Data member/using-decl. */
@@ -8141,6 +8141,8 @@ trees_in::decl_value ()
tag, TREE_CODE (TREE_TYPE (decl)), TREE_TYPE (decl));
}
+ unused = saved_unused;
+
if (DECL_MAYBE_IN_CHARGE_CDTOR_P (decl))
{
unsigned flags = u ();
@@ -8159,8 +8161,6 @@ trees_in::decl_value ()
}
}
- unused = saved_unused;
-
if (inner
&& !NAMESPACE_SCOPE_P (inner)
&& ((TREE_CODE (inner) == TYPE_DECL
@@ -8581,7 +8581,7 @@ trees_out::type_node (tree type)
tree_node (root);
int flags = -1;
-
+
if (TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE)
{
@@ -8598,7 +8598,8 @@ trees_out::type_node (tree type)
}
else
{
- // FIXME: Align
+ if (TYPE_USER_ALIGN (type))
+ flags = exact_log2 (TYPE_ALIGN (type));
}
if (streaming_p ())
@@ -9394,7 +9395,7 @@ trees_in::tree_node (bool is_use)
}
else
{
- res = build_aligned_type (res, flags);
+ res = build_aligned_type (res, 1u << flags);
TYPE_USER_ALIGN (res) = true;
}
diff --git a/gcc/testsuite/g++.dg/modules/align-type-1_a.C b/gcc/testsuite/g++.dg/modules/align-type-1_a.C
new file mode 100644
index 00000000000..71240341469
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/align-type-1_a.C
@@ -0,0 +1,8 @@
+// { dg-additional-options -fmodules-ts }
+
+export module foo;
+// { dg-module-cmi foo }
+
+export using aint = __attribute__ ((aligned(16))) int;
+
+
diff --git a/gcc/testsuite/g++.dg/modules/align-type-1_b.C b/gcc/testsuite/g++.dg/modules/align-type-1_b.C
new file mode 100644
index 00000000000..8372e6f3e1b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/align-type-1_b.C
@@ -0,0 +1,10 @@
+// { dg-additional-options -fmodules-ts }
+
+import foo;
+
+struct B
+{
+ aint m;
+};
+
+static_assert (alignof (B) == 16);
More information about the Gcc-cvs
mailing list