Commit Graph

1633 Commits

Author SHA1 Message Date
Chris Lattner e026ebd6fe steve's recent changes fixed this bogus warning.
llvm-svn: 41432
2007-08-26 06:48:28 +00:00
Chris Lattner 1a76a3c970 Break the assumption that any sort of scope (e.g. a loop scope) can
hold declarations.  Instead, introduce a new "DeclScope" scope type that
holds them explicitly.  For now, all scopes have this bit, but in the 
future we can use them to fix some issues Neil noticed.

llvm-svn: 41431
2007-08-26 06:24:45 +00:00
Chris Lattner 88078594fc remove some dead enum values.
llvm-svn: 41430
2007-08-26 06:03:04 +00:00
Chris Lattner 7460f9620c Implement casts from scalar -> complex and complex->complex.
llvm-svn: 41429
2007-08-26 05:57:57 +00:00
Chris Lattner e267f5d2f7 require that operands to __real/__imag are complex or arithmetic. This
fixes GCC PR33193

llvm-svn: 41428
2007-08-26 05:39:26 +00:00
Chris Lattner b5e1262437 implement codegen of __imag of a scalar. Our impl doesn't suffer from
GCC bug PR33192.

llvm-svn: 41427
2007-08-26 05:29:21 +00:00
Chris Lattner 9de9527ad6 Make initialization of complex vars work.
llvm-svn: 41426
2007-08-26 05:13:54 +00:00
Chris Lattner a01d898ff5 fix codegen of pre/post inc/dec of a pointer.
llvm-svn: 41425
2007-08-26 05:10:16 +00:00
Chris Lattner c7f06ca780 tolerate unimplemented codegen better
llvm-svn: 41424
2007-08-26 05:06:40 +00:00
Chris Lattner e7a160b37d int X[] isn't a VLA. This improves support for stdio.h on darwin.
llvm-svn: 41423
2007-08-26 05:02:07 +00:00
Neil Booth cd995b0b4a Make some diags EXTENSION so they are errors with pedantic errors
llvm-svn: 41422
2007-08-26 05:01:15 +00:00
Chris Lattner 57c269b5d3 implement rudimentary union layout support.
llvm-svn: 41421
2007-08-26 04:50:19 +00:00
Chris Lattner 5e75e8bc71 Why didn't gcc catch this? :(
llvm-svn: 41420
2007-08-26 04:42:42 +00:00
Chris Lattner 881440f5d2 Don't make unknown builtins fatal errors yet.
llvm-svn: 41419
2007-08-26 04:17:05 +00:00
Chris Lattner c5221650b3 remove a bunch of dead code
llvm-svn: 41418
2007-08-26 04:13:58 +00:00
Chris Lattner 71236d0485 fix a bug introduced by the recent childification of ForStmt.
llvm-svn: 41417
2007-08-26 04:11:23 +00:00
Chris Lattner b677a9398a Make parse-ast-print print the storage class and inline
specifier of functions.

llvm-svn: 41416
2007-08-26 04:02:13 +00:00
Chris Lattner 1c72d77d01 null pointers don't get an extra newline.
llvm-svn: 41415
2007-08-26 03:53:29 +00:00
Chris Lattner 0fffcb5b28 implement codegen for complex literals.
llvm-svn: 41414
2007-08-26 03:51:12 +00:00
Chris Lattner 1c20a170c0 add a new ImaginaryLiteral AST node that is used to
represent imaginary literals:

float _Complex A;
void foo() {
  A = 1.0iF;
}

generates:

  (BinaryOperator 0x2305ec0 '_Complex float' '='
    (DeclRefExpr 0x2305e60 '_Complex float' Decl='A' 0x2305cf0)
    (ImaginaryLiteral 0x2305f40 '_Complex float'
      (FloatingLiteral 0x2305ea0 'float' 1.000000))))

llvm-svn: 41413
2007-08-26 03:42:43 +00:00
Chris Lattner ed045421a8 1.0 is double, 1.0F is a float.
llvm-svn: 41412
2007-08-26 03:29:23 +00:00
Chris Lattner f55ab18663 1) refactor some code.
2) Add support for lexing imaginary constants (a GCC extension):

t.c:5:10: warning: imaginary constants are an extension
  A = 1.0iF;
         ^

3) Make the 'invalid suffix' diagnostic pointer more accurate:

t.c:6:10: error: invalid suffix 'qF' on floating constant
  A = 1.0qF;
         ^

instead of:

t.c:6:10: error: invalid suffix 'qF' on floating constant
  A = 1.0qF;
      ^

llvm-svn: 41411
2007-08-26 01:58:14 +00:00
Chris Lattner b620c34bb0 merge checkrelational and checkequality into CheckCompareOperands,
to merge duplicate code.

llvm-svn: 41410
2007-08-26 01:18:55 +00:00
Chris Lattner 1895e58c84 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.

llvm-svn: 41408
2007-08-26 01:10:14 +00:00
Chris Lattner 1bc6fac5c6 new testcase
llvm-svn: 41406
2007-08-25 21:57:08 +00:00
Chris Lattner 27f00282e9 The new correct compound assignment operators exposed a bug in codegen.
llvm-svn: 41405
2007-08-25 21:56:20 +00:00
Steve Naroff 46c72915f4 Surpress the UsualUnaryConversions for compound assignment operators. This change
eliminates the possibility that the left hand expression is an ImplicitCastExpr.
As a result, I removed the check for ImplicitCastExpr in Expr::isLvalue().

This results in the following AST's...

[dylan:~/llvm/tools/clang] admin% cat fix.c

short x; void test4(char c) { 
  x += c; 
  x = x + c;
}
[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang fix.c -parse-ast-dump
Read top-level variable decl: 'x'

void test4(char c)
(CompoundStmt 0x2605d30
  (CompoundAssignOperator 0x2605c40 'short' '+='
    (DeclRefExpr 0x2605c00 'short' Decl='x' 0x2605a80)
    (DeclRefExpr 0x2605c20 'char' Decl='c' 0x2605bc0))
  (BinaryOperator 0x2605d10 'short' '='
    (DeclRefExpr 0x2605c60 'short' Decl='x' 0x2605a80)
    (ImplicitCastExpr 0x2605d00 'short'
      (BinaryOperator 0x2605ce0 'int' '+'
        (ImplicitCastExpr 0x2605cc0 'int'
          (DeclRefExpr 0x2605c80 'short' Decl='x' 0x2605a80))
        (ImplicitCastExpr 0x2605cd0 'int'
          (DeclRefExpr 0x2605ca0 'char' Decl='c' 0x2605bc0))))))

llvm-svn: 41404
2007-08-25 19:54:59 +00:00
Chris Lattner 479ed3aab8 read and ignore the body of a namespace.
llvm-svn: 41403
2007-08-25 18:15:16 +00:00
Steve Naroff e2562ff99d 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.

llvm-svn: 41402
2007-08-25 14:37:06 +00:00
Steve Naroff aac9415bfb Give CXXBoolLiteralExpr a type (all expressions need a valid type).
This fixes the following:

******************** TEST 'Parser/cxx-bool.cpp' FAILED! ********************
Command:
clang -fsyntax-only Parser/cxx-bool.cpp
Output:
SemaExpr.cpp:731: failed assertion `!t.isNull() && "DefaultFunctionArrayConversion - missing type"'
Output/cxx-bool.cpp.out.script: line 1: 22697 Abort trap              clang -fsyntax-only Parser/cxx-bool.cpp

llvm-svn: 41401
2007-08-25 14:02:58 +00:00
Chris Lattner a5235173bc refactor enough of the top-level parsing logic to parse and
ignore 'namespace foo {}'

llvm-svn: 41400
2007-08-25 06:57:03 +00:00
Chris Lattner 66b67efa61 C++ explicitly allows an empty source file.
llvm-svn: 41399
2007-08-25 05:47:03 +00:00
Chris Lattner e33fbdb898 Fix the test/Sema/format-strings.c regression. This code should be refactored.
llvm-svn: 41398
2007-08-25 05:36:18 +00:00
Chris Lattner 6d5922fd66 reenable this.
llvm-svn: 41397
2007-08-25 05:31:19 +00:00
Chris Lattner 9449fd7bc3 Fix the regression on test/Sema/cfstring.c
llvm-svn: 41396
2007-08-25 05:30:33 +00:00
Chris Lattner a206358bb6 test the parser only, not sema.
llvm-svn: 41395
2007-08-25 05:26:51 +00:00
Chris Lattner 8692811955 Split the ASTNode out for compound assignments out from binary operators. Now
they show up in dumps etc.

llvm-svn: 41393
2007-08-25 02:00:02 +00:00
Chris Lattner d8c9fc5ed8 fix off-by-one error
llvm-svn: 41392
2007-08-25 01:55:00 +00:00
Chris Lattner e7d0864aed Fix clang -parse-ast-dump carbon.c
llvm-svn: 41391
2007-08-25 01:49:16 +00:00
Chris Lattner 4d15a0dbc0 rename sNames -> StmtClassInfo. Make lookups constant time.
llvm-svn: 41390
2007-08-25 01:42:24 +00:00
Steve Naroff 0c1c7ed5e6 This modest change insures ImplicitCastExpr's get generated for all "assignments",
while includes init decls, assignment exprs, call exprs, and return statements.

Here are a few examples with the correct AST's...

[dylan:~/llvm/tools/clang] admin% cat impcomp.c

_Complex double X;
void test2(int c) {
  X = 5;
}
void foo() {
  int i;
  double d = i;
  double _Complex a = 5;

  test2(a);
  a = 5;
  d = i;
}


[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang impcomp.c -parse-ast-dump
Read top-level variable decl: 'X'

void test2(int c)
(CompoundStmt 0x2605ce0
  (BinaryOperator 0x2605cc0 '_Complex double' '='
    (DeclRefExpr 0x2605c70 '_Complex double' Decl='X' 0x2605af0)
    (ImplicitCastExpr 0x2605cb0 '_Complex double'
      (IntegerLiteral 0x2605c90 'int' 5))))


void foo()
(CompoundStmt 0x2606030
  (DeclStmt 0x2605bd0
    0x2605d90 "int i")
  (DeclStmt 0x2605e20
    0x2605de0 "double d =
      (ImplicitCastExpr 0x2605e10 'double'
        (DeclRefExpr 0x2605dc0 'int' Decl='i' 0x2605d90))")
  (DeclStmt 0x2605e90
    0x2605e50 "_Complex double a =
      (ImplicitCastExpr 0x2605e80 '_Complex double'
        (IntegerLiteral 0x2605e30 'int' 5))")
  (CallExpr 0x2605f20 'void'
    (ImplicitCastExpr 0x2605f00 'void (*)(int)'
      (DeclRefExpr 0x2605ea0 'void (int)' Decl='test2' 0x2605c00))
    (ImplicitCastExpr 0x2605f10 'int'
      (DeclRefExpr 0x2605ec0 '_Complex double' Decl='a' 0x2605e50)))
  (BinaryOperator 0x2605fa0 '_Complex double' '='
    (DeclRefExpr 0x2605f50 '_Complex double' Decl='a' 0x2605e50)
    (ImplicitCastExpr 0x2605f90 '_Complex double'
      (IntegerLiteral 0x2605f70 'int' 5)))
  (BinaryOperator 0x2606010 'double' '='
    (DeclRefExpr 0x2605fc0 'double' Decl='d' 0x2605de0)
    (ImplicitCastExpr 0x2606000 'double'
      (DeclRefExpr 0x2605fe0 'int' Decl='i' 0x2605d90))))

llvm-svn: 41379
2007-08-24 22:33:52 +00:00
Chris Lattner 74ed76bb0e remove a dead argument
llvm-svn: 41377
2007-08-24 21:41:10 +00:00
Chris Lattner 9f0ad96b3e implement codegen for real/imag. TODO: imag of non-complex.
llvm-svn: 41376
2007-08-24 21:20:17 +00:00
Chris Lattner 30b5dd0b79 Implement sema support for __real/__imag nodes.
llvm-svn: 41375
2007-08-24 21:16:53 +00:00
Ted Kremenek 066dd939c0 Added child_begin/child_end to all subclasses of Stmt in Stmt.h. All
concrete subclasses of Stmt are now required to implement 
child_begin/child_end.

llvm-svn: 41374
2007-08-24 21:09:09 +00:00
Chris Lattner 3d966d6556 Teach emit-llvm for scalars to properly handle compound assignment
operators in all their glory :)

llvm-svn: 41373
2007-08-24 21:00:35 +00:00
Ted Kremenek 485b13f397 Added ExprCXX.cpp
llvm-svn: 41370
2007-08-24 20:24:16 +00:00
Ted Kremenek e3a0c14614 Implementation of child_begin/child_end for C++ expressions.
llvm-svn: 41369
2007-08-24 20:21:10 +00:00
Ted Kremenek acc4903b3e Implemented child_begin/child_end for our current set of C++ expressions.
llvm-svn: 41368
2007-08-24 20:20:38 +00:00
Ted Kremenek 23702b6afb Finished adding child_begin/child_end to all subclasses of Stmt in Expr.h.
llvm-svn: 41366
2007-08-24 20:06:47 +00:00