- add nonstring attribute

- allow attributes after labels (for unused)
XXX: split the attributes into function, variable, etc attributes
so that we don't accept all attributes in all places (only where they make
sense)
This commit is contained in:
christos 2021-04-30 19:46:24 +00:00
parent a0412fee12
commit 3c283926c0
2 changed files with 9 additions and 7 deletions

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: cgram.y,v 1.222 2021/04/29 17:11:30 christos Exp $ */
/* $NetBSD: cgram.y,v 1.223 2021/04/30 19:46:24 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.222 2021/04/29 17:11:30 christos Exp $");
__RCSID("$NetBSD: cgram.y,v 1.223 2021/04/30 19:46:24 christos Exp $");
#endif
#include <limits.h>
@ -123,7 +123,7 @@ anonymize(sym_t *s)
}
%}
%expect 185
%expect 189
%union {
val_t *y_val;
@ -235,6 +235,7 @@ anonymize(sym_t *s)
%token <y_type> T_AT_MODE
%token <y_type> T_AT_NOINLINE
%token <y_type> T_AT_NONNULL
%token <y_type> T_AT_NONSTRING
%token <y_type> T_AT_NORETURN
%token <y_type> T_AT_NOTHROW
%token <y_type> T_AT_NO_INSTRUMENT_FUNCTION
@ -563,6 +564,7 @@ type_attribute_spec:
| T_AT_SENTINEL
| T_AT_FORMAT_ARG T_LPAREN constant_expr T_RPAREN
| T_AT_NONNULL T_LPAREN constant_expr T_RPAREN
| T_AT_NONSTRING
| T_AT_MODE T_LPAREN T_NAME T_RPAREN
| T_AT_ALIAS T_LPAREN string T_RPAREN
| T_AT_OPTIMIZE T_LPAREN string T_RPAREN
@ -1535,7 +1537,7 @@ statement: /* C99 6.8 */
;
labeled_statement: /* C99 6.8.1 */
label statement
label opt_type_attribute statement
;
label:

View File

@ -1,4 +1,4 @@
/* $NetBSD: lex.c,v 1.29 2021/04/20 21:48:39 christos Exp $ */
/* $NetBSD: lex.c,v 1.30 2021/04/30 19:46:24 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.29 2021/04/20 21:48:39 christos Exp $");
__RCSID("$NetBSD: lex.c,v 1.30 2021/04/30 19:46:24 christos Exp $");
#endif
#include <ctype.h>
@ -189,8 +189,8 @@ static struct kwtab {
kwdef_token( "mode", T_AT_MODE, 0,0,1,1,5),
kwdef_token( "no_instrument_function",
T_AT_NO_INSTRUMENT_FUNCTION, 0,0,1,1,5),
kwdef_token( "nonnull", T_AT_NONNULL, 0,0,1,1,5),
kwdef_token( "noinline", T_AT_NOINLINE, 0,0,1,1,5),
kwdef_token( "nonstring", T_AT_NONSTRING, 0,0,1,1,5),
kwdef_token( "noreturn", T_AT_NORETURN, 0,0,1,1,5),
kwdef_token( "nothrow", T_AT_NOTHROW, 0,0,1,1,5),
kwdef_token( "optimize", T_AT_OPTIMIZE, 0,0,1,1,5),