PR c++/32839
* typeck.c (convert_arguments): Only use default args if we have
a function decl.
testsuite/
PR c++/32839
* g++.dg/expr/call4.C: New.
* g++.dg/expr/call5.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126829
138bc75d-0d04-0410-961f-
82ee72b054a4
2007-07-22 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/32839
+ * typeck.c (convert_arguments): Only use default args if we have
+ a function decl.
+
PR c++/30818
* typeck.c (structural_comptypes): No need to check
resolve_typename_type return value here.
if (typetail != 0 && typetail != void_list_node)
{
- /* See if there are default arguments that can be used. */
- if (TREE_PURPOSE (typetail)
+ /* See if there are default arguments that can be used. Because
+ we hold default arguments in the FUNCTION_TYPE (which is so
+ wrong), we can see default parameters here from deduced
+ contexts (and via typeof) for indirect function calls.
+ Fortunately we know whether we have a function decl to
+ provide default arguments in a language conformant
+ manner. */
+ if (fndecl && TREE_PURPOSE (typetail)
&& TREE_CODE (TREE_PURPOSE (typetail)) != DEFAULT_ARG)
{
for (; typetail != void_list_node; ++i)
+2007-07-22 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/32839
+ * g++.dg/expr/call4.C: New.
+ * g++.dg/expr/call5.C: New.
+
2007-07-22 Daniel Franke <franke.daniel@gmail.com>
PR fortran/32710
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2007 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 22 Jul 2007 <nathan@codesourcery.com>
+
+// Origin: Danny Boelens <danny.boelens@artwork-systems.com>
+// PR 32839. Default arguments propagated through the type system to
+// an indirect call.
+
+template<typename T>
+struct TPL
+{
+ enum Whatever {e1, e2};
+
+ static void Quux (int i = e1 | e2);
+};
+
+template <typename F>
+void DoIt (F fun)
+{
+ fun (); // { dg-error "too few arguments" }
+}
+
+void Foo ()
+{
+ DoIt (&TPL<int>::Quux);
+}
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2007 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 22 Jul 2007 <nathan@codesourcery.com>
+
+// PR 32839. Default arguments propagated through the type system to
+// an indirect call.
+
+void Quux (int i = 0);
+void Baz (int i);
+
+void Foo ()
+{
+ __typeof (Quux) *q = Baz;
+
+ q (); // { dg-error "too few arguments" }
+}
+
+