Browse Source

Driver: correct behaviour of -fmsc-version=MAJOR

Ensure that we properly handle the case where just the major version component
is provided by the user.

Thanks to Alp Toker for pointing out that this was not handled correctly!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211506 91177308-0d34-0410-b5e6-96231b3b80d8
Saleem Abdulrasool 11 years ago
parent
commit
a91f0e5edc
2 changed files with 11 additions and 1 deletions
  1. 5 1
      lib/Frontend/CompilerInvocation.cpp
  2. 6 0
      test/Driver/msc-version.c

+ 5 - 1
lib/Frontend/CompilerInvocation.cpp

@@ -1223,7 +1223,11 @@ static unsigned parseMSCVersion(ArgList &Args, DiagnosticsEngine &Diags) {
         << Arg->getAsString(Args) << Value;
         << Arg->getAsString(Args) << Value;
       return 0;
       return 0;
     }
     }
-    return (Version < 100000) ? Version * 100000 : Version;
+    if (Version < 100)
+      Version = Version * 100;    // major -> major.minor
+    if (Version < 100000)
+      Version = Version * 100000; // major.minor -> major.minor.build
+    return Version;
   }
   }
 
 
   // parse the dot-delimited component version
   // parse the dot-delimited component version

+ 6 - 0
test/Driver/msc-version.c

@@ -16,6 +16,12 @@
 // CHECK-MSC-VERSION-EXT: _MSC_FULL_VER 160030319
 // CHECK-MSC-VERSION-EXT: _MSC_FULL_VER 160030319
 // CHECK-MSC-VERSION-EXT: _MSC_VER 1600
 // CHECK-MSC-VERSION-EXT: _MSC_VER 1600
 
 
+// RUN: %clang -target i686-windows -fms-compatibility -fmsc-version=14 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-MAJOR
+
+// CHECK-MSC-VERSION-MAJOR: _MSC_BUILD 1
+// CHECK-MSC-VERSION-MAJOR: _MSC_FULL_VER 140000000
+// CHECK-MSC-VERSION-MAJOR: _MSC_VER 1400
+
 // RUN: %clang -target i686-windows -fms-compatibility -fmsc-version=17.00 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-MAJOR-MINOR
 // RUN: %clang -target i686-windows -fms-compatibility -fmsc-version=17.00 -dM -E - </dev/null -o - | FileCheck %s -check-prefix CHECK-MSC-VERSION-MAJOR-MINOR
 
 
 // CHECK-MSC-VERSION-MAJOR-MINOR: _MSC_BUILD 1
 // CHECK-MSC-VERSION-MAJOR-MINOR: _MSC_BUILD 1