Module Name:    src
Committed By:   christos
Date:           Mon Apr 12 15:55:26 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: cgram.y lex.c

Log Message:
Add attribute fallthrough


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/xlint/lint1/lex.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.211 src/usr.bin/xlint/lint1/cgram.y:1.212
--- src/usr.bin/xlint/lint1/cgram.y:1.211	Fri Apr  2 08:16:50 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Mon Apr 12 11:55:26 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.211 2021/04/02 12:16:50 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.212 2021/04/12 15:55:26 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.211 2021/04/02 12:16:50 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.212 2021/04/12 15:55:26 christos Exp $");
 #endif
 
 #include <limits.h>
@@ -218,6 +218,7 @@ anonymize(sym_t *s)
 %token <y_type>		T_AT_CONSTRUCTOR
 %token <y_type>		T_AT_DEPRECATED
 %token <y_type>		T_AT_DESTRUCTOR
+%token <y_type>		T_AT_FALLTHROUGH
 %token <y_type>		T_AT_FORMAT
 %token <y_type>		T_AT_FORMAT_ARG
 %token <y_type>		T_AT_FORMAT_GNU_PRINTF
@@ -595,6 +596,9 @@ type_attribute_spec:
 	| T_AT_WARN_UNUSED_RESULT
 	| T_AT_WEAK
 	| T_AT_VISIBILITY T_LPAREN constant_expr T_RPAREN
+	| T_AT_FALLTHROUGH {
+		fallthru(1);
+	}
 	| T_QUAL {
 		if ($1 != CONST)
 			yyerror("Bad attribute");
@@ -1490,7 +1494,8 @@ direct_abstract_decl:
 	;
 
 non_expr_statement:
-	  labeled_statement
+	  type_attribute T_SEMI
+	| labeled_statement
 	| compound_statement
 	| selection_statement
 	| iteration_statement
@@ -1498,6 +1503,7 @@ non_expr_statement:
 		seen_fallthrough = false;
 	  }
 	| asm_statement
+	;
 
 statement:			/* C99 6.8 */
 	  expr_statement

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.26 src/usr.bin/xlint/lint1/lex.c:1.27
--- src/usr.bin/xlint/lint1/lex.c:1.26	Fri Apr  9 11:58:43 2021
+++ src/usr.bin/xlint/lint1/lex.c	Mon Apr 12 11:55:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.26 2021/04/09 15:58:43 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.27 2021/04/12 15:55:26 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.26 2021/04/09 15:58:43 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.27 2021/04/12 15:55:26 christos Exp $");
 #endif
 
 #include <ctype.h>
@@ -169,6 +169,7 @@ static	struct	kwtab {
 	kwdef_token(	"enum",		T_ENUM,			0,0,0,0,1),
 	kwdef_token(	"extension",	T_EXTENSION,		0,0,1,0,4),
 	kwdef_sclass(	"extern",	EXTERN,			0,0,0,0,1),
+	kwdef_token(	"fallthrough",	T_AT_FALLTHROUGH,	0,0,1,1,5),
 	kwdef_type(	"float",	FLOAT,			0,0,0,0,1),
 	kwdef_token(	"for",		T_FOR,			0,0,0,0,1),
 	kwdef_token(	"format",	T_AT_FORMAT,		0,0,1,1,5),

Reply via email to