aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Wilson <wilson@gcc.gnu.org>1993-03-18 14:01:56 -0800
committerJim Wilson <wilson@gcc.gnu.org>1993-03-18 14:01:56 -0800
commit50a9145ce3ba5fad804d4f3fc77946c7ef79fc33 (patch)
tree9629fc6a8dc65ac2d9c2a5d89447f677be867449
parent3e3f5658134438dcfb4ed65f19204cc52faeec16 (diff)
downloadgcc-50a9145ce3ba5fad804d4f3fc77946c7ef79fc33.zip
gcc-50a9145ce3ba5fad804d4f3fc77946c7ef79fc33.tar.gz
gcc-50a9145ce3ba5fad804d4f3fc77946c7ef79fc33.tar.bz2
current_function_prototype_line): New variables.
(current_function_prototype_file, current_function_prototype_line): New variables. (start_function): Set them. (store_parm_decls): Use them for error and warning messages. From-SVN: r3782
-rw-r--r--gcc/c-decl.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 22056c9..49d5ba3 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -235,6 +235,11 @@ static tree current_function_parms;
/* Similar, for last_function_parm_tags. */
static tree current_function_parm_tags;
+/* Similar, for the file and line that the prototype came from if this is
+ an old-style definition. */
+static char *current_function_prototype_file;
+static int current_function_prototype_line;
+
/* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
that have names. Here so we can clear out their names' definitions
at the end of the function. */
@@ -5555,7 +5560,11 @@ start_function (declspecs, declarator, nested)
&& (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
== TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (old_decl))))
&& TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0)
- TREE_TYPE (decl1) = TREE_TYPE (old_decl);
+ {
+ TREE_TYPE (decl1) = TREE_TYPE (old_decl);
+ current_function_prototype_file = DECL_SOURCE_FILE (old_decl);
+ current_function_prototype_line = DECL_SOURCE_LINE (old_decl);
+ }
/* Optionally warn of old-fashioned def with no previous prototype. */
if (warn_strict_prototypes
@@ -5922,6 +5931,9 @@ store_parm_decls ()
|| TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
{
error ("number of arguments doesn't match prototype");
+ error_with_file_and_line (current_function_prototype_file,
+ current_function_prototype_line,
+ "prototype declaration");
break;
}
/* Type for passing arg must be consistent
@@ -5944,16 +5956,27 @@ store_parm_decls ()
DECL_ARG_TYPE (parm) = integer_type_node;
#endif
if (pedantic)
- pedwarn ("promoted argument `%s' doesn't match prototype",
- IDENTIFIER_POINTER (DECL_NAME (parm)));
+ {
+ warning ("promoted argument `%s' doesn't match prototype",
+ IDENTIFIER_POINTER (DECL_NAME (parm)));
+ warning_with_file_and_line
+ (current_function_prototype_file,
+ current_function_prototype_line,
+ "prototype declaration");
+ }
}
/* If -traditional, allow `int' argument to match
`unsigned' prototype. */
else if (! (flag_traditional
&& TYPE_MAIN_VARIANT (TREE_TYPE (parm)) == integer_type_node
&& TYPE_MAIN_VARIANT (TREE_VALUE (type)) == unsigned_type_node))
- error ("argument `%s' doesn't match prototype",
- IDENTIFIER_POINTER (DECL_NAME (parm)));
+ {
+ error ("argument `%s' doesn't match prototype",
+ IDENTIFIER_POINTER (DECL_NAME (parm)));
+ error_with_file_and_line (current_function_prototype_file,
+ current_function_prototype_line,
+ "prototype declaration");
+ }
}
}
TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = 0;