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 83496 - C++ parser does not allow class definition inside function
Summary: C++ parser does not allow class definition inside function
Status: CLOSED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 5.x
Hardware: Sun All
: P4 blocker (vote)
Assignee: alms
URL:
Keywords:
Depends on:
Blocks: 83575
  Show dependency tree
 
Reported: 2006-08-25 19:13 UTC by mkapoor
Modified: 2007-12-27 16:14 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 mkapoor 2006-08-25 19:13:08 UTC
The C++ parser does not recognize the keyword typeid. The lexer also
does not have any token LITERAL_typeid. The following test case does not
compile:

#include <typeinfo.h>
extern "C" int printf(const char*, ...);

main()
{
  class A {};
  int foo;
  A bar;
  printf("%s\n", typeid(foo).name());
  printf("%s\n", typeid(bar).name());
}

I preproessed this file and edited the preprocessed file to create this
small test case:

% cat y.c
namespace std {

class type_info {
public :
  virtual ~ type_info ( ) ;
  const char * name ( ) const ;
  const void * __data ;
};

}

extern "C" int printf ( const char * , ... ) ;

main ()
{
  class A { };
  int foo;
  A bar;
  printf("%s\n" , typeid(foo).name());
  printf("%s\n" , typeid(bar).name());
}

% CC y.c
% ./a.out
int
A

% tracemodel.sh y.c
y.c:16:3: unexpected token: class
y.c:16:9: unexpected token: A
Comment 1 mkapoor 2006-08-25 19:41:36 UTC
The problem is not with typeid. The problem is that the parser does not
recognize the class declaration inside main(). If the declaration of class A is
moved outside main, it compiles without errors.
But the question still remains: why is there no LITERAL_typeid token in the lexer?
Comment 2 alms 2006-10-18 16:35:44 UTC
It is fixed and commented in grammar ("cppparser.g", revision 1.2.2.20). Further
should be corrected 'AstRenderer'
Comment 3 Alexander Simon 2006-10-20 08:52:56 UTC
"unexpected token" was fixed when fixed IZ#83996:Code completion list doesn't
appear if enum defined within function (without messages) 

Comment 4 Alexander Simon 2006-10-20 09:10:33 UTC
Second part of IZ isn't fixed.
Keyword "typeid" highlighted as "keyword" but in AST tree it's a
CSM_TYPE_COMPOUND with node ID.
Grammar should has LITERAL_typeid and represent keyword "typeid" as literal.
But it's another (internal design) bug. It should be P4 because it doesn't have
influence on user.
Comment 5 Vladimir Voskresensky 2006-10-20 11:12:06 UTC
close this bug as solved.
opened http://www.netbeans.org/issues/show_bug.cgi?id=87618 for investigating
typeid support in grammar