re PR c++/80984 (ICE with label/variable ambiguity)
authorJakub Jelinek <jakub@redhat.com>
Tue, 13 Jun 2017 20:02:38 +0000 (22:02 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 13 Jun 2017 20:02:38 +0000 (22:02 +0200)
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

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/nrv18.C [new file with mode: 0644]

index 43888304bd1e6ac0c9df92bd8e38bcf6e8febad7..ae91a9ddbf6888361899a2cd5c5715ad9c76772b 100644 (file)
@@ -1,3 +1,10 @@
+2017-06-13  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <mliska@suse.cz>
 
        PR sanitize/78204
index 3c8f4b041d2c3155e5c6f6281f7405bb44782d1b..d5462087598f005744cf76436f63f19ce172d330 100644 (file)
@@ -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))))
                {
index 1eddf49423121d63ea7131aac0e5ea7f93ddc806..5164fa987b87da55effb1c46ff947c08ef8571b4 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/80984
+       * g++.dg/opt/nrv18.C: New test.
+
 2017-06-13  Martin Liska  <mliska@suse.cz>
 
        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 (file)
index 0000000..92e9bdf
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/80984
+// { dg-do compile }
+
+struct A { ~A (); };
+
+A
+foo ()
+{
+  A a;
+a:
+  return a;
+}