Skip to content

Commit

Permalink
Ajouté un warning si l'option -unsafe est utilisée alors que le source
Browse files Browse the repository at this point in the history
est un arbre de syntaxe.


git-svn-id: svn+ssh://yquem.inria.fr/net/yquem/devel/caml/svn/ocaml/trunk@4364 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
ddr committed Feb 8, 2002
1 parent d97941e commit b86c710
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions driver/compile.ml
Expand Up @@ -4,7 +4,7 @@
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* Copyright 2002 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
Expand Down Expand Up @@ -68,7 +68,7 @@ let remove_preprocessed inputfile =

exception Outdated_version

let parse_file inputfile parse_fun ast_magic =
let parse_file ppf inputfile parse_fun ast_magic =
let ic = open_in_bin inputfile in
let is_ast_file =
try
Expand All @@ -86,6 +86,9 @@ let parse_file inputfile parse_fun ast_magic =
let ast =
try
if is_ast_file then begin
if !Clflags.fast then
fprintf ppf "@[Warning: %s@]@."
"option -unsafe used with a preprocessor returning a syntax tree";
Location.input_name := input_value ic;
input_value ic
end else begin
Expand All @@ -111,7 +114,7 @@ let interface ppf sourcefile =
let modulename = String.capitalize(Filename.basename prefixname) in
let inputfile = preprocess sourcefile in
try
let ast = parse_file inputfile Parse.interface ast_intf_magic_number in
let ast = parse_file ppf inputfile Parse.interface ast_intf_magic_number in
if !Clflags.dump_parsetree then fprintf ppf "%a@." Printast.interface ast;
let sg = Typemod.transl_signature (initial_env()) ast in
if !Clflags.print_types
Expand Down Expand Up @@ -140,7 +143,7 @@ let implementation ppf sourcefile =
let oc = open_out_bin objfile in
let env = initial_env() in
try
parse_file inputfile Parse.implementation ast_impl_magic_number
parse_file ppf inputfile Parse.implementation ast_impl_magic_number
++ print_if ppf Clflags.dump_parsetree Printast.implementation
++ Typemod.type_implementation sourcefile prefixname modulename env
++ Translmod.transl_implementation modulename
Expand Down
11 changes: 7 additions & 4 deletions driver/optcompile.ml
Expand Up @@ -4,7 +4,7 @@
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* Copyright 2002 Institut National de Recherche en Informatique et *)
(* en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0. *)
(* *)
Expand Down Expand Up @@ -69,7 +69,7 @@ let remove_preprocessed inputfile =

exception Outdated_version

let parse_file inputfile parse_fun ast_magic =
let parse_file ppf inputfile parse_fun ast_magic =
let ic = open_in_bin inputfile in
let is_ast_file =
try
Expand All @@ -87,6 +87,9 @@ let parse_file inputfile parse_fun ast_magic =
let ast =
try
if is_ast_file then begin
if !Clflags.fast then
fprintf ppf "@[Warning: %s@]@."
"option -unsafe used with a preprocessor returning a syntax tree";
Location.input_name := input_value ic;
input_value ic
end else begin
Expand All @@ -105,7 +108,7 @@ let interface ppf sourcefile =
let prefixname = Misc.chop_extension_if_any sourcefile in
let modulename = String.capitalize(Filename.basename prefixname) in
let inputfile = preprocess sourcefile in
let ast = parse_file inputfile Parse.interface ast_intf_magic_number in
let ast = parse_file ppf inputfile Parse.interface ast_intf_magic_number in
if !Clflags.dump_parsetree then fprintf ppf "%a@." Printast.interface ast;
let sg = Typemod.transl_signature (initial_env()) ast in
if !Clflags.print_types then
Expand All @@ -129,7 +132,7 @@ let implementation ppf sourcefile =
let inputfile = preprocess sourcefile in
let env = initial_env() in
Compilenv.reset modulename;
parse_file inputfile Parse.implementation ast_impl_magic_number
parse_file ppf inputfile Parse.implementation ast_impl_magic_number
++ print_if ppf Clflags.dump_parsetree Printast.implementation
++ Typemod.type_implementation sourcefile prefixname modulename env
++ Translmod.transl_store_implementation modulename
Expand Down

0 comments on commit b86c710

Please sign in to comment.