Commit Graph

816 Commits

Author SHA1 Message Date
Steve Naroff 0dffa442ea Rename diagnostic to reflect it's role...
llvm-svn: 46650
2008-02-01 22:44:48 +00:00
Anders Carlsson 59435b2f9a getPrimaryDecl can return null.
llvm-svn: 46638
2008-02-01 16:01:31 +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
Chris Lattner 617bfc39ff Sema::ActOnInstanceMessage is generally doing bad things with typedefs, but
here I fix just one.  The loop that rips through pointers should use
getAsPointerType() not static_cast<PointerType*> to get the pointee.  This
fixes a crash on a large testcase.

llvm-svn: 46632
2008-02-01 06:43:02 +00:00
Nate Begeman 4cd6689d1f Remainder of the __builtin_overload feedback
llvm-svn: 46601
2008-01-31 05:38:29 +00:00
Steve Naroff e101f9548e Hack Sema::MergeTypeDefDecl() to silently ignore duplicate typedef's in system headers files.
A bizarre, non-standard hook that many compilers appear to implement (sigh:-).

llvm-svn: 46583
2008-01-30 23:46:05 +00:00
Nate Begeman 936b207407 Implement first round of feedback on __builtin_overload
llvm-svn: 46572
2008-01-30 20:50:20 +00:00
Devang Patel 57412cacb6 Add TODO marker so that it is easier to search.
llvm-svn: 46561
2008-01-30 18:00:07 +00:00
Eli Friedman 3780d35306 Ignore __aligned__ with zero arguments in addition to __aligned__ with
one argument.  Lets stuff using pthread.h compile.

llvm-svn: 46559
2008-01-30 17:38:42 +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
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
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
Fariborz Jahanian 48085b86ae AST for @synchronized.
llvm-svn: 46524
2008-01-29 19:14:59 +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 361de6164d Use the canonical type when comparing array types so the comparison
doesn't get confused by typedefs.

llvm-svn: 46502
2008-01-29 07:51:12 +00:00
Steve Naroff 31daee11be Tweak Sema::DefaultArgumentPromotion() to call UsualUnaryConversions(). This makes sure function calls that don't have a prototype get the default function/array conversion.
Patch by Eli Friedman!

llvm-svn: 46489
2008-01-29 02:42:22 +00:00
Steve Naroff 1f7f6929f4 Implement "private extern" on function decls!
llvm-svn: 46464
2008-01-28 21:57:15 +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
Steve Naroff fda820970a Add more support for Apple's "private extern" extension...
llvm-svn: 46371
2008-01-25 22:14:40 +00:00
Fariborz Jahanian cc9c5452d1 Diagnose bad receiver type.
llvm-svn: 46358
2008-01-25 17:43:39 +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
Steve Naroff d9d581fc7b Exclude vectors from Type::isScalar() predicate.
llvm-svn: 46328
2008-01-24 22:55:05 +00:00
Steve Naroff af2a022563 - Add Sema::CheckStringLiteralInit, Sema::IsStringLiteralInit.
- Use previous hooks to simplify Sema::CheckInitializerTypes()...

llvm-svn: 46235
2008-01-22 00:55:40 +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
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
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
Ted Kremenek 32a3358eab Fixed typo introduced by r46133 that caused -Wfloat-equal to break.
llvm-svn: 46134
2008-01-17 17:55:13 +00:00
Nate Begeman 1e36a85f64 Implement basic overload support via a new builtin, __builtin_overload.
__builtin_overload takes 2 or more arguments:
0) a non-zero constant-expr for the number of arguments the overloaded 
   functions will take
1) the arguments to pass to the matching overloaded function
2) a list of functions to match.

The return type of __builtin_overload is inferred from the function whose args
match the types of the arguments passed to the builtin.  For example:

float a;
float sinf(float);
int   sini(int);

float b = __builtin_overload(1, a, sini, sinf);

Says that we are overloading functions that take one argument, and trying to 
pass an argument of the same type as 'a'.  sini() does not match since it takes
and argument of type int.  sinf does match, so at codegen time this will turn
into float b = sinf(a);

llvm-svn: 46132
2008-01-17 17:46:27 +00:00
Fariborz Jahanian ad134b987e Renamed getSynthesizedSelectorSize to getSynthesizedMethodSize. Compute method name
size in accordance with how rewriter synthesizes method name.

llvm-svn: 46131
2008-01-17 17:37:26 +00:00
Ted Kremenek fff70962bb Added method Expr::IgnoreParens(), which returns the first non-ParenExpr Expr*.
Refactored the use of this method into both the Sema module and Analysis module,
which were using their own static functions that did the same thing.

llvm-svn: 46129
2008-01-17 16:57:34 +00:00
Fariborz Jahanian 386699515b Computed length of a __func__ identifier used in an objective-c method correctly,
when creating its type.

llvm-svn: 46109
2008-01-17 01:36:09 +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
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
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
Chris Lattner 49f980c334 Fix build issue on cygwin, patch by Sam Bishop
llvm-svn: 45977
2008-01-14 21:47:29 +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 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 0a8c2325fc allow __func__ in objc methods.
llvm-svn: 45915
2008-01-12 19:32:28 +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
Chris Lattner 38376f1595 Add first pieces of support for parsing and representing
extern "C" in C++ mode.  Patch by Mike Stump!

llvm-svn: 45904
2008-01-12 07:05:38 +00:00
Steve Naroff 98f7203680 - Teach Expr::isConstantExpr() about InitListExpr's (and offsetof, since I noticed it was missing).
- Rename CheckInitializer() to CheckInitializerTypes().
- Removed the isStatic argument to CheckInitializerTypes() and all of it's subroutines. Checking for constant expressions is now done separately.
- Added CheckForConstantInitializer().

llvm-svn: 45840
2008-01-10 22:15:12 +00:00