Menu

#10 Does not handle negative numbers in member initializers

open
nobody
C++ Parser (23)
5
2014-09-27
2001-02-22
No

C++ code parser does not handle negative numbers in member initialization lists. The following code compiles correctly under gcc but cannot be parsed correctly by cccc:

test.cpp
class c
{
int a;
c( void ) :
e( -1 ) {};
};

cccc generates the following:

Parsing
Processing test.cpp as C/C++ (c++.ansi)
test.cpp(4): syntax error at token c
Parser context:
test.cpp(4): trying to match class_block_item_list at 'c
test.cpp(3): trying to match class_block_item_list at 'int
test.cpp(2): trying to match class_block at '{
test.cpp(2): trying to match class_suffix at '{
test.cpp(1): trying to match class_declaration_or_definition at 'class
test.cpp(1): trying to match definition_or_declaration at 'class
test.cpp(1): trying to match link_item at 'class
test.cpp(1): trying to match start at 'class

test.cpp(6): syntax error at token }
Parser context:
test.cpp(6): trying to match start at '}
test.cpp(1): trying to match start at 'class

Changing the "-1" in the example above to a "1" will not generate an error. Enclosing the "-1" in parentheses will also not generate an error.

-->VPutz

Discussion


Log in to post a comment.

Auth0 Logo