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 122140 - Preprocessor does not match if-endif
Summary: Preprocessor does not match if-endif
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords:
Depends on:
Blocks: 109619
  Show dependency tree
 
Reported: 2007-11-16 12:51 UTC by Alexander Simon
Modified: 2007-11-21 11:08 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
proposed patch for release60 (1.98 KB, patch)
2007-11-16 15:17 UTC, Vladimir Voskresensky
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Simon 2007-11-16 12:51:04 UTC
Preprocessor do not match if-endif in following example taken from Open Solaris:

#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
#  define OS_CODE  0x00
#  if defined(__TURBOC__) || defined(__BORLANDC__)
#    if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
       /* Allow compilation with ANSI keywords only enabled */
       void _Cdecl farfree( void *block );
       void *_Cdecl farmalloc( unsigned long nbytes );
#    else
#      include <alloc.h>
#    endif
#  else /* MSC or DJGPP */
#    include <malloc.h>
#  endif
#endif
Comment 1 Alexander Simon 2007-11-16 13:00:06 UTC
Simplified test case:

#if(defined(_MSC_VER))
  int a;
#endif
Comment 2 Vladimir Voskresensky 2007-11-16 13:13:48 UTC
the problem with "(" without space after #if
Comment 3 Vladimir Voskresensky 2007-11-16 15:17:13 UTC
fixed in trunk:
- handle start comment and line continuation after preprocessor directives
- handle LPAREN after #if* preprocessor directives

cvs log:
Checking in aptlexer.g;
/shared/data/ccvs/repository/cnd/apt/src/org/netbeans/modules/cnd/apt/impl/support/aptlexer.g,v  <--  aptlexer.g
new revision: 1.16; previous revision: 1.15
done
Comment 4 Vladimir Voskresensky 2007-11-16 15:17:47 UTC
Created attachment 53130 [details]
proposed patch for release60
Comment 5 Vladimir Voskresensky 2007-11-16 15:29:36 UTC
tests:
Checking in data/org/netbeans/modules/cnd/modelimpl/trace/FileModelTest/lparenAfterPPKwds.cc;
/shared/data/ccvs/repository/cnd/modelimpl/test/unit/data/org/netbeans/modules/cnd/modelimpl/trace/FileModelTest/lparenAfterPPKwds.cc,v
 <--  lparenAfterPPKwds.cc
initial revision: 1.1
done
RCS file:
/shared/data/ccvs/repository/cnd/modelimpl/test/unit/data/goldenfiles/org/netbeans/modules/cnd/modelimpl/trace/FileModelTest/lparenAfterPPKwds.cc.dat,v
done
Checking in data/goldenfiles/org/netbeans/modules/cnd/modelimpl/trace/FileModelTest/lparenAfterPPKwds.cc.dat;
/shared/data/ccvs/repository/cnd/modelimpl/test/unit/data/goldenfiles/org/netbeans/modules/cnd/modelimpl/trace/FileModelTest/lparenAfterPPKwds.cc.dat,v
 <--  lparenAfterPPKwds.cc.dat
initial revision: 1.1
done
RCS file:
/shared/data/ccvs/repository/cnd/modelimpl/test/unit/data/goldenfiles/org/netbeans/modules/cnd/modelimpl/trace/FileModelTest/lparenAfterPPKwds.cc.err,v
done
Checking in data/goldenfiles/org/netbeans/modules/cnd/modelimpl/trace/FileModelTest/lparenAfterPPKwds.cc.err;
/shared/data/ccvs/repository/cnd/modelimpl/test/unit/data/goldenfiles/org/netbeans/modules/cnd/modelimpl/trace/FileModelTest/lparenAfterPPKwds.cc.err,v
 <--  lparenAfterPPKwds.cc.err
initial revision: 1.1
done
Checking in src/org/netbeans/modules/cnd/modelimpl/trace/FileModelTest.java;
/shared/data/ccvs/repository/cnd/modelimpl/test/unit/src/org/netbeans/modules/cnd/modelimpl/trace/FileModelTest.java,v 
<--  FileModelTest.java
new revision: 1.23; previous revision: 1.22
done
Comment 6 Jesse Grodnik 2007-11-17 00:04:55 UTC
Following HR process ...
Comment 7 Vladimir Kvashin 2007-11-17 00:11:15 UTC
I reviewed the attached fix. I think it's correct and safe.
The lexer grammar is fixed via quite an easy and safe way.
Comment 8 Vladimir Kvashin 2007-11-17 08:36:19 UTC
Changing back to P1 (it was occasionally changed to P2)
Comment 9 Alexander Pepin 2007-11-18 21:13:52 UTC
verified in the trunk build 20071118
Comment 10 Vladimir Voskresensky 2007-11-19 13:47:49 UTC
fix integrated into release60:
Checking in aptlexer.g;
/shared/data/ccvs/repository/cnd/apt/src/org/netbeans/modules/cnd/apt/impl/support/aptlexer.g,v  <--  aptlexer.g
new revision: 1.15.2.1; previous revision: 1.15
done
Comment 11 Alexander Pepin 2007-11-21 11:08:11 UTC
verified in RC2 build (200711201000)