This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for KDE default argument issue


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.
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();
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]