aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorShujing Zhao <pearly.zhao@oracle.com>2010-04-30 06:16:26 +0000
committerShujing Zhao <pzhao@gcc.gnu.org>2010-04-30 06:16:26 +0000
commit8cdea6ab132a3624569e3dd32eabff4d84fb5a25 (patch)
treec49bd712866a97c4cf438a468ac34ac0062e8133 /gcc
parent10ab8f62dbcd15439b2c1a8b6114e4fb4281731a (diff)
downloadgcc-8cdea6ab132a3624569e3dd32eabff4d84fb5a25.zip
gcc-8cdea6ab132a3624569e3dd32eabff4d84fb5a25.tar.gz
gcc-8cdea6ab132a3624569e3dd32eabff4d84fb5a25.tar.bz2
re PR c++/43779 (Parts of message not available for translation)
2010-04-30 Shujing Zhao <pearly.zhao@oracle.com> PR c++/43779 * typeck.c (warn_args_num): New function. (convert_arguments): Use warn_args_num to print the diagnostic messages. From-SVN: r158919
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/typeck.c76
2 files changed, 48 insertions, 35 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 58815e9..6a41a03 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-30 Shujing Zhao <pearly.zhao@oracle.com>
+
+ PR c++/43779
+ * typeck.c (warn_args_num): New function.
+ (convert_arguments): Use warn_args_num to print the diagnostic
+ messages.
+
2010-04-29 Fabien ChĂȘne <fabien.chene@gmail.com>
PR c++/43890
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index bc699a1..46bc34d 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -61,6 +61,7 @@ static void casts_away_constness_r (tree *, tree *);
static bool casts_away_constness (tree, tree);
static void maybe_warn_about_returning_address_of_local (tree);
static tree lookup_destructor (tree, tree, tree);
+static void warn_args_num (location_t, tree, bool);
static int convert_arguments (tree, VEC(tree,gc) **, tree, int,
tsubst_flags_t);
@@ -3286,6 +3287,44 @@ cp_build_function_call_vec (tree function, VEC(tree,gc) **params,
return ret;
}
+/* Subroutine of convert_arguments.
+ Warn about wrong number of args are genereted. */
+
+static void
+warn_args_num (location_t loc, tree fndecl, bool too_many_p)
+{
+ if (fndecl)
+ {
+ if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
+ {
+ if (DECL_NAME (fndecl) == NULL_TREE
+ || IDENTIFIER_HAS_TYPE_VALUE (DECL_NAME (fndecl)))
+ error_at (loc,
+ too_many_p
+ ? G_("too many arguments to constructor %q#D")
+ : G_("too few arguments to constructor %q#D"),
+ fndecl);
+ else
+ error_at (loc,
+ too_many_p
+ ? G_("too many arguments to member function %q#D")
+ : G_("too few arguments to member function %q#D"),
+ fndecl);
+ }
+ else
+ error_at (loc,
+ too_many_p
+ ? G_("too many arguments to function %q#D")
+ : G_("too few arguments to function %q#D"),
+ fndecl);
+ inform (DECL_SOURCE_LOCATION (fndecl),
+ "declared here");
+ }
+ else
+ error_at (loc, too_many_p ? G_("too many arguments to function")
+ : G_("too few arguments to function"));
+}
+
/* Convert the actual parameter expressions in the list VALUES to the
types in the list TYPELIST. The converted expressions are stored
back in the VALUES vector.
@@ -3307,26 +3346,11 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl,
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++)
@@ -3341,15 +3365,7 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl,
{
if (complain & tf_error)
{
- if (fndecl)
- {
- error_at (input_location, "too many arguments to %s %q#D",
- called_thing, fndecl);
- inform (DECL_SOURCE_LOCATION (fndecl),
- "declared here");
- }
- else
- error ("too many arguments to function");
+ warn_args_num (input_location, fndecl, /*too_many_p=*/true);
return i;
}
else
@@ -3454,17 +3470,7 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl,
else
{
if (complain & tf_error)
- {
- if (fndecl)
- {
- error_at (input_location, "too few arguments to %s %q#D",
- called_thing, fndecl);
- inform (DECL_SOURCE_LOCATION (fndecl),
- "declared here");
- }
- else
- error ("too few arguments to function");
- }
+ warn_args_num (input_location, fndecl, /*too_many_p=*/false);
return -1;
}
}