diff libinterp/parse-tree/lex.ll @ 33344:3606817b9994

take adavantage of compiler warnings for unhandled enum switch cases Don't use default cases in switch statements that use enum values so that compilers may warn about unhandled enum values. Use error to report enum values that are not accepted by the switch, use error with a meaningful message instead of panic_impossible.
author John W. Eaton <jwe@octave.org>
date Sat, 06 Apr 2024 14:38:17 -0400
parents 70b7f1c285c7
children 56d234504c01
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll	Sat Apr 06 18:44:45 2024 +0200
+++ b/libinterp/parse-tree/lex.ll	Sat Apr 06 14:38:17 2024 -0400
@@ -2844,12 +2844,14 @@
         }
         break;
 
-      default:
-        panic_impossible ();
+        // We should have handled all possible enum values above.  Rely
+        // on compiler diagnostics to warn if we haven't.  For example,
+        // GCC's -Wswitch option, enabled by -Wall, will provide a
+        // warning.
       }
 
     if (! tok)
-            tok = new token (kw->tok_id, true, m_tok_beg, m_tok_end, get_comment_list ());
+      tok = new token (kw->tok_id, true, m_tok_beg, m_tok_end, get_comment_list ());
 
     return tok;
   }