Fix default argument conversion failure and SFINAE.
authorJason Merrill <jason@redhat.com>
Tue, 29 Aug 2017 19:39:18 +0000 (15:39 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 29 Aug 2017 19:39:18 +0000 (15:39 -0400)
* call.c (build_over_call): Check convert_default_arg result for
error_mark_node.
* parser.c (cp_parser_late_parsing_default_args): Remember
error_mark_node.

From-SVN: r251421

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/parser.c
gcc/testsuite/g++.dg/ext/is_constructible1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/new1.C
gcc/testsuite/g++.dg/parse/crash40.C
gcc/testsuite/g++.dg/parse/defarg12.C
gcc/testsuite/g++.dg/template/error15.C

index 37ae6ea17c038a13e0600c6e07b665295960bec0..fc244a138037d685ac80691f7a46fca0dfc55668 100644 (file)
@@ -1,3 +1,11 @@
+2017-08-29  Jason Merrill  <jason@redhat.com>
+
+       Fix default argument conversion failure and SFINAE.
+       * call.c (build_over_call): Check convert_default_arg result for
+       error_mark_node.
+       * parser.c (cp_parser_late_parsing_default_args): Remember
+       error_mark_node.
+
 2017-08-28  Nathan Sidwell  <nathan@acm.org>
 
        * cp-tree.h (lang_type): Replace sorted_fields vector with
index 067db59ae2ccedd46d8970f9423c17bc05e0f7d2..6405be2d4803df586f98e85ef1a4b3404a459d63 100644 (file)
@@ -7892,10 +7892,13 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
     {
       if (TREE_VALUE (parm) == error_mark_node)
        return error_mark_node;
-      argarray[j++] = convert_default_arg (TREE_VALUE (parm),
-                                          TREE_PURPOSE (parm),
-                                          fn, i - is_method,
-                                          complain);
+      val = convert_default_arg (TREE_VALUE (parm),
+                                TREE_PURPOSE (parm),
+                                fn, i - is_method,
+                                complain);
+      if (val == error_mark_node)
+        return error_mark_node;
+      argarray[j++] = val;
     }
 
   /* Ellipsis */
index b849824fcd0fb441f4fe7a26557bb76756230097..9b7c2c0dd6e98cd223e8956e51e07d15a37542b3 100644 (file)
@@ -27645,11 +27645,6 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
        = cp_parser_late_parse_one_default_arg (parser, parmdecl,
                                                default_arg,
                                                TREE_VALUE (parm));
-      if (parsed_arg == error_mark_node)
-       {
-         continue;
-       }
-
       TREE_PURPOSE (parm) = parsed_arg;
 
       /* Update any instantiations we've already created.  */
diff --git a/gcc/testsuite/g++.dg/ext/is_constructible1.C b/gcc/testsuite/g++.dg/ext/is_constructible1.C
new file mode 100644 (file)
index 0000000..b80ac28
--- /dev/null
@@ -0,0 +1,6 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+template<class T> struct Foo { Foo(T = nullptr) {} };
+
+static_assert (!__is_constructible(Foo<int>));
index 71383706ea4efc662ed34ac8f5bce3e15676b3b6..30b651326aa34787f86e6db914a6a328b51bed26 100644 (file)
@@ -10,5 +10,5 @@ struct A
 
 void foo()
 {
-  new A;       // { dg-error "default argument" }
+  new A;
 }
index df352dd7db59d2986e6fd2f7e6861896c3a03abe..537cdb78ef1965eca0bfef0fe9a5023aab4b7f34 100644 (file)
@@ -37,6 +37,6 @@ void bar()
   int i;
   i.C::foo<0>(); /* { dg-error "which is of non-class type" } */
 
-  S<false> s; /* { dg-error "default argument" } */
+  S<false> s;
   SS<false> ss;
 }
index 2d2d7e7a06ad118d606ba920757a960c7f8e5294..df805813897c74cd8ac52c74bb51c293fb41c4f7 100644 (file)
@@ -9,5 +9,5 @@ struct A
 
 void foo()
 {
-  A().i; /* { dg-error "default argument" } */
+  A().i;
 }
index 86936581cfd74a9fbad2d466ccab19ca4b853005..ad18a1b3f9af7cbbbc2d2966b2bce2360595a569 100644 (file)
@@ -18,7 +18,7 @@ protected:
 
 template <class T>
 void B<T>::g(void) {
-  f(); // { dg-error "default argument" }
+  f();
 }
 
 template class B<long>;