Commit 95035b6f by Gabriel Dos Reis Committed by Gabriel Dos Reis

c-decl.c (define_label): Tidy.

	* c-decl.c (define_label): Tidy.  Don't use any of
	error_with_file_and_line or warning_with_file_and_file.
	(pending_xref_error): Likewise.
	(store_parm_decls): Likewise.
	(current_function_prototype_locus): New object.  Package from
	current_function_prototype_file and current_function_prototype_line.
	(start_function): Use it.
	(current_function_prototype_file): Remove.
	(current_function_prototype_line): Remove;

From-SVN: r66599
parent 7dc61d6c
2003-05-08 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-decl.c (define_label): Tidy. Don't use any of
error_with_file_and_line or warning_with_file_and_file.
(pending_xref_error): Likewise.
(store_parm_decls): Likewise.
(current_function_prototype_locus): New object. Package from
current_function_prototype_file and current_function_prototype_line.
(start_function): Use it.
(current_function_prototype_file): Remove.
(current_function_prototype_line): Remove;
2003-05-08 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2003-05-08 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.c (readonly_data_expr): New function. * builtins.c (readonly_data_expr): New function.
......
...@@ -100,8 +100,7 @@ static tree current_function_parm_tags; ...@@ -100,8 +100,7 @@ static tree current_function_parm_tags;
/* Similar, for the file and line that the prototype came from if this is /* Similar, for the file and line that the prototype came from if this is
an old-style definition. */ an old-style definition. */
static const char *current_function_prototype_file; static location_t current_function_prototype_locus;
static int current_function_prototype_line;
/* The current statement tree. */ /* The current statement tree. */
...@@ -2070,12 +2069,12 @@ shadow_label (name) ...@@ -2070,12 +2069,12 @@ shadow_label (name)
Otherwise return 0. */ Otherwise return 0. */
tree tree
define_label (filename, line, name) define_label (const char* filename, int line, tree name)
const char *filename;
int line;
tree name;
{ {
location_t locus;
tree decl = lookup_label (name); tree decl = lookup_label (name);
locus.file = filename;
locus.line = line;
/* If label with this name is known from an outer context, shadow it. */ /* If label with this name is known from an outer context, shadow it. */
if (decl != 0 && DECL_CONTEXT (decl) != current_function_decl) if (decl != 0 && DECL_CONTEXT (decl) != current_function_decl)
...@@ -2086,14 +2085,12 @@ define_label (filename, line, name) ...@@ -2086,14 +2085,12 @@ define_label (filename, line, name)
} }
if (warn_traditional && !in_system_header && lookup_name (name)) if (warn_traditional && !in_system_header && lookup_name (name))
warning_with_file_and_line (filename, line, warning ("%Htraditional C lacks a separate namespace for labels, "
"traditional C lacks a separate namespace for labels, identifier `%s' conflicts", "identifier `%s' conflicts", &locus, IDENTIFIER_POINTER (name));
IDENTIFIER_POINTER (name));
if (DECL_INITIAL (decl) != 0) if (DECL_INITIAL (decl) != 0)
{ {
error_with_file_and_line (filename, line, "duplicate label `%s'", error ("%Hduplicate label `%s'", &locus, IDENTIFIER_POINTER (name));
IDENTIFIER_POINTER (name));
return 0; return 0;
} }
else else
...@@ -2101,8 +2098,7 @@ define_label (filename, line, name) ...@@ -2101,8 +2098,7 @@ define_label (filename, line, name)
/* Mark label as having been defined. */ /* Mark label as having been defined. */
DECL_INITIAL (decl) = error_mark_node; DECL_INITIAL (decl) = error_mark_node;
/* Say where in the source. */ /* Say where in the source. */
DECL_SOURCE_FILE (decl) = filename; DECL_SOURCE_LOCATION (decl) = locus;
DECL_SOURCE_LINE (decl) = line;
return decl; return decl;
} }
} }
...@@ -2202,10 +2198,9 @@ void ...@@ -2202,10 +2198,9 @@ void
pending_xref_error () pending_xref_error ()
{ {
if (pending_invalid_xref != 0) if (pending_invalid_xref != 0)
error_with_file_and_line (pending_invalid_xref_location.file, error ("%H`%s' defined as wrong kind of tag",
pending_invalid_xref_location.line, &pending_invalid_xref_location,
"`%s' defined as wrong kind of tag", IDENTIFIER_POINTER (pending_invalid_xref));
IDENTIFIER_POINTER (pending_invalid_xref));
pending_invalid_xref = 0; pending_invalid_xref = 0;
} }
...@@ -5536,8 +5531,7 @@ start_function (declspecs, declarator, attributes) ...@@ -5536,8 +5531,7 @@ start_function (declspecs, declarator, attributes)
&& TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0) && 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_locus = DECL_SOURCE_LOCATION (old_decl);
current_function_prototype_line = DECL_SOURCE_LINE (old_decl);
} }
/* Optionally warn of old-fashioned def with no previous prototype. */ /* Optionally warn of old-fashioned def with no previous prototype. */
...@@ -5966,9 +5960,8 @@ store_parm_decls () ...@@ -5966,9 +5960,8 @@ store_parm_decls ()
|| TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node) || TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
{ {
error ("number of arguments doesn't match prototype"); error ("number of arguments doesn't match prototype");
error_with_file_and_line (current_function_prototype_file, error ("%Hprototype declaration",
current_function_prototype_line, &current_function_prototype_locus);
"prototype declaration");
break; break;
} }
/* Type for passing arg must be consistent with that /* Type for passing arg must be consistent with that
...@@ -5997,19 +5990,16 @@ store_parm_decls () ...@@ -5997,19 +5990,16 @@ store_parm_decls ()
{ {
pedwarn ("promoted argument `%s' doesn't match prototype", pedwarn ("promoted argument `%s' doesn't match prototype",
IDENTIFIER_POINTER (DECL_NAME (parm))); IDENTIFIER_POINTER (DECL_NAME (parm)));
warning_with_file_and_line warning ("%Hprototype declaration",
(current_function_prototype_file, &current_function_prototype_locus);
current_function_prototype_line,
"prototype declaration");
} }
} }
else else
{ {
error ("argument `%s' doesn't match prototype", error ("argument `%s' doesn't match prototype",
IDENTIFIER_POINTER (DECL_NAME (parm))); IDENTIFIER_POINTER (DECL_NAME (parm)));
error_with_file_and_line (current_function_prototype_file, error ("%Hprototype declaration",
current_function_prototype_line, &current_function_prototype_locus);
"prototype declaration");
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment