mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 04:10:18 +02:00
Handle ~p in 'format' warnings.
Fixes <http://bugs.gnu.org/18299>. Reported by Frank Terbeck <ft@bewatermyfriend.org>. * module/language/tree-il/analyze.scm (format-string-argument-count): Add case for ~p. * test-suite/tests/tree-il.test ("warnings")["format"]("~p", "~p, too few arguments", "~:p", "~:@p, too many arguments", "~:@p, too few arguments"): New tests.
This commit is contained in:
parent
c6a7930b38
commit
8ac39b38d1
2 changed files with 56 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
;;; TREE-IL -> GLIL compiler
|
;;; TREE-IL -> GLIL compiler
|
||||||
|
|
||||||
;; Copyright (C) 2001, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
|
;; Copyright (C) 2001, 2008, 2009, 2010, 2011, 2012,
|
||||||
|
;; 2014 Free Software Foundation, Inc.
|
||||||
|
|
||||||
;;;; This library is free software; you can redistribute it and/or
|
;;;; This library is free software; you can redistribute it and/or
|
||||||
;;;; modify it under the terms of the GNU Lesser General Public
|
;;;; modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -1273,6 +1274,16 @@ accurate information is missing from a given `tree-il' element."
|
||||||
conditions end-group
|
conditions end-group
|
||||||
(+ 1 min-count)
|
(+ 1 min-count)
|
||||||
(+ 1 max-count)))
|
(+ 1 max-count)))
|
||||||
|
((#\p #\P) (let* ((colon? (memq #\: params))
|
||||||
|
(min-count (if colon?
|
||||||
|
(max 1 min-count)
|
||||||
|
(+ 1 min-count))))
|
||||||
|
(loop (cdr chars) 'literal '()
|
||||||
|
conditions end-group
|
||||||
|
min-count
|
||||||
|
(if colon?
|
||||||
|
(max max-count min-count)
|
||||||
|
(+ 1 max-count)))))
|
||||||
((#\[)
|
((#\[)
|
||||||
(loop chars 'literal '() '()
|
(loop chars 'literal '() '()
|
||||||
(let ((selector (previous-number params))
|
(let ((selector (previous-number params))
|
||||||
|
|
|
@ -1698,6 +1698,50 @@
|
||||||
(number? (string-contains (car w)
|
(number? (string-contains (car w)
|
||||||
"expected 3, got 2")))))
|
"expected 3, got 2")))))
|
||||||
|
|
||||||
|
(pass-if "~p"
|
||||||
|
(null? (call-with-warnings
|
||||||
|
(lambda ()
|
||||||
|
(compile '(((@ (ice-9 format) format) #f "thing~p" 2))
|
||||||
|
#:opts %opts-w-format
|
||||||
|
#:to 'assembly)))))
|
||||||
|
|
||||||
|
(pass-if "~p, too few arguments"
|
||||||
|
(let ((w (call-with-warnings
|
||||||
|
(lambda ()
|
||||||
|
(compile '((@ (ice-9 format) format) #f "~p")
|
||||||
|
#:opts %opts-w-format
|
||||||
|
#:to 'assembly)))))
|
||||||
|
(and (= (length w) 1)
|
||||||
|
(number? (string-contains (car w)
|
||||||
|
"expected 1, got 0")))))
|
||||||
|
|
||||||
|
(pass-if "~:p"
|
||||||
|
(null? (call-with-warnings
|
||||||
|
(lambda ()
|
||||||
|
(compile '(((@ (ice-9 format) format) #f "~d thing~:p" 2))
|
||||||
|
#:opts %opts-w-format
|
||||||
|
#:to 'assembly)))))
|
||||||
|
|
||||||
|
(pass-if "~:@p, too many arguments"
|
||||||
|
(let ((w (call-with-warnings
|
||||||
|
(lambda ()
|
||||||
|
(compile '((@ (ice-9 format) format) #f "~d pupp~:@p" 5 5)
|
||||||
|
#:opts %opts-w-format
|
||||||
|
#:to 'assembly)))))
|
||||||
|
(and (= (length w) 1)
|
||||||
|
(number? (string-contains (car w)
|
||||||
|
"expected 1, got 2")))))
|
||||||
|
|
||||||
|
(pass-if "~:@p, too few arguments"
|
||||||
|
(let ((w (call-with-warnings
|
||||||
|
(lambda ()
|
||||||
|
(compile '((@ (ice-9 format) format) #f "pupp~:@p")
|
||||||
|
#:opts %opts-w-format
|
||||||
|
#:to 'assembly)))))
|
||||||
|
(and (= (length w) 1)
|
||||||
|
(number? (string-contains (car w)
|
||||||
|
"expected 1, got 0")))))
|
||||||
|
|
||||||
(pass-if "~?"
|
(pass-if "~?"
|
||||||
(null? (call-with-warnings
|
(null? (call-with-warnings
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue