t_5_017.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*=============================================================================
  2. Boost.Wave: A Standard compliant C++ preprocessor library
  3. http://www.boost.org/
  4. Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
  5. Software License, Version 1.0. (See accompanying file
  6. LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. The tests included in this file were initially taken from the mcpp V2.5
  8. preprocessor validation suite and were modified to fit into the Boost.Wave
  9. unit test requirements.
  10. The original files of the mcpp preprocessor are distributed under the
  11. license reproduced at the end of this file.
  12. =============================================================================*/
  13. // Tests short-circuit evaluation of #if expression.
  14. #define MACRO_0 0
  15. // 13.7: 10/0 or 10/MACRO_0 are never evaluated, "divide by zero" error
  16. // cannot occur.
  17. //R #line 28 "t_5_017.cpp"
  18. //R true
  19. #if 0 && 10 / 0
  20. false
  21. #else
  22. true
  23. #endif
  24. //R #line 36 "t_5_017.cpp"
  25. //R true
  26. #if not_defined && 10 / not_defined
  27. false
  28. #else
  29. true
  30. #endif
  31. //R #line 44 "t_5_017.cpp"
  32. //R true
  33. #if MACRO_0 && 10 / MACRO_0 > 1
  34. false
  35. #else
  36. true
  37. #endif
  38. //R #line 52 "t_5_017.cpp"
  39. //R true
  40. #if MACRO_0 ? 10 / MACRO_0 : 0
  41. false
  42. #else
  43. true
  44. #endif
  45. //R #line 58 "t_5_017.cpp"
  46. //R true
  47. #if MACRO_0 == 0 || 10 / MACRO_0 > 1 /* Valid block */
  48. true
  49. #else
  50. false
  51. #endif
  52. /*-
  53. * Copyright (c) 1998, 2002-2005 Kiyoshi Matsui <kmatsui@t3.rim.or.jp>
  54. * All rights reserved.
  55. *
  56. * Redistribution and use in source and binary forms, with or without
  57. * modification, are permitted provided that the following conditions
  58. * are met:
  59. * 1. Redistributions of source code must retain the above copyright
  60. * notice, this list of conditions and the following disclaimer.
  61. * 2. Redistributions in binary form must reproduce the above copyright
  62. * notice, this list of conditions and the following disclaimer in the
  63. * documentation and/or other materials provided with the distribution.
  64. *
  65. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
  66. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  67. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  68. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
  69. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  70. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  71. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  72. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  73. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  74. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  75. * SUCH DAMAGE.
  76. */