1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/static_warning.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,180 @@
1.4 +#ifndef BOOST_STATIC_WARNING_HPP
1.5 +#define BOOST_STATIC_WARNING_HPP
1.6 +
1.7 +// (C) Copyright Robert Ramey 2003. Jonathan Turkanis 2004.
1.8 +// Use, modification and distribution is subject to the Boost Software
1.9 +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
1.10 +// MS compatible compilers support #pragma once
1.11 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
1.12 +# pragma once
1.13 +#endif
1.14 +
1.15 +// http://www.boost.org/LICENSE_1_0.txt)
1.16 +
1.17 +// See http://www.boost.org/libs/static_assert for documentation.
1.18 +
1.19 +/*
1.20 + Revision history:
1.21 + 15 June 2003 - Initial version.
1.22 + 31 March 2004 - improved diagnostic messages and portability
1.23 + (Jonathan Turkanis)
1.24 + 03 April 2004 - works on VC6 at class and namespace scope
1.25 + - ported to DigitalMars
1.26 + - static warnings disabled by default; when enabled,
1.27 + uses pragmas to enable required compiler warnings
1.28 + on MSVC, Intel, Metrowerks and Borland 5.x.
1.29 + (Jonathan Turkanis)
1.30 + 30 May 2004 - tweaked for msvc 7.1 and gcc 3.3
1.31 + - static warnings ENabled by default; when enabled,
1.32 + (Robert Ramey)
1.33 +*/
1.34 +
1.35 +#include <boost/config.hpp>
1.36 +
1.37 +//
1.38 +// Implementation
1.39 +// Makes use of the following warnings:
1.40 +// 1. GCC prior to 3.3: division by zero.
1.41 +// 2. BCC 6.0 preview: unreferenced local variable.
1.42 +// 3. DigitalMars: returning address of local automatic variable.
1.43 +// 4. VC6: class previously seen as struct (as in 'boost/mpl/print.hpp')
1.44 +// 5. All others: deletion of pointer to incomplete type.
1.45 +//
1.46 +// The trick is to find code which produces warnings containing the name of
1.47 +// a structure or variable. Details, with same numbering as above:
1.48 +// 1. static_warning_impl<B>::value is zero iff B is false, so diving an int
1.49 +// by this value generates a warning iff B is false.
1.50 +// 2. static_warning_impl<B>::type has a constructor iff B is true, so an
1.51 +// unreferenced variable of this type generates a warning iff B is false.
1.52 +// 3. static_warning_impl<B>::type overloads operator& to return a dynamically
1.53 +// allocated int pointer only is B is true, so returning the address of an
1.54 +// automatic variable of this type generates a warning iff B is fasle.
1.55 +// 4. static_warning_impl<B>::STATIC_WARNING is decalred as a struct iff B is
1.56 +// false.
1.57 +// 5. static_warning_impl<B>::type is incomplete iff B is false, so deleting a
1.58 +// pointer to this type generates a warning iff B is false.
1.59 +//
1.60 +
1.61 +//------------------Enable selected warnings----------------------------------//
1.62 +
1.63 +// Enable the warnings relied on by BOOST_STATIC_WARNING, where possible. The
1.64 +// only pragma which is absolutely necessary here is for Borland 5.x, since
1.65 +// W8073 is disabled by default. If enabling selected warnings is considered
1.66 +// unacceptable, this section can be replaced with:
1.67 +// #if defined(__BORLANDC__) && (__BORLANDC__ <= 0x600)
1.68 +// pragma warn +stu
1.69 +// #endif
1.70 +
1.71 +# if defined(BOOST_MSVC)
1.72 +# pragma warning(2:4150) // C4150: deletion of pointer to incomplete type 'type'.
1.73 +# elif defined(BOOST_INTEL) && (defined(__WIN32__) || defined(WIN32))
1.74 +# pragma warning(2:457) // #457: delete of pointer to incomplete class.
1.75 +# elif defined(__BORLANDC__) && (__BORLANDC__ <= 0x600)
1.76 +# pragma warn +stu // W8073: Undefined structure 'structure'.
1.77 +# elif defined(__MWERKS__)
1.78 +# pragma extended_errorcheck on // Enable 'extended error checking'.
1.79 +# endif
1.80 +
1.81 +//------------------Configure-------------------------------------------------//
1.82 +
1.83 +# if defined(__BORLANDC__) && (__BORLANDC__ >= 0x600)
1.84 +# define BOOST_HAS_DESCRIPTIVE_UNREFERENCED_VARIABLE_WARNING
1.85 +# elif defined(__GNUC__) && !defined(BOOST_INTEL) // && (__GNUC__ * 100 + __GNUC_MINOR__ <= 302)
1.86 +# define BOOST_HAS_DESCRIPTIVE_DIVIDE_BY_ZERO_WARNING
1.87 +# elif defined(__DMC__)
1.88 +# define BOOST_HAS_DESCRIPTIVE_RETURNING_ADDRESS_OF_TEMPORARY_WARNING
1.89 +# elif defined(BOOST_MSVC) // && (BOOST_MSVC < 1300)
1.90 +# define BOOST_NO_PREDEFINED_LINE_MACRO
1.91 +# pragma warning(disable:4094) // C4094: untagged 'stuct' declared no symbols
1.92 +#endif
1.93 +
1.94 +//------------------Helper templates------------------------------------------//
1.95 +
1.96 +namespace boost {
1.97 +
1.98 +struct STATIC_WARNING;
1.99 +
1.100 +template<bool>
1.101 +struct static_warning_impl;
1.102 +
1.103 +template<>
1.104 +struct static_warning_impl<false> {
1.105 + enum { value = 0 };
1.106 + #if !defined(BOOST_HAS_DESCRIPTIVE_UNREFERENCED_VARIABLE_WARNING) && \
1.107 + !defined(BOOST_HAS_DESCRIPTIVE_RETURNING_ADDRESS_OF_TEMPORARY_WARNING)
1.108 + typedef boost::STATIC_WARNING type;
1.109 + #else
1.110 + typedef int type;
1.111 + #endif
1.112 + #if defined(BOOST_NO_PREDEFINED_LINE_MACRO)
1.113 + struct STATIC_WARNING { };
1.114 + #endif
1.115 +};
1.116 +
1.117 +template<>
1.118 +struct static_warning_impl<true> {
1.119 + enum { value = 1 };
1.120 + struct type { type() { } int* operator&() { return new int; } };
1.121 + #if defined(BOOST_NO_PREDEFINED_LINE_MACRO)
1.122 + class STATIC_WARNING { };
1.123 + #endif
1.124 +};
1.125 +
1.126 +} // namespace boost
1.127 +
1.128 +//------------------Definition of BOOST_STATIC_WARNING------------------------//
1.129 +
1.130 +#if defined(BOOST_HAS_DESCRIPTIVE_UNREFERENCED_VARIABLE_WARNING)
1.131 +# define BOOST_STATIC_WARNING_IMPL(B) \
1.132 + struct BOOST_JOIN(STATIC_WARNING, __LINE__) { \
1.133 + void f() { \
1.134 + ::boost::static_warning_impl<(bool)( B )>::type \
1.135 + STATIC_WARNING; \
1.136 + } \
1.137 + } \
1.138 + /**/
1.139 +#elif defined(BOOST_HAS_DESCRIPTIVE_RETURNING_ADDRESS_OF_TEMPORARY_WARNING)
1.140 +# define BOOST_STATIC_WARNING_IMPL(B) \
1.141 + struct BOOST_JOIN(STATIC_WARNING, __LINE__) { \
1.142 + int* f() { \
1.143 + ::boost::static_warning_impl<(bool)( B )>::type \
1.144 + STATIC_WARNING; \
1.145 + return &STATIC_WARNING; \
1.146 + } \
1.147 + } \
1.148 + /**/
1.149 +#elif defined(BOOST_HAS_DESCRIPTIVE_DIVIDE_BY_ZERO_WARNING)
1.150 +# define BOOST_STATIC_WARNING_IMPL(B) \
1.151 + struct BOOST_JOIN(STATIC_WARNING, __LINE__) { \
1.152 + int f() { int STATIC_WARNING = 1; \
1.153 + return STATIC_WARNING / \
1.154 + boost::static_warning_impl<(bool)( B )>::value; } \
1.155 + } \
1.156 + /**/
1.157 +#elif defined(BOOST_NO_PREDEFINED_LINE_MACRO)
1.158 + // VC6; __LINE__ macro broken when -ZI is used see Q199057, so
1.159 + // non-conforming workaround is used.
1.160 +# define BOOST_STATIC_WARNING_IMPL(B) \
1.161 + struct { \
1.162 + struct S { \
1.163 + typedef boost::static_warning_impl<(bool)( B )> f; \
1.164 + friend class f::STATIC_WARNING; \
1.165 + }; \
1.166 + } \
1.167 + /**/
1.168 +#else // Deletion of pointer to incomplete type.
1.169 +# define BOOST_STATIC_WARNING_IMPL(B) \
1.170 + struct BOOST_JOIN(STATIC_WARNING, __LINE__) { \
1.171 + ::boost::static_warning_impl<(bool)( B )>::type* p; \
1.172 + void f() { delete p; } \
1.173 + } \
1.174 + /**/
1.175 +#endif
1.176 +
1.177 +#ifndef BOOST_DISABLE_STATIC_WARNINGS
1.178 +# define BOOST_STATIC_WARNING(B) BOOST_STATIC_WARNING_IMPL(B)
1.179 +#else // #ifdef BOOST_ENABLE_STATIC_WARNINGS //-------------------------------//
1.180 +# define BOOST_STATIC_WARNING(B) BOOST_STATIC_WARNING_IMPL(true)
1.181 +#endif
1.182 +
1.183 +#endif // BOOST_STATIC_WARNING_HPP