From c6e4ff07b0c0489e0487a32ac725e7d7659d6c0f Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Tue, 20 Jun 2017 11:46:29 +0200
Subject: [PATCH] Fix compiler warnings (shadow and include-hygiene)

---
 DDCore/include/DD4hep/Dictionary.h |  9 ---------
 DDCore/include/DD4hep/Memory.h     |  6 ++++++
 DDCore/include/ROOT/LinkDef.h      | 15 ++++++++++-----
 DDEve/CMakeLists.txt               |  4 ++--
 DDEve/DDEve/DDG4IO.C               | 14 ++++++++++++++
 DDG4/include/DDG4/DDG4Dict.h       | 16 ++++++++++++++++
 6 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/DDCore/include/DD4hep/Dictionary.h b/DDCore/include/DD4hep/Dictionary.h
index 3d23b48c8..0cdfe1d7e 100644
--- a/DDCore/include/DD4hep/Dictionary.h
+++ b/DDCore/include/DD4hep/Dictionary.h
@@ -13,18 +13,9 @@
 //  Created by Pere Mato on 22/1/12.
 //
 //==========================================================================
-//
-
 #ifndef DD4HEP_GEOMETRY_DICTIONARY_H
 #define DD4HEP_GEOMETRY_DICTIONARY_H
 
-// Disable some diagnostics for ROOT dictionaries
-#ifdef __GNUC__
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#pragma GCC diagnostic ignored "-Wdeprecated"
-#pragma GCC diagnostic ignored "-Wunused"
-#endif
-
 // Framework include files
 #include "DDParsers/Evaluator.h"
 #include "DD4hep/DD4hepRootPersistency.h"
diff --git a/DDCore/include/DD4hep/Memory.h b/DDCore/include/DD4hep/Memory.h
index e05bb982d..87eeb8038 100644
--- a/DDCore/include/DD4hep/Memory.h
+++ b/DDCore/include/DD4hep/Memory.h
@@ -20,8 +20,12 @@
 #ifdef __GNUC__
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // Code that causes warning goes here
+#elif defined(__llvm__) || defined(__APPLE__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" // Code that causes warning goes here
 #endif
 
+
 // C/C++ include files
 #include <memory>
 
@@ -81,6 +85,8 @@ namespace dd4hep  {
 
 #ifdef __GNUC__
 #pragma GCC diagnostic pop
+#elif defined(__llvm__) || defined(__APPLE__)
+#pragma clang diagnostic pop
 #endif
 
 #endif  // DD4HEP_MEMORY_H
diff --git a/DDCore/include/ROOT/LinkDef.h b/DDCore/include/ROOT/LinkDef.h
index ebbf8f5b1..70b1e7ce6 100644
--- a/DDCore/include/ROOT/LinkDef.h
+++ b/DDCore/include/ROOT/LinkDef.h
@@ -13,10 +13,10 @@
 //
 //  Created by Pere Mato on 22/1/12.
 //
-// Keep this file EMPTY. All CINT statements can be put in header files preceeding this one.....
+//  Keep this file EMPTY. All CINT statements can be put in header files
+//  preceeding this one.....
 //
-
-#ifdef __GNUC__
+//==========================================================================
 
 //--------------------------------------------------------------------------
 //  These are the common warnings, which are generated by rootcling
@@ -25,11 +25,16 @@
 //
 //  M.Frank
 //--------------------------------------------------------------------------
-
+#if defined(__GNUC__)
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 #pragma GCC diagnostic ignored "-Wdeprecated"
 #pragma GCC diagnostic ignored "-Wunused"
 #pragma GCC diagnostic ignored "-Woverlength-strings"
 
-#endif
+#elif defined(__llvm__) || defined(__APPLE__)
 
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#pragma clang diagnostic ignored "-Wdeprecated"
+#pragma clang diagnostic ignored "-Wunused"
+#pragma clang diagnostic ignored "-Woverlength-strings"
+#endif
diff --git a/DDEve/CMakeLists.txt b/DDEve/CMakeLists.txt
index 2fe3b6c7d..a9bbaa1a5 100644
--- a/DDEve/CMakeLists.txt
+++ b/DDEve/CMakeLists.txt
@@ -26,13 +26,13 @@ dd4hep_add_plugin ( DDEve SOURCES src/*.cpp
 if(DD4HEP_USE_GEANT4)
   dd4hep_add_dictionary ( G__DDG4IO
     SOURCES DDEve/DDG4IO.C
-    OPTIONAL DDG4
     LINKDEF ${DDCore_INCLUDE_DIRS}/include/ROOT/LinkDef.h
+    OPTIONAL DDG4
     )
   dd4hep_add_regular_library ( DDG4IO 
     SOURCES   DDEve/IO.cpp
     GENERATED G__DDG4IO.cxx
-    OPTIONAL DDG4
+    OPTIONAL  DDG4
     )
 endif()
 
diff --git a/DDEve/DDEve/DDG4IO.C b/DDEve/DDEve/DDG4IO.C
index 89d9aa515..c445620b9 100644
--- a/DDEve/DDEve/DDG4IO.C
+++ b/DDEve/DDEve/DDG4IO.C
@@ -14,6 +14,20 @@
 //==========================================================================
 #define __DDG4_STANDALONE_DICTIONARIES__
 
+#if defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#pragma GCC diagnostic ignored "-Wdeprecated"
+#pragma GCC diagnostic ignored "-Wunused"
+#pragma GCC diagnostic ignored "-Woverlength-strings"
+
+#elif defined(__llvm__) || defined(__APPLE__)
+
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#pragma clang diagnostic ignored "-Wdeprecated"
+#pragma clang diagnostic ignored "-Wunused"
+#pragma clang diagnostic ignored "-Woverlength-strings"
+#endif
+
 // C/C++ include files
 #include "DDG4/DDG4Dict.h"
 #include "DDEve/DDEveEventData.h"
diff --git a/DDG4/include/DDG4/DDG4Dict.h b/DDG4/include/DDG4/DDG4Dict.h
index 3682825fd..78fe3e90f 100644
--- a/DDG4/include/DDG4/DDG4Dict.h
+++ b/DDG4/include/DDG4/DDG4Dict.h
@@ -18,9 +18,25 @@
 #ifndef DD4HEP_DDG4_DDG4DICT_H
 #define DD4HEP_DDG4_DDG4DICT_H
 
+#if defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#pragma GCC diagnostic ignored "-Wdeprecated"
+#pragma GCC diagnostic ignored "-Wunused"
+#pragma GCC diagnostic ignored "-Woverlength-strings"
+
+#elif defined(__llvm__) || defined(__APPLE__)
+
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#pragma clang diagnostic ignored "-Wdeprecated"
+#pragma clang diagnostic ignored "-Wunused"
+#pragma clang diagnostic ignored "-Woverlength-strings"
+#endif
+
 // FRamework include files
+#include "DD4hep/Memory.h"
 #include "DDG4/Geant4Data.h"
 #include "DDG4/Geant4Particle.h"
+
 namespace dd4hep {
   namespace DDSegmentation { }
   namespace detail   { }
-- 
GitLab