Skip to content

Commit 1097ea1

Browse files
author
casse
committed
Fixed "volatile" and "const" after "typedef TYPE".
1 parent 56ab83a commit 1097ea1

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

frontc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ SOURCES = \
1010
cparser.mly \
1111
ctoxml.ml \
1212
frontc.ml
13+
OCAMLYACC_FLAGS = -v
1314

1415
$(eval $(call ocaml_lib,frontc,$(SOURCES)))
1516

frontc/cparser.mly

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,18 +542,22 @@ typedef_type:
542542
;
543543
typedef_sub:
544544
NAMED_TYPE {(NAMED_TYPE $1, [])}
545-
| NAMED_TYPE CONST {(NAMED_TYPE $1, [BASE_CONST])}
546545
| comp_type {($1, [])}
547-
| comp_type CONST {($1, [BASE_CONST])}
548546
| typedef_qual {$1}
549547
/* !!TODO!! Unknown named type support: add option for it */
550548
| IDENT { Clexer.add_type $1; (NAMED_TYPE $1, [])}
549+
| NAMED_TYPE CONST {(NAMED_TYPE $1, [BASE_CONST])}
550+
| NAMED_TYPE VOLATILE {(NAMED_TYPE $1, [BASE_VOLATILE])}
551+
| comp_type CONST {($1, [BASE_CONST])}
552+
| comp_type VOLATILE {($1, [BASE_VOLATILE])}
551553
| IDENT CONST { Clexer.add_type $1; (NAMED_TYPE $1, [BASE_CONST])}
554+
| IDENT VOLATILE { Clexer.add_type $1; (NAMED_TYPE $1, [BASE_VOLATILE])}
552555
;
553556
typedef_qual:
554557
qual_type {$1}
555558
| typedef_qual qual_type {apply_qual $1 $2}
556559
| typedef_qual CONST {(fst $1, BASE_CONST::(snd $1))}
560+
| typedef_qual VOLATILE {(fst $1, BASE_VOLATILE::(snd $1))}
557561
;
558562
typedef_defs:
559563
typedef_def {[$1]}

test/volatile.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
typedef const int t1;
2+
typedef volatile int t2;
3+
4+
typedef int const t3;
5+
typedef int volatile t4;
6+
7+
typedef const t t5;
8+
typedef volatile t t6;
9+
10+
typedef t const t7;
11+
typedef t volatile t8;
12+
13+
typedef const struct t t9;
14+
typedef volatile struct t t10;
15+
16+
typedef struct t const t11;
17+
typedef struct t volatile t12;

0 commit comments

Comments
 (0)