From 3b96b93aec896a79bffad622ce6a161276cb198e Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Wed, 24 Feb 2016 17:23:35 +0000 Subject: [PATCH] PR c++/69912 - [6 regression] ICE in build_ctor_subob_ref initializing PR c++/69912 - [6 regression] ICE in build_ctor_subob_ref initializing a flexible array member gcc/testsuite/ChangeLog: 2016-02-24 Martin Sebor PR c++/69912 * g++.dg/ext/flexary15.C: New test. gcc/cp/ChangeLog: 2016-02-24 Martin Sebor PR c++/69912 * tree.c (build_ctor_subob_ref): Compare types' main variants instead of the types as they are. From-SVN: r233678 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/tree.c | 6 ++++-- gcc/testsuite/ChangeLog | 9 +++++++-- gcc/testsuite/g++.dg/ext/flexary15.C | 14 ++++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/flexary15.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6212d4343db3..764d2a8283e4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +016-02-24 Martin Sebor + + PR c++/69912 + * tree.c (build_ctor_subob_ref): Compare types' main variants + instead of the types as they are. + 2016-02-24 Jason Merrill * decl.c (start_preparsed_function): Condition ctor clobber on diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 3203acaff9e9..0f7287ab0d76 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2592,8 +2592,10 @@ build_ctor_subob_ref (tree index, tree type, tree obj) { /* When the destination object refers to a flexible array member verify that it matches the type of the source object except - for its domain. */ - gcc_assert (comptypes (type, objtype, COMPARE_REDECLARATION)); + for its domain and qualifiers. */ + gcc_assert (comptypes (TYPE_MAIN_VARIANT (type), + TYPE_MAIN_VARIANT (objtype), + COMPARE_REDECLARATION)); } else gcc_assert (same_type_ignoring_top_level_qualifiers_p (type, objtype)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b215d09080e4..311232fbcdbd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,8 +1,13 @@ 2016-02-24 Martin Sebor - * gcc/testsuite/gcc.dg/builtins-68.c: Avoid making unportable + PR c++/69912 + * g++.dg/ext/flexary15.C: New test. + +2016-02-24 Martin Sebor + + * gcc.dg/builtins-68.c: Avoid making unportable assumptions about the relationship between SIZE_MAX and UINT_MAX. - * gcc/testsuite/g++.dg/ext/builtin_alloca.C: Same. + * g++.dg/ext/builtin_alloca.C: Same. 2016-02-24 Maxim Kuvyrkov Charles Baylis diff --git a/gcc/testsuite/g++.dg/ext/flexary15.C b/gcc/testsuite/g++.dg/ext/flexary15.C new file mode 100644 index 000000000000..c03a60e7b50a --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/flexary15.C @@ -0,0 +1,14 @@ +// PR c++/69912 - [6 regression] ICE in build_ctor_subob_ref initializing +// a flexible array member +// { dg-do compile } +// { dg-options "-Wno-pedantic -Wno-write-strings -fpermissive" } + +struct S { + int n; + char *a[]; +}; + +void foo (const char *a) +{ + const S s = { 1, { a, "b" } }; // { dg-warning "invalid conversion" } +}