Patchwork C++ PATCH for KDE default argument issue

login
register
mail settings
Submitter Jason Merrill
Date Jan. 2, 2013, 7:58 p.m.
Message ID <50E4914E.8030706@redhat.com>
Download mbox | patch
Permalink /patch/209140/
State New
Headers show

Comments

Jason Merrill - Jan. 2, 2013, 7:58 p.m.
Jakub sent me a testcase from KDE that has started failing since my 
change to how default argument conversions are checked; we were ignoring 
'explicit' when considering applicable conversions.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 31f87e04a3bcdfe18c2672fe9725d96117a95031
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jan 2 14:14:24 2013 -0500

    	* decl.c (check_default_argument): Use LOOKUP_IMPLICIT.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 64bd4b5..52ceefc 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10829,7 +10829,7 @@  check_default_argument (tree decl, tree arg)
      parameter type.  */
   ++cp_unevaluated_operand;
   perform_implicit_conversion_flags (decl_type, arg, tf_warning_or_error,
-				     LOOKUP_NORMAL);
+				     LOOKUP_IMPLICIT);
   --cp_unevaluated_operand;
 
   if (warn_zero_as_null_pointer_constant
diff --git a/gcc/testsuite/g++.dg/overload/defarg7.C b/gcc/testsuite/g++.dg/overload/defarg7.C
new file mode 100644
index 0000000..8cc08f5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/overload/defarg7.C
@@ -0,0 +1,12 @@ 
+struct A
+{
+  A(const char *);
+  explicit A(const int *);
+};
+
+void f (A a = 0);
+
+int main()
+{
+  f();
+}