diff libinterp/parse-tree/pt-binop.h @ 18126:d76f790b4eec gui-release

enable do_braindead_shortcircuit_evaluation by default and deprecate * octave.cc (maximum_braindamage): Don't call Fdo_brainded_shortcircuit_evaluation. * pt-exp.h (tree_expression::mark_braindead_shortcircuit): Eliminate file name argument. * pt-binop.h, pt-binop.cc (tree_binary_expression::mark_braindead_shortcircuit): Likewise. * oct-parse.in.yy (if_cmd_list1, elseif_clause, loop_command): Eliminate argument from call to mark_braindead_shortcircuit. * pt-binop.h, pt-binop.cc (Vdo_braindead_shortcircuit_evaluation): Initialize to true. (tree_binary_expression::matlab_style_short_circuit_warning): New function. (tree_binary_expression::rvalue1): Call matlab_style_short_circuit_warning if short circuit evaluation occurs. (Fdo_braindead_shortcircuit_evaluation): Display deprecated warning. Delete tests for do_braindead_shortcircuit_evaluation. (tree_binary_expression::braindead_shortcircuit_warning_issued): New member variable. * NEWS: Mention change in default value and deprecated function.
author John W. Eaton <jwe@octave.org>
date Wed, 11 Dec 2013 20:51:22 -0500
parents ebb3ef964372
children 91cd85a75705
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-binop.h	Thu Dec 05 11:48:58 2013 -0800
+++ b/libinterp/parse-tree/pt-binop.h	Wed Dec 11 20:51:22 2013 -0500
@@ -46,14 +46,16 @@
                           octave_value::binary_op t
                             = octave_value::unknown_binary_op)
     : tree_expression (l, c), op_lhs (0), op_rhs (0), etype (t),
-      eligible_for_braindead_shortcircuit (false) { }
+      eligible_for_braindead_shortcircuit (false),
+      braindead_shortcircuit_warning_issued (false) { }
 
   tree_binary_expression (tree_expression *a, tree_expression *b,
                           int l = -1, int c = -1,
                           octave_value::binary_op t
                             = octave_value::unknown_binary_op)
     : tree_expression (l, c), op_lhs (a), op_rhs (b), etype (t),
-      eligible_for_braindead_shortcircuit (false) { }
+      eligible_for_braindead_shortcircuit (false),
+      braindead_shortcircuit_warning_issued (false) { }
 
   ~tree_binary_expression (void)
   {
@@ -61,23 +63,14 @@
     delete op_rhs;
   }
 
-  void mark_braindead_shortcircuit (const std::string& file)
+  void mark_braindead_shortcircuit (void)
   {
     if (etype == octave_value::op_el_and || etype == octave_value::op_el_or)
       {
-        if (file.empty ())
-          warning_with_id ("Octave:possible-matlab-short-circuit-operator",
-                           "possible Matlab-style short-circuit operator at line %d, column %d",
-                           line (), column ());
-        else
-          warning_with_id ("Octave:possible-matlab-short-circuit-operator",
-                           "%s: possible Matlab-style short-circuit operator at line %d, column %d",
-                           file.c_str (), line (), column ());
-
         eligible_for_braindead_shortcircuit = true;
 
-        op_lhs->mark_braindead_shortcircuit (file);
-        op_rhs->mark_braindead_shortcircuit (file);
+        op_lhs->mark_braindead_shortcircuit ();
+        op_rhs->mark_braindead_shortcircuit ();
       }
   }
 
@@ -122,6 +115,12 @@
   // or WHILE statement.
   bool eligible_for_braindead_shortcircuit;
 
+  // TRUE if we have already issued a warning about short circuiting
+  // for this operator.
+  bool braindead_shortcircuit_warning_issued;
+
+  void matlab_style_short_circuit_warning (const char *op);
+
   // No copying!
 
   tree_binary_expression (const tree_binary_expression&);