public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: Jan Hubicka <hubicka@ucw.cz>, gcc-patches@gcc.gnu.org
Subject: Re: [C++ PATCH] Fix alignment handling in build_cplus_array_type/cp_build_qualified_type_real (PR c++/65690)
Date: Thu, 09 Apr 2015 15:19:00 -0000	[thread overview]
Message-ID: <20150409151922.GK19273@tucnak.redhat.com> (raw)
In-Reply-To: <5526913D.4040603@redhat.com>

On Thu, Apr 09, 2015 at 10:48:29AM -0400, Jason Merrill wrote:
> So the first hunk of the first patch is OK.

Ok, I've committed this to fix the regression.

2015-04-09  Jakub Jelinek  <jakub@redhat.com>

	PR c++/65690
	* tree.c (build_cplus_array_type): Layout type before variants are
	set, but copy over TYPE_SIZE and TYPE_SIZE_UNIT from the main
	variant.

	* c-c++-common/attr-aligned-1.c: New test.

--- gcc/cp/tree.c.jj	2015-04-01 15:29:33.000000000 +0200
+++ gcc/cp/tree.c	2015-04-08 09:09:45.326939354 +0200
@@ -880,12 +880,19 @@ build_cplus_array_type (tree elt_type, t
 	{
 	  t = build_min_array_type (elt_type, index_type);
 	  set_array_type_canon (t, elt_type, index_type);
+	  if (!dependent)
+	    {
+	      layout_type (t);
+	      /* Make sure sizes are shared with the main variant.
+		 layout_type can't be called after setting TYPE_NEXT_VARIANT,
+		 as it will overwrite alignment etc. of all variants.  */
+	      TYPE_SIZE (t) = TYPE_SIZE (m);
+	      TYPE_SIZE_UNIT (t) = TYPE_SIZE_UNIT (m);
+	    }
 
 	  TYPE_MAIN_VARIANT (t) = m;
 	  TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
 	  TYPE_NEXT_VARIANT (m) = t;
-	  if (!dependent)
-	    layout_type (t);
 	}
     }
 
--- gcc/testsuite/c-c++-common/attr-aligned-1.c.jj	2015-04-08 09:22:46.181427189 +0200
+++ gcc/testsuite/c-c++-common/attr-aligned-1.c	2015-04-08 09:26:41.315627195 +0200
@@ -0,0 +1,22 @@
+/* PR c++/65690 */
+/* { dg-do run } */
+
+typedef double T[4][4] __attribute__((aligned (2 * __alignof__ (double))));
+void foo (const T);
+struct S { T s; };
+
+int
+main ()
+{
+  if (__alignof__ (struct S) != 2 * __alignof__ (double)
+      || __alignof__ (T) != 2 * __alignof__ (double)
+      || __alignof__ (const struct S) != 2 * __alignof__ (double))
+    __builtin_abort ();
+  return 0;
+}
+
+#if defined(__cplusplus) && __cplusplus >= 201103L
+static_assert (alignof (S) == 2 * alignof (double), "alignment of S");
+static_assert (alignof (T) == 2 * alignof (double), "alignment of T");
+static_assert (alignof (const S) == 2 * alignof (double), "alignment of const S");
+#endif

	Jakub

  reply	other threads:[~2015-04-09 15:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-08 10:02 Jakub Jelinek
2015-04-08 14:47 ` Jason Merrill
2015-04-08 15:08   ` Jakub Jelinek
2015-04-09 14:48     ` Jason Merrill
2015-04-09 15:19       ` Jakub Jelinek [this message]
2015-04-08 16:22   ` Jan Hubicka
2015-04-08 16:28     ` Jakub Jelinek
2015-04-08 16:32       ` Jan Hubicka
2015-04-08 17:00         ` Jakub Jelinek
2015-04-09  9:39 ` Jakub Jelinek
2015-04-09 14:51   ` Jason Merrill
2015-04-09 18:12     ` [C++ PATCH] Fix alignment handling in build_cplus_array_type/cp_build_qualified_type_real (PR c++/65715) Jakub Jelinek
2015-04-10 14:28       ` Jason Merrill
2015-04-10 14:31         ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150409151922.GK19273@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).