Граф коммитов

43 Коммитов

Автор SHA1 Сообщение Дата
Steve Naroff 8d1a3b8ca1 Two typeof() related changes...
- Changed the name of ASTContext::getTypeOfType(Expr*)->getTypeOfExpr().
- Remove FIXME for TypeOfExpr::getAsStringInternal(). This will work fine for printing the AST. It isn't ideal
for error diagnostics (since it's more natural to display the expressions type). 

One "random" (or at least delayed:-) change...

- Changed all "ext_typecheck_*" diagnostics from EXTENSION->WARNING. Reason: Since -pedantic is now
off (by default), these diagnostics were never being emitted (which is bad). With this change, clang will
emit the warning all the time. The only downside (wrt GCC compatibility) is -pedantic-errors will not turn
this diagnostics into errors (a "feature" of making tagging them with EXTENSION). When/if this becomes
an issue, we can revisit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40676 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-01 17:20:42 +00:00
Steve Naroff 2cb64ecc86 Tighten up Parser::ParseTypeofSpecifier().
Add some more tests to typeof.c. Also added a couple of missing "expect" attributes that caused the test to fail.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40656 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-31 23:56:32 +00:00
Steve Naroff d1861fd633 Add parsing and AST support for GNU "typeof".
Many small changes to lot's of files.
Still some FIXME's, however the basic support is in place.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40631 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-31 12:34:36 +00:00
Steve Naroff fec0b49c3f Finish up semantic analysis for vector components.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40584 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-30 03:29:09 +00:00
Steve Naroff e1b31fedbc Implement syntax/semantic analysis for OCU Vector Components.
Next step, AST support...



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40568 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-27 22:15:19 +00:00
Chris Lattner eca996743d don't expect to be able to reparse arbitrary system headers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40511 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-26 05:59:05 +00:00
Chris Lattner e80a59cc41 Fix a couple of bugs, add some new cool stuff.
1. Fix a todo in Parser::ParseTag, to recover better.  On code like
   that in test/Sema/decl-invalid.c it causes us to return a single
   error instead of multiple.
2. Fix an error in Sema::ParseDeclarator, where it would crash if the
   declarator didn't have an identifier.  Instead, diagnose the problem.
3. Start adding infrastructure to track the range of locations covered
   by a declspec or declarator.  This is mostly implemented for declspec,
   but could be improved, it is missing for declarator.

Thanks to Neil for pointing out this crash.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40482 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-25 00:24:17 +00:00
Steve Naroff 700204c74b Fix Sema::ParseCallExpr()...it wasn't doing the default array/function promotions on it's argument types.
This resulted in the following errors when compiling promote_types_in_proto.c test...

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang test/Parser/promote_types_in_proto.c 
test/Parser/promote_types_in_proto.c:7:24: error: incompatible types passing 'char *[]' to function expecting 'char *const []'
        arrayPromotion(argv);
        ~~~~~~~~~~~~~~ ^~~~
test/Parser/promote_types_in_proto.c:8:27: error: incompatible types passing 'void (char *const [])' to function expecting 'void (char *const [])'
        functionPromotion(arrayPromotion);
        ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~
2 diagnostics generated.

When fixing this, noticed that both ParseCallExpr() and ParseReturnStmt() were prematurely comparing types for
equivalence. This is incorrect (since the expr. promotions haven't been done yet). To fix this, I moved the
check "down" to Sema::CheckAssignmentConstraints().

I also converted Type::isArrayType() to the modern API (since I needed it). Still more Type predicates to 
convert.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40475 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-24 21:46:40 +00:00
Chris Lattner ab18c4c0ac implement ast building and trivial semantic analysis of stmt exprs.
This implements test/Sema/stmt_exprs.c



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40465 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-24 16:58:17 +00:00
Chris Lattner 8a87e57beb correctly verify that default and case are in a switchstmt,
this fixes test/Sema/switch.c.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40438 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-23 17:05:23 +00:00
Chris Lattner 706ab50019 implement a missing feature in the #include handler, where
it did not handle <xyz> headers coming from macro expansions.
This requires special treatment, as the include name is lexed
as multiple tokens, which require reassembly before processing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40418 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-23 04:56:47 +00:00
Anders Carlsson c1fcb77626 Refactor switch analysis to make it possible to detect duplicate case values
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40388 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 07:07:56 +00:00
Chris Lattner 95cfb85ad1 Catch goto's with a missing identifier, patch by Neil Booth.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40381 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-22 04:13:33 +00:00
Chris Lattner 8146b6851e Fix a lexer bug where we incorrectly rejected
int i = /*/ */ 1;

Thanks to Neil for pointing this out.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40379 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 23:43:37 +00:00
Chris Lattner 4fc37c5158 testcase from neil
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40173 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 05:32:22 +00:00
Chris Lattner d472b31d80 Fix off-by-one error when emitting diagnostics. Also, make diagnostic
a bit nicer for people who pass lots of extra arguments to calls by 
selecting them all instead of just the first one:

arg-duplicate.c:13:13: error: too many arguments to function
  f3 (1, 1, 2, 3, 4);   // expected-error {{too many arguments to function}}
            ^~~~~~~

This implements test/Sema/arg-duplicate.c, thanks to Neil for pointing
out this crash.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40136 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 03:09:58 +00:00
Chris Lattner 0fa152e72b Two fixes:
1) fix a crash on test/Sema/default.c by making
   sure that the switch scope is non-null.
2) if there is an error sema'ing a default or case stmt,
   make sure to return the substmt up, so that the error
   recovery code has more acurate info to continue with.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40134 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-21 03:00:26 +00:00
Chris Lattner 2b64fdc499 Fix a stringizing bug that Neil noticed. We should preprocess this:
#define t(x) #x
t(a
c)

to "a c", not "ac".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40060 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 16:11:58 +00:00
Steve Naroff 4aa88f8d84 Work towards fixing crasher with compound literals...
Before this commit, we crashed in ParseBinOp...

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang -parse-ast-check compound_literal.c
SemaExpr.cpp:1298: failed assertion `(rhs != 0) && "ParseBinOp(): missing right expression"'

With this commit, we still crash in the newly added action ParseCompoundLiteral (which is progress:-)

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang -parse-ast-check compound_literal.c
SemaExpr.cpp:478: failed assertion `(Op != 0) && "ParseCompoundLiteral(): missing expression"'

The crash go away once the actions return AST nodes. I will do this in a separate commit.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40032 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 01:06:55 +00:00
Chris Lattner 5265af5b55 Fix a crasher that Neil reported: Sema::GetTypeForDeclarator should never
return a null type.  If there is an error parsing the type, pick a new type
for error recovery purposes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40029 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 00:42:40 +00:00
Chris Lattner 0ea793e5e3 Correctly respect C99 5.1.1.2p4 when searching for the first '(' of
a function-like macro invocation.  Patch contributed by Neil Booth.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40026 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-19 00:07:36 +00:00
Chris Lattner 9697a5c457 I forgot to check this in earlier
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39958 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 04:58:06 +00:00
Bill Wendling 08ad47cbd1 Fix references:
According to the spec (C++ 5p6[expr]), we need to adjust "T&" to
    "T" before further analysis. We do this via the "implicit cast"
    thingy.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39953 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-17 03:52:31 +00:00
Steve Naroff 16beff8408 Implement semantic analysis for the cast operator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39943 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 23:25:18 +00:00
Chris Lattner 136f93a2b6 Make octal constant lexing use AdvanceToTokenCharacter to give more
accurate diagnostics.  For test/Lexer/comments.c we now emit:

int x = 000000080;  /* expected-error {{invalid digit}} */
               ^
constants.c:7:4: error: invalid digit '8' in octal constant
00080;             /* expected-error {{invalid digit}} */
   ^


The last line is due to an escaped newline.  The full line looks like:

int y = 0000\
00080;             /* expected-error {{invalid digit}} */


Previously, we emitted:
constants.c:4:9: error: invalid digit '8' in octal constant
int x = 000000080;  /* expected-error {{invalid digit}} */
        ^
constants.c:6:9: error: invalid digit '8' in octal constant
int y = 0000\
        ^

which isn't too bad, but the new way is better for the user,
regardless of whether there is an escaped newline or not.

All the other lexer-related diagnostics should switch over 
to using AdvanceToTokenCharacter where appropriate.  Help
wanted :).

This implements test/Lexer/constants.c.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39906 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 06:55:01 +00:00
Chris Lattner 1467e03df1 add required directories to the path automatically, so the user doesn't need to worry about it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39901 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 04:35:52 +00:00
Chris Lattner d4b80f1a0e Add support for C++'0x keywords, patch by Doug Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39897 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-16 04:18:29 +00:00
Chris Lattner 26dc7b3926 Remove an extraneous QualType from CastExpr, it's type is always
the result type of the expr node.

Implement isIntegerConstantExpr for ImplicitCastExpr nodes the same
was as for CastExpr nodes.

Implement proper sign/zero extension as well as truncation and noop
conversion in the i-c-e evaluator.  This allows us to correctly
handle i-c-e's like these:

char array[1024/(sizeof (long))];
int x['\xBb' == (char) 187 ? 1: -1];

this implements test/Sema/i-c-e2.c



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39888 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-15 23:54:50 +00:00
Gabor Greif d5e0d9854c add FIXME and un-XFAIL test
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39858 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-14 20:05:18 +00:00
Bill Wendling 11f2dfefc9 Add missing directory
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39853 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-14 09:37:10 +00:00
Chris Lattner 8bf9f079f1 Improve char literal pretty printing, patch by Keith Bauer!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39846 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-13 23:58:20 +00:00
Gabor Greif b02d4b4bdf fix type of main, use !=
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39842 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-13 23:40:27 +00:00
Gabor Greif 4db18f279b implement _Complex * == and !=
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39841 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-13 23:33:18 +00:00
Gabor Greif bacfa02138 a simple _Complex testcase
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39836 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-13 22:15:44 +00:00
Chris Lattner 7a543ad55a Unspecified type specs default to int. This fixes a crash
on test/Sema/implicit-int.c



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39833 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-13 21:02:29 +00:00
Chris Lattner 8da1cb6339 Check in these testcases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39829 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-13 20:18:44 +00:00
Chris Lattner a63ff1486d new testcase that crashes the cfe due to implicit conversion fun
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39826 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-13 20:11:01 +00:00
Chris Lattner fa7c64562d "Someone typed "PtrToInt" where they meant "IntToPtr".
I've added a tests/CodeGen directory, and a test for this case that
used to fail and now passes."

Patch by Keith Bauer



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39794 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-13 03:25:53 +00:00
Chris Lattner a7fa381a50 update tests
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39786 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-12 16:52:08 +00:00
Chris Lattner e8fdbba7d7 -pedantic no longer defaults to on.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39785 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-12 16:49:27 +00:00
Chris Lattner 2b80ec2192 update test
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39784 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-12 16:48:52 +00:00
Chris Lattner 9623feb09f don't pick up random stuff in .svn directories.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39783 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-12 16:46:07 +00:00
Reid Spencer 5f016e2cb5 Stage two of getting CFE top correct.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39734 91177308-0d34-0410-b5e6-96231b3b80d8
2007-07-11 17:01:13 +00:00