• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GCC with patches for OS216


Commit MetaInfo

Revision1bdbef090299990b1fdef6323bb3daa48acf9349 (tree)
Time2018-03-21 16:09:22
AuthorMarek Polacek <polacek@redh...>
CommiterMarek Polacek

Log Message

PR c++/71638, ICE with NSDMI and reference.

* constexpr.c (cxx_eval_bare_aggregate): Update constructor's flags
even when we replace an element.

* g++.dg/cpp0x/nsdmi14.C: New test.
* g++.dg/cpp1y/nsdmi-aggr10.C: New test.

From-SVN: r258703

Change Summary

Incremental Difference

--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
1+2018-03-21 Marek Polacek <polacek@redhat.com>
2+
3+ PR c++/71638, ICE with NSDMI and reference.
4+ * constexpr.c (cxx_eval_bare_aggregate): Update constructor's flags
5+ even when we replace an element.
6+
17 2018-03-20 Marek Polacek <polacek@redhat.com>
28
39 PR c++/84978, ICE with NRVO.
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -2873,16 +2873,17 @@ cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t,
28732873 gcc_assert (is_empty_class (TREE_TYPE (TREE_TYPE (index))));
28742874 changed = true;
28752875 }
2876- else if (new_ctx.ctor != ctx->ctor)
2877- {
2878- /* We appended this element above; update the value. */
2879- gcc_assert ((*p)->last().index == index);
2880- (*p)->last().value = elt;
2881- }
28822876 else
28832877 {
2884- CONSTRUCTOR_APPEND_ELT (*p, index, elt);
2885- /* Adding an element might change the ctor's flags. */
2878+ if (new_ctx.ctor != ctx->ctor)
2879+ {
2880+ /* We appended this element above; update the value. */
2881+ gcc_assert ((*p)->last().index == index);
2882+ (*p)->last().value = elt;
2883+ }
2884+ else
2885+ CONSTRUCTOR_APPEND_ELT (*p, index, elt);
2886+ /* Adding or replacing an element might change the ctor's flags. */
28862887 TREE_CONSTANT (ctx->ctor) = constant_p;
28872888 TREE_SIDE_EFFECTS (ctx->ctor) = side_effects_p;
28882889 }
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
1+2018-03-21 Marek Polacek <polacek@redhat.com>
2+
3+ PR c++/71638, ICE with NSDMI and reference.
4+ * g++.dg/cpp0x/nsdmi14.C: New test.
5+ * g++.dg/cpp1y/nsdmi-aggr10.C: New test.
6+
17 2018-03-21 Chenghua Xu <paul.hua.gm@gmail.com>
28
39 * gcc.dg/vect/vect-strided-shift-1.c: Add dg-skip-if for
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi14.C
@@ -0,0 +1,19 @@
1+// PR c++/71638
2+// { dg-do compile { target c++11 } }
3+// { dg-options "-Wall" }
4+
5+struct A {
6+ struct {
7+ int i;
8+ int &j = i;
9+ } b;
10+ int a = b.j;
11+};
12+
13+void bar (A);
14+
15+void
16+foo ()
17+{
18+ bar (A{});
19+}
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr10.C
@@ -0,0 +1,7 @@
1+// PR c++/71638
2+// { dg-do compile { target c++14 } }
3+
4+struct {
5+ int &&a;
6+ int b{a};
7+} c[] { { 2 } };