Commit Graph

647 Commits

Author SHA1 Message Date
Chris Lattner 871e0ceffb explicitly document that return statement argument does not necessarily follow the result type of the function. Add testcase.
llvm-svn: 46823
2008-02-06 21:20:34 +00:00
Eli Friedman 220ee41011 Fix the codegen of structs with flexible array members.
llvm-svn: 46806
2008-02-06 05:33:51 +00:00
Eli Friedman d49a720d52 Be a bit stricter about array type compatibility.
llvm-svn: 46799
2008-02-06 04:53:22 +00:00
Chris Lattner a5e4d30942 Finish off the refactoring of type handling stuff. Now we recompile every
tag decl after it has been completed

llvm-svn: 46798
2008-02-06 04:51:19 +00:00
Chris Lattner b5eda6253b pull .ll and .bc writing out of the ASTConsumer destructors into some top
level code in clang.  This is a cleanup, but does implement "-o" for 
-emit-llvm.  One effect of this is that "clang foo.c -emit-llvm" will now
emit into foo.ll instead of stdout.  Use "clang foo.c -emit-llvm -o -" or 
"clang < foo.c -emit-llvm" to get the old behavior.

llvm-svn: 46791
2008-02-06 01:42:25 +00:00
Steve Naroff e6016798bf Fix Parser::ParseObjCTryStmt() to allow for trailing @-keyword statements/expressions.
This bug fix is the result of not having 2-token lookahead to recognize specific @-keywords.

llvm-svn: 46768
2008-02-05 21:27:35 +00:00
Chris Lattner b1537ebdd4 rewrite some of the type refinement code to eliminate dangling pointers
simplify the code and generally make it more robust.

llvm-svn: 46745
2008-02-05 08:06:13 +00:00
Chris Lattner b977b6a59b Relax an assertion, fixing PR1968
llvm-svn: 46742
2008-02-05 06:37:34 +00:00
Devang Patel a703a67384 Cleanup InitListExpr code generation code.
Handle padding fields while initializing struct (fix PR 1962)

llvm-svn: 46736
2008-02-05 02:39:50 +00:00
Christopher Lamb da8e5d979e Add ending newline to test.
llvm-svn: 46692
2008-02-04 02:35:11 +00:00
Christopher Lamb 025b5fb883 Add experimental support for address space qualified types. Address space
qualifiers use the __attribute__((address_space(id))) syntax.

llvm-svn: 46691
2008-02-04 02:31:56 +00:00
Chris Lattner c43926fe67 Implement support for __extension__ which silences extwarnings in its
scope.  This is part of the fix for PR1966

llvm-svn: 46669
2008-02-02 20:20:10 +00:00
Anders Carlsson 6fa0813186 Add RUN line.
llvm-svn: 46663
2008-02-02 04:49:12 +00:00
Chris Lattner bfc2d8acd9 testcase for previous patch.
llvm-svn: 46662
2008-02-02 04:45:42 +00:00
Anders Carlsson 53fef5d9d6 Add trailing newline.
llvm-svn: 46652
2008-02-01 23:27:51 +00:00
Anders Carlsson 0b05d041f2 Only OCU vectors can be splatted.
llvm-svn: 46651
2008-02-01 23:17:55 +00:00
Steve Naroff edb5bc6f09 Fix two rewriter bugs with @catch.
- Support @catch(...), rather than crash:-)
- Make sure all catch bodies get rewritten. This "fix" is really a workaround until the iterator for the "try" AST is fixed. Will fix this in a separate commit.

llvm-svn: 46644
2008-02-01 20:02:07 +00:00
Ted Kremenek e9a709a0c5 Moved "Rewriter" tests from test/Sema to test/Rewriter.
llvm-svn: 46640
2008-02-01 17:05:54 +00:00
Anders Carlsson 806700f973 It is allowed to get the address of an array subscript, even if the array has the register qualifier, if the array is really a pointer.
llvm-svn: 46634
2008-02-01 07:15:58 +00:00
Chris Lattner a347834869 make some diagnostics more terse, update testcases.
Fix Sema::ActOnInstanceMessage to correctly do things in terms of canonical 
types, fixing bogus errors like:

NSDistantObject.m:10383:120: error: bad receiver type 'typeof((id<NSMutableCopying>)self)'
    id mess = ({ id __inv__ = ((void *)0); id __mb__ = _NSMessageBuilder((id <NSMutableCopying>)self, &__inv__); (void)[(__typeof__((id <NSMutableCopying>)self))__mb__ mutableCopyWithZone:((void *)0)]; if (!objc_collecting_enabled()) object_dispose(__mb__); __inv__; });

llvm-svn: 46633
2008-02-01 06:57:39 +00:00
Ted Kremenek 81f0550cdd Added back 'CodeGen' to test suite (accidentally removed in my last patch).
llvm-svn: 46631
2008-02-01 06:37:46 +00:00
Ted Kremenek effdafa62a Implemented casts for ConcreteInt and ConcreteIntLValue.
Implemented '==' and '!=' for ConcreteIntLValue.

llvm-svn: 46630
2008-02-01 06:36:40 +00:00
Chris Lattner 7f024fe0c6 Fix PR1965: missing diagnostics for parameters that are missing
type specifiers.  This required updating some (buggy) tests, and the
testcase was previously accidentally committed.

llvm-svn: 46603
2008-01-31 06:10:07 +00:00
Chris Lattner 4973fb9273 Fix a bogus test
llvm-svn: 46602
2008-01-31 06:06:29 +00:00
Chris Lattner a779d69029 Fix a rewriter crash when the whole body of a foreach is itself
rewritten, as in Sema/rewrite-foreach-6.m.  Fariborz/Steve,
please review this to see if it is sane.

llvm-svn: 46600
2008-01-31 05:10:40 +00:00
Chris Lattner a94035bbb8 Fix PR1921 by promoting negative indices to intptrty.
llvm-svn: 46599
2008-01-31 04:12:50 +00:00
Steve Naroff 2a2c5b98ee Fix test case and add a FIXME.
llvm-svn: 46577
2008-01-30 21:50:43 +00:00
Lauro Ramos Venancio 86b99c1b79 getLLVMFieldNo can't be called before emitting the base value.
llvm-svn: 46576
2008-01-30 21:23:20 +00:00
Lauro Ramos Venancio f5291d2871 A pointer to an opaque type is an "opaque type definition".
llvm-svn: 46575
2008-01-30 21:21:08 +00:00
Eli Friedman 1bc0fed9a5 Fix codegen for conditionals with incommpatible pointer types. Code
that causes this isn't really correct, but if we're going to accept 
this, it should come up with a consistent AST.

llvm-svn: 46557
2008-01-30 17:02:03 +00:00
Chris Lattner 05ba4cbe17 fix a problem reported by Eli, caused by not keeping bool as i1
when in a register.

llvm-svn: 46552
2008-01-30 07:01:17 +00:00
Chris Lattner e850fa2452 make this pass by adding an expected error, add some tests.
llvm-svn: 46551
2008-01-30 06:46:30 +00:00
Steve Naroff 1e7873642b Many refinements to Sema::MergeVarDecl(). This routine still needs some re-work to fully handle tentative decls.
This includes a fix to bz1908.

llvm-svn: 46540
2008-01-30 00:44:01 +00:00
Devang Patel 45a65d2ee1 Handle incomplete struct initializer.
llvm-svn: 46534
2008-01-29 23:23:18 +00:00
Fariborz Jahanian 284011b462 Rewriting of @synchronized. This has one FIXME in it. But this should allow @sychronized to be rewritten.
llvm-svn: 46533
2008-01-29 22:59:37 +00:00
Steve Naroff ddb1dd8c5f Tighten up ASTContext::typesAreCompatible()...it needs to make sure the qualifiers match. The comment and C99 citation for this routine were correct...the code needed to conform to the comment/spec. This fixes the test added below.
Tightening up this routine forced tweaks to Sema::CheckSubtractionOperands() and Sema::CheckCompareOperands(). For example, they both need to operate on the unqualified pointee...

llvm-svn: 46522
2008-01-29 18:58:14 +00:00
Eli Friedman 7031d734ed Fix a bug where CodeGen would attempt to erase an instruction that was
already used.

llvm-svn: 46519
2008-01-29 18:13:51 +00:00
Anders Carlsson a8dc3e6b52 Implement __builtin_offsetof.
llvm-svn: 46515
2008-01-29 15:56:48 +00:00
Chris Lattner 0c8a1edb8b Fix a bug where we would incorrectly emit a "cannot paste" error
message when handling the GNU ", ## __VA_ARGS__" extension.  While
I'm at it, flag uses of this as extensions.

llvm-svn: 46503
2008-01-29 07:54:23 +00:00
Anders Carlsson ce0740e1f5 Handle binary or in constant expressions.
llvm-svn: 46482
2008-01-29 01:33:32 +00:00
Anders Carlsson 0674a7417f Correctly handle constants that refer to enums.
llvm-svn: 46481
2008-01-29 01:28:48 +00:00
Anders Carlsson 6f2a10e8c9 Correctly handle scalars in braces.
llvm-svn: 46480
2008-01-29 01:15:48 +00:00
Steve Naroff f06b5ba047 Fix bz1950. ASTContext::functionTypesAreCompatible() needs to operate on the unqualified parameter types (per C99 6.7.5.3p15).
llvm-svn: 46472
2008-01-29 00:15:50 +00:00
Steve Naroff aeb6b30f64 Fix a bug with struct initializers (in Sema::CheckInitializerListTypes()).
Test case included from bz1948 (thanks Neil!).
Also fixed an 80 column violation...

llvm-svn: 46430
2008-01-28 02:00:41 +00:00
Chris Lattner 77927cc33c Add support for dispatching an objc message to a variable
in an initializer list.

llvm-svn: 46367
2008-01-25 19:43:26 +00:00
Chris Lattner 8917c5ace2 First half of a fix for the "objc message send in initializer" bug. This only
handles message sends with typenames to start with.

llvm-svn: 46366
2008-01-25 19:37:24 +00:00
Fariborz Jahanian cc9c5452d1 Diagnose bad receiver type.
llvm-svn: 46358
2008-01-25 17:43:39 +00:00
Nate Begeman 43eec490fb Support checking and codegen of constant vector globals
llvm-svn: 46343
2008-01-25 05:34:48 +00:00
Steve Naroff 78c6cdf95e Replace Sema::CheckVariableInitList, CheckConstantInitList, and CheckForCharArrayInitializer with CheckInitializerListTypes. The new routine now supports struct/union initializers.
This is a modified version of a patch by Eli Friedman. This version passes all of the clang tests and supports vectors:-)

Note that Eli and I are still unsatisfied the implementation of CheckInitializerListTypes(). We'd like to find a more elegant implementation. Nevertheless, this is a complex part of the standard (and may be hard to simplify). Since the complexity is localized to this routine, we can iterate without too much disruption:-)

llvm-svn: 46339
2008-01-25 00:51:06 +00:00
Chris Lattner 3efff5472b Fix a bug recovering from broken code with a goto that Eli reported.
llvm-svn: 46336
2008-01-25 00:01:10 +00:00
Fariborz Jahanian 60a901621f Fixed a nasty bug which took a while to come up with a test case,
diagnose, and took even longer to fix. It has to do with rewriting of a message
receiver which is an 'ivar' reference. Fix, however, is to remove a code which
was not doing the right thing and no longer needed.

llvm-svn: 46279
2008-01-23 20:34:40 +00:00
Chris Lattner 7238225c28 add support for -Wundef.
llvm-svn: 46274
2008-01-23 17:19:46 +00:00
Fariborz Jahanian 0a71ad2e07 Problem with ObjC's type-encoding of nested structs causing infinit recursion.
llvm-svn: 46260
2008-01-22 22:44:46 +00:00
Lauro Ramos Venancio 09af71c2a6 Implement bitfield write.
llvm-svn: 46258
2008-01-22 22:36:45 +00:00
Lauro Ramos Venancio 2ddcb25a3b Implement bitfield read.
llvm-svn: 46257
2008-01-22 20:17:04 +00:00
Chris Lattner 97ff7763dc Fix PR1936, a crash on malformed #if. Thanks to Neil for
noticing this!

llvm-svn: 46256
2008-01-22 19:34:51 +00:00
Steve Naroff f9eb598de3 Sema::CheckInitializerTypes(). Start simpliying and cleaning up...
llvm-svn: 46234
2008-01-21 23:53:58 +00:00
Fariborz Jahanian 7718e36e25 Elimate bogus warning when va_start is correctly used in
a method.

llvm-svn: 46232
2008-01-21 22:59:53 +00:00
Lauro Ramos Venancio 37bae3e8aa Simplify the bitfield codegen.
llvm-svn: 46230
2008-01-21 22:54:57 +00:00
Fariborz Jahanian eab81cd03f Synthesize methods with va-arg list correctly.
llvm-svn: 46212
2008-01-21 20:14:23 +00:00
Steve Naroff c7d2df23f8 Fix two bugs with an @throw that doesn't have a statement.
- ObjCAtThrowStmt::getSourceRange() needs to check if it has a statement (and not go "boom":-)
- RewriteTest::RewriteObjCThrowStmt() needs to generate refer to the current exception. 

llvm-svn: 46184
2008-01-19 00:42:38 +00:00
Steve Naroff acb6fa6bea Sema::FinalizeDeclaratorGroup(): Tighten up the tentative definition rule when dealing with arrays.
Bug submitted by Eli.

llvm-svn: 46179
2008-01-18 20:40:52 +00:00
Anders Carlsson 60bfc161a0 Assert that the type of the cast is equal to the _unqualified_ type of the subexpression. Fixes a problem spotted by Nuno Lopes.
llvm-svn: 46158
2008-01-18 02:25:57 +00:00
Steve Naroff b716fbab44 Sema::FinalizeDeclaratorGroup()...make sure we emit an diagnostic for tentative definitions with incomplete types. Touch up all test cases that are effected.
llvm-svn: 46152
2008-01-18 00:39:39 +00:00
Fariborz Jahanian 9a5124a67e Don't ICE on missing interface declaration when declaring one of its protocols.
llvm-svn: 46141
2008-01-17 20:33:24 +00:00
Steve Naroff 1aa1941889 Declarator::clear(): Null out variable after it's been deleted.
This avoids a double free (which is good:-)

Bug submitted by Eli.

llvm-svn: 46105
2008-01-17 00:36:28 +00:00
Steve Naroff 8a0abea999 Type::isArithmeticType(): disallow incomplete enum decls.
Bug submitted by Eli.

llvm-svn: 46102
2008-01-16 23:54:22 +00:00
Chris Lattner a65e1f3b31 Move promoteExprToType from being a static method in SemaExpr.cpp to being
a method named ImpCastExprToType in Sema.

Use this method to insert implicit casts for case statements from their 
operand type to the condition type of the switch.  This fixes a crash on
test/CodeGen/statements.c, reported by Eli Friedman.

llvm-svn: 46083
2008-01-16 19:17:22 +00:00
Steve Naroff 17832a48f8 Sema::MergeFunctionDecl()...make sure diagnostic is accurate (wrt function declarations/definitions). Patch by Carl Lewis!
llvm-svn: 46070
2008-01-16 15:01:34 +00:00
Fariborz Jahanian b860cbf052 Added support for rewriting of continue/break statements inside ObjC2's foreach-stmt.
llvm-svn: 46037
2008-01-15 23:58:23 +00:00
Steve Naroff abefc391dd Finish up handling all permutations of "complex int" (in Sema::UsualArithmeticConversions()).
A FIXME remains to verify the conversion rules are consistent with GCC.

Thanks to Eli for the new/improved test case...

llvm-svn: 46022
2008-01-15 22:21:49 +00:00
Steve Naroff 6fcfd0581d - Change Type::isComplexType() to exlude GCC's complex integer extension. In general, we will keep the lowest level Type predicates "pure" (i.e. true to the C99 spec).
- Modify Sema::UsualArithmeticConversions() to work with the new definition of Type::isComplexType().

This is a nice cleanup and also fixes a bug submitted by Eli (which I've added to the test suite).

llvm-svn: 46005
2008-01-15 19:36:10 +00:00
Chris Lattner 15346fae70 avoid pasting L + "foo" into L"foo".
llvm-svn: 46000
2008-01-15 05:22:14 +00:00
Steve Naroff 7f988889ef Rework commit r45976, which was incorrect.
- Add Type::isComplexIntegerType(), Type::getAsComplexIntegerType().
- Don't inlude complex types with Type::isIntegerType(), which is too general.
- Use the new predicates in Sema::UsualArithmeticConversions() to recognize/convert the types.

llvm-svn: 45992
2008-01-15 01:41:59 +00:00
Steve Naroff d8c7d484af Make sure Sema::GetTypeForDeclarator() deals with abstract declarators when diagnosing incorrect code.
Bug submitted by Eli.

llvm-svn: 45989
2008-01-14 23:33:18 +00:00
Steve Naroff c28f46c6b4 Teach Type::isIntegerType() about GCC's __complex__ integer extensions...
Bug submitted by Eli.

llvm-svn: 45976
2008-01-14 21:38:57 +00:00
Steve Naroff 012484d6c8 Fix crasher when redefining functions. Not 100% pleased with this solution, but it is clearly an improvement. Will discuss with Chris later.
llvm-svn: 45975
2008-01-14 20:51:29 +00:00
Steve Naroff d32419de0d Record if a compound literal expression is @ file scope. This allows us to implement C99 6.5.2.5p6. This could have been done without modifying the AST (by checking the decl type and passing the info down to isContextExpr), however we concluded this is more desirable.
Bug/patch by Eli Friedman!

llvm-svn: 45966
2008-01-14 18:19:28 +00:00
Steve Naroff 4871fe0b8f Revert r45951, Chris says it violates the C99 spec.
llvm-svn: 45961
2008-01-14 16:10:57 +00:00
Anders Carlsson 1ba25ca171 Add codegen upport for implicit casts to aggregate exprs.
llvm-svn: 45954
2008-01-14 06:28:57 +00:00
Chris Lattner fd65291aa3 Fix ASTContext::typesAreCompatible when analyzing a function type with
proto and function type without proto.  It would never call 
'functionTypesAreCompatible' because they have different type classes.

llvm-svn: 45952
2008-01-14 05:45:46 +00:00
Steve Naroff 090353191c Rewrite Expr::isNullPointerConstant() to deal with multiple levels of explicit casts.
Now, isNullPointerConstant() will return true for the following: "(void*)(double*)0"

llvm-svn: 45951
2008-01-14 02:53:34 +00:00
Steve Naroff 826e91ae04 Change Sema::CheckAddressOfOperation() to respect C99-only addressof rules.
Remove diagnostics from Sema::CheckIndirectionOperand(). C89/C99 allow dereferencing an incomplete type. clang appears to be emulating some incorrect gcc behavior (see below).

void
foo (void)
{
 struct b;
 struct b* x = 0;
 struct b* y = &*x; // gcc produces an error ("dereferencing pointer to incomplete type")
}

With this patch, the above is now allowed.

Bug/Patch by Eli Friedman!

llvm-svn: 45933
2008-01-13 17:10:08 +00:00
Chris Lattner 317e6ba07f Tighten up handling of __func__ and friends: it should be an array
of const char, and it should error if it occurs outside a function.

Is it valid in an objc method?  If so we should handle that too.

llvm-svn: 45910
2008-01-12 18:39:25 +00:00
Chris Lattner a81a0279cc Fix the type of predefined identifiers like __func__. Patch by
Eli Friedman!

llvm-svn: 45906
2008-01-12 08:14:25 +00:00
Fariborz Jahanian 939776756f Recover from user typo not having proper @interface decl and a bad foreach decl.
llvm-svn: 45839
2008-01-10 20:33:58 +00:00
Fariborz Jahanian 2de9a0be09 Remove non-ascii chaaracter from diagnostic
llvm-svn: 45836
2008-01-10 18:10:31 +00:00
Fariborz Jahanian c644ee4992 Warn (as gcc does) when @end does not close anything.
llvm-svn: 45834
2008-01-10 17:58:07 +00:00
Fariborz Jahanian db701b47d2 Pass rewritten output to 'clang' for verification.
llvm-svn: 45794
2008-01-10 00:30:24 +00:00
Fariborz Jahanian 82ae0152a7 Allow messaging expression as foreach's collection expression.
llvm-svn: 45793
2008-01-10 00:24:29 +00:00
Steve Naroff e6b0ec8b5e Fix Sema::ActOnDeclarator() to call MergeFunctionDecl for function decls that aren't in scope. Since C functions are in a flat namespace, we need to give them special treatment (when compared with variables and typedefs).
llvm-svn: 45789
2008-01-09 23:34:55 +00:00
Steve Naroff c6edcbdb5d Fix ASTContext::typesAreCompatible to allow for int/enum compatibility (C99 6.7.2.2p4).
Fix Sema::MergeFunctionDecl to allow for function type compatibility (by using the predicate on ASTContext). Function types don't have to be identical to be compatible...

llvm-svn: 45784
2008-01-09 22:43:08 +00:00
Steve Naroff 08ddb8c55c Teach Sema::ActOnCompoundLiteral about constraint C99 6.5.2.5p3.
llvm-svn: 45782
2008-01-09 20:58:06 +00:00
Chris Lattner 41a1ef0dfe implement proper support for _Bool in memory, which is usually i8, not i1.
This fixes a crash reported by Seo Sanghyeon

llvm-svn: 45778
2008-01-09 18:47:25 +00:00
Fariborz Jahanian 6fa7516bc9 Type-cast RHS of assignment to prevent warning compiling rewritten foreach code.
llvm-svn: 45777
2008-01-09 18:15:42 +00:00
Fariborz Jahanian 22f2347791 Fixed a bug whereby a parethesized collection expression was not being rewritten correctly.
llvm-svn: 45776
2008-01-09 17:50:00 +00:00
Fariborz Jahanian 05d2876ec3 Another test case for testing rewriteing of nested foreach-statement.
llvm-svn: 45769
2008-01-09 00:47:02 +00:00
Fariborz Jahanian a305a5609e Remove dependency on objc.h
llvm-svn: 45767
2008-01-09 00:33:05 +00:00
Steve Naroff 66a26044f8 Teach Expr::isConstantExpr() about CompoundLiterals.
llvm-svn: 45764
2008-01-09 00:05:37 +00:00
Fariborz Jahanian 965a8961c7 Patch to rewrite ObjC2's foreach-stmt.
llvm-svn: 45760
2008-01-08 22:06:28 +00:00