Commit Graph

12 Commits

Author SHA1 Message Date
Chris Lattner d2e97c1f80 Handle void correctly in the argument list for a function. For:
X = sizeof(int (void a));
  X = sizeof(int (int, void));
  X = sizeof(int (void, ...));

We now emit:

t.c:6:24: error: void argument may not have a name
  X = sizeof(int (void a));
                       ^
t.c:7:24: error: 'void' must be the first and only parameter if specified
  X = sizeof(int (int, void));
                       ^
t.c:8:19: error: 'void' must be the first and only parameter if specified
  X = sizeof(int (void, ...));
                  ^


And we pretty print this correctly (even though void isn't stored in the
arg list of the function type):
  X = sizeof(int (void));


However, this approach will have to change to handle typedefs of void.

llvm-svn: 39235
2006-12-03 02:03:33 +00:00
Chris Lattner c6ad8131dd implement AST representation for function types with and without a prototype.
This lets us pretty print stuff like this:

void foo() {
  int X;
  X = sizeof(void (*(*)())());
  X = sizeof(int(*)(int, float, ...));
  X = sizeof(void (*(int arga, void (*argb)(double Y)))(void* Z));

as:

  X = sizeof(void (*(*)())())
  X = sizeof(int (*)(int, float, ...))
  X = sizeof(void (*(int, void (*)(double)))(void *))

Ah the wonders of 'modern' C syntax!

llvm-svn: 39232
2006-12-02 07:52:18 +00:00
Chris Lattner f0a40e7ef4 correctly handle stuff like:
typedef int G;
  X = sizeof(const G);
  X = sizeof(restrict G);

llvm-svn: 39190
2006-11-20 04:17:27 +00:00
Chris Lattner d0342e5989 Create a new TypeNameType class, which represents typedefs as types. This
allows us to handle stuff like:

typedef int G;
 ..
  X = sizeof(G);

llvm-svn: 39189
2006-11-20 04:02:15 +00:00
Chris Lattner 558cb292da add an action for parsing type names.
llvm-svn: 39180
2006-11-19 01:31:06 +00:00
Chris Lattner 9dfdb3c70d rearrange the type printing code so that we can do the horrible C "inside out"
thing properly.  This allows us to print types like:
int (*A)[restrict static 4][6];

properly, in addition to representing them properly. :)

llvm-svn: 39178
2006-11-13 07:38:09 +00:00
Chris Lattner d235d162d0 change print methods to render into a string, which is more useful for diagnostics
and for handling precedence of types more accurately

llvm-svn: 39177
2006-11-13 06:22:30 +00:00
Chris Lattner 7ccecb90d4 Implement parsing, printing and AST'ing of array types (except for the bounds).
This allows us to handle:

int (*A)[restrict static 4][6];

for example.

llvm-svn: 39176
2006-11-12 08:50:50 +00:00
Chris Lattner d5973ebbe2 Teach ASTContext to delete all created types in its dtor.
Teach getPointerType to (stupidly) memoize all created pointers.
Give types an enum so we can implement classof.

llvm-svn: 39174
2006-11-12 00:53:46 +00:00
Chris Lattner 970e54e3ac Build ASTs for the pointer qualifiers on declarators. This allows us to
parse (and print) things like:

int* const* restrict* const volatile***

etc.

llvm-svn: 39173
2006-11-12 00:37:36 +00:00
Chris Lattner b571a5cbdc implement conversion of simple declspec base types, and implement TypeRef::dump
llvm-svn: 39170
2006-11-11 23:56:48 +00:00
Chris Lattner f84a79c4e9 restructure code to build the framework for creating types from declarators.
llvm-svn: 39166
2006-11-11 22:59:23 +00:00