SST  11.0.0
StructuralSimulationToolkit
warnmacros.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2021 NTESS. Under the terms
4 // of Contract DE-NA0003525 with NTESS, the U.S.
5 // Government retains certain rights in this software.
6 //
7 // Copyright (c) 2009-2021, NTESS
8 // All rights reserved.
9 //
10 // This file is part of the SST software package. For license
11 // information, see the LICENSE file in the top level directory of the
12 // distribution.
13 
14 #ifndef SST_CORE_WARNMACROS_H
15 #define SST_CORE_WARNMACROS_H
16 
17 
18 #define UNUSED(x) x __attribute__((unused))
19 
20 
21 #define DIAG_STR(s) #s
22 #define DIAG_JOINSTR(x,y) DIAG_STR(x ## y)
23 #define DIAG_DO_PRAGMA(x) _Pragma(#x)
24 #define DIAG_PRAGMA(compiler,x) DIAG_DO_PRAGMA(compiler diagnostic x)
25 
26 
27 #define DIAG_DISABLE(option) \
28  DIAG_PRAGMA(DIAG_COMPILER,push) \
29  DIAG_PRAGMA(DIAG_COMPILER,ignored DIAG_JOINSTR(-W,option))
30 
31 #define REENABLE_WARNING \
32  DIAG_PRAGMA(DIAG_COMPILER,pop)
33 
34 #if defined(__clang__)
35 #define DIAG_COMPILER clang
36 
37 
38 #define DISABLE_WARN_DEPRECATED_REGISTER \
39  DIAG_DISABLE(deprecated-register)
40 
41 #define DISABLE_WARN_STRICT_ALIASING \
42  DIAG_DISABLE(strict-aliasing)
43 
44 #define DISABLE_WARN_MISSING_OVERRIDE \
45  DIAG_DISABLE(inconsistent-missing-override)
46 
47 #define DISABLE_WARN_DEPRECATED_DECLARATION \
48  DIAG_DISABLE(deprecated-declarations)
49 
50 
51 #elif defined(__GNUC__)
52 #define DIAG_COMPILER GCC
53 
54 #define DISABLE_WARN_DEPRECATED_REGISTER
55 
56 #define DISABLE_WARN_STRICT_ALIASING \
57  DIAG_DISABLE(strict-aliasing)
58 
59 #if (__GNUC__ >= 5)
60 #define DISABLE_WARN_MISSING_OVERRIDE \
61  DIAG_DISABLE(suggest-override)
62 #else
63 #define DISABLE_WARN_MISSING_OVERRIDE
64 #endif
65 
66 #define DISABLE_WARN_DEPRECATED_DECLARATION \
67  DIAG_DISABLE(deprecated-declarations)
68 
69 #else
70 
71 #undef REENABLE_WARNING
72 #define REENABLE_WARNING
73 #define DISABLE_WARN_DEPRECATED_REGISTER
74 #define DISABLE_WARN_STRICT_ALIASING
75 #define DISABLE_WARN_MISSING_OVERRIDE
76 #endif
77 
78 #endif