summaryrefslogtreecommitdiff
path: root/gcc/c-typeck.c
diff options
context:
space:
mode:
authormrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>2002-10-26 01:18:52 +0000
committermrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>2002-10-26 01:18:52 +0000
commitf2b25a66d5747dd62bfb0aaf6c6296fb600f59d1 (patch)
tree2d00071b22ba1ea6afacc4fa452106cec43387de /gcc/c-typeck.c
parentb78815d4fd55eb9b2612ec0365a10dbcd3f05008 (diff)
downloadgcc-f2b25a66d5747dd62bfb0aaf6c6296fb600f59d1.tar.gz
* c-typeck.c (warn_for_assignment): Don't print argument number, if zero.
Fixes gcc.dg/warn-1.c. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@58550 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r--gcc/c-typeck.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index b5bc210dab4..0915b1091c8 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -4309,7 +4309,8 @@ c_convert_parm_for_inlining (parm, value, fn)
/* Print a warning using MSGID.
It gets OPNAME as its one parameter.
- If OPNAME is null, it is replaced by "passing arg ARGNUM of `FUNCTION'".
+ if OPNAME is null and ARGNUM is 0, it is replaced by "passing arg of `FUNCTION'".
+ Otherwise if OPNAME is null, it is replaced by "passing arg ARGNUM of `FUNCTION'".
FUNCTION and ARGNUM are handled specially if we are building an
Objective-C selector. */
@@ -4330,7 +4331,27 @@ warn_for_assignment (msgid, opname, function, argnum)
function = selector;
argnum -= 2;
}
- if (function)
+ if (argnum == 0)
+ {
+ if (function)
+ {
+ /* Function name is known; supply it. */
+ const char *const argstring = _("passing arg of `%s'");
+ new_opname = (char *) alloca (IDENTIFIER_LENGTH (function)
+ + strlen (argstring) + 1
+ + 1);
+ sprintf (new_opname, argstring,
+ IDENTIFIER_POINTER (function));
+ }
+ else
+ {
+ /* Function name unknown (call through ptr). */
+ const char *const argnofun = _("passing arg of pointer to function");
+ new_opname = (char *) alloca (strlen (argnofun) + 1 + 1);
+ sprintf (new_opname, argnofun);
+ }
+ }
+ else if (function)
{
/* Function name is known; supply it. */
const char *const argstring = _("passing arg %d of `%s'");