From: Jason Merrill Date: Tue, 13 May 2014 16:05:13 +0000 (-0400) Subject: re PR c++/60713 (ICE in iterative_hash_expr) X-Git-Tag: releases/gcc-4.8.3~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e9be32e558c7ed347bddb7f17a9d154fbf9f18a;p=thirdparty%2Fgcc.git re PR c++/60713 (ICE in iterative_hash_expr) PR c++/60713 * typeck2.c (PICFLAG_SIDE_EFFECTS): New. (picflag_from_initializer): Return it. (process_init_constructor): Handle it. From-SVN: r210383 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 13989d0b1d47..9d63170ac7eb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2014-05-13 Jason Merrill + PR c++/60713 + * typeck2.c (PICFLAG_SIDE_EFFECTS): New. + (picflag_from_initializer): Return it. + (process_init_constructor): Handle it. + PR c++/60628 * decl.c (create_array_type_for_decl): Complain about array of auto. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 9c9f0751f33f..ca4414a49da5 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1015,6 +1015,7 @@ digest_init_flags (tree type, tree init, int flags) #define PICFLAG_ERRONEOUS 1 #define PICFLAG_NOT_ALL_CONSTANT 2 #define PICFLAG_NOT_ALL_SIMPLE 4 +#define PICFLAG_SIDE_EFFECTS 8 /* Given an initializer INIT, return the flag (PICFLAG_*) which better describe it. */ @@ -1025,7 +1026,12 @@ picflag_from_initializer (tree init) if (init == error_mark_node) return PICFLAG_ERRONEOUS; else if (!TREE_CONSTANT (init)) - return PICFLAG_NOT_ALL_CONSTANT; + { + if (TREE_SIDE_EFFECTS (init)) + return PICFLAG_SIDE_EFFECTS; + else + return PICFLAG_NOT_ALL_CONSTANT; + } else if (!initializer_constant_valid_p (init, TREE_TYPE (init))) return PICFLAG_NOT_ALL_SIMPLE; return 0; @@ -1392,7 +1398,12 @@ process_init_constructor (tree type, tree init, tsubst_flags_t complain) TREE_TYPE (init) = type; if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == NULL_TREE) cp_complete_array_type (&TREE_TYPE (init), init, /*do_default=*/0); - if (flags & PICFLAG_NOT_ALL_CONSTANT) + if (flags & PICFLAG_SIDE_EFFECTS) + { + TREE_CONSTANT (init) = false; + TREE_SIDE_EFFECTS (init) = true; + } + else if (flags & PICFLAG_NOT_ALL_CONSTANT) /* Make sure TREE_CONSTANT isn't set from build_constructor. */ TREE_CONSTANT (init) = false; else diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist81.C b/gcc/testsuite/g++.dg/cpp0x/initlist81.C new file mode 100644 index 000000000000..5978c6388938 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist81.C @@ -0,0 +1,25 @@ +// PR c++/60713 +// { dg-options "-O" } +// { dg-do compile { target c++11 } } + +template < class x0, class x1, class x2, class x3, class x4 > +int *x5 (x0 *, x2 (x1::*)(x3, x4)); + +class x6 +{ + void x7 (); + struct x8 + { + int *x9; + }; + void x10 (x8); + void x11 (int *, int *); +}; + +void +x6::x7 () +{ + x10 ({ + x5 (this, &x6::x11) + }); +}