Skip to content

Commit e58de49

Browse files
committed
Add comments about C11 generic
1 parent 005a453 commit e58de49

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/frontc/cabs.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type typeSpecifier = (* Merge all specifiers into one type *)
8080
| Tenum of string * enum_item list option * attribute list
8181
| TtypeofE of expression (* GCC __typeof__ *)
8282
| TtypeofT of specifier * decl_type (* GCC __typeof__ *)
83-
| Tdefault
83+
| Tdefault (** "default" in generic associations *)
8484

8585
and storage =
8686
NO_STORAGE | AUTO | STATIC | EXTERN | REGISTER

src/frontc/cabs2cil.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4857,6 +4857,9 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
48574857
| _ -> true
48584858
| exception (Failure _) -> false
48594859
in
4860+
(* cppreference mentions "lvalue conversions" on e before compatibility: https://en.cppreference.com/w/c/language/generic.
4861+
C11 standard section 6.5.1.1.3 does not mention anything.
4862+
TODO: Which is it and does doExp already do this? *)
48604863
let (_, _, e_typ) = doExp false e (AExp None) in
48614864
let al_compatible = List.filter (fun (at, _) -> typ_compatible e_typ (doOnlyType at JUSTBASE)) al_nondefault in
48624865

src/frontc/cprint.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ and print_type_spec = function
196196
(print_enum_items enum_items)
197197
| TtypeofE e -> printl ["__typeof__";"("]; print_expression e; print ") "
198198
| TtypeofT (s,d) -> printl ["__typeof__";"("]; print_onlytype (s, d); print ") "
199-
| Tdefault -> print "default "
199+
| Tdefault -> print "default " (* TODO: is this right? *)
200200

201201

202202
(* print "struct foo", but with specified keyword and a list of
@@ -404,7 +404,7 @@ and get_operator exp =
404404
| TYPE_SIZEOF _ -> ("", 16)
405405
| EXPR_ALIGNOF exp -> ("", 16)
406406
| TYPE_ALIGNOF _ -> ("", 16)
407-
| GENERIC _ -> ("", 16)
407+
| GENERIC _ -> ("", 16) (* TODO: is this right? *)
408408
| IMAG exp -> ("", 16)
409409
| REAL exp -> ("", 16)
410410
| CLASSIFYTYPE exp -> ("", 16)
@@ -541,6 +541,7 @@ and print_expression_level (lvl: int) (exp : expression) =
541541
print_onlytype (bt, dt);
542542
print ")"
543543
| GENERIC (exp, lst) ->
544+
(* TODO: is this right? *)
544545
let print_generic_list l =
545546
match l with
546547
[] -> ()

0 commit comments

Comments
 (0)