say what is wrong with a pointer type, and stop mangling fn ones
The guard against nested pointer chains searched every sublist for a `*', including the ones that hold a type of their own. A function type with a pointer parameter, while the same type with an int parameter passed. (* [char 4]) was let through as well and came out as `vector-ref char 4 * p'. A `*' inside an array or a function type belongs to that type, so the search stops there. What the flat conversion cannot express is now named: a fn type is a function pointer already, and a pointer to an array is not supported. Parameters of a function type are walked without their names. C writes a parameter name into a declarator and a type has none, so fmt-c prints whatever it is handed there as a type: `(s (* char))' came out as `char(*) s'. fmt-c printed a nameless array declarator's #f into the C, which showed up in these parameters.
This commit is contained in:
@@ -737,10 +737,13 @@
|
||||
(cat (c-type (cadr type) #f)
|
||||
" (*" (or name "") ")("
|
||||
(fmt-join (lambda (x) (c-type x #f)) (caddr type) ", ") ")"))
|
||||
;; MODIFIED FROM UPSTREAM fmt-c: a nameless declarator -- an
|
||||
;; array parameter of a function type, where C has no room
|
||||
;; for a name -- arrives as #f, and upstream printed it
|
||||
((%array)
|
||||
(let ((name (cat name "[" (if (pair? (cddr type))
|
||||
(c-expr (caddr type))
|
||||
"")
|
||||
(let ((name (cat (or name "") "[" (if (pair? (cddr type))
|
||||
(c-expr (caddr type))
|
||||
"")
|
||||
"]")))
|
||||
(c-type (cadr type) name)))
|
||||
((%pointer *)
|
||||
@@ -773,10 +776,13 @@
|
||||
(cat (c-type (cadr type) #f)
|
||||
" (*" (or name "") ")("
|
||||
(fmt-join (lambda (x) (c-type x #f)) (caddr type) ", ") ")"))
|
||||
;; MODIFIED FROM UPSTREAM fmt-c: a nameless declarator -- an
|
||||
;; array parameter of a function type, where C has no room
|
||||
;; for a name -- arrives as #f, and upstream printed it
|
||||
((%array)
|
||||
(let ((name (cat name "[" (if (pair? (cddr type))
|
||||
(c-expr (caddr type))
|
||||
"")
|
||||
(let ((name (cat (or name "") "[" (if (pair? (cddr type))
|
||||
(c-expr (caddr type))
|
||||
"")
|
||||
"]")))
|
||||
(c-type (cadr type) name)))
|
||||
((%pointer *)
|
||||
|
||||
Reference in New Issue
Block a user