Commit Graph

34109 Commits

Author SHA1 Message Date
Chris Lattner 3034f66584 add option for C++ operator names, patch by Bill.
llvm-svn: 39244
2006-12-04 07:46:15 +00:00
Chris Lattner 69c7ee2d51 allow getTokenName to work for keywords.
llvm-svn: 39243
2006-12-04 07:45:05 +00:00
Chris Lattner 2114d5e948 add some comments
llvm-svn: 39242
2006-12-04 07:40:24 +00:00
Chris Lattner 5c5fbccc96 Scrutinize K&R parameter declarations. This implements C99 6.9.1p6, correctly
diagnosing malformed K&R function definitions.

llvm-svn: 39241
2006-12-03 08:41:30 +00:00
Chris Lattner 0d89d5a638 Enforce C99 6.7.5.3p3, rejecting code like:
void foo(void (*q)(a,b,c)) {}

llvm-svn: 39240
2006-12-03 07:14:39 +00:00
Chris Lattner 969ca15b41 Diagnose errors like:
void bar(int X, int X);

void blah(X, Y, X) int X, Y; {}

llvm-svn: 39239
2006-12-03 06:29:03 +00:00
Chris Lattner 53e776c1e4 reject int(const void).
llvm-svn: 39238
2006-12-03 03:07:05 +00:00
Chris Lattner 726f97b435 implement a fixme: make BuiltinType have an enum, specifying which type it is,
instead of having a string.

llvm-svn: 39237
2006-12-03 02:57:32 +00:00
Chris Lattner c81f079d7e move void argument checking from the parser to the semantic analysis stage.
This allows us to handle typedefs of void correctly.  This implements
clang/test/Sema/void_arg.c

llvm-svn: 39236
2006-12-03 02:43:54 +00:00
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 a606ac0fe3 finesse the interface to Declarator for function declarators so that the
declarator interface handles all alloc/dealloc issues related to the argument
list.  Before the client had to alloc and Declarator did the dealloc.

llvm-svn: 39234
2006-12-02 08:05:17 +00:00
Chris Lattner 784b168c92 new testcase
llvm-svn: 39233
2006-12-02 07:59: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 216d8654fd implement ParseParamDeclaratorType in the ast builder
llvm-svn: 39231
2006-12-02 06:47:41 +00:00
Chris Lattner cbc426d4f7 Next step of retaining information about function prototypes: actually retain
the info.  Also, call Actions.ParseParamDeclaratorType instead of
Actions.ParseDeclarator for parameter type lists: we don't want declaration
objects created when parsing a function declarator, we just want type info.

llvm-svn: 39230
2006-12-02 06:43:02 +00:00
Chris Lattner edc9e39d88 First step towards accurately retaining information about function
parameters: build an array of ParamInfo structures and pass it to the
declarator for safe keeping (it owns the list).

Next step: actually populate the arg array with useful stuff.

llvm-svn: 39229
2006-12-02 06:21:46 +00:00
Chris Lattner cd3ea0cf35 doing this makes the diagnostics too verbose for no useful gain.
llvm-svn: 39228
2006-11-28 05:36:12 +00:00
Chris Lattner b20e89449f capture sourcelocation info for type specifiers. This improves diagnostics
for things like 'short _Complex'.

llvm-svn: 39227
2006-11-28 05:30:29 +00:00
Chris Lattner 60809f5aaf record location info for const/volatile/restrict
llvm-svn: 39226
2006-11-28 05:18:46 +00:00
Chris Lattner 1b22eed03c add loc info for the inline specifier, fix some fixme's by using it.
llvm-svn: 39225
2006-11-28 05:12:07 +00:00
Chris Lattner 4d8f873b5b record accurate sourceloc info for storage class specs, so we can report
things like:

t.c:4:10: error: invalid storage class specifier in function declarator
int foo2(auto int Aaslfkasdflkj, register B);
         ^

instead of:

t.c:4:19: error: invalid storage class specifier in function declarator
int foo2(auto int Aaslfkasdflkj, register B);
                  ^

llvm-svn: 39224
2006-11-28 05:05:08 +00:00
Chris Lattner 353f5740b1 Finish converting DeclSpec to use accessors.
llvm-svn: 39223
2006-11-28 04:50:12 +00:00
Chris Lattner a925dc66e4 Convert more code to use DeclSpec accessors
llvm-svn: 39222
2006-11-28 04:33:46 +00:00
Chris Lattner f055d43211 add accessors to DeclSpec, start moving clients over to use them.
llvm-svn: 39221
2006-11-28 04:28:12 +00:00
Chris Lattner 0d0111b8e4 Group declspec ivars together.
llvm-svn: 39220
2006-11-28 04:10:07 +00:00
Chris Lattner 43e956c3b7 verify C99 6.7.5.3p2
llvm-svn: 39219
2006-11-28 04:05:37 +00:00
Chris Lattner 652c16924e Produce a nice error message for '#define and' in C++. Patch by Bill!
llvm-svn: 39218
2006-11-21 23:47:30 +00:00
Chris Lattner bb233fe3aa add some comments.
llvm-svn: 39217
2006-11-21 23:13:27 +00:00
Chris Lattner 2bb8a95389 eliminate string compares when checking for the 'defined' token.
llvm-svn: 39216
2006-11-21 22:24:17 +00:00
Chris Lattner c5b966f893 check minutia of the standard.
llvm-svn: 39215
2006-11-21 17:31:32 +00:00
Chris Lattner 5b9f4891d7 Add support for C++ operator keywords. Patch by Bill Wendling.
llvm-svn: 39214
2006-11-21 17:23:33 +00:00
Chris Lattner 058b4b6b41 run .cpp files as tests
llvm-svn: 39213
2006-11-21 17:22:28 +00:00
Chris Lattner d6775fa217 add note in the output
llvm-svn: 39212
2006-11-21 06:36:58 +00:00
Chris Lattner 00348acace clear file info after processing one file, it shouldn't carry over to the
next.

llvm-svn: 39211
2006-11-21 06:34:57 +00:00
Chris Lattner 2ea9dd7fc0 ProcessInputFile no longer mutates LangInfo.
llvm-svn: 39210
2006-11-21 06:18:11 +00:00
Chris Lattner b352e3edb5 Change KeepComments/KeepMacroComments modes to be facets of the preprocessor
state, not aspects of the language standard being parsed.

llvm-svn: 39209
2006-11-21 06:17:10 +00:00
Chris Lattner ad7cdd37b3 simplify the Preprocessor ctor.
llvm-svn: 39208
2006-11-21 06:08:20 +00:00
Chris Lattner 96327eaa52 first step refactoring driver so that it can process multiple input files
at once.

llvm-svn: 39207
2006-11-21 05:52:55 +00:00
Chris Lattner a92809b1ab add an accessor
llvm-svn: 39206
2006-11-21 05:52:33 +00:00
Chris Lattner 87f267ef4e eliminate global variables now that PPCallbacks can have state
llvm-svn: 39205
2006-11-21 05:02:33 +00:00
Chris Lattner 09d5804683 Make it easier to run tests from the top level with a helper target
llvm-svn: 39204
2006-11-21 05:01:56 +00:00
Chris Lattner b8d6d5a81d Formalize preprocessor callbacks together into a PPCallbacks structure, instead
of having a loose collection of function pointers.  This also allows clients to
maintain state, and reduces the size of the Preprocessor.h interface.

llvm-svn: 39203
2006-11-21 04:09:30 +00:00
Chris Lattner 38495cb2e7 -fsyntax-only is synonym for -parse-ast for now.
llvm-svn: 39202
2006-11-21 04:07:21 +00:00
Chris Lattner 017865fb62 adjust test
llvm-svn: 39201
2006-11-21 04:06:06 +00:00
Chris Lattner b0e7a06e53 Add some standard include paths for C++.
llvm-svn: 39200
2006-11-21 03:40:37 +00:00
Chris Lattner d8702cd845 Implement a TODO: properly invoke actions for the * in things like:
where P is a pointer.

  int A[*P];

llvm-svn: 39199
2006-11-21 03:12:15 +00:00
Chris Lattner a966bf6ebf fix a variable shadowing issue that caused us to misparse:
void B() {
  memcpy (3, 2, 1);
}

where memcpy is undeclared.

llvm-svn: 39198
2006-11-21 01:40:01 +00:00
Chris Lattner 740b2f30c7 When a decl is popped from its current scope, link it to the decl chain for
the containing function.  This avoids leaking decls.

llvm-svn: 39197
2006-11-21 01:32:20 +00:00
Chris Lattner 229ce60fc9 split the ParseFunctionDefinition action into two actions, one which is
called before and one which is called after function definition parsing.

llvm-svn: 39196
2006-11-21 01:21:07 +00:00
Chris Lattner eda517e456 new testcase
llvm-svn: 39195
2006-11-20 07:03:41 +00:00