PR#7460, GPR#1011: Fix uncaught Arg.Bad exception in compenv.ml

This was a regression in 4.04.0, where passing files with unknown
extension (foo.xwds) to the compiler raises an uncaught Arg.Bad
exception.
master
Bernhard Schommer 2017-01-13 20:18:26 +01:00 committed by Gabriel Scherer
parent f15634f562
commit 9b2b2b64f8
7 changed files with 77 additions and 13 deletions

View File

@ -313,6 +313,11 @@ Next minor version (4.04.1):
for ocaml build with WITH_FRAME_POINTERS defined
(Christoph Cullmann)
- PR#7460, GPR#1011: catch uncaught exception when unknown files are passed
as argument (regression in 4.04.0)
(Bernhard Schommer, review by Florian Angeletti and Gabriel Scherer,
report by Stephen Dolan)
- GPR#912: Fix segfault in Unix.create_process on Windows caused by wrong header
configuration.
(David Allsopp)

View File

@ -129,12 +129,20 @@ let main () =
try
readenv ppf Before_args;
Arg.parse_expand Options.list anonymous usage;
Compenv.process_deferred_actions
(ppf,
Compile.implementation,
Compile.interface,
".cmo",
".cma");
begin try
Compenv.process_deferred_actions
(ppf,
Compile.implementation,
Compile.interface,
".cmo",
".cma");
with Arg.Bad msg ->
begin
prerr_endline msg;
Arg.usage Options.list usage;
exit 2
end
end;
readenv ppf Before_link;
if
List.length (List.filter (fun x -> !x)

View File

@ -236,15 +236,24 @@ let main () =
let ppf = Format.err_formatter in
try
readenv ppf Before_args;
Arg.parse_expand (Arch.command_line_options @ Options.list) anonymous usage;
let spec = Arch.command_line_options @ Options.list in
Arg.parse_expand spec anonymous usage;
if !gprofile && not Config.profiling then
fatal "Profiling with \"gprof\" is not supported on this platform.";
Compenv.process_deferred_actions
(ppf,
Optcompile.implementation ~backend,
Optcompile.interface,
".cmx",
".cmxa");
begin try
Compenv.process_deferred_actions
(ppf,
Optcompile.implementation ~backend,
Optcompile.interface,
".cmx",
".cmxa");
with Arg.Bad msg ->
begin
prerr_endline msg;
Arg.usage spec usage;
exit 2
end
end;
readenv ppf Before_link;
if
List.length (List.filter (fun x -> !x)

View File

@ -0,0 +1,40 @@
#**************************************************************************
#* *
#* OCaml *
#* *
#* Bernhard Schommer *
#* *
#* Copyright 2010 Institut National de Recherche en Informatique et *
#* en Automatique. *
#* *
#* All rights reserved. This file is distributed under the terms of *
#* the GNU Lesser General Public License version 2.1, with the *
#* special exception on linking described in the file LICENSE. *
#* *
#**************************************************************************
BASEDIR=../..
default:
@$(OCAMLOPT) unknown-file 2>&1 | grep "don't know what to do with unknown-file"\
> unknown-file.opt.result || true
@$(OCAMLC) unknown-file 2>&1 | grep "don't know what to do with unknown-file" \
> unknown-file.byte.result || true
@for file in *.opt.reference; do \
printf " ... testing '$$file':"; \
$(DIFF) $$file `basename $$file reference`result >/dev/null \
&& echo " => passed" || echo " => failed"; \
done
@for file in *.byte.reference; do \
printf " ... testing '$$file':"; \
$(DIFF) $$file `basename $$file reference`result >/dev/null \
&& echo " => passed" || echo " => failed"; \
done
promote: defaultpromote
clean: defaultclean
@rm -f *.result
include $(BASEDIR)/makefiles/Makefile.common

View File

@ -0,0 +1 @@
don't know what to do with unknown-file

View File

@ -0,0 +1 @@
don't know what to do with unknown-file