[cfe-dev] [PATCH]: Parsing for C++ classes

Argiris Kirtzidis akyrtzi at gmail.com
Fri Jun 13 07:10:03 PDT 2008


Hi,

The attached patch adds C++ classes support to the Parser. I'll provide 
the Sema support in a separate patch.
Here's what can be parsed:

-Access specifiers
-method declarations and inline method definitions
-static members
-typedefs, enums, and nested classes
-'this' keyword

Inline method definitions are lexed and their tokens stored for later 
parsing, after the class is complete.

This test is representative of the new features:

// RUN: clang -parse-noop -verify %s
class C {

protected:
  typedef int A,B;
  static int sf(), u;

  auto int sx; // expected-error {{error: storage class specified for a 
member declaration}}
  register int sy; // expected-error {{error: storage class specified 
for a member declaration}}
  extern int sz; // expected-error {{error: storage class specified for 
a member declaration}}

  struct S {};
  enum {};
  int; // expected-error {{error: declaration does not declare anything}}

  int b : 1, w : 2;
  typedef int E : 1; // expected-error {{error: cannot declare 'E' to be 
a bit-field type}}
  static int sb : 1; // expected-error {{error: static member 'sb' 
cannot be a bit-field}}

  int i = 0; // expected-error {{error: member 'i' can be initialized 
only if it is a static const integral data member}}

public:
  void m() {
    int l = 2;
  }
 
private:
  int x,f(),y,g();
};

int x = this; // expected-error {{error: invalid use of 'this' at top 
level}}



-Argiris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cxx-classes-parser.patch
Type: text/x-diff
Size: 36991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080613/30d92a85/attachment.patch>


More information about the cfe-dev mailing list