Ignore:
Timestamp:
Aug 5, 2009, 7:28:54 PM (10 years ago)
Author:
gz
Message:

Bunch of tests for declaration warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/ansi-tests/ccl.lsp

    r12472 r12532  
    902902                                            (muffle-warning c))))
    903903      (test-compile (test-source-file text) :hide-warnings t))
    904     warnings))
     904    (nreverse warnings)))
    905905 
    906906(deftest ccl.49345-u1
     
    10551055          (values (read-from-string (prin1-to-string "123456789012345")))))
    10561056  "123456789012345")
     1057
     1058(deftest ccl.decl.1
     1059    (test-compiler-warning "(defun ccl.decl.1 (a) (lambda () (declare (fixnum a)) a))")
     1060  ())
     1061
     1062(deftest ccl.decl.2
     1063    (test-compiler-warning "(defun ccl.decl.2 (a) (flet ((fn () (declare (fixnum a)) a)) #'fn))")
     1064  ())
     1065
     1066(deftest ccl.decl.3
     1067    (test-compiler-warning "(defun ccl.decl.3 ()
     1068                              (declare (dynamic-extent #'ccl.decl.3-none-such)
     1069                                       (notinline ccl.decl.3-none-other)))")
     1070  (:unknown-declaration-function :unknown-declaration-function))
     1071
     1072(deftest ccl.decl.4
     1073    (test-compiler-warning "(defun ccl.decl.4 () (flet ((fn () t) (fn1 () t)) (declare (inline fn) (dynamic-extent #'fn1)) (list (fn) (fn1))))")
     1074  ())
     1075
     1076(deftest ccl.decl.5
     1077    (test-compiler-warning "(defun ccl.decl.5 () (flet ((fn () t)) (declare (notinline ccl.decl.5-none-sch) (dynamic-extent #'ccl.decl.5-non-other)) #'fn))")
     1078  (:unknown-declaration-function :unknown-declaration-function))
     1079
     1080(deftest ccl.ftype.1
     1081    (test-compiler-warning "(lambda () (declare (ftype integer ccl.ftype.1)))")
     1082  (:bad-declaration))
     1083
     1084(deftest ccl.ftype.2
     1085    (test-compiler-warning "(lambda () (declare (ftype function ccl.ftype.2)) #'ccl.ftype.2)")
     1086  ())
     1087
     1088(deftest ccl.ftype.3
     1089    (test-compiler-warning "(declaim (ftype (function (t) (values integer)) ccl.ftype.3))
     1090                            (defun ccl.ftype.3-caller () (the cons (ccl.ftype.3 nil)))")
     1091  (:type-conflict))
     1092
     1093
     1094(deftest ccl.ftype.4
     1095    (test-compiler-warning "(declaim (ftype (function (t) (values integer)) ccl.ftype.4))
     1096                            (defun ccl.ftype.4-caller () (ccl.ftype.4))")
     1097  (:ftype-mismatch))
     1098
     1099(deftest ccl.ftype.5
     1100    (test-compiler-warning "(declaim (ftype (function (t &key (:a integer)) (values integer)) ccl.ftype.5))
     1101                            (defun ccl.ftype.5-caller () (ccl.ftype.5 1 :a :x))")
     1102  (:type))
     1103
     1104(deftest ccl.ftype.6
     1105    (test-compiler-warning "(declaim (ftype (function (t &key (:a integer)) (values integer)) ccl.ftype.6))
     1106                            (defun ccl.ftype.6-caller () (ccl.ftype.6 :b 17))")
     1107  (:ftype-mismatch))
     1108
     1109
     1110(deftest ccl.ftype.7
     1111    (test-compiler-warning "(declaim (ftype (function (t t t) t) ccl.ftype.7))
     1112                            (defun ccl.ftype.7-caller () (ccl.ftype.7))")
     1113  (:ftype-mismatch))
     1114
     1115(deftest ccl.ftype.8
     1116    (test-compiler-warning "(declaim (ftype (function (t t t) t) ccl.ftype.8))
     1117                            (defun ccl.ftype.8-caller ()
     1118                               (flet ((ccl.ftype.8 () t)) (ccl.ftype.8)))")
     1119  ())
     1120
     1121(deftest ccl.ftype.9-pre
     1122    (test-compiler-warning "(declaim (ftype (function (unknown) t) ccl.ftype.9-pre))")
     1123  (:undefined-type))
     1124
     1125(deftest ccl.ftype.9
     1126    (test-compiler-warning "(defun ccl.ftype.9 (x) x)
     1127                            (declaim (ftype (function (unknown) t) ccl.ftype.9))
     1128                            (defun ccl.ftype.9-caller () (ccl.ftype.9 17))")
     1129  ;; The :undefined-type is from the declaim itself (see ccl.ftype.9-pre).  There
     1130  ;; should be no added type warnings from the actual use of the fn
     1131  (:undefined-type))
     1132
     1133(deftest ccl.ftype.10
     1134    (test-compiler-warning "(defun ccl.ftype.10-caller (x)
     1135                              (declare (ftype (function (t) t) ccl.ftype.10))
     1136                              (ccl.ftype.10 x))")
     1137  ())
     1138
     1139
     1140(deftest ccl.ftype.11-pre
     1141    (test-compiler-warning "(defun ccl.ftype.11-pre-caller (x)
     1142                              (declare (ftype (function (unknown) t) ccl.ftype.11-pre))
     1143                              x)")
     1144  (:unknown-type-in-declaration))
     1145
     1146(deftest ccl.ftype.11
     1147    (test-compiler-warning "(defun ccl.ftype.11-caller (x)
     1148                              (declare (ftype (function (unknown) t) ccl.ftype.11))
     1149                              (ccl.ftype.11 x))")
     1150  ;; The :unknown-type-in-declaration is from the declare itself (see ccl.ftype.11-pre).  There
     1151  ;; should be no added type warnings from the actual use of the fn
     1152  (:unknown-type-in-declaration :undefined-function))
     1153
     1154(deftest ccl.ftype.54161
     1155  (test-compiler-warning "(declaim (ftype (function (integer) (values integer)) ccl.ftype.54161))
     1156  (defun ccl.ftype.54161-caller () (ccl.ftype.54161 :x))")
     1157  (:type))
     1158
    10571159
    10581160;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Note: See TracChangeset for help on using the changeset viewer.