bugnyacc parser generator - Bugs: bug #65439, Single void in function's argument...

 
 

bug #65439: Single void in function's argument list generates erroneous code

Submitter:  None
Submitted:  Sat 09 Mar 2024 06:43:10 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  mwette
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 09 Mar 2024 09:54:04 PM UTC, comment #2: 

Ah.  I see I fixed, but not released yet.  Should appear 1.09.4

commit 741b988dc63471addd96e669f3f22e3a36abb53d

ndex f85119ec..137dabaf 100644
--- a/module/nyacc/lang/c99/ffi-help.scm
+++ b/module/nyacc/lang/c99/ffi-help.scm
@@ -1175,13 +1175,16 @@
         (mdecl (udecl->mdecl udecl)))
     (mdecl->fh-wrapper mdecl)))
 
+(define void-params '((param-decl (decl-spec-list (type-spec (void))))))
+
 ;; @deffn {Procedure} cnvt-fctn name specl params
 ;; name is string
 ;; specl is decl-spec-list tree
 ;; params is list of param-decl trees (i.e., cdr of param-list tree)
 ;; @end deffn
 (define (cnvt-fctn name rdecl params)
-  (let* ((varargs? (and (pair? params) (equal? (last params) '(ellipsis))))
+  (let* ((params (if (equal? params void-params) '() params))
+         (varargs? (and (pair? params) (equal? (last params) '(ellipsis))))
         (decl-return (gen-decl-return rdecl))
         (decl-params (gen-decl-params params))
         (exec-return (gen-exec-return-wrapper rdecl))

Matt Wette <mwette>
Group administrator
Sat 09 Mar 2024 09:49:31 PM UTC, comment #1: 

what version.  I think I did fix this recently.

Matt Wette <mwette>
Group administrator
Sat 09 Mar 2024 06:43:10 PM UTC, original submission:  

Consider this function declaration:

int foo(void);


It yields this code:

  (define foo
    (let ((~foo
            (delay (fh-link-proc
                     ffi:int
                     "foo"
                     (list ffi:void)
                     (force ffi-hydrogen-llibs)))))
      (lambda (arg0)
        (let () ((force ~foo) arg0)))))


The argument list is (list ffi:void) but Guile doesn't allow for the foreign functions to have void type arguments.
Additionally the generated wrapper function expects one argument, which is obviously wrong.

The generated code should look like this instead:

  (define foo
    (let ((~foo
            (delay (fh-link-proc
                     ffi:int
                     "foo"
                     (list)
                     (force ffi-hydrogen-llibs)))))
      (lambda ()
        (let () ((force ~foo))))))


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mwette (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-03-10 mwette StatusNone Fixed
        Assigned toNone mwette

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code