Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_CompilerCodeTweakMacros.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_COMPILER_CODE_TWEAK_MACROS_HPP
11 #define TEUCHOS_COMPILER_CODE_TWEAK_MACROS_HPP
12 
13 #include "TeuchosCore_config.h"
14 
15 
16 //
17 // Implementations of below macros
18 //
19 
20 
21 #ifdef __NVCC__
22  #define TEUCHOS_UNREACHABLE_RETURN_IMPL(dummyReturnVal)
23 #else
24  #define TEUCHOS_UNREACHABLE_RETURN_IMPL(dummyReturnVal) \
25  return dummyReturnVal
26 #endif
27 // Above, the unreachable return statement is only removed for __NVCC__. This
28 // is because only __NVCC__ warns about the unreachable return. Having that
29 // return statement added for other compilers that don't warn leads to safer
30 // code by avoiding undefined behavior in case a function is modified in such
31 // a way that this return is no longer unreachable. In that case, we want it
32 // to return something to avoid undefined behavior in case it ever gets
33 // executed. That is just good defensive programming. Also, by leaving this
34 // return statement by default, we avoid the (incorrect) warning by some
35 // compilers that the function may not return a value.
36 
37 
38 //
39 // User interface macros
40 //
41 
42 
99 #define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal) \
100  TEUCHOS_UNREACHABLE_RETURN_IMPL(dummyReturnVal)
101 
102 
103 #endif // TEUCHOS_COMPILER_CODE_TWEAK_MACROS_HPP