summaryrefslogtreecommitdiff
path: root/usr.bin/xlint/lint1/cgram.y
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/xlint/lint1/cgram.y')
-rw-r--r--usr.bin/xlint/lint1/cgram.y67
1 files changed, 43 insertions, 24 deletions
diff --git a/usr.bin/xlint/lint1/cgram.y b/usr.bin/xlint/lint1/cgram.y
index 70d9c649889..39f98e756b1 100644
--- a/usr.bin/xlint/lint1/cgram.y
+++ b/usr.bin/xlint/lint1/cgram.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: cgram.y,v 1.13 2005/11/30 18:47:11 deraadt Exp $ */
+/* $OpenBSD: cgram.y,v 1.14 2005/12/03 00:27:54 cloder Exp $ */
/* $NetBSD: cgram.y,v 1.8 1995/10/02 17:31:35 jpo Exp $ */
/*
@@ -34,7 +34,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: cgram.y,v 1.13 2005/11/30 18:47:11 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: cgram.y,v 1.14 2005/12/03 00:27:54 cloder Exp $";
#endif
#include <stdlib.h>
@@ -71,6 +71,7 @@ static void ignuptorp(void);
scl_t y_scl;
tspec_t y_tspec;
tqual_t y_tqual;
+ attr_t y_attr;
type_t *y_type;
tnode_t *y_tnode;
strg_t *y_strg;
@@ -110,6 +111,9 @@ static void ignuptorp(void);
/* qualifiers (const, volatile, restrict) */
%token <y_tqual> T_QUAL
+/* attributes (noreturn, format, etc.) */
+%token <y_attr> T_ATTR
+
/* struct or union */
%token <y_tspec> T_SOU
@@ -306,7 +310,7 @@ data_def: T_SEMI
warning(2);
}
}
- | declspecs deftyp type_init_decls opt_attribute_spec T_SEMI
+ | declspecs deftyp type_init_decls T_SEMI
| error T_SEMI {
globclup();
}
@@ -341,11 +345,6 @@ func_def:
}
;
-opt_attribute_spec:
- /* empty */
- | T_ATTRIBUTE T_LPARN T_LPARN read_until_rparn T_RPARN
- ;
-
func_decl:
clrtyp deftyp notype_decl {
$$ = $3;
@@ -460,6 +459,7 @@ declmods:
| clrtyp T_SCLASS {
addscl($2);
}
+ | clrtyp attribute_spec
| declmods declmod
;
@@ -470,6 +470,25 @@ declmod:
| T_SCLASS {
addscl($1);
}
+ | attribute_spec
+ ;
+
+attribute_spec:
+ T_ATTRIBUTE T_LPARN T_LPARN T_ATTR T_RPARN T_RPARN {
+ /* XXX: addattr($4) */
+ }
+ | T_ATTRIBUTE T_LPARN T_LPARN T_NAME read_until_rparn T_RPARN
+ | T_ATTRIBUTE T_LPARN T_LPARN T_QUAL read_until_rparn T_RPARN
+ ;
+
+attribute_specs:
+ attribute_spec
+ | attribute_specs attribute_spec
+ ;
+
+opt_attribute_specs:
+ /* EMPTY */
+ | attribute_specs
;
clrtyp_typespec:
@@ -579,10 +598,10 @@ member_declaration_list_with_rbrace:
;
member_declaration_list:
- member_declaration {
+ member_declaration opt_attribute_specs {
$$ = $1;
}
- | member_declaration_list T_SEMI member_declaration {
+ | member_declaration_list T_SEMI member_declaration opt_attribute_specs {
$$ = lnklst($1, $3);
}
;
@@ -792,7 +811,7 @@ type_init_decls:
;
notype_init_decl:
- notype_decl opt_attribute_spec opt_asm_spec {
+ notype_decl opt_asm_spec {
idecl($1, 0);
chksz($1);
}
@@ -816,10 +835,10 @@ type_init_decl:
;
notype_decl:
- notype_direct_decl {
+ notype_direct_decl opt_attribute_specs {
$$ = $1;
}
- | pointer notype_direct_decl {
+ | pointer notype_direct_decl opt_attribute_specs {
$$ = addptr($2, $1);
}
;
@@ -845,10 +864,10 @@ notype_direct_decl:
;
type_decl:
- type_direct_decl {
+ type_direct_decl opt_attribute_specs {
$$ = $1;
}
- | pointer type_direct_decl {
+ | pointer type_direct_decl opt_attribute_specs {
$$ = addptr($2, $1);
}
;
@@ -939,17 +958,17 @@ direct_notype_param_decl:
;
pointer:
- asterisk {
+ asterisk opt_attribute_specs {
$$ = $1;
}
- | asterisk type_qualifier_list {
- $$ = mergepq($1, $2);
+ | asterisk opt_attribute_specs type_qualifier_list {
+ $$ = mergepq($1, $3);
}
- | asterisk pointer {
- $$ = mergepq($1, $2);
+ | asterisk opt_attribute_specs pointer {
+ $$ = mergepq($1, $3);
}
- | asterisk type_qualifier_list pointer {
- $$ = mergepq(mergepq($1, $2), $3);
+ | asterisk opt_attribute_specs type_qualifier_list pointer {
+ $$ = mergepq(mergepq($1, $3), $4);
}
;
@@ -1050,10 +1069,10 @@ vararg_parameter_type_list:
;
parameter_type_list:
- parameter_declaration opt_asm_spec {
+ parameter_declaration opt_attribute_specs opt_asm_spec {
$$ = $1;
}
- | parameter_type_list T_COMMA parameter_declaration opt_asm_spec {
+ | parameter_type_list T_COMMA parameter_declaration opt_attribute_specs opt_asm_spec {
$$ = lnklst($1, $3);
}
;