1 /*============================================================================= 2 Boost.Wave: A Standard compliant C++ preprocessor library 3 http://www.boost.org/ 4 5 Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost 6 Software License, Version 1.0. (See accompanying file 7 LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 9 The tests included in this file were initially taken from the mcpp V2.5 10 preprocessor validation suite and were modified to fit into the Boost.Wave 11 unit test requirements. 12 The original files of the mcpp preprocessor are distributed under the 13 license reproduced at the end of this file. 14 =============================================================================*/ 15 16 // Tests whether rescanning of a macro replace any macro call in the replacement 17 // text after substitution of parameters by pre-expanded-arguments. This 18 // re-examination may involve the succeeding sequences from the source 19 // file (what a queer thing!). 20 21 // Note: The tests 27.4 and 27.5 are currently disabled because of Wave's 22 // problem with replacement-list terminating in partial macro expansion. 23 24 // 27.1: Cascaded use of object-like macros. 25 //R #line 34 "t_5_030.cpp" 26 #define NEST8 NEST7 + 8 27 #define NEST7 NEST6 + 7 28 #define NEST6 NEST5 + 6 29 #define NEST5 NEST4 + 5 30 #define NEST4 NEST3 + 4 31 #define NEST3 NEST2 + 3 32 #define NEST2 NEST1 + 2 33 #define NEST1 1 34 NEST8 //R 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 35 36 // 27.2: Cascaded use of function-like macros. 37 //R #line 42 "t_5_030.cpp" 38 #define FUNC4(a, b) FUNC3(a, b) + NEST4 39 #define FUNC3(a, b) FUNC2(a, b) + NEST3 40 #define FUNC2(a, b) FUNC1(a, b) + NEST2 41 #define FUNC1(a, b) (a) + (b) 42 FUNC4(NEST1, NEST2) //R (1) + ( 1 + 2) + 1 + 2 + 1 + 2 + 3 + 1 + 2 + 3 + 4 43 44 // 27.3: An identifier generated by ## operator is subject to expansion. 45 //R #line 48 "t_5_030.cpp" 46 #define GLUE( a, b) a ## b 47 #define MACRO_1 1 48 GLUE(MACRO_, 1) //R 1 49 50 // 27.4: 'SUB' as an argument of math() is not pre-expanded, since '(' 51 // missing. 52 //R #line 55 "t_5_030.cpp" 53 #define SUB(x, y) (x - y) 54 #define MATH(op, a, b) op( (a), (b)) 55 MATH(SUB, a, b) //R ( ( a) - ( b)) 56 57 // 27.5: Queer thing. 58 // R #line 28 "t_5_030.cpp" 59 //#define HEAD SUB( 60 // HEAD a,b ) // R 61 62 // 27.6: Recursive macro. 63 //R #line 66 "t_5_030.cpp" 64 #define M N 65 #define N(a) a 66 M(m) //R m 67 68 /*- 69 * Copyright (c) 1998, 2002-2005 Kiyoshi Matsui <kmatsui@t3.rim.or.jp> 70 * All rights reserved. 71 * 72 * Redistribution and use in source and binary forms, with or without 73 * modification, are permitted provided that the following conditions 74 * are met: 75 * 1. Redistributions of source code must retain the above copyright 76 * notice, this list of conditions and the following disclaimer. 77 * 2. Redistributions in binary form must reproduce the above copyright 78 * notice, this list of conditions and the following disclaimer in the 79 * documentation and/or other materials provided with the distribution. 80 * 81 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 82 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 83 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 84 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 85 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 86 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 87 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 88 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 89 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 90 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 91 * SUCH DAMAGE. 92 */ 93 94