[m-rev.] diff: Visual C version information in mmc

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Jul 13 16:48:45 AEST 2011


Branches: main, 11.07

Make it possible for the compiler to deal with different versions of Visual C.

compiler/globals.m:
 	Store Visual C version information along with the C compiler type.

compiler/compile_target_code.m:
 	Conform to the above change.

Julien.

Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.171
diff -u -r1.171 compile_target_code.m
--- compiler/compile_target_code.m	11 Jul 2011 07:33:32 -0000	1.171
+++ compiler/compile_target_code.m	13 Jul 2011 06:32:36 -0000
@@ -709,7 +709,7 @@
              % XXX Check whether we need to do anything for these C compilers?
              ( C_CompilerType = cc_clang(_)
              ; C_CompilerType = cc_lcc
-            ; C_CompilerType = cc_cl
+            ; C_CompilerType = cc_cl(_)
              ),
              C_FnAlignOpt = ""
          ;
Index: compiler/globals.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.102
diff -u -r1.102 globals.m
--- compiler/globals.m	11 Jul 2011 07:33:32 -0000	1.102
+++ compiler/globals.m	13 Jul 2011 06:40:11 -0000
@@ -143,7 +143,7 @@
              )
      ;       cc_clang(maybe(clang_version))
      ;       cc_lcc
-    ;       cc_cl
+    ;       cc_cl(maybe(int))
      ;       cc_unknown.

  :- type clang_version
@@ -392,7 +392,7 @@
  convert_c_compiler_type_simple("gcc",      cc_gcc(no, no, no)).
  convert_c_compiler_type_simple("clang",    cc_clang(no)).
  convert_c_compiler_type_simple("lcc",      cc_lcc).
-convert_c_compiler_type_simple("cl",       cc_cl).
+convert_c_compiler_type_simple("cl",       cc_cl(no)).
  convert_c_compiler_type_simple("unknown",  cc_unknown).

  :- pred convert_c_compiler_type_with_version(string::in, c_compiler_type::out)
@@ -405,6 +405,8 @@
          convert_gcc_version(Major, Minor, Patch, C_CompilerType)
      ; Tokens = ["clang", Major, Minor, Patch] ->
          convert_clang_version(Major, Minor, Patch, C_CompilerType)
+    ; Tokens = ["cl", Version] ->
+        convert_msvc_version(Version, C_CompilerType)
      ;
           false
      ).
@@ -476,17 +478,24 @@
      c_compiler_type::out) is semidet.

  convert_clang_version(MajorStr, MinorStr, PatchStr, C_CompilerType) :-
-    ( if
-        string.to_int(MajorStr, Major),
-        string.to_int(MinorStr, Minor),
-        string.to_int(PatchStr, Patch),
-        Major >= 0, Minor >= 0, Patch >= 0
-      then
-        ClangVersion = clang_version(Major, Minor, Patch),
-        C_CompilerType = cc_clang(yes(ClangVersion))
-     else
-        false
-    ).
+    string.to_int(MajorStr, Major),
+    string.to_int(MinorStr, Minor),
+    string.to_int(PatchStr, Patch),
+    Major >= 0, Minor >= 0, Patch >= 0,
+    ClangVersion = clang_version(Major, Minor, Patch),
+    C_CompilerType = cc_clang(yes(ClangVersion)).
+
+    % Create the value of C compiler type when we have version information
+    % for Visual C available.
+    % The version number is an integer literal (corresponding to the value
+    % of the builtin macro _MSC_VER).
+    %
+:- pred convert_msvc_version(string::in, c_compiler_type::out) is semidet.
+
+convert_msvc_version(VersionStr, C_CompilerType) :-
+    string.to_int(VersionStr, Version),
+    Version > 0,
+    C_CompilerType = cc_cl(yes(Version)).

  convert_env_type("posix",   env_type_posix).
  convert_env_type("cygwin",  env_type_cygwin).

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list