Suggested patch:

- accept gcc versions if a major version only, e.g. "5"
- when comparing gcc versions, "x" is considered younger than any "x.y"
  (similar to "x.y" is younger than any "x.y.z")

Note that clang-3.5 suffers from the same problem.

Cheers, Roderich
--- a/clang/lib/Driver/ToolChains.cpp	2015-03-15 22:29:24.220793493 +0100
+++ b/clang/lib/Driver/ToolChains.cpp	2015-03-15 19:52:19.123853234 +0100
@@ -1107,10 +1107,13 @@
       GoodVersion.Major < 0)
     return BadVersion;
   GoodVersion.MajorStr = First.first.str();
-  if (Second.first.getAsInteger(10, GoodVersion.Minor) ||
-      GoodVersion.Minor < 0)
-    return BadVersion;
-  GoodVersion.MinorStr = Second.first.str();
+  // Starting with GCC5 version strings like just "5" are OK.
+  if (GoodVersion.Major < 5 || !Second.first.empty()) {
+      if (Second.first.getAsInteger(10, GoodVersion.Minor) ||
+          GoodVersion.Minor < 0)
+        return BadVersion;
+      GoodVersion.MinorStr = Second.first.str();
+  }
 
   // First look for a number prefix and parse that if present. Otherwise just
   // stash the entire patch string in the suffix, and leave the number
@@ -1141,8 +1144,13 @@
                                           StringRef RHSPatchSuffix) const {
   if (Major != RHSMajor)
     return Major < RHSMajor;
-  if (Minor != RHSMinor)
+  if (Minor != RHSMinor) {
+    if (RHSMinor == -1)
+      return true;
+    if (Minor == -1)
+      return false;
     return Minor < RHSMinor;
+  }
   if (Patch != RHSPatch) {
     // Note that versions without a specified patch sort higher than those with
     // a patch.

Reply via email to