diff --git a/lib/tests/scaffold/70-function-destruct-declare.c b/lib/tests/scaffold/70-function-destruct-declare.c new file mode 100644 index 00000000..eef51a77 --- /dev/null +++ b/lib/tests/scaffold/70-function-destruct-declare.c @@ -0,0 +1,41 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +struct foo +{ + int bar; +}; + +struct foo * test (struct foo *f); + +int +main () +{ + struct foo f = { 1 }; + int i = test (&f)->bar; + return test (&f)->bar - i; +} + +struct foo * +test (struct foo *f) +{ + void (*fun) () = test; + return f; +} diff --git a/module/mescc/compile.scm b/module/mescc/compile.scm index 11e3d94c..1faadfe1 100644 --- a/module/mescc/compile.scm +++ b/module/mescc/compile.scm @@ -2330,8 +2330,7 @@ (((ftn-declr (ident ,name) . ,_)) (let ((functions (.functions info))) (if (member name functions) info - (let* ((type (ftn-declr:get-type info `(ftn-declr (ident ,name) ,@_))) - (function (make-function name type #f))) + (let ((function (make-function name type #f))) (clone info #:functions (cons (cons name function) functions)))))) (((ftn-declr (scope (ptr-declr ,pointer (ident ,name))) ,param-list) ,init) (let* ((rank (pointer->rank pointer)) @@ -2623,11 +2622,6 @@ (ast->type type info)) (_ (error "fctn-defn:get-type: not supported:" o)))) -(define (ftn-declr:get-type info o) - (pmatch o - ((ftn-declr (ident _) . _) #f) - (_ (error "fctn-decrl:get-type: not supported:" o)))) - (define (fctn-defn:get-statement o) (pmatch o ((_ (ftn-declr (ident _) _) ,statement) statement)