Mercurial > hg > octave-terminal
changeset 8974:fde2a916b2ac
include line and file info in parser warnings
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 13 Mar 2009 10:26:59 -0400 |
parents | ddea8b06ed7c |
children | 2e9af3363669 |
files | src/ChangeLog src/lex.l src/parse.y |
diffstat | 3 files changed, 66 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2009-03-13 John W. Eaton <jwe@octave.org> + + * 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 <highegg@gmail.com> * 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 <jwe@octave.org> - - * 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 <jason@acm.org> * DLD-FUNCTIONS/lu.cc (lu): Call fact.Pr_mat () and fact.Pc_mat ()
--- a/src/lex.l +++ b/src/lex.l @@ -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
--- a/src/parse.y +++ b/src/parse.y @@ -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<tree_binary_expression *> (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;