PR c++/89297 - ICE with OVERLOAD in template.
authorMarek Polacek <polacek@redhat.com>
Wed, 13 Feb 2019 21:39:18 +0000 (21:39 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 13 Feb 2019 21:39:18 +0000 (21:39 +0000)
* semantics.c (finish_compound_literal): Call
instantiate_non_dependent_expr_sfinae.

* g++.dg/cpp0x/initlist113.C: New test.

From-SVN: r268854

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist113.C [new file with mode: 0644]

index ef51d9a46e6f45c203056314f46ab7d67d2d4250..d6d1f595f1ccae5e81f27f885ed442b22072589a 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-13  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/89297 - ICE with OVERLOAD in template.
+       * semantics.c (finish_compound_literal): Call
+       instantiate_non_dependent_expr_sfinae.
+
 2019-02-13  Alexandre Oliva <aoliva@redhat.com>
 
        PR c++/86379
index 89ea438ebeefb3f62469fa258c2355d1e7065314..aa5a163dd64747dfce35ba9dbe46e0e7692bf452 100644 (file)
@@ -2827,9 +2827,13 @@ finish_compound_literal (tree type, tree compound_literal,
     return error_mark_node;
   compound_literal = reshape_init (type, compound_literal, complain);
   if (SCALAR_TYPE_P (type)
-      && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal)
-      && !check_narrowing (type, compound_literal, complain))
-    return error_mark_node;
+      && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal))
+    {
+      tree t = instantiate_non_dependent_expr_sfinae (compound_literal,
+                                                     complain);
+      if (!check_narrowing (type, t, complain))
+       return error_mark_node;
+    }
   if (TREE_CODE (type) == ARRAY_TYPE
       && TYPE_DOMAIN (type) == NULL_TREE)
     {
index 74d0ad3e0e69844c036a12011622bcbf1af7eb1f..c4aef56378bf22126af7331656679fa6f44647e0 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-13  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/89297 - ICE with OVERLOAD in template.
+       * g++.dg/cpp0x/initlist113.C: New test.
+
 2019-02-13  Alexandre Oliva <aoliva@redhat.com>
 
        PR c++/86379
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist113.C b/gcc/testsuite/g++.dg/cpp0x/initlist113.C
new file mode 100644 (file)
index 0000000..0b7e7ff
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/89297
+// { dg-do compile { target c++11 } }
+
+int id(int v) { return v; }
+float id(float v) { return v; }
+
+template <typename>
+int foo(int v)
+{
+    return int{id(v)};
+}