take a name after a qualified type as the bound

[int const N] read N as the type a trailing const was waiting for, and
wrote int const N b[]; a qualifier waits for a name only when no type
came before it.
This commit is contained in:
2026-10-15 14:48:25 +03:00
parent dd1718dffb
commit 6ced17c20e
2 changed files with 19 additions and 7 deletions

View File

@@ -409,14 +409,14 @@
arglist))
;;; The last element is a bound unless what precedes it is still
;;; waiting for a type name -- a `*', a qualifier, a tag's keyword. C
;;; spells a type with one name at most, so a name after a name, or
;;; after a grouped type, can only be the bound:
;;; waiting for a type name -- a `*', a tag's keyword, a qualifier with
;;; no type before it. C spells a type with one name at most, so a name
;;; after a name, or after a grouped type, can only be the bound:
;;;
;;; (¤ int 4) four of int (¤ unsigned int) unsized
;;; (¤ pthread-t CAP) CAP of pthread-t (¤ struct point) unsized
;;; (¤ (* T) CAP) CAP of (* T) (¤ const mytype) unsized
;;; (¤ * size-t) unsized
;;; (¤ int const N) N of const int (¤ * size-t) unsized
;;;
;;; TYPE is the whole `(¤ ...)' form.
(define (array-bound? type)
@@ -426,8 +426,13 @@
(cond
((not (symbol? bound)) #t)
((or (memq bound +c-specifiers+) (memq bound +c-qualifiers+)) #f)
(else (not (or (memq preceding '(* struct union enum))
(memq preceding +c-qualifiers+))))))))
((memq preceding '(* struct union enum)) #f)
((memq preceding +c-qualifiers+)
(any (lambda (word)
(not (or (memq word '(* struct union enum))
(memq word +c-qualifiers+))))
(drop-right (cdr type) 2)))
(else #t)))))
;;; What one element of a written array type is:
;;; (¤ struct point 2) -> (struct point), (¤ * const char 2) -> (* const char)