]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/69912 - [6 regression] ICE in build_ctor_subob_ref initializing
authorMartin Sebor <msebor@redhat.com>
Wed, 24 Feb 2016 17:23:35 +0000 (17:23 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Wed, 24 Feb 2016 17:23:35 +0000 (10:23 -0700)
PR c++/69912 - [6 regression] ICE in build_ctor_subob_ref initializing
a flexible array member

gcc/testsuite/ChangeLog:
2016-02-24  Martin Sebor  <msebor@redhat.com>

PR c++/69912
* g++.dg/ext/flexary15.C: New test.

gcc/cp/ChangeLog:
2016-02-24  Martin Sebor  <msebor@redhat.com>

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
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/flexary15.C [new file with mode: 0644]

index 6212d4343db34f84a276b2958c2105e874c0b657..764d2a8283e4778e783058f04b9039be42e263c9 100644 (file)
@@ -1,3 +1,9 @@
+016-02-24  Martin Sebor  <msebor@redhat.com>
+
+       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  <jason@redhat.com>
 
        * decl.c (start_preparsed_function): Condition ctor clobber on
index 3203acaff9e94f6d6c23a4f8390b82764ef5158e..0f7287ab0d76eaa7aed2e9e232b26c997e27e901 100644 (file)
@@ -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));
index b215d09080e4b05fc2d17108a1c583e3774c12d9..311232fbcdbdcf61b37c60a91ee5e91c63a5f1d6 100644 (file)
@@ -1,8 +1,13 @@
 2016-02-24  Martin Sebor  <msebor@redhat.com>
 
-       * 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  <msebor@redhat.com>
+
+       * 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  <maxim.kuvyrkov@linaro.org>
            Charles Baylis  <charles.baylis@linaro.org>
diff --git a/gcc/testsuite/g++.dg/ext/flexary15.C b/gcc/testsuite/g++.dg/ext/flexary15.C
new file mode 100644 (file)
index 0000000..c03a60e
--- /dev/null
@@ -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" }
+}