From: Jakub Jelinek Date: Thu, 7 Jul 2016 18:45:43 +0000 (+0200) Subject: re PR c++/70869 (internal compiler error: Segmentation fault on array of pointer... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=842dc2e6ed6e6095032eb5af7037e3b5718d3336;p=gcc.git re PR c++/70869 (internal compiler error: Segmentation fault on array of pointer to function members) PR c++/70869 PR c++/71054 * cp-gimplify.c (cp_genericize_r): For DECL_EXPR for non-static artificial vars, genericize their initializers. * g++.dg/cpp0x/pr70869.C: New test. * g++.dg/cpp0x/pr71054.C: New test. Co-Authored-By: Kai Tietz From-SVN: r238124 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c129b5f7ce6..12f15db59dd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2016-07-07 Jakub Jelinek + Kai Tietz + + PR c++/70869 + PR c++/71054 + * cp-gimplify.c (cp_genericize_r): For DECL_EXPR for non-static + artificial vars, genericize their initializers. + 2016-07-05 David Malcolm PR c++/62314 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 97b043acbf2..1d81fb1e3d2 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1304,7 +1304,15 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) { tree d = DECL_EXPR_DECL (stmt); if (TREE_CODE (d) == VAR_DECL) - gcc_assert (CP_DECL_THREAD_LOCAL_P (d) == DECL_THREAD_LOCAL_P (d)); + { + gcc_assert (CP_DECL_THREAD_LOCAL_P (d) == DECL_THREAD_LOCAL_P (d)); + /* User var initializers should be genericized during containing + BIND_EXPR genericization when walk_tree walks DECL_INITIAL + of BIND_EXPR_VARS. Artificial temporaries might not be + mentioned there though, so walk them now. */ + if (DECL_ARTIFICIAL (d) && !TREE_STATIC (d) && DECL_INITIAL (d)) + cp_walk_tree (&DECL_INITIAL (d), cp_genericize_r, data, NULL); + } } else if (TREE_CODE (stmt) == OMP_PARALLEL || TREE_CODE (stmt) == OMP_TASK diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 88b4be6b24c..c61e6e5a201 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2016-07-07 Jakub Jelinek + Kai Tietz + + PR c++/70869 + PR c++/71054 + * g++.dg/cpp0x/pr70869.C: New test. + * g++.dg/cpp0x/pr71054.C: New test. + 2016-07-07 David Edelsohn * g++.dg/debug/pr71432.C: Fail on AIX. diff --git a/gcc/testsuite/g++.dg/cpp0x/pr70869.C b/gcc/testsuite/g++.dg/cpp0x/pr70869.C new file mode 100644 index 00000000000..84c532b6772 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr70869.C @@ -0,0 +1,25 @@ +// PR c++/70869 +// { dg-do run { target c++11 } } + +#include + +struct A +{ + int f () { return 1; } + int g () { return 2; } + int h () { return 3; } +}; + +int +main () +{ + int cnt = 0; + for (const auto &m : { &A::f, &A::g, &A::h }) + { + A a; + if ((a.*m) () != ++cnt) + __builtin_abort (); + } + if (cnt != 3) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr71054.C b/gcc/testsuite/g++.dg/cpp0x/pr71054.C new file mode 100644 index 00000000000..518bafcbd21 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr71054.C @@ -0,0 +1,21 @@ +// PR c++/71054 +// { dg-do compile { target c++11 } } + +#include + +template +struct S +{ + struct A + { + int a; + int b; + T p; + }; + S () { std::initializer_list a{ {0, 0, &D::V} }; } +}; +struct R { + void V (int); + void U (int); +}; +S b;