[m-rev.] for review: implement --warn-stdlib-shadowing, part 1
Julien Fischer
jfischer at opturion.com
Thu Dec 30 15:24:06 AEDT 2021
On Thu, 30 Dec 2021, Zoltan Somogyi wrote:
> Set up for --warn-stdlib-shadowing.
>
> This diff does not implement the option itself. The reason is that we want
> to turn it off in library/LIB_FLAGS.in, and we can do that only when the
> installed compiler knows about the option. This diff is therefore the first
> step in the two-step bootstrapping process.
...
> diff --git a/compiler/mercury_compile_main.m b/compiler/mercury_compile_main.m
> index 66b4a9243..7d96ed878 100644
> --- a/compiler/mercury_compile_main.m
> +++ b/compiler/mercury_compile_main.m
> @@ -740,86 +742,81 @@ do_op_mode_standalone_interface(Globals, StandaloneIntBasename, !IO) :-
> io::di, io::uo) is det.
>
> do_op_mode_query(Globals, OpModeQuery, !IO) :-
> + io.stdout_stream(StdOut, !IO),
> (
> OpModeQuery = opmq_output_cc,
> globals.lookup_string_option(Globals, cc, CC),
> - io.stdout_stream(StdOut, !IO),
> - io.write_string(StdOut, CC ++ "\n", !IO)
> + io.write_string(StdOut, add_suffix("\n", CC), !IO)
You could just use io.print_line in a lot of these places.
...
> diff --git a/compiler/options.m b/compiler/options.m
> index e3eeb5f86..6d5a1a6f2 100644
> --- a/compiler/options.m
> +++ b/compiler/options.m
> @@ -1403,7 +1406,8 @@ optdef(oc_opmode, only_opmode_output_library_link_flags, bool(no)).
> optdef(oc_opmode, only_opmode_output_grade_defines, bool(no)).
> optdef(oc_opmode, only_opmode_output_c_include_directory_flags, bool(no)).
> optdef(oc_opmode, only_opmode_output_target_arch, bool(no)).
> -optdef(oc_opmode, only_opmode_output_class_dir, bool(no)).
> +optdef(oc_opmode, only_opmode_output_java_class_dir, bool(no)).
> +optdef(oc_opmode, only_opmode_output_stdlib_modules, bool(no)).
>
> % Auxiliary output options.
>
> @@ -2238,6 +2242,8 @@ long_option("warn-potentially-ambiguous-pragma",
> warn_potentially_ambiguous_pragma).
> long_option("warn-potentially-ambiguous-pragmas",
> warn_potentially_ambiguous_pragma).
> +long_option("warn-stdlib-shadowing",
> + warn_stdlib_shadowing).
> long_option("inform-inferred", inform_inferred).
> long_option("inform-inferred-types", inform_inferred_types).
> long_option("inform-inferred-modes", inform_inferred_modes).
> @@ -2346,8 +2352,9 @@ long_option("output-c-include-directory-flags",
> long_option("output-c-include-dir-flags",
> only_opmode_output_c_include_directory_flags).
> long_option("output-target-arch", only_opmode_output_target_arch).
> -long_option("output-class-directory", only_opmode_output_class_dir).
> -long_option("output-class-dir", only_opmode_output_class_dir).
> +long_option("output-class-directory", only_opmode_output_java_class_dir).
> +long_option("output-class-dir", only_opmode_output_java_class_dir).
I think you can add "--output-java-class-dir" etc as a synonym for for
"--output-class-dir". In the (very) long run we can remove the older forms.
...
> diff --git a/library/library.m b/library/library.m
> index bed458bee..af1f505d9 100644
> --- a/library/library.m
> +++ b/library/library.m
> @@ -28,11 +28,26 @@
>
> :- interface.
>
> + % Is a module or submodule intended to be documented, or not?
I suggest:
Is a module or submodule intended to be documented in the library
reference manual, or not?
> +:- type doc_or_undoc
> + ---> doc
> + ; undoc.
> +
> % Succeeds iff the string is the (unqualified) name of one of the
> % modules in the Mercury standard library.
> %
> :- pred mercury_std_library_module(string::in) is semidet.
The rest looks fine.
Julien.
More information about the reviews
mailing list