From 240c9a7f60f72060b1adb91d6e87d73579ef1cc1 Mon Sep 17 00:00:00 2001
From: Christoph Hasse <christoph.hasse@cern.ch>
Date: Wed, 22 Jul 2020 12:08:54 +0000
Subject: [PATCH] Minor fixes for Clang 10 build, adapt BinaryTagUtils to allow
 compiler version >10

---
 GaudiAlg/GaudiAlg/FunctionalDetails.h              | 2 +-
 GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp | 2 +-
 GaudiKernel/src/Lib/Bootstrap.cpp                  | 5 ++++-
 GaudiKernel/tests/src/test_StatusCode_fail.cxx     | 7 ++++---
 GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp           | 2 +-
 cmake/BinaryTagUtils.cmake                         | 4 ++--
 6 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/GaudiAlg/GaudiAlg/FunctionalDetails.h b/GaudiAlg/GaudiAlg/FunctionalDetails.h
index 81ad2ff40..c0bd4e6c0 100644
--- a/GaudiAlg/GaudiAlg/FunctionalDetails.h
+++ b/GaudiAlg/GaudiAlg/FunctionalDetails.h
@@ -35,7 +35,7 @@ namespace ranges::views {
 }
 #endif
 
-#if defined( __clang__ ) && ( __clang_major__ < 9 ) || defined( __APPLE__ ) && ( __clang_major__ < 12 )
+#if defined( __clang__ ) && ( __clang_major__ < 11 ) || defined( __APPLE__ ) && ( __clang_major__ < 12 )
 #  define GF_SUPPRESS_SPURIOUS_CLANG_WARNING_BEGIN                                                                     \
     _Pragma( "clang diagnostic push" ) _Pragma( "clang diagnostic ignored \"-Wunused-lambda-capture\"" )
 #  define GF_SUPPRESS_SPURIOUS_CLANG_WARNING_END _Pragma( "clang diagnostic pop" )
diff --git a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp
index a39ca73de..cfe1b9552 100644
--- a/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp
+++ b/GaudiCoreSvc/src/ApplicationMgr/ApplicationMgr.cpp
@@ -1013,7 +1013,7 @@ StatusCode ApplicationMgr::decodeDllNameList() {
   std::vector<std::string>            newList;
   std::map<std::string, unsigned int> dllInList, duplicateList;
   {
-    for ( const auto it : m_dllNameList ) {
+    for ( const auto& it : m_dllNameList ) {
       if ( 0 == dllInList[it] ) {
         newList.push_back( it ); // first instance of this module
       } else {
diff --git a/GaudiKernel/src/Lib/Bootstrap.cpp b/GaudiKernel/src/Lib/Bootstrap.cpp
index 41ba27e39..a0f5ef63b 100644
--- a/GaudiKernel/src/Lib/Bootstrap.cpp
+++ b/GaudiKernel/src/Lib/Bootstrap.cpp
@@ -246,7 +246,10 @@ bool PyHelper( setProperty )( IInterface* p, char* name, char* value ) {
 }
 const char* PyHelper( getProperty )( IInterface* p, char* name ) {
   auto prop = SmartIF<IProperty>( p );
-  return prop ? prop->getProperty( name ).toString().c_str() : nullptr;
+  if ( !prop ) return nullptr;
+  static std::string value;
+  value = prop->getProperty( name ).toString();
+  return value.c_str();
 }
 bool PyHelper( configureApp )( IInterface* app ) {
   auto ui = SmartIF<IAppMgrUI>( app );
diff --git a/GaudiKernel/tests/src/test_StatusCode_fail.cxx b/GaudiKernel/tests/src/test_StatusCode_fail.cxx
index 565c31e20..2a3eea9b1 100644
--- a/GaudiKernel/tests/src/test_StatusCode_fail.cxx
+++ b/GaudiKernel/tests/src/test_StatusCode_fail.cxx
@@ -12,9 +12,10 @@
 
 int main() {
   {
-    StatusCode sc = 42; // FAIL01: no implicit conversion from int
-    int        i  = sc; // FAIL02: no implicit conversion to int
-    bool       b  = sc; // FAIL03: no implicit conversion to bool
+    StatusCode sc{};
+    sc     = 42; // FAIL01: no implicit conversion from int
+    int  i = sc; // FAIL02: no implicit conversion to int
+    bool b = sc; // FAIL03: no implicit conversion to bool
     (void)i;
     (void)b; // silence "unused" compiler warnings
   }
diff --git a/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp b/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp
index 8b6cb1035..d8e061178 100644
--- a/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp
+++ b/GaudiSvc/src/MetaDataSvc/MetaDataSvc.cpp
@@ -69,7 +69,7 @@ StatusCode MetaDataSvc::collectData() {
   {
     auto joSvc = service<IJobOptionsSvc>( "JobOptionsSvc" );
     if ( !joSvc.isValid() ) return StatusCode::FAILURE;
-    for ( const auto c : joSvc->getClients() ) {
+    for ( const auto& c : joSvc->getClients() ) {
       // get options for this client
       const auto props = joSvc->getProperties( c );
       if ( props ) {
diff --git a/cmake/BinaryTagUtils.cmake b/cmake/BinaryTagUtils.cmake
index 251fa36be..26b24187a 100644
--- a/cmake/BinaryTagUtils.cmake
+++ b/cmake/BinaryTagUtils.cmake
@@ -119,8 +119,8 @@ macro(parse_binary_tag)
     set(${_variable}_COMP_VERSION ${CMAKE_MATCH_2})
     if(NOT ${_variable}_COMP_NAME STREQUAL "icc")
       # all known compilers except icc have one digit per version level
-      # so we map "XY" to "X.Y"
-      string(REGEX MATCHALL "[0-9]" _out "${${_variable}_COMP_VERSION}")
+      # or is less than 20 so we map "1X" to "1X" and "XY" to "X.Y"
+      string(REGEX MATCHALL "(1[0-9]|[0-9])" _out "${${_variable}_COMP_VERSION}")
       set(${_variable}_COMP_VERSION)
       list(GET _out 0 ${_variable}_COMP_VERSION)
       list(REMOVE_AT _out 0)
-- 
GitLab