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

5456 Коммитов

Автор SHA1 Сообщение Дата
Anders Carlsson 6eda8c9cef Add some more diagnostics for va_start, fix tests so they pass with these new diags.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42917 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 17:48:41 +00:00
Fariborz Jahanian bece4ac257 Fixed a bug whereby, struct tag name matches a typedef/objc-class name
and hid them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42915 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 16:34:10 +00:00
Steve Naroff 075878af57 Temporary fix to test case. This area is currently under construction...test case will be changing again soon.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42914 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 16:15:17 +00:00
Fariborz Jahanian 243b64b000 This patch implementa objective-c's @compatibilty-alias declaration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42883 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-11 23:42:27 +00:00
Fariborz Jahanian dfbcce2b55 Implemented parsing of objctive-c protocol conforming type used in
an identifier statement. Fixed up pretty priting to print this type 
correctly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42866 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-11 18:08:47 +00:00
Fariborz Jahanian 4b6c9051c6 Patch to create protocol conforming class types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42856 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-11 00:55:41 +00:00
Chris Lattner 3b427b3ba5 rename -parse-ast-print to -ast-print
rename -parse-ast-dump to -ast-dump
remove -parse-ast, which is redundant with -fsyntax-only



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42852 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-11 00:18:28 +00:00
Steve Naroff e21b573bbf Refinements to Sema::GetObjcIdType()...
- Cache the typedef, not the type (avoids importing AST/Type.h).
- Emit an error if "id" cannot be found.
- Comment the routine and add a FIXME to reconsider how we emulate GCC's new fangled behavior. This isn't a priority for now, since almost no code depends on having "id" built-in.
- Add a test.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42845 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-10 23:24:43 +00:00
Steve Naroff 3b950178e2 - Make sure default return/argument types (for methods) default to "id".
- Cache the "id" type in Sema...initialize ObjcIdType and TUScope (oops).
- Fix ActOnInstanceMessage to allow for "id" type receivers...still work to do (next).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42842 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-10 21:53:07 +00:00
Anders Carlsson 2d85f8ba62 Emit a warning when the body of an if block is a NullStmt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42840 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-10 20:50:11 +00:00
Steve Naroff b216c8861c Make sure methods with no return type default to "id".
This fixes a crasher in Sema::MatchTwoMethodDeclarations(), identified by selector-overload.m (just added).

Added Action::ActOnTranslationUnitScope() and renamed Action::PopScope to ActOnPopScope.

Added a Translation Unit Scope instance variable to Sema (will be very useful to ObjC-related actions, since ObjC declarations are always file-scoped).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42817 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-09 22:01:59 +00:00
Devang Patel 2c30d8fee8 Recognize while(1) and avoid extra blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42811 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-09 20:51:27 +00:00
Devang Patel a2c534223d new test
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42810 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-09 20:37:41 +00:00
Devang Patel c049e4f406 Code gen case statement ranges.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42766 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-08 20:57:48 +00:00
Fariborz Jahanian 245f92a886 This is the first patch toward supporting protocol conforming
objective-c types. It also removes use of Scope* parameter in
getObjCProtocolDecl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42649 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-05 21:01:53 +00:00
Devang Patel 2d79d0f3ac Support case statement ranges.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42648 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-05 20:54:07 +00:00
Fariborz Jahanian 85ff2646c1 Patch for 1) Checking for duplicate methods decls in intterface and category.
2) Use of the new DenseSet<t> abstractions instead of DenseMap<t,char>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42641 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-05 18:00:57 +00:00
Devang Patel 51b09f2c52 switch statement code gen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42616 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-04 23:45:31 +00:00
Fariborz Jahanian b384d329e0 this patch accomodates clattner's comments on expression processing in @try-statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42611 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-04 20:19:06 +00:00
Fariborz Jahanian 4b6df3fa95 Fixed all my recent test cases to have the RUN command and
fixed consequence of these changes in clang.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42600 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-04 00:22:33 +00:00
Fariborz Jahanian ca3adf7e8c Previously, I warned those methods not implemented in implementation class/category.
Now, I also warn those class/categories which are incomplete because of this.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42544 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-02 20:06:01 +00:00
Fariborz Jahanian 8f3fde00ad This patch introduces the ObjcCategoryImplDecl class and does the checking related to
unimplemented methods in category implementation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42531 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-02 16:38:50 +00:00
Fariborz Jahanian 00ae8d5955 Patch to warn on umimplemented methods coming from class's
protocols.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42436 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-28 17:40:07 +00:00
Fariborz Jahanian d0b015461a Patch for method implementation. It populates ObjcImplementationDecl object with method implementation declarations .
It checks and warns on those methods declared in class interface and not implemented.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42412 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-27 18:57:03 +00:00
Chris Lattner a9c0102172 objc messages have side effects, return true from hasLocalSideEffect,
fixing:

VoidMethod.m:14:5: warning: expression result unused
    [Greeter hello];
    ^~~~~~~~~~~~~~~



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42380 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-26 22:06:30 +00:00
Ted Kremenek 9f3d942e99 Removed option "-parse-ast-check" from clang driver. This is now implemented
using "-parse-ast -verify".

Updated all test cases (using a sed script) that invoked -parse-ast-check to
now use -parse-ast -verify.

Fixed a bug where using "-verify" instead of "-parse-ast-check" would not
correctly create the DiagClient needed to accumulate diagnostics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42365 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-26 20:14:22 +00:00
Fariborz Jahanian d0b90bff98 This patch inserts ivars declared in @implementation in its object and verifies
that they conform(in type, name and numbers) to those declared in @interface. 
Test case highlights kind of checking we do here.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42360 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-26 18:27:25 +00:00
Fariborz Jahanian 0da1c10338 Patch to make ObjcImplementationDecl derived from TypeDecl and supprt legacy
objective-c code with no @interface declaration.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42319 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-25 21:00:20 +00:00
Fariborz Jahanian ccb4f31424 This patch introduces a new class to keep track of class implementation info. It also adds more
semantic checks for class and protocol declarations. Test cases are good indications of kind of 
checking being done in this patch.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42311 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-25 18:38:09 +00:00
Chris Lattner f37bb25120 If we see an invalid #ifdef directive, enter a conditional compilation region
so that we don't emit an error on the #endif.  Suggestion by Neil.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42258 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-24 05:14:57 +00:00
Fariborz Jahanian b27c156688 This patch adds to new things to clang:
1. Handles saving and checking on protocols used in an @interface declaration
2. Checks and saves class's super class.
3. Adds semantic check to category declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42218 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-22 00:01:35 +00:00
Fariborz Jahanian 894c57f565 This patch instantiates objects for forward protocols and in general handles use of
protocols referenced in @protocol declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42191 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-21 15:40:54 +00:00
Fariborz Jahanian bd51b8745c Handle forward declaration of classes and prevent re-instantiation of
ObjcInterfaceClass Objects.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42172 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-20 20:26:44 +00:00
Fariborz Jahanian 1d5b0e37cd Match to do some semantic analysis on objective-c class decl.
1. Detect used of undeclared/forward declared super class.
2. Detect duplicate definition of a class.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42168 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-20 17:54:07 +00:00
Fariborz Jahanian 397fcc117e Patch to parse objective-c's @try-statement and @throw-statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42148 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-19 19:14:32 +00:00
Fariborz Jahanian 25e077d59a Patch to add objective-c's @protocl type declaration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42060 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-17 21:07:36 +00:00
Fariborz Jahanian e267ab6246 Semantic analysis for objective-c ivars.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41954 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-14 16:27:55 +00:00
Steve Naroff 410e3e206b Remove a FIXME. Replace a couple asserts with an appropriate error
diagnostic for illegal initializers.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41889 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-12 20:13:48 +00:00
Steve Naroff 3536b443bc The goal of this commit is to get just enough Sema support to recognize Objective-C classes
as types. That said, the AST nodes ObjcInterfaceDecl, ObjcInterfaceType, and ObjcClassDecl are *very*
preliminary.

The good news is we no longer need -parse-noop (aka MinimalActions) to parse cocoa.m.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41752 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-06 21:24:23 +00:00
Fariborz Jahanian a65ff6c81f Patch for parsing objective-c style method calls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41731 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-05 23:08:20 +00:00
Fariborz Jahanian 0ccb27ded1 1. Fix parsing of method prototype involving c-style argument declarations.
2. Fixes all allowable key-words used as selectors.
3. Template to do the messaging parse.
4. A test case for all allowable selector names.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41723 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-05 19:52:07 +00:00
Chris Lattner e39245b067 disable this for now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41701 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-04 16:49:09 +00:00
Steve Naroff 371227d6dc More fun with initializers!
- Fixed many bugs, enhanced test case considerably, added a diagnostic, etc.
- Refactored CheckInitList() into CheckVariableInitList()/CheckConstantInitList().
- Added CheckInitExpr().
- Support for multi-dimensional arrays looking good.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41690 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-04 02:20:04 +00:00
Steve Naroff d35005ece9 Finish getting "array-init.c" to work properly.
Array scalar initialization is now is reasonable shape.

Next step, structure and array of structure initializers.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41681 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-03 01:24:23 +00:00
Steve Naroff 38374b0579 More progress on array initializers.
- Added Expr::isConstantExpr().
- Added type checking for InitListExpr elements.
- Added diagnostic for trying to initialize a variable sized object.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41674 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-02 20:30:18 +00:00
Steve Naroff 6f9f307d52 More semantic analysis of initializers.
Added 2 errors and one warning, updated test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41672 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-02 15:34:30 +00:00
Steve Naroff f009063ab7 Start implementing semantic analysis for C initializers.
Step 1: Start instantiating InitListExpr's.
Step 2: Call newly added function Sema::CheckInitializer() from Sema::ParseDeclarator().
Step 3: Give InitListExpr's a preliminary type.
Step 4: Start emitting diagnostics for simple assignments.

Note:

As a result of step 1, the CodeGen/mandel.c test asserts "Unimplemented agg expr!", which is expected.

As a result of step 4, the test below now fails. This isn't expected and needs to be investigated (it appears type checking for C++ references is flawed in some way).

******************** TEST 'Sema/cxx-references.cpp' FAILED! ********************
Command: 
 clang -fsyntax-only Sema/cxx-references.cpp
Output:
Sema/cxx-references.cpp:8:12: warning: incompatible pointer types assigning 'int &*' to 'int *'
  int *p = &r;
           ^~
Sema/cxx-references.cpp:10:20: error: incompatible types assigning 'int (int)' to 'int (&)(int)'
  int (&rg)(int) = g;
                   ^
Sema/cxx-references.cpp:13:18: error: incompatible types assigning 'int [3]' to 'int (&)[3]'
  int (&ra)[3] = a;
                 ^
Sema/cxx-references.cpp:16:14: error: incompatible types assigning 'int *' to 'int *&'
  int *& P = Q;
             ^
4 diagnostics generated.
******************** TEST 'Sema/cxx-references.cpp' FAILED! ********************




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41671 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-02 02:04:30 +00:00
Chris Lattner 98414c1b7d Fix a bug/missing-feature Ted noticed: the 'unused' warning should not
warn about the last stmt in a stmtexpr, f.e. there should be no warning for:

int maxval_stmt_expr(int x, int y) {
  return ({int _a = x, _b = y; _a > _b ? _a : _b; });
}



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41655 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-31 21:49:55 +00:00
Steve Naroff d7444aac1a Removed Sema::VerifyConstantArrayType(). With the new Array/ConstantArray/VariableArray nodes, this
routine was causing more trouble than it was worth. Anders/Chris noticed that it could return an error code
without emiting a diagnostic (which results in an silent invalid decl, which should *never* happen). In addition,
this routine didn't work well for typedefs and field decls. Lastly, it didn't consider that initializers aren't
in place yet.

Added Type::getAsConstantArrayType(), Type::getAsVariableArrayType(), Type::getAsVariablyModifiedType(),
and Type::isVariablyModifiedType();

Modified Sema::ParseDeclarator() and Sema::ParseField() to use the new predicates. Also added a FIXME for
the initializer omission. Also added a missing test for "static" @ file scope.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41647 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-31 17:20:07 +00:00
Steve Naroff 42471f8bc6 Final phase of array cleanup (for now), removing a FIXME from yesterday.
Moved several array constraints checks from Sema::VerifyConstantArrayType() to
Sema::GetTypeForDeclarator(). VerifyConstantArrayType() is now very simple, and
could be removed eventually.

Now, we get the following (correct) messages for BlockVarDecls:-)

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang x.c -pedantic
x.c:4:20: error: size of array has non-integer type 'float'
  int size_not_int[f];
                   ^
x.c:5:21: error: array size is negative
  int negative_size[1-2];
                    ^~~
x.c:6:17: warning: zero size arrays are an extension
  int zero_size[0];
                ^
3 diagnostics generated.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41624 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-30 22:35:45 +00:00
Chris Lattner d3fb6adc88 a new testcase
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41614 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-30 17:51:09 +00:00
Chris Lattner 054fad5a89 -C mode doesn't return comments on "#" lines, so the diag checker doesn't pick them up.
Test this the hard way.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41605 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-30 06:38:49 +00:00
Neil Booth b94495155d Ensure we diagnose long long literals in C90 mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41581 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-29 22:00:19 +00:00
Ted Kremenek 9b3d3a9f3d Added checking (during parsing) of comparison of floating point values using == or !=.
This is the same functionality gcc provides via --Wfloat-equal.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41574 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-29 18:06:12 +00:00
Chris Lattner d5bbce4382 Teach Type::is[un]SignedIntegerType about enum decls. This allows the code generator
to emit signed comparisons when needed for enum decl references.  This implements
test/CodeGen/enum.c.  I think enums should be good now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41572 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-29 17:48:46 +00:00
Steve Naroff 53a3234f4b Move the "invalid decl" idiom up to Decl (where we have some bits to steal:-)
Converted ParmVarDecl, FileVarDecl, BlockVarDecl, and Sema::ParseIdentifierExpr() to use the idiom.

Updated array-constraint.c to make sure we no longer get "undeclared identifier" errors:-)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41552 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28 18:45:29 +00:00
Chris Lattner 94f81fd0b0 extwarn about VLAs in C89 mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41545 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28 16:54:00 +00:00
Chris Lattner b23deda733 warn about long long when in c89 mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41543 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28 16:40:32 +00:00
Chris Lattner 1e45efa00b new testcase
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41541 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28 16:20:14 +00:00
Chris Lattner ac60968d45 compute the required destination type for an enum, emitting various warnings.
TODO: update the types of the constants and the enum.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41532 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28 06:15:15 +00:00
Chris Lattner ae3b701f59 now that all the infrastructure is in place, enforce C99 6.8.5p3.
Note the FIXME: we need some way to mark a decl erroneous :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41524 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-28 05:03:08 +00:00
Chris Lattner 9cff1a9ac2 add some more testcases now that sema is happier :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41492 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27 16:37:44 +00:00
Chris Lattner 02b3c26e71 testcase that doesn't work quite yet
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41478 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27 05:23:45 +00:00
Chris Lattner c30ebfbf23 extwarn about decls intermixed with code in c89 mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41477 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27 04:29:41 +00:00
Steve Naroff 77878cc5aa Add Type::getAsBuiltinType() and Type::builtinTypesAreCompatible().
Modified Type::typesAreCompatible() to use the above.

This fixes the following bug submitted by Keith Bauer (thanks!).

int equal(char *a, const char *b)
{
    return a == b;
}

Also tweaked Sema::CheckCompareOperands() to ignore the qualifiers when
comparing two pointer types (though it doesn't relate directly to this bug).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41476 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27 04:08:11 +00:00
Chris Lattner 45a566cfcb implement a fixme: __extension__ marker on decls in compound stmts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41473 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-27 01:01:57 +00:00
Chris Lattner 2215325a56 Fix test/Parser/if-scope-*.c. Patch by Neil Booth!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41471 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26 23:08:06 +00:00
Chris Lattner 8ae3a9f8be new testcases
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41465 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26 22:41:57 +00:00
Chris Lattner 6e844adbe9 Fix a bug reported by Keith Bauer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41452 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26 17:32:59 +00:00
Steve Naroff 26b8ff45ba Fix bogus warnings (noticed by Chris) with array-constraints.c.
Remove bogus type conversions in Sema::GetTypeForDeclarator(). This commit
only deals with the array types (DeclaratorCheck::Array), though the
rest of this routine should be reviewed. Given the complexity of C declarators,
I don't want to change the entire routine now (will discuss with Chris tomorrow).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41443 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26 14:38:38 +00:00
Chris Lattner ce7f4cc77f steve's recent changes fixed this bogus warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41432 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26 06:48:28 +00:00
Chris Lattner d28f815705 Cases like this:
char *C;
  C != ((void*)0);

Should not warn about incompatible pointer types.  Also, make sure to
insert an implicit conversion even if the operand is null.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41408 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-26 01:10:14 +00:00
Chris Lattner 9c62c1d628 new testcase
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41406 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-25 21:57:08 +00:00
Steve Naroff ad7ef480b9 Change Expr::isLvalue() to properly deal with ImplicitCastExpr's.
This fixes the following bug...

t.c:1:31: error: expression is not assignable
short x; void foo(char c) { x += c; }

This case, among others are now captured in implicit-casts.c.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41402 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-25 14:37:06 +00:00
Chris Lattner e45fa6af52 reenable this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41397 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-25 05:31:19 +00:00
Chris Lattner 388577b3bd test the parser only, not sema.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41395 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-25 05:26:51 +00:00
Chris Lattner 46f93d021a implement codegen for real/imag. TODO: imag of non-complex.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41376 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-24 21:20:17 +00:00
Chris Lattner 1f1ded9629 Teach emit-llvm for scalars to properly handle compound assignment
operators in all their glory :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41373 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-24 21:00:35 +00:00
Chris Lattner fd90ac054e make this harder
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41346 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-23 23:49:47 +00:00
Chris Lattner 0471f5bc81 finish off switch case overlap checking, adding support for
verifying case ranges.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41331 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-23 18:29:20 +00:00
Chris Lattner 6efc4d3659 detect and diagnose empty case ranges:
switch.c:16:8: warning: empty case range specified
  case 100 ... 99: ;  // expected-warning {{empty case range}}
       ^~~~~~~~~~



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41328 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-23 17:48:14 +00:00
Chris Lattner f334850cd2 fix a segfault in cases where there are no cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41317 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-23 14:29:07 +00:00
Chris Lattner b2ec9d6fed report duplicate case values. TODO: report duplicate/overlapping ranges.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41315 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-23 06:23:56 +00:00
Chris Lattner 99351fdeaf this test is passing, though it is generating bogus code at the moment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41314 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-23 05:47:53 +00:00
Chris Lattner f4021e7d52 start checking case values of switch stmts more closely. Emit overflow
warnings when converting case values to the expression type.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41313 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-23 05:46:52 +00:00
Chris Lattner e389201e39 run .m files as tests
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41308 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-23 01:09:45 +00:00
Chris Lattner d818a7114f Test that cocoa parses with -parse-noop. In the future
(when ready) this test should change to test -fsyntax-only.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41307 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-23 01:08:54 +00:00
Chris Lattner a36ce713cf Fix a nasty C99 scope issue that Neil pointed out (for ifs)
This fixes test/Parser/control-scope.c


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41263 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-22 05:16:28 +00:00
Chris Lattner 2f9d5fe98e add a testcase I forgot to check in long ago
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41219 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 05:56:30 +00:00
Chris Lattner 2b8bac52b8 we now correctly emit:
unused-expr.c:8:6: warning: comparison of distinct pointer types ('int volatile *' and 'int *')
  VP == P;
  ~~ ^  ~




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41210 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 01:19:46 +00:00
Chris Lattner 7016a706c9 Fix array->pointer decay. This unbreaks test/CodeGen/array.c
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41202 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-20 22:37:10 +00:00
Ted Kremenek f8f9517d7d Added test cases for the return-stack-address checker to test support
for the following C++ casts: static_cast, reinterpret_cast, and const_cast.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41181 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-20 16:28:05 +00:00
Ted Kremenek 4774b4df07 Added extra test case to check proper handling of archaic array indexing: 4[A]
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41147 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-17 22:17:23 +00:00
Anders Carlsson 71993dd85e Add initial support for constant CFStrings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41136 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-17 05:31:46 +00:00
Steve Naroff e77fd3c15c Fixed Sema::CheckEqualityOperands() and Sema::CheckRelationalOperands() to deal more
thoughtfully with incompatible pointers. This includes:

- Emit a diagnostic when two pointers aren't compatible!
- Promote one of the pointers/integers so we maintain the invariant expected by the 
code generator (i.e. that the left/right types match).
- Upgrade the pointer/integer comparison diagnostic to include the types. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41127 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-16 21:48:38 +00:00
Ted Kremenek 71895b9aa3 Added support for additional format string checking for the printf
family of functions.  Previous functionality only included checking to
see if the format string was a string literal.  Now we check parse the
format string (if it is a literal) and perform the following checks:

(1) Warn if: number conversions (e.g. "%d") != number data arguments.

(2) Warn about missing format strings  (e.g., "printf()").

(3) Warn if the format string is not a string literal.

(4) Warn about the use se of '%n' conversion.  This conversion is
    discouraged for security reasons.

(5) Warn about malformed conversions.  For example '%;', '%v'; these
    are not valid.

(6) Warn about empty format strings; e.g. printf("").  Although these
    can be optimized away by the compiler, they can be indicative of
    broken programmer logic.  We may need to add additional support to
    see when such cases occur within macro expansion to avoid false
    positives.

(7) Warn if the string literal is wide; e.g. L"%d".

(8) Warn if we detect a '\0' character WITHIN the format string.

Test cases are included.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41076 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-14 17:39:48 +00:00
Chris Lattner 954698cd84 xfail this for now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41015 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-11 00:05:07 +00:00
Chris Lattner c3018153a1 add support for a top-level __extension__ marker, implementing a todo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41004 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-10 20:57:02 +00:00
Chris Lattner 59907c4d8f initial support for checking format strings, patch by Ted Kremenek:
"I've coded up some support in clang to flag warnings for non-constant format strings used in calls to printf-like functions (all the functions listed in "man fprintf").  Non-constant format strings are a source of many security exploits in C/C++ programs, and I believe are currently detected by gcc using the flag -Wformat-nonliteral."



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41003 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-10 20:18:51 +00:00
Chris Lattner 009e9f7e45 Build ASTs before relexing the file. This avoids having comment finding mutate the
preprocessor state, causing bogus diagnostics when the file is parsed for real.  This
implements Misc/diag-checker.c.  Thanks to Ted for noticing this.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41000 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-10 18:27:41 +00:00
Chris Lattner cff944ba26 fix this test to pass.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40996 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-10 17:18:58 +00:00
Chris Lattner 12b2be25f8 make this harder
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40994 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-10 17:02:59 +00:00
Steve Naroff 13b7c5ff42 Finish implementing __builtin_classify_type()...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40951 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-08 22:15:55 +00:00
Steve Naroff 69625f4925 Make sure the good old "function/array conversion" is done to function parameters.
This resulted in the following error...

[dylan:clang/test/Parser] admin% cat parmvardecl_conversion.c 
// RUN: clang -parse-ast-check %s

void f (int p[]) { p++; }

[dylan:clang/test/Parser] admin% clang -parse-ast-check parmvardecl_conversion.c 
Errors seen but not expected:
  Line 3: cannot modify value of type 'int []'

With this fix, the test case above succeeds.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40831 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-05 02:16:31 +00:00
Chris Lattner 345dc62fd5 the sse intrinsics are missing, leading to errors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40800 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-04 00:19:10 +00:00
Chris Lattner 52e3de597c fix hang in testsuite
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40799 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-04 00:18:28 +00:00
Steve Naroff 608e0ee4b4 Restrict vector component access (using "." and "[]") to variables.
Chris suggested this, since it simplifies the code generator.
If this features is needed (and we don't think it is), we can revisit.

The following test case now produces an error.
[dylan:~/llvm/tools/clang] admin% cat t.c

typedef __attribute__(( ocu_vector_type(4) )) float float4;

static void test() {
    float4 vec4;

    vec4.rg.g;
    vec4.rg[1];
}
[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang t.c
t.c:8:12: error: vector component access limited to variables
    vec4.rg.g;
           ^~
t.c:9:12: error: vector component access limited to variables
    vec4.rg[1];
           ^~~
2 diagnostics generated.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40795 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 22:40:33 +00:00
Steve Naroff d04fdd5f99 Implement __builtin_choose_expr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40794 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 21:21:27 +00:00
Steve Naroff 441995e92e Add a test case to validate code gen for typeof/builtin_types_compatible.
This test case currently generates the following unexpected warnings (when compared with gcc).

[dylan:clang/test/Parser] admin% ../../../../Debug/bin/clang -parse-ast-check builtin_types_compatible.c
Warnings seen but not expected:
  Line 28: expression result unused
  Line 29: expression result unused
  Line 30: expression result unused
  Line 31: expression result unused
  Line 32: expression result unused
  Line 33: expression result unused



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40789 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 18:38:22 +00:00
Chris Lattner 90997ac90d testcase for vector element access stuff.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40783 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-03 16:42:43 +00:00
Chris Lattner f13ebf03b7 oops, this is the real fix.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40766 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 22:41:43 +00:00
Chris Lattner 6f66c26c94 update test
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40765 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 22:36:03 +00:00
Chris Lattner 281a492261 make sure we don't lose the ability to parse carbon.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40759 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-02 21:40:29 +00:00
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