# HG changeset patch # User John W. Eaton # Date 1236954419 14400 # Node ID fde2a916b2ac6e6efe50cf38885cfc391491796c # Parent ddea8b06ed7c320377a2165bea9e209843d74ffe include line and file info in parser warnings diff -r ddea8b06ed7c -r fde2a916b2ac src/ChangeLog --- a/src/ChangeLog Fri Mar 13 09:45:07 2009 -0400 +++ b/src/ChangeLog Fri Mar 13 10:26:59 2009 -0400 @@ -1,3 +1,16 @@ +2009-03-13 John W. Eaton + + * parse.y (maybe_warn_assign_as_truth_value, make_binary_op, + maybe_warn_variable_switch_label, maybe_warn_associativity_change): + Print file and line number info if available. + * lex.l (gripe_matlab_incompatible): Likewise. + + * error.cc (pr_where): Use octave_call_stack::backtrace to print + complete stack trace at once. Don't attempt to print code. + (error_2): Set error_state to 0 before calling pr_where. + (warning_1): Switch sense of test on symbol_table::at_top_level. + Call pr_where after printing primary warning message. + 2009-03-13 Jaroslav Hajek * ov-range.h (octave_range::octave_range (const Range&)): Allow @@ -7,14 +20,6 @@ * data.cc (fill_matrix): Return packed form (zero-step range) if possible. -2009-03-13 John W. Eaton - - * error.cc (pr_where): Use octave_call_stack::backtrace to print - complete stack trace at once. Don't attempt to print code. - (error_2): Set error_state to 0 before calling pr_where. - (warning_1): Switch sense of test on symbol_table::at_top_level. - Call pr_where after printing primary warning message. - 2009-03-10 Jason Riedy * DLD-FUNCTIONS/lu.cc (lu): Call fact.Pr_mat () and fact.Pc_mat () diff -r ddea8b06ed7c -r fde2a916b2ac src/lex.l --- a/src/lex.l Fri Mar 13 09:45:07 2009 -0400 +++ b/src/lex.l Fri Mar 13 10:26:59 2009 -0400 @@ -3377,9 +3377,16 @@ static void gripe_matlab_incompatible (const std::string& msg) { - warning_with_id ("Octave:matlab-incompatible", - "potential Matlab compatibility problem: %s", - msg.c_str ()); + std::string nm = curr_fcn_file_full_name; + + if (nm.empty ()) + warning_with_id ("Octave:matlab-incompatible", + "potential Matlab compatibility problem: %s", + msg.c_str ()); + else + warning_with_id ("Octave:matlab-incompatible", + "potential Matlab compatibility problem: %s near line %d offile %s", + msg.c_str (), input_line_number, nm.c_str ()); } static void diff -r ddea8b06ed7c -r fde2a916b2ac src/parse.y --- a/src/parse.y Fri Mar 13 09:45:07 2009 -0400 +++ b/src/parse.y Fri Mar 13 10:26:59 2009 -0400 @@ -1512,9 +1512,15 @@ if (expr->is_assignment_expression () && expr->paren_count () < 2) { - warning_with_id - ("Octave:assign-as-truth-value", - "suggest parenthesis around assignment used as truth value"); + if (curr_fcn_file_full_name.empty ()) + warning_with_id + ("Octave:assign-as-truth-value", + "suggest parenthesis around assignment used as truth value"); + else + warning_with_id + ("Octave:assign-as-truth-value", + "suggest parenthesis around assignment used as truth value near line %d, column %d in file `%s'", + expr->line (), expr->column (), curr_fcn_file_full_name.c_str ()); } } @@ -1524,8 +1530,16 @@ maybe_warn_variable_switch_label (tree_expression *expr) { if (! expr->is_constant ()) - warning_with_id ("Octave:variable-switch-label", - "variable switch label"); + { + if (curr_fcn_file_full_name.empty ()) + warning_with_id ("Octave:variable-switch-label", + "variable switch label"); + else + warning_with_id + ("Octave:variable-switch-label", + "variable switch label near line %d, column %d in file `%s'", + expr->line (), expr->column (), curr_fcn_file_full_name.c_str ()); + } } static tree_expression * @@ -1817,10 +1831,18 @@ { std::string op_str = octave_value::binary_op_as_string (op_type); - warning_with_id - ("Octave:associativity-change", - "meaning may have changed due to change in associativity for %s operator", op_str.c_str ()); - } + if (curr_fcn_file_full_name.empty ()) + warning_with_id + ("Octave:associativity-change", + "meaning may have changed due to change in associativity for %s operator", + op_str.c_str ()); + else + warning_with_id + ("Octave:associativity-change", + "meaning may have changed due to change in associativity for %s operator near line %d, column %d in file `%s'", + op_str.c_str (), op->line (), op->column (), + curr_fcn_file_full_name.c_str ()); + } } } @@ -1920,9 +1942,18 @@ = dynamic_cast (op2); if (e->op_type () == octave_value::op_el_and) - warning_with_id - ("Octave:precedence-change", - "meaning may have changed due to change in precedence for & and | operators"); + { + if (curr_fcn_file_full_name.empty ()) + warning_with_id + ("Octave:precedence-change", + "meaning may have changed due to change in precedence for & and | operators"); + else + warning_with_id + ("Octave:precedence-change", + "meaning may have changed due to change in precedence for & and | operators near line %d, column %d in file `%s'", + op2->line (), op2->column (), + curr_fcn_file_full_name.c_str ()); + } } break;