From: Paolo Carlini Date: Thu, 8 Feb 2018 09:06:33 +0000 (+0000) Subject: re PR c++/83204 (c++ -std=c++14 ICE in maybe_undo_parenthesized_ref, at cp/semantics... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=66a90e86694bdcfc674bfa5951d10088fc5b41a8;p=gcc.git re PR c++/83204 (c++ -std=c++14 ICE in maybe_undo_parenthesized_ref, at cp/semantics.c:1694) /cp 2018-02-08 Paolo Carlini PR c++/83204 * pt.c (tsubst_copy_and_build): Use force_paren_expr for INDIRECT_REF. /testsuite 2018-02-08 Paolo Carlini PR c++/83204 * g++.dg/cpp0x/lambda/lambda-ice25.C: New. From-SVN: r257478 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0b710e9140f..b898ba15a37 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-02-08 Paolo Carlini + + PR c++/83204 + * pt.c (tsubst_copy_and_build): Use force_paren_expr for INDIRECT_REF. + 2018-02-07 Jakub Jelinek PR c++/84082 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0d9e153b5ee..a9e47701527 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -17224,8 +17224,8 @@ tsubst_copy_and_build (tree t, r = build_x_indirect_ref (input_location, r, RO_UNARY_STAR, complain|decltype_flag); - if (TREE_CODE (r) == INDIRECT_REF) - REF_PARENTHESIZED_P (r) = REF_PARENTHESIZED_P (t); + if (REF_PARENTHESIZED_P (t)) + r = force_paren_expr (r); RETURN (r); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 22ec5d18eb6..16f2b1a9522 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-08 Paolo Carlini + + PR c++/83204 + * g++.dg/cpp0x/lambda/lambda-ice25.C: New. + 2018-02-07 Will Schmidt * gcc.target/powerpc/vsxcopy.c: Update scan-assembler stanzas. diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice25.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice25.C new file mode 100644 index 00000000000..1a33fb16364 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice25.C @@ -0,0 +1,27 @@ +// PR c++/83204 +// { dg-do compile { target c++11 } } + +int rand(); + +template +struct s +{ + int count() { return rand(); } +}; + +template +void f(s a) +{ + int const x = a.count(); + int r = 0; + auto l = [&](int& r) + { + for(int y = 0, yend = (x); y < yend; ++y) + { + r += y; + } + }; + l(r); +} + +template void f(s);