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]

[PATCH, C++] Fix pr43779


Hi,

This patch fixed pr43779 that emits the diagnostic for easy translation.
Tested on i686-pc-linux-gnu with no regression. OK for trunk?
Since it is reported for 4.5.0, should gcc-4_5-branch be fixed too?

Thanks
Pearly
2010-04-28  Shujing Zhao  <pearly.zhao@oracle.com>

	PR c++/43779
	* typeck.c (convert_arguments): Emit the diagnostics for easy
	translation.

Index: typeck.c
===================================================================
--- typeck.c	(revision 158822)
+++ typeck.c	(working copy)
@@ -3307,26 +3307,11 @@ convert_arguments (tree typelist, VEC(tr
 		   int flags, tsubst_flags_t complain)
 {
   tree typetail;
-  const char *called_thing = 0;
   unsigned int i;
 
   /* Argument passing is always copy-initialization.  */
   flags |= LOOKUP_ONLYCONVERTING;
 
-  if (fndecl)
-    {
-      if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
-	{
-	  if (DECL_NAME (fndecl) == NULL_TREE
-	      || IDENTIFIER_HAS_TYPE_VALUE (DECL_NAME (fndecl)))
-	    called_thing = "constructor";
-	  else
-	    called_thing = "member function";
-	}
-      else
-	called_thing = "function";
-    }
-
   for (i = 0, typetail = typelist;
        i < VEC_length (tree, *values);
        i++)
@@ -3343,8 +3328,21 @@ convert_arguments (tree typelist, VEC(tr
             {
               if (fndecl)
                 {
-                  error_at (input_location, "too many arguments to %s %q#D", 
-			    called_thing, fndecl);
+		  if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
+		    {
+		      if (DECL_NAME (fndecl) == NULL_TREE
+			  || IDENTIFIER_HAS_TYPE_VALUE (DECL_NAME (fndecl)))
+			error_at (input_location, 
+				  "too many arguments to constructor %q#D",
+				  fndecl);
+		      else
+			error_at (input_location,
+				  "too many arguments to member function %q#D",
+				  fndecl);
+		    }
+		  else
+		    error_at (input_location,
+			      "too many arguments to function %q#D", fndecl);
 		  inform (DECL_SOURCE_LOCATION (fndecl),
 			  "declared here");
                 }
@@ -3457,8 +3455,21 @@ convert_arguments (tree typelist, VEC(tr
             {
               if (fndecl)
                 {
-                  error_at (input_location, "too few arguments to %s %q#D", 
-			    called_thing, fndecl);
+		  if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
+		    {
+		      if (DECL_NAME (fndecl) == NULL_TREE
+			  || IDENTIFIER_HAS_TYPE_VALUE (DECL_NAME (fndecl)))
+			error_at (input_location,
+				  "too few arguments to constructor %q#D",
+				  fndecl);
+		      else
+			error_at (input_location,
+				  "too few arguments to member function %q#D",
+				  fndecl);
+		    }
+		  else
+		    error_at (input_location,
+			      "too few arguments to function %q#D", fndecl);
 		  inform (DECL_SOURCE_LOCATION (fndecl),
 			  "declared here");
                 }

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