diagnostic.c (inform): Add an explicit location_t parameter.

2008-08-18  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	* diagnostic.c (inform): Add an explicit location_t parameter.
	* toplev.h (inform): Update declaration.
	* builtins.c: Update all calls to inform.
	* c-common.c: Likewise.
	* c-decl.c: Likewise.
	* c-opts.c: Likewise.
	* c-pch.c: Likewise.
	* c-pragma.c: Likewise.
	* c-typeck.c: Likewise.
	* coverage.c: Likewise.
	* opts.c: Likewise.
	* toplev.c: Likewise.
	* tree-cfg.c: Likewise.
	* tree-ssa.c: Likewise.
cp/	
	* parser.c: Update all calls to inform.
	* typeck.c: Likewise.
	* init.c: Likewise.
	* class.c: Likewise.
	* call.c: Likewise.
	* method.c: Likewise.
	* friend.c: Likewise.
	* typeck2.c: Likewise.
	* pt.c: Likewise.
	* name-lookup.c: Likewise.
	* lex.c: Likewise.

From-SVN: r139293
This commit is contained in:
Manuel López-Ibáñez 2008-08-20 13:35:00 +00:00
parent f4857d6e2a
commit 1f5b386928
27 changed files with 103 additions and 70 deletions

View File

@ -1,3 +1,20 @@
2008-08-20 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
* diagnostic.c (inform): Add an explicit location_t parameter.
* toplev.h (inform): Update declaration.
* builtins.c: Update all calls to inform.
* c-common.c: Likewise.
* c-decl.c: Likewise.
* c-opts.c: Likewise.
* c-pch.c: Likewise.
* c-pragma.c: Likewise.
* c-typeck.c: Likewise.
* coverage.c: Likewise.
* opts.c: Likewise.
* toplev.c: Likewise.
* tree-cfg.c: Likewise.
* tree-ssa.c: Likewise.
2008-08-20 H.J. Lu <hongjiu.lu@intel.com>
PR target/37169

View File

@ -4933,14 +4933,14 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
if (!gave_help && warned)
{
gave_help = true;
inform ("(so you should pass %qT not %qT to %<va_arg%>)",
inform (input_location, "(so you should pass %qT not %qT to %<va_arg%>)",
promoted_type, type);
}
/* We can, however, treat "undefined" any way we please.
Call abort to encourage the user to fix the program. */
if (warned)
inform ("if this code is reached, the program will abort");
inform (input_location, "if this code is reached, the program will abort");
t = build_call_expr (implicit_built_in_decls[BUILT_IN_TRAP], 0);
gimplify_and_add (t, pre_p);

View File

@ -1436,7 +1436,7 @@ vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note)
if (emit_lax_note && !emitted_lax_note)
{
emitted_lax_note = true;
inform ("use -flax-vector-conversions to permit "
inform (input_location, "use -flax-vector-conversions to permit "
"conversions between vectors with differing "
"element types or numbers of subparts");
}

View File

@ -1029,14 +1029,14 @@ diagnose_arglist_conflict (tree newdecl, tree olddecl,
if (TREE_CHAIN (t) == 0
&& TYPE_MAIN_VARIANT (type) != void_type_node)
{
inform ("a parameter list with an ellipsis can%'t match "
inform (input_location, "a parameter list with an ellipsis can%'t match "
"an empty parameter name list declaration");
break;
}
if (c_type_promotes_to (type) != type)
{
inform ("an argument type that has a default promotion can%'t match "
inform (input_location, "an argument type that has a default promotion can%'t match "
"an empty parameter name list declaration");
break;
}
@ -1120,11 +1120,11 @@ locate_old_decl (tree decl)
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
;
else if (DECL_INITIAL (decl))
inform ("previous definition of %q+D was here", decl);
inform (input_location, "previous definition of %q+D was here", decl);
else if (C_DECL_IMPLICIT (decl))
inform ("previous implicit declaration of %q+D was here", decl);
inform (input_location, "previous implicit declaration of %q+D was here", decl);
else
inform ("previous declaration of %q+D was here", decl);
inform (input_location, "previous declaration of %q+D was here", decl);
}
/* Subroutine of duplicate_decls. Compare NEWDECL to OLDDECL.

View File

@ -321,7 +321,7 @@ c_common_handle_option (size_t scode, const char *arg, int value)
error ("-I- specified twice");
quote_chain_split = true;
split_quote_chain ();
inform ("obsolete option -I- used, please use -iquote instead");
inform (input_location, "obsolete option -I- used, please use -iquote instead");
}
break;

View File

@ -463,7 +463,7 @@ c_common_pch_pragma (cpp_reader *pfile, const char *name)
if (!cpp_get_options (pfile)->preprocessed)
{
error ("pch_preprocess pragma should only be used with -fpreprocessed");
inform ("use #include instead");
inform (input_location, "use #include instead");
return;
}
@ -474,7 +474,7 @@ c_common_pch_pragma (cpp_reader *pfile, const char *name)
if (c_common_valid_pch (pfile, name, fd) != 1)
{
if (!cpp_get_options (pfile)->warn_invalid_pch)
inform ("use -Winvalid-pch for more information");
inform (input_location, "use -Winvalid-pch for more information");
fatal_error ("%s: PCH file was invalid", name);
}

View File

@ -1203,7 +1203,7 @@ handle_pragma_message (cpp_reader *ARG_UNUSED(dummy))
warning (OPT_Wpragmas, "junk at end of %<#pragma message%>");
if (TREE_STRING_LENGTH (message) > 1)
inform ("#pragma message: %s", TREE_STRING_POINTER (message));
inform (input_location, "#pragma message: %s", TREE_STRING_POINTER (message));
}
/* A vector of registered pragma callbacks. */

View File

@ -2411,7 +2411,7 @@ build_function_call (tree function, tree params)
if (warning (0, "function called through a non-compatible type"))
/* We can, however, treat "undefined" any way we please.
Call abort to encourage the user to fix the program. */
inform ("if this code is reached, the program will abort");
inform (input_location, "if this code is reached, the program will abort");
if (VOID_TYPE_P (return_type))
return trap;

View File

@ -334,7 +334,7 @@ get_coverage_counts (unsigned counter, unsigned expected,
static int warned = 0;
if (!warned++)
inform ((flag_guess_branch_prob
inform (input_location, (flag_guess_branch_prob
? "file %s not found, execution counts estimated"
: "file %s not found, execution counts assumed to be zero"),
da_file_name);
@ -369,9 +369,9 @@ get_coverage_counts (unsigned counter, unsigned expected,
if (!inhibit_warnings)
{
if (entry->checksum != checksum)
inform ("checksum is %x instead of %x", entry->checksum, checksum);
inform (input_location, "checksum is %x instead of %x", entry->checksum, checksum);
else
inform ("number of counters is %d instead of %d",
inform (input_location, "number of counters is %d instead of %d",
entry->summary.num, expected);
}
@ -379,12 +379,12 @@ get_coverage_counts (unsigned counter, unsigned expected,
&& !inhibit_warnings
&& !warned++)
{
inform ("coverage mismatch ignored due to -Wcoverage-mismatch");
inform (flag_guess_branch_prob
inform (input_location, "coverage mismatch ignored due to -Wcoverage-mismatch");
inform (input_location, flag_guess_branch_prob
? "execution counts estimated"
: "execution counts assumed to be zero");
if (!flag_guess_branch_prob)
inform ("this can result in poorly optimized code");
inform (input_location, "this can result in poorly optimized code");
}
return NULL;

View File

@ -1,3 +1,17 @@
2008-08-20 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
* parser.c: Update all calls to inform.
* typeck.c: Likewise.
* init.c: Likewise.
* class.c: Likewise.
* call.c: Likewise.
* method.c: Likewise.
* friend.c: Likewise.
* typeck2.c: Likewise.
* pt.c: Likewise.
* name-lookup.c: Likewise.
* lex.c: Likewise.
2008-08-19 Jakub Jelinek <jakub@redhat.com>
PR debug/37156

View File

@ -2545,24 +2545,24 @@ print_z_candidate (const char *msgstr, struct z_candidate *candidate)
if (TREE_CODE (candidate->fn) == IDENTIFIER_NODE)
{
if (candidate->num_convs == 3)
inform ("%s %D(%T, %T, %T) <built-in>", msgstr, candidate->fn,
inform (input_location, "%s %D(%T, %T, %T) <built-in>", msgstr, candidate->fn,
candidate->convs[0]->type,
candidate->convs[1]->type,
candidate->convs[2]->type);
else if (candidate->num_convs == 2)
inform ("%s %D(%T, %T) <built-in>", msgstr, candidate->fn,
inform (input_location, "%s %D(%T, %T) <built-in>", msgstr, candidate->fn,
candidate->convs[0]->type,
candidate->convs[1]->type);
else
inform ("%s %D(%T) <built-in>", msgstr, candidate->fn,
inform (input_location, "%s %D(%T) <built-in>", msgstr, candidate->fn,
candidate->convs[0]->type);
}
else if (TYPE_P (candidate->fn))
inform ("%s %T <conversion>", msgstr, candidate->fn);
inform (input_location, "%s %T <conversion>", msgstr, candidate->fn);
else if (candidate->viable == -1)
inform ("%s %+#D <near match>", msgstr, candidate->fn);
inform (input_location, "%s %+#D <near match>", msgstr, candidate->fn);
else
inform ("%s %+#D", msgstr, candidate->fn);
inform (input_location, "%s %+#D", msgstr, candidate->fn);
}
static void
@ -6651,7 +6651,7 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn)
&& warning (OPT_Wconversion, " for conversion from %qT to %qT",
source, w->second_conv->type))
{
inform (" because conversion sequence for the argument is better");
inform (input_location, " because conversion sequence for the argument is better");
}
}
else

View File

@ -6174,7 +6174,7 @@ resolve_address_of_overloaded_function (tree target_type,
permerror (input_location, "assuming pointer to member %qD", fn);
if (!explained)
{
inform ("(a pointer to member can only be formed with %<&%E%>)", fn);
inform (input_location, "(a pointer to member can only be formed with %<&%E%>)", fn);
explained = 1;
}
}

View File

@ -574,7 +574,7 @@ do_friend (tree ctype, tree declarator, tree decl,
"%q#D declares a non-template function", decl);
if (! explained && warned)
{
inform ("(if this is not what you intended, make sure "
inform (input_location, "(if this is not what you intended, make sure "
"the function template has already been declared "
"and add <> after the function name here) ");
explained = 1;

View File

@ -3039,7 +3039,7 @@ build_delete (tree type, tree addr, special_function_kind auto_delete,
"delete operator:"))
{
cxx_incomplete_type_diagnostic (addr, type, DK_WARNING);
inform ("neither the destructor nor the class-specific "
inform (input_location, "neither the destructor nor the class-specific "
"operator delete will be called, even if they are "
"declared when the class is defined.");
}

View File

@ -490,7 +490,7 @@ unqualified_fn_lookup_error (tree name)
static bool hint;
if (!hint)
{
inform ("(if you use %<-fpermissive%>, G++ will accept your "
inform (input_location, "(if you use %<-fpermissive%>, G++ will accept your "
"code, but allowing the use of an undeclared name is "
"deprecated)");
hint = true;

View File

@ -813,8 +813,8 @@ synthesize_method (tree fndecl)
pop_deferring_access_checks ();
if (error_count != errorcount || warning_count != warningcount)
inform ("%Hsynthesized method %qD first required here ",
&input_location, fndecl);
inform (input_location, "synthesized method %qD first required here ",
fndecl);
}
/* Use EXTRACTOR to locate the relevant function called for each base &

View File

@ -1226,7 +1226,7 @@ check_for_out_of_scope_variable (tree decl)
static bool hint;
if (!hint)
{
inform ("(if you use %<-fpermissive%> G++ will accept your code)");
inform (input_location, "(if you use %<-fpermissive%> G++ will accept your code)");
hint = true;
}
}

View File

@ -2229,8 +2229,9 @@ cp_parser_check_for_definition_in_return_type (cp_declarator *declarator,
&& declarator->kind == cdk_function)
{
error ("%Hnew types may not be defined in a return type", &type_location);
inform ("%H(perhaps a semicolon is missing after the definition of %qT)",
&type_location, type);
inform (type_location,
"(perhaps a semicolon is missing after the definition of %qT)",
type);
}
}
@ -2358,8 +2359,9 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser,
if (TREE_CODE (field) == TYPE_DECL
&& DECL_NAME (field) == id)
{
inform ("%H(perhaps %<typename %T::%E%> was intended)",
&location, BINFO_TYPE (b), id);
inform (location,
"(perhaps %<typename %T::%E%> was intended)",
BINFO_TYPE (b), id);
break;
}
if (field)
@ -5576,8 +5578,8 @@ cp_parser_new_expression (cp_parser* parser)
{
error ("%Harray bound forbidden after parenthesized type-id",
&token->location);
inform ("%Htry removing the parentheses around the type-id",
&token->location);
inform (token->location,
"try removing the parentheses around the type-id");
cp_parser_direct_new_declarator (parser);
}
nelts = NULL_TREE;
@ -9984,13 +9986,13 @@ cp_parser_template_id (cp_parser *parser,
"%<<::%> cannot begin a template-argument list"))
{
static bool hint = false;
inform ("%H%<<:%> is an alternate spelling for %<[%>. Insert whitespace "
"between %<<%> and %<::%>",
&next_token->location);
inform (next_token->location,
"%<<:%> is an alternate spelling for %<[%>."
" Insert whitespace between %<<%> and %<::%>");
if (!hint && !flag_permissive)
{
inform ("%H(if you use %<-fpermissive%> G++ will accept your code)",
&next_token->location);
inform (next_token->location, "(if you use %<-fpermissive%>"
" G++ will accept your code)");
hint = true;
}
}
@ -10180,7 +10182,7 @@ cp_parser_template_name (cp_parser* parser,
/* Explain what went wrong. */
error ("%Hnon-template %qD used as template",
&token->location, identifier);
inform ("use %<%T::template %D%> to indicate that it is a template",
inform (input_location, "use %<%T::template %D%> to indicate that it is a template",
parser->scope, identifier);
/* If parsing tentatively, find the location of the "<" token. */
if (cp_parser_simulate_error (parser))
@ -13168,7 +13170,7 @@ cp_parser_direct_declarator (cp_parser* parser,
{
error ("%Hinvalid use of constructor as a template",
&declarator_id_start_token->location);
inform ("use %<%T::%D%> instead of %<%T::%D%> to "
inform (input_location, "use %<%T::%D%> instead of %<%T::%D%> to "
"name the constructor in a qualified name",
class_type,
DECL_NAME (TYPE_TI_TEMPLATE (class_type)),

View File

@ -2741,9 +2741,9 @@ check_for_bare_parameter_packs (tree t)
name = DECL_NAME (pack);
if (name)
inform (" %qD", name);
inform (input_location, " %qD", name);
else
inform (" <anonymous>");
inform (input_location, " <anonymous>");
parameter_packs = TREE_CHAIN (parameter_packs);
}
@ -4020,7 +4020,7 @@ push_template_decl_real (tree decl, bool is_friend)
template arguments to %qD do not match original template %qD",
decl, DECL_TEMPLATE_RESULT (tmpl));
if (!uses_template_parms (TI_ARGS (tinfo)))
inform ("use template<> for an explicit specialization");
inform (input_location, "use template<> for an explicit specialization");
/* Avoid crash in import_export_decl. */
DECL_INTERFACE_KNOWN (decl) = 1;
return error_mark_node;
@ -4141,7 +4141,7 @@ redeclare_class_template (tree type, tree parms)
{
error ("redeclared with %d template parameter(s)",
TREE_VEC_LENGTH (parms));
inform ("previous declaration %q+D used %d template parameter(s)",
inform (input_location, "previous declaration %q+D used %d template parameter(s)",
tmpl, TREE_VEC_LENGTH (tmpl_parms));
return false;
}
@ -4187,7 +4187,7 @@ redeclare_class_template (tree type, tree parms)
A template-parameter may not be given default arguments
by two different declarations in the same scope. */
error ("redefinition of default argument for %q#D", parm);
inform ("%Joriginal definition appeared here", tmpl_parm);
inform (input_location, "%Joriginal definition appeared here", tmpl_parm);
return false;
}
@ -4570,7 +4570,7 @@ convert_nontype_argument (tree type, tree expr)
{
error ("%qE is not a valid template argument for type %qT "
"because it is a pointer", expr, type);
inform ("try using %qE instead", TREE_OPERAND (expr, 0));
inform (input_location, "try using %qE instead", TREE_OPERAND (expr, 0));
return NULL_TREE;
}
@ -4608,7 +4608,7 @@ convert_nontype_argument (tree type, tree expr)
error ("%qE is not a valid template argument for type %qT "
"because it is of type %qT", expr, type,
TREE_TYPE (expr));
inform ("standard conversions are not allowed in this context");
inform (input_location, "standard conversions are not allowed in this context");
return NULL_TREE;
}
}
@ -9722,7 +9722,7 @@ tsubst_qualified_id (tree qualified_id, tree args,
{
error ("dependent-name %qE is parsed as a non-type, but "
"instantiation yields a type", qualified_id);
inform ("say %<typename %E%> if a type is meant", qualified_id);
inform (input_location, "say %<typename %E%> if a type is meant", qualified_id);
}
return error_mark_node;
}

View File

@ -4009,7 +4009,7 @@ build_x_unary_op (enum tree_code code, tree xarg, tsubst_flags_t complain)
error ("invalid use of %qE to form a pointer-to-member-function",
xarg);
if (TREE_CODE (xarg) != OFFSET_REF)
inform (" a qualified-id is required");
inform (input_location, " a qualified-id is required");
return error_mark_node;
}
else

View File

@ -313,18 +313,18 @@ abstract_virtuals_error (tree decl, tree type)
unsigned ix;
tree fn;
inform ("%J because the following virtual functions are pure "
inform (input_location, "%J because the following virtual functions are pure "
"within %qT:", TYPE_MAIN_DECL (type), type);
for (ix = 0; VEC_iterate (tree, pure, ix, fn); ix++)
inform ("\t%+#D", fn);
inform (input_location, "\t%+#D", fn);
/* Now truncate the vector. This leaves it non-null, so we know
there are pure virtuals, but empty so we don't list them out
again. */
VEC_truncate (tree, pure, 0);
}
else
inform ("%J since type %qT has pure virtual functions",
inform (input_location, "%J since type %qT has pure virtual functions",
TYPE_MAIN_DECL (type), type);
return 1;

View File

@ -489,16 +489,16 @@ emit_diagnostic (diagnostic_t kind, location_t location, int opt,
return report_diagnostic (&diagnostic);
}
/* An informative note. Use this for additional details on an error
/* An informative note at LOCATION. Use this for additional details on an error
message. */
void
inform (const char *gmsgid, ...)
inform (location_t location, const char *gmsgid, ...)
{
diagnostic_info diagnostic;
va_list ap;
va_start (ap, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &ap, input_location, DK_NOTE);
diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_NOTE);
report_diagnostic (&diagnostic);
va_end (ap);
}

View File

@ -1088,8 +1088,8 @@ decode_options (unsigned int argc, const char **argv)
if (flag_exceptions && flag_reorder_blocks_and_partition)
{
inform
("-freorder-blocks-and-partition does not work with exceptions");
inform (input_location,
"-freorder-blocks-and-partition does not work with exceptions");
flag_reorder_blocks_and_partition = 0;
flag_reorder_blocks = 1;
}
@ -1100,7 +1100,7 @@ decode_options (unsigned int argc, const char **argv)
if (flag_unwind_tables && ! targetm.unwind_tables_default
&& flag_reorder_blocks_and_partition)
{
inform ("-freorder-blocks-and-partition does not support unwind info");
inform (input_location, "-freorder-blocks-and-partition does not support unwind info");
flag_reorder_blocks_and_partition = 0;
flag_reorder_blocks = 1;
}
@ -1113,8 +1113,8 @@ decode_options (unsigned int argc, const char **argv)
&& (!targetm.have_named_sections
|| (flag_unwind_tables && targetm.unwind_tables_default)))
{
inform
("-freorder-blocks-and-partition does not work on this architecture");
inform (input_location,
"-freorder-blocks-and-partition does not work on this architecture");
flag_reorder_blocks_and_partition = 0;
flag_reorder_blocks = 1;
}

View File

@ -1350,7 +1350,7 @@ init_asm_output (const char *name)
NULL);
}
else
inform ("-frecord-gcc-switches is not supported by the current target");
inform (input_location, "-frecord-gcc-switches is not supported by the current target");
}
#ifdef ASM_COMMENT_START

View File

@ -69,7 +69,7 @@ extern bool pedwarn_at (location_t, int, const char *, ...)
ATTRIBUTE_GCC_DIAG(3,4);
extern bool permerror (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void inform (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void rest_of_decl_compilation (tree, int, int);

View File

@ -3842,7 +3842,7 @@ verify_stmt (gimple_stmt_iterator *gsi)
if (addr)
{
debug_generic_expr (addr);
inform ("in statement");
inform (input_location, "in statement");
debug_gimple_stmt (stmt);
return true;
}

View File

@ -1423,7 +1423,7 @@ warn_uninit (tree t, const char *gmsgid, void *data)
if (xloc.file != floc.file
|| xloc.line < floc.line
|| xloc.line > LOCATION_LINE (cfun->function_end_locus))
inform ("%J%qD was declared here", var, var);
inform (input_location, "%J%qD was declared here", var, var);
}
}