• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 macro arguments are pre-expanded (unless the argument is an
17 // operand of # or ## operator) separately, that is, are macro-replaced
18 // completely prior to rescanning.
19 
20 #define ZERO_TOKEN
21 #define MACRO_0         0
22 #define MACRO_1         1
23 #define TWO_ARGS        a,b
24 #define SUB(x, y)       (x - y)
25 #define GLUE(a, b)      a ## b
26 #define XGLUE(a, b)     GLUE( a, b)
27 #define STR(a)          # a
28 
29 // 25.1: "TWO_ARGS" is read as one argument to "SUB", then expanded to
30 //       "a,b", then "x" is substituted by "a,b".
31 //R #line 32 "t_5_028.cpp"
32 SUB(TWO_ARGS, 1)              //R (a,b - 1)
33 
34 // 25.2: An argument pre-expanded to 0-token.    */
35 //R #line 36 "t_5_028.cpp"
36 SUB(ZERO_TOKEN, a)            //R ( - a)
37 
38 // 25.3: "glue( a, b)" is pre-expanded.  */
39 //R #line 40 "t_5_028.cpp"
40 XGLUE(GLUE(a, b), c)          //R abc
41 
42 // 25.4: Operands of ## operator are not pre-expanded.
43 //R #line 44 "t_5_028.cpp"
44 GLUE(MACRO_0, MACRO_1)        //R MACRO_0MACRO_1
45 
46 // 25.5: Operand of # operator is not pre-expanded.
47 //R #line 48 "t_5_028.cpp"
48 STR(ZERO_TOKEN)               //R "ZERO_TOKEN"
49 
50 /*-
51  * Copyright (c) 1998, 2002-2005 Kiyoshi Matsui <kmatsui@t3.rim.or.jp>
52  * All rights reserved.
53  *
54  * Redistribution and use in source and binary forms, with or without
55  * modification, are permitted provided that the following conditions
56  * are met:
57  * 1. Redistributions of source code must retain the above copyright
58  *    notice, this list of conditions and the following disclaimer.
59  * 2. Redistributions in binary form must reproduce the above copyright
60  *    notice, this list of conditions and the following disclaimer in the
61  *    documentation and/or other materials provided with the distribution.
62  *
63  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
64  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
65  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
66  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
67  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
68  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
69  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
70  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
71  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
72  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
73  * SUCH DAMAGE.
74  */
75 
76