Repository: conan-io/conan

Issue:
Clang 6.0 implications in cppstd flags
We have added to the `settings.yml` clang 6.0, but we have to review the `cppstd` flags and `package_id` to adjust it correctly and knowing the default one of the compiler to keep the compatibility of packages that do not specify the `cppstd` setting.



Discussion:

Resolving patch:
diff --git a/conans/client/build/cppstd_flags.py b/conans/client/build/cppstd_flags.py
--- a/conans/client/build/cppstd_flags.py
+++ b/conans/client/build/cppstd_flags.py
@@ -24,16 +24,18 @@ def cppstd_flag(compiler, compiler_version, cppstd):
 
 
 def cppstd_default(compiler, compiler_version):
-
     default = {"gcc": _gcc_cppstd_default(compiler_version),
-               "clang": "gnu++98",
-               "apple-clang": "gnu++98",
+               "clang": _clang_cppstd_default(compiler_version),
+               "apple-clang": "gnu98",
                "Visual Studio": _visual_cppstd_default(compiler_version)}.get(str(compiler), None)
     return default
 
 
-def _gcc_cppstd_default(compiler_version):
+def _clang_cppstd_default(compiler_version):
+    return "gnu98" if Version(compiler_version) < "6.0" else "gnu14"
+
 
+def _gcc_cppstd_default(compiler_version):
     return "gnu98" if Version(compiler_version) < "6.1" else "gnu14"
 
 
@@ -113,12 +115,17 @@ def _cppstd_clang(clang_version, cppstd):
     if Version(clang_version) >= "3.5":
         v14 = "c++14"
         vgnu14 = "gnu++14"
-        v17 = "c++1z"
-        vgnu17 = "gnu++1z"
     elif Version(clang_version) >= "3.4":
         v14 = "c++1y"
         vgnu14 = "gnu++1y"
 
+    if Version(clang_version) >= "5":
+        v17 = "c++17"
+        vgnu17 = "gnu++17"
+    elif Version(clang_version) >= "3.5":
+        v17 = "c++1z"
+        vgnu17 = "gnu++1z"
+
     flag = {"98": v98, "gnu98": vgnu98,
             "11": v11, "gnu11": vgnu11,
             "14": v14, "gnu14": vgnu14,


Test patch:
diff --git a/conans/test/build_helpers/cpp_std_flags_test.py b/conans/test/build_helpers/cpp_std_flags_test.py
--- a/conans/test/build_helpers/cpp_std_flags_test.py
+++ b/conans/test/build_helpers/cpp_std_flags_test.py
@@ -78,26 +78,26 @@ def test_clang_cppstd_flags(self):
         self.assertEquals(cppstd_flag("clang", "5", "11"), '-std=c++11')
         self.assertEquals(cppstd_flag("clang", "5", "14"), '-std=c++14')
         self.assertEquals(cppstd_flag("clang", "5", "gnu14"), '-std=gnu++14')
-        self.assertEquals(cppstd_flag("clang", "5", "17"), '-std=c++1z')
+        self.assertEquals(cppstd_flag("clang", "5", "17"), '-std=c++17')
 
         self.assertEquals(cppstd_flag("clang", "5.1", "11"), '-std=c++11')
         self.assertEquals(cppstd_flag("clang", "5.1", "14"), '-std=c++14')
-        self.assertEquals(cppstd_flag("clang", "5.1", "17"), '-std=c++1z')
+        self.assertEquals(cppstd_flag("clang", "5.1", "17"), '-std=c++17')
 
         self.assertEquals(cppstd_flag("clang", "7", "11"), '-std=c++11')
         self.assertEquals(cppstd_flag("clang", "7", "14"), '-std=c++14')
-        self.assertEquals(cppstd_flag("clang", "7", "17"), '-std=c++1z')
+        self.assertEquals(cppstd_flag("clang", "7", "17"), '-std=c++17')
 
     def test_clang_cppstd_defaults(self):
-        self.assertEquals(cppstd_default("clang", "2"), "gnu++98")
-        self.assertEquals(cppstd_default("clang", "2.1"), "gnu++98")
-        self.assertEquals(cppstd_default("clang", "3.0"), "gnu++98")
-        self.assertEquals(cppstd_default("clang", "3.1"), "gnu++98")
-        self.assertEquals(cppstd_default("clang", "3.4"), "gnu++98")
-        self.assertEquals(cppstd_default("clang", "3.5"), "gnu++98")
-        self.assertEquals(cppstd_default("clang", "5"), "gnu++98")
-        self.assertEquals(cppstd_default("clang", "5.1"), "gnu++98")
-        self.assertEquals(cppstd_default("clang", "7"), "gnu++98")
+        self.assertEquals(cppstd_default("clang", "2"), "gnu98")
+        self.assertEquals(cppstd_default("clang", "2.1"), "gnu98")
+        self.assertEquals(cppstd_default("clang", "3.0"), "gnu98")
+        self.assertEquals(cppstd_default("clang", "3.1"), "gnu98")
+        self.assertEquals(cppstd_default("clang", "3.4"), "gnu98")
+        self.assertEquals(cppstd_default("clang", "3.5"), "gnu98")
+        self.assertEquals(cppstd_default("clang", "5"), "gnu98")
+        self.assertEquals(cppstd_default("clang", "5.1"), "gnu98")
+        self.assertEquals(cppstd_default("clang", "7"), "gnu14")
 
     def test_apple_clang_cppstd_flags(self):
         self.assertEquals(cppstd_flag("apple-clang", "3.9", "98"), None)
@@ -137,14 +137,14 @@ def test_apple_clang_cppstd_flags(self):
         self.assertEquals(cppstd_flag("apple-clang", "9", "17"), "-std=c++1z")
 
     def test_apple_clang_cppstd_defaults(self):
-        self.assertEquals(cppstd_default("apple-clang", "2"), "gnu++98")
-        self.assertEquals(cppstd_default("apple-clang", "3"), "gnu++98")
-        self.assertEquals(cppstd_default("apple-clang", "4"), "gnu++98")
-        self.assertEquals(cppstd_default("apple-clang", "5"), "gnu++98")
-        self.assertEquals(cppstd_default("apple-clang", "6"), "gnu++98")
-        self.assertEquals(cppstd_default("apple-clang", "7"), "gnu++98")
-        self.assertEquals(cppstd_default("apple-clang", "8"), "gnu++98")
-        self.assertEquals(cppstd_default("apple-clang", "9"), "gnu++98")
+        self.assertEquals(cppstd_default("apple-clang", "2"), "gnu98")
+        self.assertEquals(cppstd_default("apple-clang", "3"), "gnu98")
+        self.assertEquals(cppstd_default("apple-clang", "4"), "gnu98")
+        self.assertEquals(cppstd_default("apple-clang", "5"), "gnu98")
+        self.assertEquals(cppstd_default("apple-clang", "6"), "gnu98")
+        self.assertEquals(cppstd_default("apple-clang", "7"), "gnu98")
+        self.assertEquals(cppstd_default("apple-clang", "8"), "gnu98")
+        self.assertEquals(cppstd_default("apple-clang", "9"), "gnu98")
 
     def test_visual_cppstd_flags(self):
         self.assertEquals(cppstd_flag("Visual Studio", "12", "11"), None)