mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 17:18:20 +00:00
Add "fallthrough" keyword, require a flow statement to end case blocks.
Case blocks in switch statements now must end in a break, return, or fallthrough statement to give best mix of safety, readability, and flexibility. The new fallthrough keyword explicitly allows control to be passed to the next case block in a switch statement. Addresses #754.
This commit is contained in:
parent
8695053e27
commit
be71a42f4c
8 changed files with 150 additions and 33 deletions
|
@ -16,6 +16,7 @@ typedef enum {
|
|||
STMT_ADD, STMT_DELETE,
|
||||
STMT_LIST, STMT_EVENT_BODY_LIST,
|
||||
STMT_INIT,
|
||||
STMT_FALLTHROUGH,
|
||||
STMT_NULL
|
||||
#define NUM_STMTS (int(STMT_NULL) + 1)
|
||||
} BroStmtTag;
|
||||
|
@ -24,7 +25,8 @@ typedef enum {
|
|||
FLOW_NEXT, // continue on to next statement
|
||||
FLOW_LOOP, // go to top of loop
|
||||
FLOW_BREAK, // break out of loop
|
||||
FLOW_RETURN // return from function
|
||||
FLOW_RETURN, // return from function
|
||||
FLOW_FALLTHROUGH// fall through to next switch case
|
||||
} stmt_flow_type;
|
||||
|
||||
extern const char* stmt_name(BroStmtTag t);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue