Commit Graph

34710 Commits

Author SHA1 Message Date
Chris Lattner 9fba02845b Enums are integer constant exprs, return their values.
llvm-svn: 39645
2007-06-11 03:47:05 +00:00
Chris Lattner 4ef40013d7 Implement capturing of enum values and chaining of enums together.
llvm-svn: 39644
2007-06-11 01:28:17 +00:00
Steve Naroff a8fd973aa0 Bug #:
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
2007-06-11 00:35:03 +00:00
Chris Lattner 843c592e28 GCC accepts code like this as an extension:
static int seminal(from, to)
{
}

llvm-svn: 39642
2007-06-10 23:40:34 +00:00
Bill Wendling 314ae547a1 Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Added a method "IgnoreDiagnostic" so that the diagnostic client can
  tell the diagnostic object that it doesn't want to handle a particular
  diagnostic message. In which case, it won't be counted as either a
  diagnostic or error.

llvm-svn: 39641
2007-06-10 04:13:42 +00:00
Steve Naroff 0f05a7ae7a Bug #:
Submitted by:
Reviewed by:
Changed the name of DeclSpec.AddAttribute and Declarator.AddAttribute to
AddAttributes(). Also added some (much needed) comments. While documenting,
realized I could simplify & tighten up Declarator.AddAttributes...

llvm-svn: 39640
2007-06-09 23:38:17 +00:00
Steve Naroff 5b6afadf81 Bug #:
Submitted by:
Reviewed by:
Add initialization and memory management for AttributeList.
Added a big FIXME comment for handling expressions (which are currently leaked).

llvm-svn: 39639
2007-06-09 14:13:39 +00:00
Chris Lattner 3f4b6e3623 Fix lexing octal escapes like:
void foo() {
"\0";
}

llvm-svn: 39638
2007-06-09 06:20:47 +00:00
Chris Lattner b2dd241b15 fix a crash parsing spass
llvm-svn: 39637
2007-06-09 06:16:32 +00:00
Chris Lattner ff591e24eb Don't warn about escaped newlines in // comments if the next line is also
a // comment, this reduces noise in the llvm testsuite.

llvm-svn: 39636
2007-06-09 06:07:22 +00:00
Chris Lattner 736ed5dfb8 accept __extension__, update todo list.
llvm-svn: 39635
2007-06-09 05:59:07 +00:00
Chris Lattner 6d9b49ae64 add another example
llvm-svn: 39634
2007-06-09 05:56:19 +00:00
Chris Lattner 0c7e82de07 Accept horrible code like this:
2005-10-18-VariableSizedElementCrash.c:5:41: warning: expected ';' at end of declaration list
  struct bar {foo f1; int f2:3; int f3:4} *p = (struct bar *) pi;
                                        ^

llvm-svn: 39633
2007-06-09 05:54:40 +00:00
Chris Lattner 36e46a219b Add support for a little extension. ISO C does not allow extra ;'s in structs,
e.g.:

struct A {
  ;
  int X;;
  const;
};

llvm-svn: 39632
2007-06-09 05:49:55 +00:00
Steve Naroff 9507c79698 Bug #:
Submitted by:
Reviewed by:
Incorporate some feedback from Chris.
Fixed a crasher, added an assert.

llvm-svn: 39631
2007-06-09 05:31:51 +00:00
Steve Naroff 6d26a892d4 Bug #:
Submitted by:
Reviewed by:
Move Attr.h to the correct group in the Xcode project file...

llvm-svn: 39630
2007-06-09 03:59:22 +00:00
Steve Naroff 06f0f8c414 Bug #:
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: 39629
2007-06-09 03:47:54 +00:00
Steve Naroff b309644a35 Bug #:
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
2007-06-09 03:47:53 +00:00
Steve Naroff 29ca72ae02 Bug #:
Submitted by:
Reviewed by:
Add new file AttributeList.h

llvm-svn: 39627
2007-06-09 03:40:25 +00:00
Steve Naroff b8371e1e6a Bug #:
Submitted by:
Reviewed by:
Add AttributeList.cpp (for "raw" attributes).

llvm-svn: 39626
2007-06-09 03:39:29 +00:00
Chris Lattner 45bb914249 Convert argument types over, which works for trivial scalars.
llvm-svn: 39625
2007-06-09 02:28:57 +00:00
Chris Lattner 1ad38f8fee codegen all declarators in a declstmt, allowing us to successfully codegen
stuff like:

void test() {
  int *X, Y, *Z[14];

  X[Y] = 4;
}

llvm-svn: 39624
2007-06-09 01:20:56 +00:00
Chris Lattner 776fac8703 Finally break down and chain together decls that are defined with common 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
2007-06-09 00:53:06 +00:00
Chris Lattner d9d2fb1420 Implement array subscripts for non-vla types.
llvm-svn: 39622
2007-06-08 23:31:14 +00:00
Chris Lattner de12ae2fd7 Add support for binary literals:
http://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html#Binary-constants

llvm-svn: 39621
2007-06-08 22:42:30 +00:00
Chris Lattner 8655428238 factor casts together, add a case for __extension__
llvm-svn: 39620
2007-06-08 22:32:33 +00:00
Chris Lattner d0f76515f7 add missing case
llvm-svn: 39619
2007-06-08 22:16:53 +00:00
Chris Lattner 901ae1faf2 fix assertion on out-of-range shift
llvm-svn: 39618
2007-06-08 21:54:26 +00:00
Chris Lattner 4cd73fd380 Fix bugs in isIntegerConstantExpr handling character and enum literals
llvm-svn: 39617
2007-06-08 21:51:02 +00:00
Bill Wendling 344b92e993 Submitted by: Bill Wendling
- Say! why don't we increment the NumDiagnostics variable too?

llvm-svn: 39616
2007-06-08 19:21:50 +00:00
Bill Wendling da0c8a9641 Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Make the counting of errors and diagnostic messages sane. Place them into the
  Diagnostic class instead of in the DiagnosticClient class.

llvm-svn: 39615
2007-06-08 19:17:38 +00:00
Chris Lattner 7cf04d1653 we correctly reject array of void now
llvm-svn: 39614
2007-06-08 18:15:09 +00:00
Chris Lattner 5a1a0250f8 this testcase has errors, we expect clang to reject it
llvm-svn: 39613
2007-06-08 18:14:27 +00:00
Chris Lattner 7a89360402 This testcase bus errors because semantics analysis of these operators isn't implemented.
llvm-svn: 39612
2007-06-08 18:13:24 +00:00
Chris Lattner c84413e0a8 Diagnostics coming from a memory buffer (e.g. pragmas) don't have a
corresponding file buffer, don't dereference null pointers.  This
fixes a regression on test/Preprocessor/_Pragma-syshdr.c

llvm-svn: 39611
2007-06-08 18:11:33 +00:00
Chris Lattner 1abbd417be implement a fixme, fixing test/Sema/i-c-e1.c
llvm-svn: 39610
2007-06-08 17:58:43 +00:00
Chris Lattner 43312241ea new testcase
llvm-svn: 39609
2007-06-08 17:58:14 +00:00
Chris Lattner e9a7da1d55 Make make check work again.
llvm-svn: 39608
2007-06-08 17:57:13 +00:00
Chris Lattner e8b2724017 Fix a bug steve noticed where we warned that __attribute is an extension,
but where we didn't warn about __attribute__.

llvm-svn: 39607
2007-06-08 17:27:55 +00:00
Chris Lattner 2c1720681f add a new text file for low-prio QOI todos
llvm-svn: 39606
2007-06-08 17:15:31 +00:00
Chris Lattner 328fa5c913 Emit better diagnostics for out of range digits:
diag.c:1:9: error: invalid digit '8' in octal constant
int x = 000080;
        ^
diag.c:2:9: error: invalid digit 'A' in decimal constant
int z = 1000080ABC;
        ^

instead of:

diag.c:1:9: error: invalid suffix '80' on integer constant
int x = 000080;
        ^
diag.c:2:9: error: invalid suffix 'ABC' on integer constant
int z = 1000080ABC;
        ^

llvm-svn: 39605
2007-06-08 17:12:06 +00:00
Bill Wendling c2b867ac4f Submitted by: Bill Wendling
- Renamed file guard.

llvm-svn: 39604
2007-06-07 18:58:07 +00:00
Bill Wendling 37b1ddecf6 Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Separated out the diagnostic client from the clang driver. This is in
  preparation for creating a diagnostic client that will be used to check
  error and warning messages.

llvm-svn: 39603
2007-06-07 09:34:54 +00:00
Steve Naroff 98d153c730 Bug #:
Submitted by:
Reviewed by:

Fixed a bug in the parser's handling of attributes on pointer declarators.

For example, the following code was producing a syntax error...

int *__attribute(()) foo;

attrib.c:10:25: error: expected identifier or '('
int *__attribute(()) foo;
                        ^
Changed Parser::ParseTypeQualifierListOpt to not consume the token following
an attribute declaration.

Also added LexerToken::getName() convenience method...useful when tracking
down errors like this.

llvm-svn: 39602
2007-06-06 23:19:11 +00:00
Steve Naroff 98cf3e95ce Bug #:
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
2007-06-06 18:38:38 +00:00
Chris Lattner 2e550fea6a When parsing an expr in stmt context, make sure to consume the semicolon
after the expr along with the expr.  If we don't do this, the semicolon
gets parsed as a nullstmt, which makes the generated AST very strange.

llvm-svn: 39600
2007-06-06 05:26:32 +00:00
Chris Lattner 3d01e4eacb On bogus code like this:
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
2007-06-06 05:14:05 +00:00
Chris Lattner 3343f81a25 Fix semantic analysis of calls on stuff like:
int func() {
 int (*FP)();
 FP();
 (*****FP)();
}

llvm-svn: 39598
2007-06-06 05:05:41 +00:00
Chris Lattner 4347e369b4 implement codegen of string literals.
llvm-svn: 39597
2007-06-06 04:54:52 +00:00
Chris Lattner 83b484b3be implement the real int/fp conversions
llvm-svn: 39596
2007-06-06 04:39:08 +00:00