check_redeclaration_exception_specification (newdecl, olddecl);
TREE_TYPE (newdecl) = TREE_TYPE (olddecl) = newtype;
+ if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ check_default_args (newdecl);
+
/* Lay the type out, unless already done. */
if (! same_type_p (newtype, oldtype)
&& TREE_TYPE (newdecl) != error_mark_node
you declare a function, these types can be incomplete, but they
must be complete when you define the function. */
check_function_type (decl1, current_function_parms);
- /* Make sure no default arg is missing. */
- check_default_args (decl1);
/* Build the return declaration for the function. */
restype = TREE_TYPE (fntype);
--- /dev/null
+// PR c++/28274
+// { dg-do "compile" }
+
+void f1(int, int, int, int, int = 0);
+void f1(int, int, int, int = 0, int);
+void f1(int, int, int = 0, int, int);
+void f1(int = 0, int, int, int, int); // { dg-error "default" }
+
+void f2(int, int, int, int, int = 0) {}
+void f2(int, int, int, int = 0, int);
+void f2(int, int, int = 0, int, int);
+void f2(int = 0, int, int, int, int); // { dg-error "default" }
+
+void f3(int, int, int, int, int = 0);
+void f3(int, int, int, int = 0, int) {}
+void f3(int, int, int = 0, int, int);
+void f3(int = 0, int, int, int, int); // { dg-error "default" }
+
+void f4(int, int, int, int, int = 0);
+void f4(int, int, int, int = 0, int);
+void f4(int, int, int = 0, int, int) {}
+void f4(int = 0, int, int, int, int); // { dg-error "default" }
+
+void f5(int, int, int, int, int = 0);
+void f5(int, int, int, int = 0, int);
+void f5(int, int, int = 0, int, int);
+void f5(int = 0, int, int, int, int) {} // { dg-error "default" }
+
+
+struct A
+{
+ void F1(int, int, int = 0);
+ void F2(int, int, int = 0);
+};
+
+void A::F1(int, int = 0, int) {}
+void A::F2(int = 0, int, int) {} // { dg-error "default" }
+
+
+template<int> struct B
+{
+ void F1(int, int, int = 0);
+ void F2(int, int, int = 0);
+};
+
+template<int N> void B<N>::F1(int, int = 0, int) {}
+template<int N> void B<N>::F2(int = 0, int, int) {} // { dg-error "default" }