Menu

#10 C++ parser can't parse std C++ header

open
nobody
None
9
2002-12-05
2001-11-16
No

invoking 'make' in demo/C++ yields

../../synopsis -c config.py
-Wc,parser=C++,formatter=HTML,linker=Linker -o html
GapBuffer.hh
/usr/include/g++-3/stl_alloc.h:344: parse error before
`_Obj *'
/usr/include/g++-3/stl_alloc.h:351: parse error before
`void *'
/usr/include/g++-3/stl_alloc.h:398: parse error before
`: static'
/usr/include/g++-3/stl_alloc.h:406: parse error before
`( __n'
/usr/include/g++-3/stl_alloc.h:409: parse error before
`__my_free_list ='
/usr/include/g++-3/stl_alloc.h:417: parse error before
`* __my_free_list'
/usr/include/g++-3/stl_alloc.h:418: parse error before
`( __result'
/usr/include/g++-3/stl_alloc.h:420: parse error before
`__r ;'
/usr/include/g++-3/stl_alloc.h:422: parse error before
`* __my_free_list'
/usr/include/g++-3/stl_alloc.h:423: parse error before
`( __result'
errors while parsing file /tmp/synopsis-x0o66k

no clue what the problem is at this point (i.e. a real
parse error, wrong context, i.e. incomplete macro
expansion, etc.). Thus it makes no sense to attach the
file in question...

Discussion

  • Nobody/Anonymous

    Logged In: NO

    The problem lies in the fact that C++ comment are not
    removed eg:
    line 344 of stl_alloc is:
    static _Obj* __VOLATILE _S_free_list[_NFREELISTS];
    which is expanded to:
    static _Obj* volatile // Needed at -O3 on SGI
    _S_free_list[_NFREELISTS];
    because in std_alloc.h we have a line 114:
    # define __VOLATILE volatile // Needed at -O3 on SGI
    < this
    above is not removed>

     
  • Stephen Davies

    Stephen Davies - 2002-12-05

    Logged In: YES
    user_id=768

    OCC handles comments just fine, so that shouldn't be a problem.

    Only the first parse error has any macro anyway.

    I just tried compiling it with the debug "occ.gdb", and it
    works fine, once I figured out you have to parse alloc.h to
    get both stl_config.h first and then stl_alloc.h.

     
  • Stephen Davies

    Stephen Davies - 2002-12-05
    • status: open --> closed
     
  • Nobody/Anonymous

    Logged In: NO

    The point I have tried to made is:
    static _Obj* volatile // Needed at -O3 on SGI
    _S_free_list[_NFREELISTS];
    every things on the same line will not be compiled correctly
    whatever
    is the compiler.
    I do not know why using occ.gdb makes it work, I could only
    guess that
    somehow the comment are discarded.
    --Fathi

     
  • Stephen Davies

    Stephen Davies - 2002-12-05

    Logged In: YES
    user_id=768

    Okay, I see what you're saying. The form screwed up your
    text.. you're saying that everything is on the same line,
    with the comment in the middle?

    When I parse it here, I don't get a comment. What OS are you
    using? From the comment it sounds like SGI.

    I wrote up a little test case that #defines a macro with a
    comment like that, and the comment it is not included
    whether I use gcc's cpp or the ucpp used by Synopsis. I also
    tried running Synopsis on the file and got no parse errors.

    Can you try with the latest version from CVS?

     
  • Stephen Davies

    Stephen Davies - 2002-12-05
    • status: closed --> open
     
  • Nobody/Anonymous

    Logged In: NO

    Sorry I can't get it from CVS.
    I cannot recall on wich OS I reproduced the problem
    but it can only be Solaris 2.5 - 2.8 or Linux RH7.0.
    Since I am unable to compile Synopsis-0.4.1 under
    Solaris I think it might have been Linux. I'll give it a try
    at home.
    The comment about SGI only acknowledge that
    the implementation of STL is a derived one from SGI.
    Which remind me to state that in both case the compiler
    I use is gcc.
    --Fathi

     
  • Stefan Seefeld

    Stefan Seefeld - 2002-12-06

    Logged In: YES
    user_id=764

    hmm, it has been a while, but I remember it to be a bug in a
    RH specific gcc version. The bug was precisely that the
    preprocessor, when called with option '-C' correctly kept
    comments, but expanded macros incorrectly (i.e. removed
    newlines, leading to '//' comments in the middle of a line
    of code...

     

Log in to post a comment.

MongoDB Logo MongoDB