public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] d: Set TYPE_ARTIFICIAL on internal TypeInfo types
@ 2022-06-15 11:56 Iain Buclaw
  0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2022-06-15 11:56 UTC (permalink / raw)
  To: gcc-patches

Hi,

This patch sets the TYPE_ARTIFICIAL flag on internally generated
object.TypeInfo types, preventing them from triggering warnings when
compiling with `-Wpadded'.

Regression tested on x86_64-linux-gnu/-m32/-mx32, committed to mainline,
and backported to the release/gcc-10, gcc-11, and gcc-12 branches.

Regards,
Iain.

---
gcc/d/ChangeLog:

	* typeinfo.cc (make_internal_typeinfo): Set TYPE_ARTIFICIAL.

gcc/testsuite/ChangeLog:

	* gdc.dg/Wpadded.d: New test.
---
 gcc/d/typeinfo.cc              | 1 +
 gcc/testsuite/gdc.dg/Wpadded.d | 4 ++++
 2 files changed, 5 insertions(+)
 create mode 100644 gcc/testsuite/gdc.dg/Wpadded.d

diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc
index 1647521555d..1f8afdd2c74 100644
--- a/gcc/d/typeinfo.cc
+++ b/gcc/d/typeinfo.cc
@@ -180,6 +180,7 @@ make_internal_typeinfo (tinfo_kind tk, Identifier *ident, ...)
 
   /* Create the TypeInfo type.  */
   tree type = make_node (RECORD_TYPE);
+  TYPE_ARTIFICIAL (type) = 1;
   finish_builtin_struct (type, ident->toChars (), fields, NULL_TREE);
 
   tinfo_types[tk] = type;
diff --git a/gcc/testsuite/gdc.dg/Wpadded.d b/gcc/testsuite/gdc.dg/Wpadded.d
new file mode 100644
index 00000000000..8a9cca7e225
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/Wpadded.d
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-options "-Wpadded" }
+
+class EmptyClass { }
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-15 11:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 11:56 [committed] d: Set TYPE_ARTIFICIAL on internal TypeInfo types Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).