From: Jakub Jelinek Date: Tue, 13 Jun 2017 20:02:38 +0000 (+0200) Subject: re PR c++/80984 (ICE with label/variable ambiguity) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c60dc05326dbf6960dbaa898db854fd062afeecd;p=gcc.git re PR c++/80984 (ICE with label/variable ambiguity) PR c++/80984 * cp-gimplify.c (cp_genericize): Only look for VAR_DECLs in BLOCK_VARS (outer) chain. (cxx_omp_const_qual_no_mutable): Likewise. * g++.dg/opt/nrv18.C: New test. From-SVN: r249173 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 43888304bd1..ae91a9ddbf6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2017-06-13 Jakub Jelinek + + PR c++/80984 + * cp-gimplify.c (cp_genericize): Only look for VAR_DECLs in + BLOCK_VARS (outer) chain. + (cxx_omp_const_qual_no_mutable): Likewise. + 2017-06-13 Martin Liska PR sanitize/78204 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 3c8f4b041d2..d5462087598 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1590,7 +1590,8 @@ cp_genericize (tree fndecl) if (outer) for (var = BLOCK_VARS (outer); var; var = DECL_CHAIN (var)) - if (DECL_NAME (t) == DECL_NAME (var) + if (VAR_P (var) + && DECL_NAME (t) == DECL_NAME (var) && DECL_HAS_VALUE_EXPR_P (var) && DECL_VALUE_EXPR (var) == t) { @@ -1836,7 +1837,8 @@ cxx_omp_const_qual_no_mutable (tree decl) if (outer) for (var = BLOCK_VARS (outer); var; var = DECL_CHAIN (var)) - if (DECL_NAME (decl) == DECL_NAME (var) + if (VAR_P (var) + && DECL_NAME (decl) == DECL_NAME (var) && (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (var)))) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1eddf494231..5164fa987b8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-06-13 Jakub Jelinek + + PR c++/80984 + * g++.dg/opt/nrv18.C: New test. + 2017-06-13 Martin Liska PR sanitize/78204 diff --git a/gcc/testsuite/g++.dg/opt/nrv18.C b/gcc/testsuite/g++.dg/opt/nrv18.C new file mode 100644 index 00000000000..92e9bdf3dbc --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/nrv18.C @@ -0,0 +1,12 @@ +// PR c++/80984 +// { dg-do compile } + +struct A { ~A (); }; + +A +foo () +{ + A a; +a: + return a; +}