Ignore:
Timestamp:
May 16, 2009, 11:13:38 AM (10 years ago)
Author:
gz
Message:

Add an unknown-type-in-declaration warning that doesn't care if the type is defined later, use it for type declarations. Other tweaks: make the generic bad declaration message even more vague. Try not to whine more than once for the same declaration. Remember whether the user said ignorable or ignore-if-unused, for error messages.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/compiler/nx0.lisp

    r12069 r12071  
    770770
    771771(defun nx-bad-decls (decls)
    772   (nx1-whine :unknown-declaration decls))
    773 
    774 
    775 
    776 (defnxdecl special (pending decl env)
     772  (nx1-whine :bad-declaration decls))
     773
     774
     775(defnxdecl special (pending decl env &aux whined)
    777776  (declare (ignore env))
    778777  (dolist (s (%cdr decl))
    779778    (if (symbolp s)
    780779      (nx-new-vdecl pending s 'special)
    781       (nx-bad-decls decl))))
    782 
    783 (defnxdecl notspecial (pending decl env)
     780      (unless (shiftf whined t) (nx-bad-decls decl)))))
     781
     782(defnxdecl notspecial (pending decl env &aux whined)
    784783  (declare (ignore env))
    785784  (dolist (s (%cdr decl))
    786785    (if (symbolp s)
    787786      (nx-new-vdecl pending s 'notspecial)
    788       (nx-bad-decls decl))))
    789 
    790 
    791 (defnxdecl dynamic-extent (pending decl env)
     787      (unless (shiftf whined t) (nx-bad-decls decl)))))
     788
     789(defnxdecl dynamic-extent (pending decl env &aux whined)
    792790  (declare (ignore env))
    793791  (dolist (s (%cdr decl))
     
    800798               (setq s (validate-function-name (cadr s))))
    801799        (nx-new-fdecl pending s 'dynamic-extent t)
    802         (nx-bad-decls decl)))))
    803 
    804 (defnxdecl ignorable (pending decl env)
     800        (unless (shiftf whined t) (nx-bad-decls decl))))))
     801
     802(defnxdecl ignorable (pending decl env &aux whined)
    805803  (declare (ignore env))
    806804  (dolist (s (%cdr decl))
    807805    (if (symbolp s)
    808       (nx-new-vdecl pending s 'ignore-if-unused t)
     806      (nx-new-vdecl pending s 'ignorable)
    809807      (if (and (consp s)
    810808               (eq (%car s) 'function)
     
    812810               (valid-function-name-p (cadr s))
    813811               (setq s (validate-function-name (cadr s))))
    814         (nx-new-fdecl pending s 'ignore-if-unused t)
    815         (nx-bad-decls decl)))))
    816 
    817 (defnxdecl ftype (pending decl env)
     812        (nx-new-fdecl pending s 'ignorable)
     813        (unless (shiftf whined t) (nx-bad-decls decl))))))
     814
     815(defnxdecl ftype (pending decl env &aux whined)
    818816  (destructuring-bind (type &rest fnames) (%cdr decl)
    819     (if (not (every (lambda (f) (or (symbolp f) (setf-function-name-p f))) fnames))
    820       (nx-bad-decls decl)
    821       (let ((ctype (specifier-type-if-known type env :whine t)))
    822         (when ctype
    823           (dolist (s fnames)
    824             (nx-new-fdecl pending s 'ftype type)))))))
     817    (if (specifier-type-if-known type env)
     818      (dolist (s fnames)
     819        (if (or (symbolp s) (setf-function-name-p s))
     820            (nx-new-fdecl pending s 'ftype type)
     821            (unless (shiftf whined t) (nx-bad-decls decl))))
     822      (nx1-whine :unknown-type-in-declaration type))))
    825823
    826824(defnxdecl settable (pending decl env)
     
    830828  (nx-settable-decls pending decl env nil))
    831829
    832 (defun nx-settable-decls (pending decl env val)
     830(defun nx-settable-decls (pending decl env val &aux whined)
    833831  (declare (ignore env))
    834832  (dolist (s (%cdr decl))
    835833    (if (symbolp s)
    836834      (nx-new-vdecl pending s 'settable val)
    837       (nx-bad-decls decl))))
     835      (unless (shiftf whined t) (nx-bad-decls decl)))))
    838836
    839837(defnxdecl function (pending decl env)
     
    843841  (nx-process-type-decl pending decl (cadr decl) (cddr decl) env))
    844842
    845 (defun nx-process-type-decl (pending decl type vars env)
    846   (if (not (every #'symbolp vars))
    847     (nx-bad-decls decl)
    848     (let ((ctype (specifier-type-if-known type env :whine t)))
    849       (when ctype
    850         (dolist (sym vars)
    851           (nx-new-vdecl pending sym 'type ctype))))))
     843(defun nx-process-type-decl (pending decl type vars env &aux whined)
     844  (if (specifier-type-if-known type env)
     845    (dolist (sym vars)
     846      (if (symbolp sym)
     847        (nx-new-vdecl pending sym 'type type)
     848        (unless (shiftf whined t) (nx-bad-decls decl))))
     849    (nx1-whine :unknown-type-in-declaration type)))
    852850
    853851(defnxdecl global-function-name (pending decl env)
     
    869867
    870868
    871 (defun nx-inline-decl (pending decl val &aux valid-name)
     869(defun nx-inline-decl (pending decl val &aux valid-name whined)
    872870  (dolist (s (%cdr decl))
    873871    (multiple-value-setq (valid-name s) (valid-function-name-p s))
     
    877875          (setq *nx-inlined-self* val))
    878876        (nx-new-fdecl pending s 'inline (if val 'inline 'notinline)))
    879       (nx-bad-decls decl))))
     877      (unless (shiftf whined t) (nx-bad-decls decl)))))
    880878
    881879(defnxdecl inline (pending decl env)
     
    887885  (nx-inline-decl pending decl nil))
    888886
    889 (defnxdecl ignore (pending decl env)
     887(defnxdecl ignore (pending decl env &aux whined)
    890888  (declare (ignore env))
    891889  (dolist (s (%cdr decl))
     
    898896               (setq s (validate-function-name (cadr s))))
    899897        (nx-new-fdecl pending s 'ignore t)
    900         (nx-bad-decls decl)))))
    901 
    902 (defnxdecl ignore-if-unused (pending decl env)
     898        (unless (shiftf whined t) (nx-bad-decls decl))))))
     899
     900(defnxdecl ignore-if-unused (pending decl env &aux whined)
    903901  (declare (ignore env))
    904902  (dolist (s (%cdr decl))
    905903    (if (symbolp s)
    906904      (nx-new-vdecl pending s 'ignore-if-unused)
    907       (nx-bad-decls decl))))
     905      (unless (shiftf whined t) (nx-bad-decls decl)))))
    908906
    909907(defun nx-self-call-p (name &optional ignore-lexical (allow *nx-inlined-self*))
     
    10661064      (if (and (fixnump v) (<= 0 v 3) (memq q '(speed space compilation-speed safety debug)))
    10671065        (push (cons q v) mdecls)
    1068         (nx-bad-decls specs)))))
     1066        (nx-bad-decls spec)))))
    10691067
    10701068(defun %proclaim-optimize (specs &aux q v)
Note: See TracChangeset for help on using the changeset viewer.