This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 96806 - Incorrect preprocessing of BOOST_PP_REPEAT macro from boost library
Summary: Incorrect preprocessing of BOOST_PP_REPEAT macro from boost library
Status: CLOSED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-28 18:44 UTC by Vladimir Kvashin
Modified: 2007-12-14 08:45 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Kvashin 2007-02-28 18:44:13 UTC
When BOOST_PP_REPEAT macro from boost library is used, code model fails to parse
the file. 

This macro is defined in the file
<boost/preprocessor/repetition/repeat.hpp>

The description of the macro is here
http://www.boost.org/libs/preprocessor/doc/ref/repeat.html

Below is a simplified fragment that shows the error.

If you use g++ -E  or  cc -E, it expands to 
int x0 = 0 ; int x1 = 1 ;
But code model fails to parse this example

//--------------------------------------------------------------

//--- excerpts from boost headers

#define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b)
#define BOOST_PP_CAT_I(a, b) a ## b

// this is the only macro that has its right part replaced by just "1"
// since it expands to 1
// (otherwise we have too complicated file)
#define BOOST_PP_AUTO_REC(pred, n) 1

# define BOOST_PP_REPEAT_1(c, m, d) BOOST_PP_REPEAT_1_I(c, m, d)
# define BOOST_PP_REPEAT_2(c, m, d) BOOST_PP_REPEAT_2_I(c, m, d)

# define BOOST_PP_REPEAT_1_I(c, m, d) BOOST_PP_REPEAT_1_ ## c(m, d)
# define BOOST_PP_REPEAT_2_I(c, m, d) BOOST_PP_REPEAT_2_ ## c(m, d)

# define BOOST_PP_REPEAT_1_0(m, d)
# define BOOST_PP_REPEAT_1_1(m, d) m(2, 0, d)
# define BOOST_PP_REPEAT_1_2(m, d) BOOST_PP_REPEAT_1_1(m, d) m(2, 1, d)

# define BOOST_PP_REPEAT BOOST_PP_CAT(BOOST_PP_REPEAT_,
BOOST_PP_AUTO_REC(BOOST_PP_REPEAT_P, 4))

//--- below is the example of these macros usage

#define DECL(z, n, text) text ## n = n;

BOOST_PP_REPEAT(2, DECL, int x)
Comment 1 Vladimir Kvashin 2007-02-28 18:50:47 UTC
This construct is used quite frequently in boost.
And often parser can not recover after this error.
Upgrading to P2.
Comment 2 Vladimir Kvashin 2007-02-28 19:07:52 UTC
Below is simplified variant of the same problem.
CC or g++ preprocessor expands it to 
int int a = 1;
Code model fails to parse the example.

#define CAT(a, b) a ## b
#define FUN_1(x) int x  = 1;
#define MAC_A  CAT(FUN_, 1)

#define LAST(x) MAC_A(x)

LAST(int a)
Comment 3 Vladimir Kvashin 2007-02-28 19:51:57 UTC
Yet even more simple example.
The code below should expand to int b = 1;
Model preprocessor expands it to FUN_1 ( b )

#define CAT(a, b) a ## b
#define FUN_1(x) int x  = 1;
#define MAC_A  CAT(FUN_, 1)
MAC_A(b)
Comment 4 Vladimir Voskresensky 2007-03-01 17:24:41 UTC
fixed:
 - fixed expanding problem
 - fixed concatenation/stringizing problem

cvs log:
Checking in APTExpandedStream.java;
/shared/data/ccvs/repository/cnd/apt/src/org/netbeans/modules/cnd/apt/impl/support/APTExpandedStream.java,v
 <--  APTExpandedStream.java
new revision: 1.1.2.7; previous revision: 1.1.2.6
done