mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 21:10:27 +02:00
Add -Wshadowed-toplevel.
* module/language/tree-il/analyze.scm (shadowed-toplevel-analysis): New variable. * module/language/tree-il/compile-cps.scm (%warning-passes): Add it. * module/system/base/message.scm (%warning-types): Add it. * test-suite/tests/tree-il.test ("warnings")["shadowed-toplevel"]: New test prefix. * module/ice-9/boot-9.scm (%auto-compilation-options): Add it. * doc/ref/api-evaluation.texi (Compilation): Add 'shadowed-toplevel' and 'macro-use-before-definition'.
This commit is contained in:
parent
741c45458d
commit
bdcd0ba8a7
6 changed files with 131 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
|||
;;; TREE-IL -> GLIL compiler
|
||||
|
||||
;; Copyright (C) 2001, 2008-2014 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2001, 2008-2014, 2018 Free Software Foundation, Inc.
|
||||
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -34,6 +34,7 @@
|
|||
analyze-tree
|
||||
unused-variable-analysis
|
||||
unused-toplevel-analysis
|
||||
shadowed-toplevel-analysis
|
||||
unbound-variable-analysis
|
||||
macro-use-before-definition-analysis
|
||||
arity-analysis
|
||||
|
@ -813,6 +814,37 @@ given `tree-il' element."
|
|||
|
||||
(make-reference-graph vlist-null vlist-null #f))))
|
||||
|
||||
|
||||
;;;
|
||||
;;; Shadowed top-level definition analysis.
|
||||
;;;
|
||||
|
||||
(define shadowed-toplevel-analysis
|
||||
;; Report top-level definitions that shadow previous top-level
|
||||
;; definitions from the same compilation unit.
|
||||
(make-tree-analysis
|
||||
(lambda (x defs env locs)
|
||||
;; Going down into X.
|
||||
(record-case x
|
||||
((<toplevel-define> name src)
|
||||
(match (vhash-assq name defs)
|
||||
((_ . previous-definition)
|
||||
(warning 'shadowed-toplevel src name
|
||||
(toplevel-define-src previous-definition))
|
||||
defs)
|
||||
(#f
|
||||
(vhash-consq name x defs))))
|
||||
(else defs)))
|
||||
|
||||
(lambda (x defs env locs)
|
||||
;; Leaving X's scope.
|
||||
defs)
|
||||
|
||||
(lambda (defs env)
|
||||
#t)
|
||||
|
||||
vlist-null))
|
||||
|
||||
|
||||
;;;
|
||||
;;; Unbound variable analysis.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; Continuation-passing style (CPS) intermediate language (IL)
|
||||
|
||||
;; Copyright (C) 2013, 2014, 2015, 2017 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2013, 2014, 2015, 2017, 2018 Free Software Foundation, Inc.
|
||||
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1014,6 +1014,7 @@ integer."
|
|||
(define %warning-passes
|
||||
`((unused-variable . ,unused-variable-analysis)
|
||||
(unused-toplevel . ,unused-toplevel-analysis)
|
||||
(shadowed-toplevel . ,shadowed-toplevel-analysis)
|
||||
(unbound-variable . ,unbound-variable-analysis)
|
||||
(macro-use-before-definition . ,macro-use-before-definition-analysis)
|
||||
(arity-mismatch . ,arity-analysis)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue