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 205815 - __LINE__ breaks macro expansion
Summary: __LINE__ breaks macro expansion
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 7.1
Hardware: PC Solaris
: P3 normal (vote)
Assignee: Alexander Simon
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-01 23:18 UTC by hajma
Modified: 2011-12-08 12:11 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 hajma 2011-12-01 23:18:36 UTC
Working on Qt 4.7.4 (tests/auto/tst_qaccessibility.cpp), the IDE says that 

"EXPECT(entry == 0 && iface->object() == parent->object());"
expands to
"do { if (!errorAt && !( entry == 0 && iface->object() == parent->object() )) { errorAt = ; qWarning("level: %d, middle: %d, role: %d (%s)", treelevel, middle, iface->role(0), "entry==0&&iface->object()==parent->object()" ); } } while (0);"

and because of the "errorAt = ;" marks the line as error.

This is wrong as EXPECT is defined as
#define EXPECT(cond) \
    do { \
        if (!errorAt && !(cond)) { \
            errorAt = __LINE__; \
            qWarning("level: %d, middle: %d, role: %d (%s)", treelevel, middle, iface->role(0), #cond); \
        } \
    } while (0)

The only problem is the IDE does not handle the __LINE__macro well
Comment 1 Alexander Simon 2011-12-02 07:53:47 UTC
Code model should know compile-time macros.
Code model should ignore compile-time macro values from tool collection.
Comment 2 Vladimir Voskresensky 2011-12-02 09:42:50 UTC
hajma, in fact we do support __LINE__ (and other proprocessor built-in macros). The issue you've faced most probable is due to the fact that you use Solaris Studio C++ compiler which reports in it's predefined macro values __LINE__ macro with empty expansion. 
Workaround would be go to Tools->Options->C++->Code Assistance and in C++ Compiler tab in list of macro values delete __LINE__, __FILE__, ...
Comment 3 Vladimir Voskresensky 2011-12-02 12:53:33 UTC
Alexander, please, try to do that on toolchain side. Code Model uses provided macro info as is.
Comment 4 Alexander Simon 2011-12-02 15:40:27 UTC
fixed, change set:
http://hg.netbeans.org/cnd-main/rev/864a9bf831cd
Comment 5 Quality Engineering 2011-12-08 12:11:52 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/864a9bf831cd
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixed Bug #205815 __LINE__ breaks macro expansion