Skip to content

Commit 3ea254e

Browse files
authored
Add parsing support for 'asm inline', a few gcc builtin's and an error-state reset function (#151)
1 parent 0d7db1c commit 3ea254e

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/cil.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,6 +2978,7 @@ let initGccBuiltins () : unit =
29782978
H.add h "__builtin_inff" (floatType, [], false);
29792979
H.add h "__builtin_infl" (longDoubleType, [], false);
29802980
H.add h "__builtin_memcpy" (voidPtrType, [ voidPtrType; voidConstPtrType; sizeType ], false);
2981+
H.add h "__builtin_memchr" (voidPtrType, [voidConstPtrType; intType; ulongType], false);
29812982
H.add h "__builtin_mempcpy" (voidPtrType, [ voidPtrType; voidConstPtrType; sizeType ], false);
29822983
H.add h "__builtin_memset" (voidPtrType,
29832984
[ voidPtrType; intType; intType ], false);
@@ -3052,6 +3053,7 @@ let initGccBuiltins () : unit =
30523053
H.add h "__builtin_sqrtl" (longDoubleType, [ longDoubleType ], false);
30533054

30543055
H.add h "__builtin_stpcpy" (charPtrType, [ charPtrType; charConstPtrType ], false);
3056+
H.add h "__builtin_strcat" (charPtrType, [charPtrType; charConstPtrType], false);
30553057
H.add h "__builtin_strchr" (charPtrType, [ charPtrType; intType ], false);
30563058
H.add h "__builtin_strcmp" (intType, [ charConstPtrType; charConstPtrType ], false);
30573059
H.add h "__builtin_strcpy" (charPtrType, [ charPtrType; charConstPtrType ], false);

src/frontc/cparser.mly

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,7 @@ asmattr:
16451645
/* empty */ { [] }
16461646
| VOLATILE asmattr { ("volatile", []) :: $2 }
16471647
| CONST asmattr { ("const", []) :: $2 }
1648+
| INLINE asmattr { ("inline", []) :: $2 }
16481649
;
16491650
asmtemplate:
16501651
one_string_constant { [$1] }
@@ -1682,15 +1683,15 @@ asmopname:
16821683

16831684
asmclobber:
16841685
/* empty */ { [] }
1685-
| COLON asmcloberlst { $2 }
1686+
| COLON asmclobberlst { $2 }
16861687
;
1687-
asmcloberlst:
1688+
asmclobberlst:
16881689
/* empty */ { [] }
1689-
| asmcloberlst_ne { $1 }
1690+
| asmclobberlst_ne { $1 }
16901691
;
1691-
asmcloberlst_ne:
1692+
asmclobberlst_ne:
16921693
one_string_constant { [$1] }
1693-
| one_string_constant COMMA asmcloberlst_ne { $1 :: $3 }
1694+
| one_string_constant COMMA asmclobberlst_ne { $1 :: $3 }
16941695
;
16951696

16961697
%%

src/frontc/frontc.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ let args : (string * Arg.spec * string) list =
106106
exception ParseError of string
107107
exception CabsOnly
108108

109+
let resetErrors () = E.hadErrors := false
110+
109111
(* parse, and apply patching *)
110112
let rec parse_to_cabs fname =
111113
begin

src/frontc/frontc.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ val args: (string * Arg.spec * string) list
4747

4848
(* the main command to parse a file. Return a thunk that can be used to
4949
convert the AST to CIL. *)
50+
val resetErrors: unit -> unit
51+
5052
val parse: string -> (unit -> Cil.file)
5153

5254
val parse_with_cabs: string -> (unit -> Cabs.file * Cil.file)

0 commit comments

Comments
 (0)