Skip to content

adds more (and fixes existing) GCC-specific builtin floating types #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontc/cabs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ and storage =
and base_type =
| NO_TYPE (** Old K&R declaration without type *)
| VOID (** "void" type *)
| BOOL (** C99 boolean (_Bool) type *)
| CHAR of sign (** "char" type with sign modifier *)
| INT of size * sign (** "int" type with size and sign modifiers *)
| BITFIELD of sign * expression
Expand Down
14 changes: 12 additions & 2 deletions frontc/clexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,18 @@ let keywords =
("extern", id EXTERN);
("long", id LONG);
("_Complex", id COMPLEX);
builtin "_Float128";
builtin "__float128";
builtin "__float80";
builtin "__ibm128";
builtin "_Float16";
builtin "_Float32";
builtin "_Float32x";
builtin "_Float64";
builtin "_Float64x";
builtin "_Float80";
builtin "_Ibm80";
builtin "_Float128";
builtin "_Float128x";
builtin "_Ibm128";
("short", id SHORT);
("register", id REGISTER);
("signed", id SIGNED);
Expand All @@ -153,6 +162,7 @@ let keywords =
("__restrict", id RESTRICT);
("restrict", id RESTRICT);
("char", id CHAR);
("_Bool", id BOOL);
("int", id INT);
("float", id FLOAT);
("double", id DOUBLE);
Expand Down
1 change: 1 addition & 0 deletions frontc/cparser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ only_dec:
/*** Base type ***/
qual_type:
| VOID {(VOID, [])}
| BOOL {(BOOL, [])}
| CHAR {(CHAR NO_SIGN, [])}
| INT {(INT (NO_SIZE, NO_SIGN), [])}
| FLOAT {(FLOAT false, [])}
Expand Down
1 change: 1 addition & 0 deletions frontc/cprint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ let rec print_base_type typ =
match typ with
NO_TYPE -> ()
| VOID -> print "void"
| BOOL -> print "_Bool"
| CHAR sign -> print ((get_sign sign) ^ "char")
| INT (size, sign) -> print ((get_sign sign) ^ (get_size size) ^ "int")
| BITFIELD (sign, _) -> print ((get_sign sign) ^ "int")
Expand Down
2 changes: 1 addition & 1 deletion frontc/ctokens.mly
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
%token <Cabs.gnu_attrs> GNU_ATTRS

%token EOF
%token CHAR INT DOUBLE FLOAT VOID
%token CHAR BOOL INT DOUBLE FLOAT VOID
%token ENUM STRUCT TYPEDEF UNION
%token SIGNED UNSIGNED LONG SHORT COMPLEX
%token VOLATILE EXTERN STATIC CONST AUTO REGISTER RESTRICT
Expand Down
1 change: 1 addition & 0 deletions frontc/ctoxml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ and convert_type _type =
let base_type name = Cxml.new_elt name [] [] in
match _type with
NO_TYPE -> convert_type (INT (NO_SIZE, NO_SIGN))
| BOOL -> base_type "bool"
| VOID -> base_type "void"
| CHAR NO_SIGN
| CHAR SIGNED -> base_type "char"
Expand Down