Skip to content

Commit c1cb0cb

Browse files
committed
Move all warning suppression to one place
(#534)
1 parent 56c01a2 commit c1cb0cb

39 files changed

+109
-334
lines changed

include/galsim/IgnoreWarnings.h

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* -*- c++ -*-
2+
* Copyright (c) 2012-2016 by the GalSim developers team on GitHub
3+
* https://github.com/GalSim-developers
4+
*
5+
* This file is part of GalSim: The modular galaxy image simulation toolkit.
6+
* https://github.com/GalSim-developers/GalSim
7+
*
8+
* GalSim is free software: redistribution and use in source and binary forms,
9+
* with or without modification, are permitted provided that the following
10+
* conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice, this
13+
* list of conditions, and the disclaimer given in the accompanying LICENSE
14+
* file.
15+
* 2. Redistributions in binary form must reproduce the above copyright notice,
16+
* this list of conditions, and the disclaimer given in the documentation
17+
* and/or other materials provided with the distribution.
18+
*/
19+
20+
// The boost header files tend to emit lots of warnings, so pretty much any GalSim
21+
// code that imports boost should import this first to suppress the warnings.
22+
23+
// icpc pretends to be GNUC, since it thinks it's compliant, but it's not.
24+
// It doesn't understand #pragma GCC
25+
// Rather, it uses #pragma warning(disable:nn)
26+
#ifdef __INTEL_COMPILER
27+
28+
// Disable "overloaded virtual function ... is only partially overridden"
29+
#pragma warning(disable:654)
30+
31+
#else
32+
33+
// The boost unit tests have some unused variables, so suppress the warnings about that.
34+
// I think pragma GCC was introduced in gcc 4.2, so guard for >= that version
35+
#if defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 2)
36+
#pragma GCC diagnostic ignored "-Wunused-variable"
37+
#endif
38+
39+
// Not sure when this was added. Currently check for it for versions >= 4.3
40+
#if defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 3)
41+
#pragma GCC diagnostic ignored "-Warray-bounds"
42+
#endif
43+
44+
#if defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 8)
45+
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
46+
#endif
47+
48+
// For 32-bit machines, g++ -O2 optimization in some TMV calculations uses an optimization
49+
// that is technically not known to not overflow 32 bit integers. In fact, it is totally
50+
// fine to use, but we need to remove a warning about it in this file for gcc >= 4.5
51+
#if defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 5)
52+
#pragma GCC diagnostic ignored "-Wstrict-overflow"
53+
#endif
54+
55+
56+
#ifdef __clang__
57+
// Only clang seems to have this
58+
#if __has_warning("-Wlogical-op-parentheses")
59+
#pragma GCC diagnostic ignored "-Wlogical-op-parentheses"
60+
#endif
61+
62+
// And clang might need this even if it claims to be GNUC before 4.8.
63+
#if __has_warning("-Wunused-local-typedefs")
64+
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
65+
#endif
66+
67+
#endif // clang
68+
69+
#endif // intel

include/galsim/Random.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,7 @@
3131
* Wraps Boost.Random classes in a way that lets us swap Boost RNG's without affecting client code.
3232
*/
3333

34-
// icpc pretends to be GNUC, since it thinks it's compliant, but it's not.
35-
// It doesn't understand "pragma GCC"
36-
#ifndef __INTEL_COMPILER
37-
38-
// There are some uninitialized values in boost.random stuff, which aren't a problem but
39-
// sometimes confuse the compiler sufficiently that it emits a warning.
40-
#if defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 2)
41-
#pragma GCC diagnostic ignored "-Wuninitialized"
42-
#endif
43-
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 8))
44-
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
45-
#endif
46-
47-
#endif
48-
34+
#include "galsim/IgnoreWarnings.h"
4935

5036
// Variable defined to use a private copy of Boost.Random, modified
5137
// to avoid any reference to Boost.Random elements that might be on

pysrc/Angle.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
* and/or other materials provided with the distribution.
1818
*/
1919

20-
#ifndef __INTEL_COMPILER
21-
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 8))
22-
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
23-
#endif
24-
#endif
20+
#include "galsim/IgnoreWarnings.h"
2521

2622
#define BOOST_NO_CXX11_SMART_PTR
2723
#include "boost/python.hpp"

pysrc/Bessel.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
* and/or other materials provided with the distribution.
1818
*/
1919

20-
#ifndef __INTEL_COMPILER
21-
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 8))
22-
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
23-
#endif
24-
#endif
20+
#include "galsim/IgnoreWarnings.h"
2521

2622
#define BOOST_NO_CXX11_SMART_PTR
2723
#include "boost/python.hpp"

pysrc/Bounds.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
* and/or other materials provided with the distribution.
1818
*/
1919

20-
#ifndef __INTEL_COMPILER
21-
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 8))
22-
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
23-
#endif
24-
#endif
20+
#include "galsim/IgnoreWarnings.h"
2521

2622
#define BOOST_NO_CXX11_SMART_PTR
2723
#include "boost/python.hpp"

pysrc/CDModel.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
* and/or other materials provided with the distribution.
1818
*/
1919

20-
#ifndef __INTEL_COMPILER
21-
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 8))
22-
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
23-
#endif
24-
#endif
20+
#include "galsim/IgnoreWarnings.h"
2521

2622
#define BOOST_NO_CXX11_SMART_PTR
2723
#include "boost/python.hpp"

pysrc/CorrelatedNoise.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
* and/or other materials provided with the distribution.
1818
*/
1919

20-
#ifndef __INTEL_COMPILER
21-
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 8))
22-
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
23-
#endif
24-
#endif
20+
#include "galsim/IgnoreWarnings.h"
2521

2622
#define BOOST_NO_CXX11_SMART_PTR
2723
#include "boost/python.hpp"

pysrc/HSM.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
* and/or other materials provided with the distribution.
1818
*/
1919

20+
#include "galsim/IgnoreWarnings.h"
21+
2022
#define BOOST_PYTHON_MAX_ARITY 22 // We have a function with 21 params here...
2123
// c.f. www.boost.org/libs/python/doc/v2/configuration.html
22-
#ifndef __INTEL_COMPILER
23-
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 8))
24-
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
25-
#endif
26-
#endif
2724

2825
#define BOOST_NO_CXX11_SMART_PTR
2926
#include "boost/python.hpp"

pysrc/Image.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
* and/or other materials provided with the distribution.
1818
*/
1919

20-
#ifndef __INTEL_COMPILER
21-
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 8))
22-
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
23-
#endif
24-
#endif
20+
#include "galsim/IgnoreWarnings.h"
2521

2622
#define BOOST_NO_CXX11_SMART_PTR
2723
#include "boost/python.hpp" // header that includes Python.h always needs to come first

pysrc/Integ.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
* and/or other materials provided with the distribution.
1818
*/
1919

20-
#ifndef __INTEL_COMPILER
21-
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ >= 5 || __GNUC_MINOR__ >= 8))
22-
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
23-
#endif
24-
#endif
20+
#include "galsim/IgnoreWarnings.h"
2521

2622
#define BOOST_NO_CXX11_SMART_PTR
2723
#include "boost/python.hpp"

0 commit comments

Comments
 (0)