Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added warning for missing mli interface file #9407

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ Working version

### Compiler user-interface and warnings:

- #9407: added warning for missing mli interface file
(Anukriti Kumar, review by Florian Angeletti)

- #9960: extend ocamlc/ocamlopt's -o option to work when compiling C files
(Sébastien Hinderer, reported by Daniel Bünzli, review by Florian
Angeletti and Gabriel Scherer)
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ INCLUDES=-I utils -I parsing -I typing -I bytecomp -I file_formats \
-I asmcomp -I asmcomp/debug \
-I driver -I toplevel

COMPFLAGS=-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66 \
COMPFLAGS=-strict-sequence -principal -absname \
-w +a-4-9-40-41-42-44-45-48-66-70 \
-warn-error +a \
-bin-annot -safe-string -strict-formats $(INCLUDES)
LINKFLAGS=
Expand Down
2 changes: 1 addition & 1 deletion debugger/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DYNLINKDIR=$(ROOTDIR)/otherlibs/dynlink
UNIXDIR=$(ROOTDIR)/otherlibs/$(UNIXLIB)

CAMLC=$(BEST_OCAMLC) -g -nostdlib -I $(ROOTDIR)/stdlib
COMPFLAGS=$(INCLUDES) -absname -w +a-4-9-41-42-44-45-48 -warn-error +A \
COMPFLAGS=$(INCLUDES) -absname -w +a-4-9-41-42-44-45-48-70 -warn-error +A \
-safe-string -strict-sequence -strict-formats
LINKFLAGS=-linkall -I $(UNIXDIR) -I $(DYNLINKDIR)
OCAMLLEX ?= $(BEST_OCAMLLEX)
Expand Down
2 changes: 1 addition & 1 deletion lex/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ OCAMLYACCFLAGS = -v
CAMLC = $(BOOT_OCAMLC) -strict-sequence -nostdlib \
-I $(ROOTDIR)/boot -use-prims $(ROOTDIR)/runtime/primitives
CAMLOPT = $(CAMLRUN) $(ROOTDIR)/ocamlopt$(EXE) -nostdlib -I $(ROOTDIR)/stdlib
COMPFLAGS = -absname -w +a-4-9-41-42-44-45-48 -warn-error +A \
COMPFLAGS = -absname -w +a-4-9-41-42-44-45-48-70 -warn-error +A \
-safe-string -strict-sequence -strict-formats -bin-annot
LINKFLAGS =
OCAMLLEX ?= $(BOOT_OCAMLLEX)
Expand Down
2 changes: 1 addition & 1 deletion man/ocamlc.m
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ compilation in any way (even if it is fatal). If a warning is enabled,

.IP
The default setting is
.BR \-w\ +a\-4\-6\-7\-9\-27\-29\-30\-32..42\-44\-45\-48\-50\-60\-66..69 .
.BR \-w\ +a\-4\-6\-7\-9\-27\-29\-30\-32..42\-44\-45\-48\-50\-60\-66..70 .
Note that warnings
.BR 5 \ and \ 10
are not always triggered, depending on the internals of the type checker.
Expand Down
2 changes: 1 addition & 1 deletion ocamldoc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ INCLUDES_NODEP=\
DEPINCLUDES=$(INCLUDES_DEP)
INCLUDES=$(INCLUDES_DEP) $(INCLUDES_NODEP)

COMPFLAGS=$(INCLUDES) -absname -w +a-4-9-41-42-44-45-48 -warn-error +A \
COMPFLAGS=$(INCLUDES) -absname -w +a-4-9-41-42-44-45-48-70 -warn-error +A \
-safe-string -strict-sequence -strict-formats -bin-annot -principal

LINKFLAGS=$(INCLUDES) -nostdlib
Expand Down
3 changes: 2 additions & 1 deletion otherlibs/dynlink/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ OCAMLC=$(BEST_OCAMLC) -g -nostdlib -I $(ROOTDIR)/stdlib
OCAMLOPT=$(BEST_OCAMLOPT) -g -nostdlib -I $(ROOTDIR)/stdlib

# COMPFLAGS should be in sync with the toplevel Makefile's COMPFLAGS.
COMPFLAGS=-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66 \
COMPFLAGS=-strict-sequence -principal -absname \
-w +a-4-9-40-41-42-44-45-48-66-70 \
-warn-error +A \
-bin-annot -safe-string -strict-formats
ifeq "$(FLAMBDA)" "true"
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TARGET_BINDIR ?= $(BINDIR)

COMPILER=$(ROOTDIR)/ocamlc$(EXE)
CAMLC=$(CAMLRUN) $(COMPILER)
COMPFLAGS=-strict-sequence -absname -w +a-4-9-41-42-44-45-48 \
COMPFLAGS=-strict-sequence -absname -w +a-4-9-41-42-44-45-48-70 \
-g -warn-error +A -bin-annot -nostdlib -principal \
-safe-string -strict-formats
ifeq "$(FLAMBDA)" "true"
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/lib-unix/win-env/test_env.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST
include unix
flags += "-strict-sequence -safe-string -w +A -warn-error +A"
flags += "-strict-sequence -safe-string -w +A-70 -warn-error +A"
modules = "stubs.c"
* libwin32unix
** bytecode
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/typing-fstclassmod/fstclassmod.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* TEST
flags = "-w +A -warn-error +A"
flags = "-w +A-70 -warn-error +A"
*)

(* Example of algorithm parametrized with modules *)
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/deprecated_module_assigment.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* bytecode

Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/deprecated_module_use.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module = "deprecated_module.mli"
*** ocamlc.byte
module = "deprecated_module.ml"
**** ocamlc.byte
flags = "-w +A"
flags = "-w +A-70"
module = "deprecated_module_use.ml"
***** check-ocamlc.byte-output

Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w01.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w03.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w04.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w04_failure.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w06.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w32b.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w33.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w45.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w47_inline.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w50.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w51.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* TEST
flags = "-w +A"
flags = "-w +A-70"
* expect
*)

Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w51_bis.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w53.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A-60"
flags = "-w +A-60-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w54.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w55.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"
compile_only = "true"

* setup-ocamlc.byte-build-env
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w58.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"
files = "module_without_cmx.mli"

* setup-ocamlc.byte-build-env
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w59.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"
compile_only = "true"

* setup-ocamlc.byte-build-env
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/warnings/w68.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(* TEST

flags = "-w +A"
flags = "-w +A-70"

* setup-ocamlopt.byte-build-env
** ocamlopt.byte
Expand Down
4 changes: 2 additions & 2 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ INCLUDES = $(addprefix -I $(ROOTDIR)/,utils parsing typing bytecomp \
middle_end middle_end/closure middle_end/flambda \
middle_end/flambda/base_types driver toplevel \
file_formats lambda)
COMPFLAGS = -absname -w +a-4-9-41-42-44-45-48 -strict-sequence -warn-error +A \
-principal -safe-string -strict-formats -bin-annot $(INCLUDES)
COMPFLAGS = -absname -w +a-4-9-41-42-44-45-48-70 -strict-sequence \
-warn-error +A -principal -safe-string -strict-formats -bin-annot $(INCLUDES)
LINKFLAGS = $(INCLUDES)
VPATH := $(filter-out -I,$(INCLUDES))

Expand Down
2 changes: 2 additions & 0 deletions typing/typemod.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2816,6 +2816,8 @@ let type_implementation sourcefile outputprefix modulename initial_env ast =
signature = dclsig
}
end else begin
Location.prerr_warning (Location.in_file sourcefile)
Warnings.Missing_mli;
let coercion =
Includemod.compunit initial_env ~mark:Mark_positive
sourcefile sg "(inferred signature)" simple_sg
Expand Down
10 changes: 8 additions & 2 deletions utils/warnings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type t =
| Unused_functor_parameter of string (* 67 *)
| Match_on_mutable_state_prevent_uncurry (* 68 *)
| Unused_field of string * field_usage_warning (* 69 *)
| Missing_mli (* 70 *)
;;

(* If you remove a warning, leave a hole in the numbering. NEVER change
Expand Down Expand Up @@ -183,9 +184,10 @@ let number = function
| Unused_functor_parameter _ -> 67
| Match_on_mutable_state_prevent_uncurry -> 68
| Unused_field _ -> 69
| Missing_mli -> 70
;;

let last_warning_number = 69
let last_warning_number = 70
;;

(* Third component of each tuple is the list of names for each warning. The
Expand Down Expand Up @@ -346,6 +348,8 @@ let descriptions =
["match-on-mutable-state-prevent-uncurry"];
69, "Unused record field.",
["unused-field"];
70, "Missing interface file.",
["missing-mli"]
]
;;

Expand Down Expand Up @@ -658,7 +662,7 @@ let parse_options errflag s =
alerts

(* If you change these, don't forget to change them in man/ocamlc.m *)
let defaults_w = "+a-4-6-7-9-27-29-30-32..42-44-45-48-50-60-66..69";;
let defaults_w = "+a-4-6-7-9-27-29-30-32..42-44-45-48-50-60-66..70";;
let defaults_warn_error = "-a+31";;

let () = ignore @@ parse_options false defaults_w;;
Expand Down Expand Up @@ -909,6 +913,8 @@ let message = function
| Unused_field (s, Not_mutated) ->
"mutable record field " ^ s ^
" is never mutated."
| Missing_mli ->
"Cannot find interface file."
;;

let nerrors = ref 0;;
Expand Down
1 change: 1 addition & 0 deletions utils/warnings.mli
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ type t =
| Unused_functor_parameter of string (* 67 *)
| Match_on_mutable_state_prevent_uncurry (* 68 *)
| Unused_field of string * field_usage_warning (* 69 *)
| Missing_mli (* 70 *)
;;

type alert = {kind:string; message:string; def:loc; use:loc}
Expand Down