PR c++/85240 - LTO ICE with using of undeduced auto fn.
authorJason Merrill <jason@redhat.com>
Fri, 6 Apr 2018 15:12:28 +0000 (11:12 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 6 Apr 2018 15:12:28 +0000 (11:12 -0400)
* cp-gimplify.c (cp_genericize_r): Discard using of undeduced auto.

From-SVN: r259177

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

index 759e9c99e0d7966dc3d1dd3ef8d686db1716a406..71eceaaa31b5c2b20aee9360284f51c3eacdd4da 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-06  Jason Merrill  <jason@redhat.com>
+
+       PR c++/85240 - LTO ICE with using of undeduced auto fn.
+       * cp-gimplify.c (cp_genericize_r): Discard using of undeduced auto.
+
 2018-04-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/85209
index fd0c37f9be280b280fbef24b5e39649f7b961015..fb0aea3e0c738b33d27cc86d942d52a0998f2d6d 100644 (file)
@@ -1294,16 +1294,20 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
          }
        if (block)
          {
-           tree using_directive;
-           gcc_assert (TREE_OPERAND (stmt, 0));
+           tree decl = TREE_OPERAND (stmt, 0);
+           gcc_assert (decl);
 
-           using_directive = make_node (IMPORTED_DECL);
-           TREE_TYPE (using_directive) = void_type_node;
+           if (undeduced_auto_decl (decl))
+             /* Omit from the GENERIC, the back-end can't handle it.  */;
+           else
+             {
+               tree using_directive = make_node (IMPORTED_DECL);
+               TREE_TYPE (using_directive) = void_type_node;
 
-           IMPORTED_DECL_ASSOCIATED_DECL (using_directive)
-             = TREE_OPERAND (stmt, 0);
-           DECL_CHAIN (using_directive) = BLOCK_VARS (block);
-           BLOCK_VARS (block) = using_directive;
+               IMPORTED_DECL_ASSOCIATED_DECL (using_directive) = decl;
+               DECL_CHAIN (using_directive) = BLOCK_VARS (block);
+               BLOCK_VARS (block) = using_directive;
+             }
          }
        /* The USING_STMT won't appear in GENERIC.  */
        *stmt_p = build1 (NOP_EXPR, void_type_node, integer_zero_node);
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn51.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn51.C
new file mode 100644 (file)
index 0000000..7e4f488
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/85240
+// { dg-do compile { target c++14 } }
+
+auto foo();
+
+void bar()
+{
+  using ::foo;
+}