summaryrefslogtreecommitdiffstats
path: root/clang/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Bug #:Steve Naroff2007-07-091-6/+4
| | | | | | | | | Submitted by: Reviewed by: Fix a bozo bug in HandleDeclAttribute...only install a new type when appropriate. Also changed setType/setUnderlyingType to return void. llvm-svn: 39716
* Bug #:Steve Naroff2007-07-063-15/+37
| | | | | | | | | | | | | | | | | | Submitted by: Reviewed by: - Finished semantic analysis for vectors, added some diagnostics. - Added AST for vectors (instantiation, installation into the decl). - Fixed bug in ParseArraySubscriptExpr()...this crasher was introduced by me when we added the range support. - Turned pedantic off by default. Since vectors are gcc extensions, having pedantic on by default was annoying. Turning it off by default is also consistent with gcc (but this wasn't my primary motivation). - Tweaked some comments and diagnostics. Note: The type checking code is still under construction (for vectors). This will be my next check-in. llvm-svn: 39715
* Submitted by: Bill WendlingBill Wendling2007-06-291-1/+1
| | | | | | | | | | | | Reviewed by: Chris Lattner - Fix for C++ casting operators failing during parsing. Deriving the C++ cast expressions from CastExpr was the wrong way to go. Its constructor creates null QualTypes in one of its constructors. This doesn't work well with how the C++ casting expression class wanted to do things. Derive just from Expr instead. llvm-svn: 39714
* Rename ArithAssignBinaryOperator -> CompoundAssignOperator, implementChris Lattner2007-06-291-1/+1
| | | | | | codegen support for +=. llvm-svn: 39710
* Record the intermediate computation type for compound assignments in the AST.Chris Lattner2007-06-281-38/+36
| | | | | | | | | | | | | For example, for: int test(short S, long L) { return S /= L; } record that the division is done as a long, even though the result type is short. llvm-svn: 39700
* add a method to get more precise arrow positioning for expressions. RenameChris Lattner2007-06-271-2/+1
| | | | | | some ivars to more obvious names, eliminating some comments. llvm-svn: 39685
* First cut at warning about expressions whose results are ignored. For example,Chris Lattner2007-06-272-0/+15
| | | | | | | | | | | | | | | | | | | this produces: warn.c:4:3: warning: expression result unused X == Y; ^~~~~~ warn.c:5:3: warning: expression result unused (void)X; ^~~~~~~ warn.c:11:3: warning: expression result unused A == foo(1, 2); ^~~~~~~~~~~~~~ warn.c:13:3: warning: expression result unused foo(1,2)+foo(4,3); ^~~~~~~~~~~~~~~~~ llvm-svn: 39682
* Finally bite the bullet and make the major change: split the clang namespaceChris Lattner2007-06-158-32/+22
| | | | | | | | | | | | | out of the llvm namespace. This makes the clang namespace be a sibling of llvm instead of being a child. The good thing about this is that it makes many things unambiguous. The bad things is that many things in the llvm namespace (notably data structures like smallvector) now require an llvm:: qualifier. IMO, libsystem and libsupport should be split out of llvm into their own namespace in the future, which will fix this issue. llvm-svn: 39659
* Bug #:Steve Naroff2007-06-131-11/+32
| | | | | | | | | | Submitted by: Reviewed by: Fix CheckRelationalOperands/CheckEqualityOperands to deal with null pointer constants. The new logic also deals (more) correctly for non-pointer/integer operands. llvm-svn: 39654
* Implement support for formal arguments. We can now compile this:Chris Lattner2007-06-132-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | int test(int X, short Y, float Z) { return (int)(X*Y+Z); } to: define i32 @test(i32 %X, i16 %Y, float %Z) { entry: %promote = sext i16 %Y to i32 ; <i32> [#uses=1] %mul = mul i32 %promote, %X ; <i32> [#uses=1] %promote3 = sitofp i32 %mul to float ; <float> [#uses=1] %add = add float %promote3, %Z ; <float> [#uses=1] %conv = fptosi float %add to i32 ; <i32> [#uses=1] ret i32 %conv } with: $ clang -emit-llvm t.c | llvm-as | opt -std-compile-opts | llvm-dis llvm-svn: 39652
* Bug #:Steve Naroff2007-06-132-11/+18
| | | | | | | | | | | | | | Submitted by: Reviewed by: Fixed typechecking bugs wrt UsualUnaryConversions. Includes two distinct fixes: #1: Call UsualUnaryConversions in CheckRelationalOperands/CheckEqualityOperands. #2: UsualArithmeticConversions arguments are now output parameters. This insures the implicit conversion is seen by clients (and fixes bugs in CheckAdditionOperands and CheckSubtractionOperands when doing pointer arithmetic). ~ llvm-svn: 39649
* Implement capturing of enum values and chaining of enums together.Chris Lattner2007-06-112-17/+47
| | | | llvm-svn: 39644
* Bug #:Steve Naroff2007-06-112-2/+89
| | | | | | | | | | | | | | | | | | | | | | | | | Submitted by: Reviewed by: Implement semantic analysis for vector_size attribute! We now produce the following diagnostics... [administrators-powerbook59:~/llvm/tools/clang] admin% ../../Debug/bin/clang vector.c vector.c:2:29: error: attribute requires precisely 1 argument typedef int __attribute__(( vector_size )) tVecp; ^ vector.c:7:32: error: attribute requires precisely 1 argument extern int foo __attribute__(( vector_size )); ^ vector.c:8:34: error: attribute requires precisely 1 argument extern float bar __attribute__(( vector_size(16,18) )); ^ vector.c:11:34: error: vector_size requires integer constant (attribute ignored) extern char foo2 __attribute__(( vector_size(16.2) )); ^ ~~~~ vector.c:21:47: error: invalid vector type 'struct s' struct s { int a; } structVar __attribute__(( vector_size(16) )); llvm-svn: 39643
* GCC accepts code like this as an extension:Chris Lattner2007-06-101-1/+1
| | | | | | | | static int seminal(from, to) { } llvm-svn: 39642
* fix a crash parsing spassChris Lattner2007-06-091-1/+1
| | | | llvm-svn: 39637
* add another exampleChris Lattner2007-06-091-0/+3
| | | | llvm-svn: 39634
* Bug #:Steve Naroff2007-06-093-47/+28
| | | | | | | | | | Submitted by: Reviewed by: Lot's of attribute scaffolding. Modernized ParseArraySubscriptExpr...call DefaultFunctionArrayConversion (which simplified the logic considerably) and upgrade Diags to use the range support. llvm-svn: 39628
* Finally break down and chain together decls that are defined with common ↵Chris Lattner2007-06-092-20/+50
| | | | | | | | | | | declspecs, like: int X, Y, Z; This is required for the code gen to get to all of the declarations in a DeclStmt, and should simplify some other code. llvm-svn: 39623
* factor casts together, add a case for __extension__Chris Lattner2007-06-081-12/+15
| | | | llvm-svn: 39620
* add missing caseChris Lattner2007-06-081-1/+1
| | | | llvm-svn: 39619
* Bug #:Steve Naroff2007-06-063-43/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Submitted by: Reviewed by: The following code illustrates a bug in the semantic analysis for assignments: int func() { int *P; char *x; P = x; // type of this assignment expression should be "int *", NOT "char *". } While the type checking/diagnostics are correct, the type of the assignment expression is incorrect (which shows up during code gen). With the fix, the llvm code looks correct... [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang cast.c -emit-llvm cast.c:4:5: warning: incompatible pointer types assigning 'char *' to 'int *' P = x; // type of assignment expression is "int *", NOT "char *". ~ ^ ~ ; ModuleID = 'foo' define i32 @func() { entry: %P = alloca i32* ; <i32**> [#uses=1] %x = alloca i8* ; <i8**> [#uses=1] %allocapt = bitcast i32 undef to i32 ; <i32> [#uses=0] %tmp = load i8** %x ; <i8*> [#uses=1] %conv = bitcast i8* %tmp to i32* ; <i32*> [#uses=1] store i32* %conv, i32** %P ret i32 undef } Even though the fix was simple, I decided to rename/refactor the surrounding code to make a clearer distinction between constraint checking and conversion. - Renamed AssignmentConversionResult -> AssignmentCheckResult. - Renamed UsualAssignmentConversions -> CheckAssignmentConstraints. - Changed the return type of CheckAssignmentConstraints and CheckPointerTypesForAssignment from QualType -> AssignmentCheckResult. These routines no longer take a reference to the result (obviously). - Changed CheckAssignmentOperands to return the correct type (with spec annotations). llvm-svn: 39601
* On bogus code like this:Chris Lattner2007-06-061-2/+14
| | | | | | | | | | | | | | | | | | | | | int *P2; P2(1, 2, 3); register short X; X(); emit: ds.c:10:3: error: called object is not a function or function pointer P2(1, 2, 3); ^~~~~~~~~~~ ds.c:13:3: error: called object is not a function or function pointer X(); ^~~ instead of aborting. llvm-svn: 39599
* Fix semantic analysis of calls on stuff like:Chris Lattner2007-06-061-2/+4
| | | | | | | | | | int func() { int (*FP)(); FP(); (*****FP)(); } llvm-svn: 39598
* implement codegen of string literals.Chris Lattner2007-06-061-1/+0
| | | | llvm-svn: 39597
* add some fixme's for incorrect semaChris Lattner2007-06-051-0/+3
| | | | llvm-svn: 39591
* Bug #:Steve Naroff2007-06-051-4/+4
| | | | | | | | Submitted by: Reviewed by: Touch up a couple comments (one was incorrect/out-of-date). llvm-svn: 39589
* Rename Sema::isConstantArrayType -> VerifyConstantArrayType. Make sure toChris Lattner2007-06-052-25/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | check canonical types in a few places. Tighten up VerifyConstantArrayType to diagnose more errors, now that we can evaluate i-c-e's. Add some fixmes about poor diagnostics. We now correctly typecheck this example: void s(void) { typedef int a[(int) +1.0]; static a b; // invalid, static VLA static int c[(int) +1.0]; // invalid, static VLA } void t(void) { typedef int a[(int)1.0]; static a b; // valid, constant size } void u() { static int X[-1]; static int Y[0]; } producing: static-vla.c:3:12: error: variable length array declared outside of any function static a b; // invalid, static VLA ^ static-vla.c:5:14: error: variable length array declared outside of any function static int c[(int) +1.0]; // invalid, static VLA ^ ~~~~~~~~~~ static-vla.c:15:14: error: array size is negative static int X[-1]; ^ ~~ static-vla.c:16:14: warning: zero size arrays are an extension static int Y[0]; ^ ~ llvm-svn: 39587
* fix two checks that should be integer-constant-exprs not just c-e's.Chris Lattner2007-06-051-1/+1
| | | | llvm-svn: 39583
* Bug #:Steve Naroff2007-06-043-28/+43
| | | | | | | | | | | | | | | | | | | | | | | Submitted by: Reviewed by: Fixed an "impurity" in the typechecking code (to more closely model the C99 spec)... - Added function Sema::DefaultFunctionArrayConversion(). This is called by UsualUnaryConversions(). It is also called from several contexts that don't call for integer promotions (logical negation for expressions, and while/if/do/for conditions in statements). It is also used in UsualAssignmentConversions (which is cleaner than the check I was using before). - Changed the name from UsualUnaryConversion->UsualUnaryConversions. - Added comments to the header. Since several contexts don't call for integer promotions, llvm-svn: 39581
* Bug #:Steve Naroff2007-06-031-4/+4
| | | | | | | | | | | | | | | | | | | Submitted by: Reviewed by: Apply UsualUnaryConversion() to statement conditions that expect scalars. UsualUnaryConversion() converts function/arrays to pointers. This fixes the following... int func() { int A[10]; while (A) { } if (A) ; for (; A; ) ; } llvm-svn: 39580
* eliminate unneeded castChris Lattner2007-06-031-2/+3
| | | | llvm-svn: 39575
* Fix a fixme, produce diagnostics like this:Chris Lattner2007-06-022-11/+15
| | | | | | | | ds.c:11:16: error: case label does not reduce to an integer constant case 0 ? 0 : foo(): ~~~~~~~~^~~~~ llvm-svn: 39574
* Submitted by: Bill WendlingBill Wendling2007-06-021-2/+20
| | | | | | | | | Reviewed by: Chris Lattner - Disallow references to references, pointers to references, or arrays of references. llvm-svn: 39569
* Submitted by: Bill WendlingBill Wendling2007-06-021-0/+5
| | | | | | | | | Reviewed by: Chris Lattner - If the LHS and/or RHS is a reference, then see if they're compatible. If so, the type is that of the LHS. llvm-svn: 39568
* When a function decays into its address, ensure the result type keeps anyChris Lattner2007-06-021-1/+1
| | | | | | typedef information associated with the input. llvm-svn: 39562
* Correct the type of logical not.Chris Lattner2007-06-021-0/+2
| | | | llvm-svn: 39558
* Submitted by: Bill WendlingBill Wendling2007-06-021-1/+2
| | | | | | | - Added C99 reference to why "auto" and "register" cannot be used as a storage class specifier for file scoped variable declarations. llvm-svn: 39557
* Modify Expr::isConstantExpr and friends take a pointer to a SourceLoc insteadChris Lattner2007-06-022-3/+4
| | | | | | of one by reference, making it optional. llvm-svn: 39552
* Bug #:Steve Naroff2007-06-012-7/+8
| | | | | | | | | | Submitted by: Reviewed by: After speaking with Chris, decided not to have GCC "attributes" inherit from Decl. This will enable us to grow the attribute hierarchy over time without effecting Decls. llvm-svn: 39543
* Bug #:Steve Naroff2007-06-012-0/+24
| | | | | | | | | | | | | | | Submitted by: Reviewed by: Implement support for GCC __attribute__. - Implement "TODO" in Parser::ParseAttributes. Changed the return type from void to Parser::DeclTy. Changed all call sites to accept the return value. - Added Action::ParseAttribute and Sema::ParseAttribute to return an appropriate AST node. Added new node AttributeDecl to Decl.h. Still to do...hook up to the Decl... llvm-svn: 39539
* add fixmeChris Lattner2007-05-311-0/+3
| | | | llvm-svn: 39536
* Bug #:Steve Naroff2007-05-302-3/+4
| | | | | | | | | | | | Submitted by: Reviewed by: - ParseForStatement(): Put back a test/assignment. My removal of ParseExprStmt() was a bit over zealous:-(thanks to Chris for pointing it out) - Add assert to VisitDeclStmt(). - Removed an out-of-date FIXME - Added some curlies for a couple multi-line calls to Diag(). llvm-svn: 39528
* Submitted by: Bill WendlingBill Wendling2007-05-301-5/+5
| | | | | | Comment format changes. llvm-svn: 39527
* Bug #:Steve Naroff2007-05-302-16/+29
| | | | | | | | | | Submitted by: Reviewed by: - Many tweaks to various diagnostics. - Fixed some location/range issues. - Bug fix to Sema::ParseDeclStmt() - error return code is "true", not 0. llvm-svn: 39526
* Bug #:Steve Naroff2007-05-301-26/+24
| | | | | | | | | | | | | Submitted by: Reviewed by: Unified the diagnostics for function calls. Since we have range support, there is no need for including the argument number. Instead, I've made the diags more expressive by including more type info. Also improved the indentation of many calls to Diag (which can be 2-3 lines now). llvm-svn: 39523
* Bug #:Steve Naroff2007-05-292-3/+4
| | | | | | | | | | | | | | | | | Submitted by: Reviewed by: Implement some FIXME's that stand in the way of fully typechecking "for" statements. This involved: - Adding a DeclStmt AST node (with statement visitor). The DeclStmt printer is preliminary. - Added a ParseDeclStmt action, called from Parser::ParseForStatement() and Parser::ParseStatementOrDeclaration(). DID NOT add to Parser::ParseIdentifierStatement()...probably could have, however didn't really understand the context of this rule (will speak with Chris). - Removed ParseExprStmt (and it's clients)...it was vestigial. llvm-svn: 39518
* Bug #:Steve Naroff2007-05-293-39/+38
| | | | | | | | | | | Submitted by: Reviewed by: - Finished Sema::ParseReturnStmt(). Still need to tweak ranges. - Tweaked location for function arguments (they now point at the expression directly, no parens or commas). - Added InvalidOperands helper...was sick of looking at the same 3 lines in ~9 Check functions. - Added a few diags and moved a group of statement diags to the proper comment/category. llvm-svn: 39517
* Bug #:Steve Naroff2007-05-291-4/+49
| | | | | | | | | Submitted by: Reviewed by: Implement type checking for ParseDoStmt, ParseWhileStmt, ParseIfStmt, and ParseForStmt. ParseForStmt still under construction (contains a FIXME). llvm-svn: 39515
* Bug #:Steve Naroff2007-05-281-3/+6
| | | | | | | | Submitted by: Reviewed by: Add range support to Sema::CheckConditionalOperands(). llvm-svn: 39514
* Bug #:Steve Naroff2007-05-281-14/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Submitted by: Reviewed by: Refine Sema::ParseCallExpr() diags (range support, add types). Before: func-assign.c:27:11: warning: passing argument 1 from incompatible pointer type pintFunc(&FOO); ^ func-assign.c:28:12: error: incompatible type for argument 1 floatFunc(&FOO); ^ func-assign.c:29:12: error: too many arguments to function floatFunc(1,2,3); ^ After: func-assign.c:27:11: warning: passing incompatible pointer 'struct foo *' to function expecting 'int *' pintFunc(&FOO); ~~~~~~~~^~~~~ func-assign.c:28:12: error: passing incompatible type 'struct foo *' to function expecting 'float' floatFunc(&FOO); ~~~~~~~~~^~~~~ func-assign.c:29:12: error: too many arguments to function floatFunc(1,2,3); ~~~~~~~~~^ ~ llvm-svn: 39513
OpenPOWER on IntegriCloud