Changeset 15314
- Timestamp:
- Apr 10, 2012, 5:57:45 AM (13 years ago)
- Location:
- trunk/source/compiler
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/compiler/nx-basic.lisp
r15307 r15314 690 690 (:format-error . "~:{~@?~%~}") 691 691 (:program-error . "~a") 692 (:unsure . "Nonspecific warning"))) 692 (:unsure . "Nonspecific warning") 693 (:duplicate-binding . "Multiple bindings of ~S in ~A form") 694 (:shadow-cl-package-definition . "Local function or macro name ~s shadows standard CL definition."))) 693 695 694 696 (defun report-invalid-type-compiler-warning (condition stream) -
trunk/source/compiler/nx0.lisp
r15307 r15314 1110 1110 (neq (nx-var-root-nsetqs target) (cadr pair))) 1111 1111 (push (cons var target) *nx-punted-vars*))))) 1112 1113 ;;; Someone might be able to come up with a case where (perhaps through 1114 ;;; use of (DECLAIM (IGNORE ...))) it might make some sense to bind 1115 ;;; the same variable more than once in a parallel binding construct. 1116 ;;; Even if that's done intentionally, there's probably some value 1117 ;;; in warning about it (and it's hard to guess whether it's done 1118 ;;; intentionally. 1119 ;;; Something like (LET* ((X 1) (X (1+ X))) ...) is well-defined (even 1120 ;;; if it's a bit unaesthetic. 1121 ;;; We error if there are duplicate required args in a lambda list, 1122 ;;; but let things like (LAMBDA (A &OPTIONAL A) ...) slide. (Those 1123 ;;; cases generally generate an unused-variable warning, so we don't 1124 1125 (defun nx1-check-duplicate-bindings (syms context) 1126 (do* () 1127 ((null syms)) 1128 (let* ((sym (pop syms))) 1129 (when (member sym syms :test #'eq) 1130 (nx1-whine :duplicate-binding (maybe-setf-name sym) context))))) 1131 1112 1132 1113 1133 (defun nx1-punt-var (var initform) … … 1933 1953 1934 1954 (defun nx1-whine (about &rest forms) 1935 (push (make-condition (or (cdr (assq about *compiler-whining-conditions*)) 'compiler-warning) 1936 :function-name (list *nx-cur-func-name*) 1937 :source-note *nx-current-note* 1938 :warning-type about 1939 :args (or forms (list nil))) 1940 *nx-warnings*)) 1955 ;; Don't turn STYLE-WARNINGs generated during compilation into 1956 ;; vanilla COMPILER-WARNINGs. 1957 (let* ((c (if (and (eq about :program-error) 1958 (typep (car forms) 'style-warning)) 1959 (let* ((c (car forms))) 1960 (with-slots (source-note function-name) c 1961 (setq source-note *nx-current-note* 1962 function-name (list *nx-cur-func-name*)) 1963 c)) 1964 (make-condition (or (cdr (assq about *compiler-whining-conditions*)) 1965 'compiler-warning) 1966 :function-name (list *nx-cur-func-name*) 1967 :source-note *nx-current-note* 1968 :warning-type about 1969 :args (or forms (list nil)))))) 1970 1971 (push c *nx-warnings*))) 1941 1972 1942 1973 (defun p2-whine (afunc about &rest forms) -
trunk/source/compiler/nx1.lisp
r15307 r15314 207 207 (defnx1 nx1-macrolet macrolet context (defs &body body) 208 208 (let* ((old-env *nx-lexical-environment*) 209 (new-env (new-lexical-environment old-env))) 209 (new-env (new-lexical-environment old-env)) 210 (names ())) 210 211 (dolist (def defs) 211 212 (destructuring-bind (name arglist &body mbody) def 213 (push name names) 212 214 (push 213 215 (cons … … 220 222 function))) 221 223 (lexenv.functions new-env)))) 224 (nx1-check-duplicate-bindings names 'macrolet) 222 225 (let* ((*nx-lexical-environment* new-env)) 223 226 (with-nx-declarations (pending) … … 235 238 (let ((env *nx-lexical-environment*) 236 239 (*nx-bound-vars* *nx-bound-vars*)) 237 (dolist (def defs) 238 (destructuring-bind (sym expansion) def 239 (let* ((var (nx-new-var pending sym)) 240 (bits (nx-var-bits var))) 241 (when (%ilogbitp $vbitspecial bits) 242 (nx-error "SPECIAL declaration applies to symbol macro ~s" sym)) 243 (nx-set-var-bits var (%ilogior (%ilsl $vbitignoreunused 1) bits)) 244 (setf (var-ea var) (cons :symbol-macro expansion))))) 240 (collect ((vars) 241 (symbols)) 242 (dolist (def defs) 243 (destructuring-bind (sym expansion) def 244 (let* ((var (nx-new-var pending sym)) 245 (bits (nx-var-bits var))) 246 (symbols sym) 247 (when (%ilogbitp $vbitspecial bits) 248 (nx-error "SPECIAL declaration applies to symbol macro ~s" sym)) 249 (nx-set-var-bits var (%ilogior (%ilsl $vbitignoreunused 1) bits)) 250 (setf (var-ea var) (cons :symbol-macro expansion)) 251 (vars var)))) 252 (nx1-check-duplicate-bindings (symbols) 'symbol-macrolet)) 245 253 (nx-effect-other-decls pending env) 246 254 (nx1-env-body context body old-env)))))) … … 1773 1781 *nx-new-p2decls*)))) 1774 1782 1783 (defun maybe-warn-about-shadowing-cl-function-name (funcname) 1784 (when (and (symbolp funcname) 1785 (fboundp funcname) 1786 (eq (symbol-package funcname) (find-package "CL"))) 1787 (nx1-whine :shadow-cl-package-definition funcname) 1788 t)) 1789 1775 1790 (defun maybe-warn-about-nx1-alphatizer-binding (funcname) 1776 (when (and (symbolp funcname) 1777 (gethash funcname *nx1-alphatizers*)) 1778 (nx1-whine :special-fbinding funcname))) 1791 (or (maybe-warn-about-shadowing-cl-function-name funcname) 1792 (when (and (symbolp funcname) 1793 (gethash funcname *nx1-alphatizers*)) 1794 (nx1-whine :special-fbinding funcname)))) 1795 1796 1779 1797 1780 1798 (defnx1 nx1-flet flet context (defs &body forms) … … 1788 1806 (pairs nil) 1789 1807 (fname nil) 1790 (name nil)) 1808 (name nil) 1809 (fnames ())) 1791 1810 (multiple-value-bind (body decls) (parse-body forms env nil) 1792 1811 (nx-process-declarations pending decls) … … 1794 1813 (destructuring-bind (funcname lambda-list &body flet-function-body) def 1795 1814 (setq fname (nx-need-function-name funcname)) 1815 (push fname fnames) 1796 1816 (maybe-warn-about-nx1-alphatizer-binding funcname) 1797 1817 (multiple-value-bind (body decls) … … 1815 1835 (push (setq name (make-symbol (symbol-name funcname))) names) 1816 1836 (push (cons funcname (cons 'function (cons func name))) (lexenv.functions new-env)))))) 1837 (nx1-check-duplicate-bindings fnames 'flet) 1817 1838 (let ((vars nil) 1818 1839 (rvars nil) … … 1874 1895 (blockname nil) 1875 1896 (fname nil) 1876 (name nil)) 1897 (name nil) 1898 (fnames ())) 1877 1899 (multiple-value-bind (body decls) (parse-body forms env nil) 1878 1900 (dolist (def defs (setq funcs (nreverse funcs) bodies (nreverse bodies))) … … 1882 1904 (setq blockname funcname) 1883 1905 (setq fname (nx-need-function-name funcname)) 1906 (push fname fnames) 1884 1907 (when (consp funcname) 1885 1908 (setq blockname (%cadr funcname) funcname fname)) … … 1908 1931 (nx-reconcile-inherited-vars funcrefs) 1909 1932 (dolist (f funcrefs) (nx1-afunc-ref f)) 1933 (nx1-check-duplicate-bindings fnames 'labels) 1910 1934 (make-acode 1911 1935 (%nx1-operator labels) … … 2467 2491 (nx1-progn-body context (if (or (memq 'eval when) (memq :execute when)) body))) 2468 2492 2469 (defnx1 nx1-misplaced (declare) context (&rest args) 2470 (nx-error "~S not expected in ~S." *nx-sfname* (cons *nx-sfname* args))) 2471 2493 (defnx1 nx1-misplaced (declare) context (&whole w &rest args) 2494 (declare (ignore args)) 2495 (nx-error "The DECLARE expression ~s is being treated as a form, 2496 possibly because it's the result of macroexpansion. DECLARE expressions 2497 can only appear in specified contexts and must be actual subexressions 2498 of the containing forms." w)) 2499 2500
Note:
See TracChangeset
for help on using the changeset viewer.
