Commit Graph

34 Commits

Author SHA1 Message Date
Chris Lattner bdf8b8d251 Enforce C99 6.7.2.1p2:
t.c:5:8: error: field 'foo' declared as a function
  void foo();
       ^

llvm-svn: 39294
2007-01-24 02:11:17 +00:00
Chris Lattner 1300fb9603 create field decl objects for the members of a struct/union. Diagnose code
like:
struct S { struct S {} X; };

with:
t.c:2:19: error: nested redefinition of 'struct'
struct S { struct S {} X; };
                  ^
t.c:2:1: error: previous definition is here
struct S { struct S {} X; };
^

llvm-svn: 39292
2007-01-23 23:42:53 +00:00
Chris Lattner 7b9ace672b simplify structure body parsing code. Reorganize how tags are processed.
Diagnose redefintion of tag types, e.g.:

t.c:7:8: error: redefinition of 'blah'
struct blah {};
       ^
t.c:1:8: error: previous definition is here
struct blah {
       ^
2 diagnostics generated.

llvm-svn: 39286
2007-01-23 20:11:08 +00:00
Chris Lattner c284e9b905 fix some incorrect assertions
llvm-svn: 39283
2007-01-23 05:14:32 +00:00
Chris Lattner bf0b798b87 There is no need for the Action::TagType enum, use DeclSpec::TST instead.
llvm-svn: 39278
2007-01-23 04:27:41 +00:00
Chris Lattner f34c4da0c3 Finish tag processing. Since it can be shared with C++ Classes and enums,
rename it to ParseTag.

llvm-svn: 39277
2007-01-23 04:08:05 +00:00
Chris Lattner 7e783a1a08 Diagnose mixing of tags. For example, for:
struct blah * P;
union blah *P2;

we now emit:

t.c:2:1: error: redefinition of 'blah' with tag that does not match previous use
union blah *P2;
^
t.c:1:8: error: previous use is here
struct blah * P;
       ^

llvm-svn: 39275
2007-01-23 02:05:42 +00:00
Chris Lattner 8799cf202c When parsing a struct/union tag, we need to know whether the tag is a use
or a definition/declaration of a tag.  This is required to handle
C99 6.7.2.3p11 properly.

llvm-svn: 39274
2007-01-23 01:57:16 +00:00
Chris Lattner ff65b6bc85 Unstack identifiers more carefully when poping scope. Add assertion to catch the bad
case and handle identifiers in the same namespace correctly.  This implements
test/Parser/c-namespace.c

llvm-svn: 39272
2007-01-23 01:33:16 +00:00
Chris Lattner 18b196282f Make name lookup properly obey C namespaces, simplify decl construction by
eliminating the 'next' pointer from the ctor, and add initial support for
parsing struct/union tags.

llvm-svn: 39265
2007-01-22 07:39:13 +00:00
Chris Lattner 99d3177103 Change scopes to maintain decls, not identifiers.
Detect and emit errors when names are redefined in the same scope, e.g.
test/Parser/argument_redef.c, which now emits:

argument_redef.c:4:22: error: redefinition of 'A'
int foo(int A) { int A; }
                     ^
argument_redef.c:4:13: error: previous definition is here
int foo(int A) { int A; }
            ^

llvm-svn: 39257
2007-01-21 22:37:37 +00:00
Chris Lattner f61c8a805d Handle C99 6.7.5.3p10, fixing test/Parser/attributes.c
llvm-svn: 39256
2007-01-21 19:04:43 +00:00
Chris Lattner c5cdf4d092 Next big step in function parsing: create decl objects for parameters,
inserting them into the function body scope and registering them with the
corresponding FunctionDecl.

llvm-svn: 39253
2007-01-21 07:42:07 +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 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 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 353f5740b1 Finish converting DeclSpec to use accessors.
llvm-svn: 39223
2006-11-28 04:50:12 +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 ac18be9ad2 Add support for C90 implicitly defined functions, e.g.:
int A() {
  return X();
}

llvm-svn: 39194
2006-11-20 06:49:47 +00:00
Chris Lattner 0d8b1a1eff remember and pretty-print cast types
llvm-svn: 39191
2006-11-20 04:34:45 +00:00
Chris Lattner 2ebe4bb64d when a typedef name is parsed as part of declspecs, remember the decl for the
typedef.

llvm-svn: 39188
2006-11-20 01:29:42 +00:00
Chris Lattner 5ca17df626 decls should all have types
llvm-svn: 39187
2006-11-19 23:32:49 +00:00
Chris Lattner 591a675b1c remove #include of clang/Parse/DeclSpec.h from clang/AST/Decl.h
llvm-svn: 39186
2006-11-19 23:16:18 +00:00
Chris Lattner da8aa7b3a8 implement RTTI for Decl objects, eliminate some hokey virtual methods.
llvm-svn: 39185
2006-11-19 23:12:30 +00:00
Chris Lattner 200bdc3b90 add an action method for declspecs without declarators, like "struct foo;".
llvm-svn: 39184
2006-11-19 02:43:37 +00:00
Chris Lattner 302b4be4c2 build TypedefDecl objects when parsing typedefs.
Add a parsing fastpath for when we see typedef at the top-level.

llvm-svn: 39182
2006-11-19 02:31:38 +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
Chris Lattner cb6a382b67 introduce a new ASTContext class to hold long-lived ast nodes.
llvm-svn: 39161
2006-11-10 06:20:45 +00:00
Chris Lattner e168f76c2d move the rest of the expr sema to SemaExpr.cpp and the decl processing stuff
to SemaDecl.cpp

llvm-svn: 39159
2006-11-10 05:29:30 +00:00
Chris Lattner 697e5d692b Change courses on how we do semantic analysis. Semantic analysis
fundamentally requires having an AST around, so move all sema to the
AST library.  This is the first step, later steps will be needed to
clean up libast.

llvm-svn: 39150
2006-11-09 06:32:27 +00:00