## ---------------------------------------------------------------------
##
-## Copyright (C) 2012 - 2014 by the deal.II authors
+## Copyright (C) 2012 - 2015 by the deal.II authors
##
## This file is part of the deal.II library.
##
#
# Check for existence of the __builtin_expect facility of newer
-# gcc compilers. This can be used to hint the compiler's branch
+# GCC compilers. This can be used to hint the compiler's branch
# prediction unit in some cases. We use it in the AssertThrow
# macros.
#
#
-# Newer versions of gcc have a very nice feature: you can set
+# Newer versions of GCC have a very nice feature: you can set
# a verbose terminate handler, that not only aborts a program
# when an exception is thrown and not caught somewhere, but
# before aborting it prints that an exception has been thrown,
#
-# Gcc and some other compilers have __PRETTY_FUNCTION__, showing
+# GCC and some other compilers have __PRETTY_FUNCTION__, showing
# an unmangled version of the function we are presently in,
# while __FUNCTION__ (or __func__ in ISO C99) simply give the
# function name which would not include the arguments of that
#
-# Newer versions of gcc can pass a flag to the assembler to
+# Newer versions of GCC can pass a flag to the assembler to
# compress debug sections. At the time of writing this test,
# this can save around 230 MB of disk space on the object
# files we produce (810MB down to 570MB for the debug versions
#
-# Gcc and some other compilers have an attribute of the form
+# GCC and some other compilers have an attribute of the form
# __attribute__((deprecated)) that can be used to make the
# compiler warn whenever a deprecated function is used. See
# if this attribute is available.
SET(DEAL_II_DEPRECATED " ")
ENDIF()
+
+#
+# GCC and Clang allow fine grained control of diagnostics via the "GCC
+# diagnostic" pragma. Check whether the compiler supports the "push" and
+# "pop" mechanism and the "ignored" toggle. Further, test for the
+# alternative "_Pragma(...)" variant (and that it does not emit a warning).
+#
+# - Matthias Maier, 2015
+#
+PUSH_CMAKE_REQUIRED("-Werror")
+CHECK_CXX_SOURCE_COMPILES(
+ "
+ _Pragma(\"GCC diagnostic push\")
+ _Pragma(\"GCC diagnostic ignored \\\\\\\"-Wextra\\\\\\\"\")
+ int main() { return 0; }
+ _Pragma(\"GCC diagnostic pop\")
+ "
+ DEAL_II_COMPILER_HAS_DIAGNOSTIC_PRAGMA)
+RESET_CMAKE_REQUIRED()
+
#define __deal2__config_h
-/***********************************************************************
- * Two macro names that we put at the top and bottom of all deal.II files
- * and that will be expanded to "namespace dealii {" and "}".
- */
-
-#define DEAL_II_NAMESPACE_OPEN namespace dealii {
-#define DEAL_II_NAMESPACE_CLOSE }
-
-
/***********************************************************************
* Information about deal.II:
*/
#cmakedefine DEAL_II_HAVE_LIBSTDCXX_DEMANGLER
#cmakedefine __PRETTY_FUNCTION__ @__PRETTY_FUNCTION__@
#cmakedefine DEAL_II_DEPRECATED @DEAL_II_DEPRECATED@
+#cmakedefine DEAL_II_COMPILER_HAS_DIAGNOSTIC_PRAGMA
/***********************************************************************
/***********************************************************************
* Various macros for version number query and comparison:
+ *
+ * These macros are defined to make testing for specific versions within
+ * the deal.II main code as simple as possible.
*/
/*
* PETSC_USE_COMPLEX
*/
-/*
- * These macros are defined to make testing for PETSc versions within
- * the deal.II main code as simple as possible. In brief they are used
- * like this: (i) DEAL_II_PETSC_VERSION_LT is used to advance the
- * PETScWrappers to newer versions of PETSc while preserving backward
- * compatibility; and (ii) DEAL_II_PETSC_VERSION_GTE is used to add
- * functionality to the PETScWrappers that does not exist in previous
- * versions of PETSc. Examples of usage can be found in
- * lac/source/petsc_matrix_base.h. Note: SLEPcWrappers do not need
- * their own analogical macros, since SLEPc and PETSc must have
- * identical version numbers anyways.
- */
#define DEAL_II_PETSC_VERSION_LT(major,minor,subminor) \
((PETSC_VERSION_MAJOR * 10000 + \
PETSC_VERSION_MINOR * 100 + \
#endif
+/***********************************************************************
+ * Two macro names that we put at the top and bottom of all deal.II files
+ * and that will be expanded to "namespace dealii {" and "}".
+ */
+
+#define DEAL_II_NAMESPACE_OPEN namespace dealii {
+#define DEAL_II_NAMESPACE_CLOSE }
+
+
+/***********************************************************************
+ * Two macros to guard external header includes.
+ *
+ * Selectively disable diagnostics set by "-Wextra" (and similar flags) for
+ * GCC and compiler accepting GCC dialects (such as clang).
+ * "diagnostic push" is supported since gcc-4.6 and clang-3.3.
+ */
+
+#ifdef DEAL_II_COMPILER_HAS_DIAGNOSTIC_PRAGMA
+
+# define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS \
+_Pragma("GCC diagnostic push") \
+_Pragma("GCC diagnostic ignored \"-Wextra\"") \
+_Pragma("GCC diagnostic ignored \"-Woverloaded-virtual\"") \
+_Pragma("GCC diagnostic ignored \"-Wunused-function\"") \
+_Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") \
+_Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+
+# define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS \
+_Pragma("GCC diagnostic pop")
+
+#else
+
+# define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
+# define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
+
+#endif
+
+
/***********************************************************************
* Final inclusions:
*/