mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-02 08:40:26 +08:00
re PR c++/86669 (Complete object constructor clone omits length for a c++11 braced initialiser)
PR c++/86669 * call.c (make_temporary_var_for_ref_to_temp): Call pushdecl even for automatic vars. * g++.dg/cpp0x/initlist105.C: New test. * g++.dg/cpp0x/initlist106.C: New test. * g++.dg/other/pr86669.C: New test. From-SVN: r266893
This commit is contained in:
parent
26004f51f9
commit
29f0d7d457
@ -1,5 +1,9 @@
|
||||
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.
|
||||
|
||||
|
@ -11148,14 +11148,12 @@ make_temporary_var_for_ref_to_temp (tree decl, tree type)
|
||||
tree name = mangle_ref_init_variable (decl);
|
||||
DECL_NAME (var) = name;
|
||||
SET_DECL_ASSEMBLER_NAME (var, name);
|
||||
|
||||
var = pushdecl (var);
|
||||
}
|
||||
else
|
||||
/* Create a new cleanup level if necessary. */
|
||||
maybe_push_cleanup_level (type);
|
||||
|
||||
return var;
|
||||
return pushdecl (var);
|
||||
}
|
||||
|
||||
/* EXPR is the initializer for a variable DECL of reference or
|
||||
|
@ -1,3 +1,10 @@
|
||||
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.
|
||||
|
||||
2018-12-07 Richard Sandiford <richard.sandiford@arm.com>
|
||||
|
||||
* gcc.target/aarch64/sve/pred_elim_2.c: New test.
|
||||
|
28
gcc/testsuite/g++.dg/cpp0x/initlist105.C
Normal file
28
gcc/testsuite/g++.dg/cpp0x/initlist105.C
Normal file
@ -0,0 +1,28 @@
|
||||
// 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 ();
|
||||
}
|
29
gcc/testsuite/g++.dg/cpp0x/initlist106.C
Normal file
29
gcc/testsuite/g++.dg/cpp0x/initlist106.C
Normal file
@ -0,0 +1,29 @@
|
||||
// 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 ();
|
||||
}
|
10
gcc/testsuite/g++.dg/other/pr86669.C
Normal file
10
gcc/testsuite/g++.dg/other/pr86669.C
Normal file
@ -0,0 +1,10 @@
|
||||
// PR c++/86669
|
||||
// { dg-do compile }
|
||||
|
||||
struct S { S (); };
|
||||
struct T : public S {};
|
||||
|
||||
S::S ()
|
||||
{
|
||||
int *p = { (int *) &p };
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user