re PR c++/67576 (expression of typeid( expression ) is evaluated twice)
PR c++/67576 PR c++/25466 * rtti.c (build_typeid): Use save_expr, not stabilize_reference. From-SVN: r231776
This commit is contained in:
parent
1ad2439bea
commit
6ef15591e3
|
@ -1,3 +1,9 @@
|
||||||
|
2015-12-17 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/67576
|
||||||
|
PR c++/25466
|
||||||
|
* rtti.c (build_typeid): Use save_expr, not stabilize_reference.
|
||||||
|
|
||||||
2015-12-16 Patrick Palka <ppalka@gcc.gnu.org>
|
2015-12-16 Patrick Palka <ppalka@gcc.gnu.org>
|
||||||
|
|
||||||
PR c++/16333
|
PR c++/16333
|
||||||
|
|
|
@ -332,7 +332,7 @@ build_typeid (tree exp, tsubst_flags_t complain)
|
||||||
/* So we need to look into the vtable of the type of exp.
|
/* So we need to look into the vtable of the type of exp.
|
||||||
Make sure it isn't a null lvalue. */
|
Make sure it isn't a null lvalue. */
|
||||||
exp = cp_build_addr_expr (exp, complain);
|
exp = cp_build_addr_expr (exp, complain);
|
||||||
exp = stabilize_reference (exp);
|
exp = save_expr (exp);
|
||||||
cond = cp_convert (boolean_type_node, exp, complain);
|
cond = cp_convert (boolean_type_node, exp, complain);
|
||||||
exp = cp_build_indirect_ref (exp, RO_NULL, complain);
|
exp = cp_build_indirect_ref (exp, RO_NULL, complain);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
// { dg-do run }
|
||||||
|
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
|
struct Base { virtual void foo() {} }; // polymorphic
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Base b;
|
||||||
|
Base *ary[] = { &b, &b, &b};
|
||||||
|
|
||||||
|
int iter = 0;
|
||||||
|
typeid(*ary[iter++]);
|
||||||
|
if (iter != 1) // should be 1
|
||||||
|
__builtin_abort(); // but 2
|
||||||
|
}
|
Loading…
Reference in New Issue