Commit 5fde6a45 by Marek Polacek Committed by Marek Polacek

re PR c/70297 (GCC Segfaults when using -g3)

	PR c/70297
	* c-decl.c (merge_decls): Also set TYPE_ALIGN and TYPE_USER_ALIGN.

	* decl.c (duplicate_decls): Also set TYPE_ALIGN and TYPE_USER_ALIGN.

	* c-c++-common/pr70297.c: New test.
	* g++.dg/cpp0x/typedef-redecl.C: New test.
	* gcc.dg/typedef-redecl2.c: New test.

From-SVN: r234626
parent 97eb24c4
2016-03-31 Marek Polacek <polacek@redhat.com>
PR c/70297
* c-decl.c (merge_decls): Also set TYPE_ALIGN and TYPE_USER_ALIGN.
2016-03-18 David Malcolm <dmalcolm@redhat.com> 2016-03-18 David Malcolm <dmalcolm@redhat.com>
PR c/70281 PR c/70281
......
...@@ -2358,6 +2358,35 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) ...@@ -2358,6 +2358,35 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
DECL_ATTRIBUTES (newdecl) DECL_ATTRIBUTES (newdecl)
= targetm.merge_decl_attributes (olddecl, newdecl); = targetm.merge_decl_attributes (olddecl, newdecl);
/* For typedefs use the old type, as the new type's DECL_NAME points
at newdecl, which will be ggc_freed. */
if (TREE_CODE (newdecl) == TYPE_DECL)
{
/* But NEWTYPE might have an attribute, honor that. */
tree tem = newtype;
newtype = oldtype;
if (TYPE_USER_ALIGN (tem))
{
if (TYPE_ALIGN (tem) > TYPE_ALIGN (newtype))
TYPE_ALIGN (newtype) = TYPE_ALIGN (tem);
TYPE_USER_ALIGN (newtype) = true;
}
/* And remove the new type from the variants list. */
if (TYPE_NAME (TREE_TYPE (newdecl)) == newdecl)
{
tree remove = TREE_TYPE (newdecl);
for (tree t = TYPE_MAIN_VARIANT (remove); ;
t = TYPE_NEXT_VARIANT (t))
if (TYPE_NEXT_VARIANT (t) == remove)
{
TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (remove);
break;
}
}
}
/* Merge the data types specified in the two decls. */ /* Merge the data types specified in the two decls. */
TREE_TYPE (newdecl) TREE_TYPE (newdecl)
= TREE_TYPE (olddecl) = TREE_TYPE (olddecl)
......
2016-03-31 Marek Polacek <polacek@redhat.com>
PR c/70297
* decl.c (duplicate_decls): Also set TYPE_ALIGN and TYPE_USER_ALIGN.
2016-03-31 Richard Biener <rguenther@suse.de> 2016-03-31 Richard Biener <rguenther@suse.de>
PR c++/70430 PR c++/70430
......
...@@ -2028,8 +2028,17 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -2028,8 +2028,17 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
at newdecl, which will be ggc_freed. */ at newdecl, which will be ggc_freed. */
if (TREE_CODE (newdecl) == TYPE_DECL) if (TREE_CODE (newdecl) == TYPE_DECL)
{ {
/* But NEWTYPE might have an attribute, honor that. */
tree tem = TREE_TYPE (newdecl);
newtype = oldtype; newtype = oldtype;
if (TYPE_USER_ALIGN (tem))
{
if (TYPE_ALIGN (tem) > TYPE_ALIGN (newtype))
TYPE_ALIGN (newtype) = TYPE_ALIGN (tem);
TYPE_USER_ALIGN (newtype) = true;
}
/* And remove the new type from the variants list. */ /* And remove the new type from the variants list. */
if (TYPE_NAME (TREE_TYPE (newdecl)) == newdecl) if (TYPE_NAME (TREE_TYPE (newdecl)) == newdecl)
{ {
......
2016-03-31 Marek Polacek <polacek@redhat.com>
PR c/70297
* c-c++-common/pr70297.c: New test.
* g++.dg/cpp0x/typedef-redecl.C: New test.
* gcc.dg/typedef-redecl2.c: New test.
2016-03-31 Jakub Jelinek <jakub@redhat.com> 2016-03-31 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/70460 PR rtl-optimization/70460
......
/* PR c/70297 */
/* { dg-do compile } */
/* { dg-options "-g" } */
typedef int T;
typedef int T __attribute__((aligned (4)));
struct S {
T *t;
};
// PR c/70297
// { dg-do compile { target c++11 } }
#define N 64
typedef int T;
typedef int T __attribute__((aligned (N)));
typedef int T __attribute__((aligned (N * 2)));
typedef int T __attribute__((aligned (N)));
typedef int T;
static_assert (alignof (T) == N * 2, "N * 2");
/* PR c/70297 */
/* { dg-do compile } */
/* { dg-options "" } */
#define N 64
typedef int T;
typedef int T __attribute__((aligned (N)));
typedef int T __attribute__((aligned (N * 2)));
typedef int T __attribute__((aligned (N)));
typedef int T;
_Static_assert (_Alignof (T) == N * 2, "N * 2");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment