Commit Graph

69 Commits

Author SHA1 Message Date
Steve Naroff c27f89ebb3 Bug #:
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
2007-06-03 18:23:48 +00:00
Chris Lattner 35e287bed1 eliminate unneeded cast
llvm-svn: 39575
2007-06-03 01:44:43 +00:00
Chris Lattner 0c46c5d55a Fix a fixme, produce diagnostics like this:
ds.c:11:16: error: case label does not reduce to an integer constant
  case 0 ? 0 : foo():
       ~~~~~~~~^~~~~

llvm-svn: 39574
2007-06-02 23:53:17 +00:00
Chris Lattner 238cbc58c3 Modify Expr::isConstantExpr and friends take a pointer to a SourceLoc instead
of one by reference, making it optional.

llvm-svn: 39552
2007-06-02 04:48:48 +00:00
Chris Lattner 1c31050d21 add fixme
llvm-svn: 39536
2007-05-31 06:00:00 +00:00
Steve Naroff 9992bbab14 Bug #:
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
2007-05-30 16:27:15 +00:00
Steve Naroff 56faab2d4f Bug #:
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
2007-05-30 04:20:12 +00:00
Steve Naroff 2a8ad18e71 Bug #:
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
2007-05-29 22:59:26 +00:00
Steve Naroff 6f49f5df03 Bug #:
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
2007-05-29 14:23:36 +00:00
Steve Naroff 86272ea1fe Bug #:
Submitted by:
Reviewed by:
Implement type checking for ParseDoStmt, ParseWhileStmt, ParseIfStmt, and
ParseForStmt. ParseForStmt still under construction (contains a FIXME).

llvm-svn: 39515
2007-05-29 02:14:17 +00:00
Chris Lattner eefa10e78a implement full sema support for the GCC address-of-label extension.
llvm-svn: 39510
2007-05-28 06:56:27 +00:00
Chris Lattner e2473068d4 Change GotoStmt's to have a pointer to the LabelStmt instead of a pointer to
the label identifier.  Handle fwd references etc.  This allows us to detect
uses of undefined labels and label redefinitions, such as:

t.c:2:12: error: redefinition of label 'abc'
  abc: ;   abc:
           ^
t.c:2:3: error: previous definition is here
  abc: ;   abc:
  ^
t.c:12:12: error: use of undeclared label 'hijl'
      goto hijl;
           ^

llvm-svn: 39509
2007-05-28 06:28:18 +00:00
Chris Lattner 0f203a7c1c add action for null stmt, create ast node.
llvm-svn: 39506
2007-05-28 01:45:28 +00:00
Steve Naroff 9358c715da Bug #:
Submitted by:
Reviewed by:
- Added type checking to Sema::ParseReturnStmt (still under construction).
- Improved Expr::isLvalue() and Expr::isModifiableLvalue() to return more
info. Used the info in Sema::CheckAssignmentOperands() to produce more
descriptive diagnostics. Added FIXME to other clients of isLvalue()/etc.
- Added a SourceLocation slot to MemberExpr...changed the implementation
of getSourceRange().
- Added getResultType() helper to FunctionDecl.
- Changed many Diag calls to use the SourceRange support (now that it's
a big hit...we better milk it:-).

llvm-svn: 39501
2007-05-27 23:58:33 +00:00
Chris Lattner 3bbe7bed39 Don't "optimize" empty or unit compound exprs away.
llvm-svn: 39467
2007-05-20 22:47:04 +00:00
Steve Naroff 72cada0ad9 Bug #:
Submitted by:
Reviewed by:
Extended Expr's constant expression predicates to return a source location
if the predicate returns false. This enables us to position the cursor
exactly were the error occurred (simple pleasures:-).

constant.c:9:9: error: enumerator value for 'E2' is not an integer constant
  E2 = (aconst + 1), // illegal
        ^
constant.c:10:8: error: enumerator value for 'E3' is not an integer constant
  E3 = "abc",
       ^
constant.c:12:12: error: enumerator value for 'E5' is not an integer constant
  E5 = 0?7:printf("xx"), // illegal
           ^
constant.c:13:12: error: enumerator value for 'E6' is not an integer constant
  E6 = 1?7:printf("xx"), // legal
           ^
constant.c:16:14: error: enumerator value for 'E9' is not an integer constant
  E9 = E0 || a, // illegal
             ^
constant.c:21:6: error: array has incomplete element type 'void'
void ary[7];
     ^
constant.c:22:28: error: variable length array declared outside of any function
struct { int a; } ary2[1?7:printf("xx")],
                           ^
constant.c:23:34: error: variable length array declared outside of any function
                  aryIllegal[0?7:printf("yy")];
                                 ^
constant.c:25:10: error: variable length array declared outside of any function
int ary3[a]; // illegal
         ^
constant.c:26:17: error: size of array has non-integer type 'float'
typedef int vla[2.0]; // illegal
                ^
constant.c:30:22: error: size of array has non-integer type 'float'
int nonIntegerArray2[1+2.0];
                     ^

llvm-svn: 39454
2007-05-18 00:18:52 +00:00
Steve Naroff 8eeeb1345f Bug #:
Submitted by:
Reviewed by:
- Added Sema::isConstantArrayType() and Type::isConstantSizeType().
- Implemented type checking for "variably modified" types (i.e. VLA's).
Added checking for file scope variables, static variables, member variables,
and typedefs.
- Changed Expr::isIntegerConstantExpr() to non-virtual implementation.
Fixed bug with sizeof/alignof. Looking at the diff, I may need to
add a check to exclude alignof.
- Added Expr::isConstantExpr()...non-virtual, like above.
- Added typechecking for case statements (found a bug with actions/parsing...).
- Added several diagnostics.
- Fixed several comments.
Started implemented constant expression checking for arrays.

llvm-svn: 39437
2007-05-08 21:09:37 +00:00
Chris Lattner eaafe122b6 move semantic analysis of break/continue out of the parser into the sema class.
llvm-svn: 39157
2006-11-10 05:17:58 +00:00
Chris Lattner af8d581230 move semantic analysis of statements to it's own file.
llvm-svn: 39156
2006-11-10 05:07:45 +00:00