Backported from mainline
2018-12-07 Jakub Jelinek <jakub@redhat.com>
+ PR c++/86669
+ * call.c (make_temporary_var_for_ref_to_temp): Call pushdecl even for
+ automatic vars.
+
PR c++/87506
* constexpr.c (adjust_temp_type): Handle EMPTY_CLASS_EXPR.
var = pushdecl_top_level (var);
}
else
- /* Create a new cleanup level if necessary. */
- maybe_push_cleanup_level (type);
+ {
+ /* Create a new cleanup level if necessary. */
+ maybe_push_cleanup_level (type);
+ var = pushdecl (var);
+ }
return var;
}
Backported from mainline
2018-12-07 Jakub Jelinek <jakub@redhat.com>
+ PR c++/86669
+ * g++.dg/cpp0x/initlist105.C: New test.
+ * g++.dg/cpp0x/initlist106.C: New test.
+ * g++.dg/other/pr86669.C: New test.
+
PR fortran/88377
* gfortran.dg/gomp/pr88377.f90: New test.
--- /dev/null
+// PR c++/86669
+// { dg-do run { target c++11 } }
+
+#include <initializer_list>
+
+struct S { S (); };
+struct T : public S {};
+int cnt;
+void foo (int) { cnt++; }
+
+S::S ()
+{
+ int e = 1, f = 2, g = 3, h = 4;
+
+ for (auto k : { e, f, g, h })
+ foo (k);
+}
+
+int
+main ()
+{
+ S s;
+ if (cnt != 4)
+ __builtin_abort ();
+ T t;
+ if (cnt != 8)
+ __builtin_abort ();
+}
--- /dev/null
+// PR c++/86669
+// { dg-do run { target c++11 } }
+
+#include <initializer_list>
+
+struct A { };
+struct S : virtual public A { S (); };
+struct T : public S, virtual public A {};
+int cnt;
+void foo (int) { cnt++; }
+
+S::S ()
+{
+ int e = 1, f = 2, g = 3, h = 4;
+
+ for (auto k : { e, f, g, h })
+ foo (k);
+}
+
+int
+main ()
+{
+ S s;
+ if (cnt != 4)
+ __builtin_abort ();
+ T t;
+ if (cnt != 8)
+ __builtin_abort ();
+}
--- /dev/null
+// PR c++/86669
+// { dg-do compile }
+
+struct S { S (); };
+struct T : public S {};
+
+S::S ()
+{
+ int *p = { (int *) &p };
+}