Commit Graph

255 Commits

Author SHA1 Message Date
Sebastian Redl c470476420 Implement C++ 'typeid' parsing and sema.
llvm-svn: 59042
2008-11-11 11:37:55 +00:00
Chris Lattner 8c5dd730ce Fix PR3031 by silencing follow-on errors in invalid declarations.
llvm-svn: 59027
2008-11-11 06:13:16 +00:00
Sebastian Redl f4485de48a Update C++ status to reflect parser capabilities for chapter 9 (classes). Slightly extend the class parser test.
llvm-svn: 58909
2008-11-08 15:40:37 +00:00
Daniel Dunbar f8362f9e5d "One" line fix for -parse-noop failure, "id" and several other things
were being treated as type names for non-Objective-C files.
 - Other lines are just because MinimalAction didn't have access to
   the LangOptions.

llvm-svn: 58498
2008-10-31 08:56:51 +00:00
Douglas Gregor 8e1cf608dc Implement initialization of a reference (C++ [dcl.init.ref]) as part
of copy initialization. Other pieces of the puzzle:

  - Try/Perform-ImplicitConversion now handles implicit conversions
    that don't involve references.
  - Try/Perform-CopyInitialization uses
    CheckSingleAssignmentConstraints for C. PerformCopyInitialization
    is now used for all argument passing and returning values from a
    function.
  - Diagnose errors with declaring references and const values without
    an initializer. (Uses a new Action callback, ActOnUninitializedDecl).
  
We do not yet have implicit conversion sequences for reference
binding, which means that we don't have any overloading support for
reference parameters yet.

llvm-svn: 58353
2008-10-29 00:13:59 +00:00
Chris Lattner 9a53fdc23e implement some more FIXMEs, by rejecting more bogus stuff in
objc mode.

llvm-svn: 58216
2008-10-26 23:29:41 +00:00
Chris Lattner 46dcba6d2d add some simple designator testcases. Reject things like this:
struct foo Y[10] = {
  [4] .arr [2] 4  // expected-error {{expected '=' or another designator}}
};

because the "missing equals" extension only is valid if there 
is exactly one array designator.

llvm-svn: 58215
2008-10-26 23:22:23 +00:00
Chris Lattner 29e6f2b674 Support attributes in *yet another* place. Is there any place you
can't stick an attributes?

llvm-svn: 57795
2008-10-20 04:57:38 +00:00
Chris Lattner 8ff2c6c9f0 Fix a parser bug where we let attributes interfere with our disambiguation
of whether a '(' was a grouping paren or the start of a function declarator.
This is PR2796.

Now we eat the attribute before deciding whether the paren is grouping or
not, then apply it to the resultant decl or to the first argument as needed.

One somewhat surprising aspect of this is that attributes interact with
implicit int in cases like this:

void a(x, y) // k&r style function
void b(__attribute__(()) x, y); // function with two implicit int arguments
void c(x, __attribute__(()) y); // error, can't have attr in identifier list.

Fun stuff.

llvm-svn: 57790
2008-10-20 02:05:46 +00:00
Argyrios Kyrtzidis e8addf5e04 Allow variadic arguments without named ones for C++, e.g. "void(...);"
llvm-svn: 57143
2008-10-06 00:07:55 +00:00
Daniel Dunbar fdfb0a0d5e De-XFAIL test/Parser/pragma-pack.c
llvm-svn: 57069
2008-10-04 19:45:56 +00:00
Chris Lattner cc498392a2 Move the expected-warning lines to a place that clang -verify will pick them
up.  Speculatularly hacktastic, but strangely beautiful?
Daniel, lines 20/21 are rejected, please investigate.

llvm-svn: 57067
2008-10-04 19:38:15 +00:00
Daniel Dunbar 921b968841 Add Parser support for #pragma pack
- Uses Action::ActOnPragmaPack
 - Test case is XFAIL pending verifier fixes.

llvm-svn: 57066
2008-10-04 19:21:03 +00:00
Daniel Dunbar 26e2ab4a37 Parser support for prefix __attribute__ on @protocol.
llvm-svn: 56642
2008-09-26 04:48:09 +00:00
Chris Lattner a7b034463e Fix rdar://6222856: the receiver of a message expr is an
arbitrary expr, not just a assign expr.  The grammar comment
was right, the code was just wrong.

llvm-svn: 56353
2008-09-19 17:44:00 +00:00
Argyrios Kyrtzidis f602e427e9 Fix test case.
llvm-svn: 56012
2008-09-09 20:56:12 +00:00
Argyrios Kyrtzidis 2b4072fe55 Implement parser support for the 'condition' part of C++ selection-statements and iteration-statements (if/switch/while/for).
Add new 'ActOnCXXConditionDeclarationExpr' action, called when the 'condition' is a declaration instead of an expression.

llvm-svn: 56007
2008-09-09 20:38:47 +00:00
Argyrios Kyrtzidis 2545aeb710 Support "typeof unary-expression" (GNU C++ extension).
llvm-svn: 55833
2008-09-05 11:26:19 +00:00
Steve Naroff d450bffcf1 Pull code from last commit. will put back soon.
llvm-svn: 55637
2008-09-02 18:04:36 +00:00
Steve Naroff 95bffc74da Implement block pseudo-storage class modifiers (__block, __byref).
llvm-svn: 55635
2008-09-02 15:20:19 +00:00
Steve Naroff 0ac012835f Add parser/action support for block literal expressions.
Parser support for blocks is almost complete...just need to add support for the __block() storage class qualifier.

llvm-svn: 55495
2008-08-28 19:20:44 +00:00
Steve Naroff ec33ed9ced First wave of changes to support "blocks" (an extension to C).
This commit adds the declaration syntax (and associated type).

llvm-svn: 55417
2008-08-27 16:04:49 +00:00
Eli Friedman 002ad1274b Fix a minor crash-on-invalid.
llvm-svn: 55082
2008-08-20 22:07:34 +00:00
Argyrios Kyrtzidis 16d63a727e C++ casts, (static_cast. dynamic_cast, etc.) can have postfix-expression pieces.
llvm-svn: 54850
2008-08-16 19:45:32 +00:00
Chris Lattner bd2d634424 continue cleaning up code, and disable sending a message directly to an
interface.  This fixes a bug where we used to accept:

void test2(NSNumber x) {
	[x METH];
}

which doesn't make sense and GCC rejects.

llvm-svn: 53841
2008-07-21 06:12:56 +00:00
Argyrios Kyrtzidis f4ebe9ea4f Handle unnamed bitfields when parsing C++ classes.
llvm-svn: 52855
2008-06-28 08:10:48 +00:00
Argyrios Kyrtzidis 7bbb20e338 Add parsing support for C++ classes.
Note that Parser::ParseCXXMemberSpecification is temporarily disabled until the Sema support is in place.
Once ParseCXXMemberSpecification is enabled, the Parser/cxx-class.cpp test will pass.

llvm-svn: 52694
2008-06-24 22:12:16 +00:00
Chris Lattner 091f698d29 "this patch adds code generation hooks for Objective-C constant strings. It also modifies Sema so that Objective-C constant strings are treated as untyped objects if the interface for the constant string class can not be found. This is consistent with Apple GCC. I thought it was consistent with GNU GCC, since this was causing failures when trying to compile GNUstep with (GNU) GCC, but it appears that this is not the case when attempting to produce a simple test case to demonstrate it. Possibly there is a way of making the error go away, but I haven't found out what it is yet."
Patch by David Chisnall!

llvm-svn: 52599
2008-06-21 21:44:18 +00:00
Argyrios Kyrtzidis 351763e156 Multiple tests in a single test file must be linked with '&&'.
Otherwise, failing tests other than the last one will not be reported.

llvm-svn: 52231
2008-06-12 12:40:02 +00:00
Chris Lattner fd2fe8270e handle the full assignment-expression grammar when using an
objc message send in an initializer expression.

llvm-svn: 51882
2008-06-02 21:31:07 +00:00
Chris Lattner a120a521a5 Fix a couple crashes on invalid input.
llvm-svn: 51622
2008-05-27 23:32:43 +00:00
Eli Friedman 1c2d5f56f8 Change diagnostic per suggestion, to make it a bit clearer what is
happening.

llvm-svn: 51574
2008-05-27 02:01:50 +00:00
Gabor Greif f61cb42ab5 fix typo
llvm-svn: 51479
2008-05-23 11:19:39 +00:00
Eli Friedman 4b44e2ee8c Test from PR2332; bug already fixed by r51311.
llvm-svn: 51316
2008-05-20 12:55:29 +00:00
Eli Friedman 2460b0c941 Fix the scope of K&R-style argument declarations so that they don't
extend beyond the end of the function.

I'm not completely sure this is the right way to fix this bug, so 
someone familiar with the parser should double-check.

llvm-svn: 51311
2008-05-20 09:10:20 +00:00
Nate Begeman f322eabbce Extend vector member references to include {.hi, .lo, .e, .o} which return a
vector of the same element type and half the width, with the high, low, even,
and odd elements respectively.

Allow member references to member references, so that .hi.hi gives you the high
quarter of a vector.  This is fairly convenient syntax for some insert/extract
operations.

Remove some unnecessary methods/types in the ExtVectorElementExpr class.

llvm-svn: 50892
2008-05-09 06:41:27 +00:00
Chris Lattner 14cd1ee95f Two improvements to initializer parsing:
1. If we hit a semantic error, try harder to recover to emit
   diagnostics for later initializer errors (PR2241).
2. Don't leak parsed initializers on an error.

llvm-svn: 49998
2008-04-20 19:07:56 +00:00
Nate Begeman ce4d7fce6b OCUVector -> ExtVector, shorthand for extended vector, per feedback from Chris.
llvm-svn: 49942
2008-04-18 23:10:10 +00:00
Chris Lattner 285a3e47be reject 'int test(x, x) int x; {}'
llvm-svn: 49271
2008-04-06 06:50:56 +00:00
Chris Lattner 67b450cb48 reject 'typedef int y; int test(x, y)'.
llvm-svn: 49270
2008-04-06 06:47:48 +00:00
Chris Lattner 9d51f2b9d4 Fix handling of implicit int, resolving PR2012 and reverting (and
subsuming) my patch for PR1999.

llvm-svn: 49251
2008-04-05 06:32:51 +00:00
Chris Lattner 3e4683262e implement simple support for arbitrary token lookahead. Change the
objc @try parser to use it, fixing a FIXME.  Update the 
objc-try-catch-1.m file to pass now that we get more reasonable 
errors.

llvm-svn: 48129
2008-03-10 06:06:04 +00:00
Chris Lattner 855d024a83 Remove the first layer of support for "portability" warnings. This is
theoretically useful, but not useful in practice.  It adds a bunch of 
complexity, and not much value.  It's best to nuke it.  One big advantage
is that it means the target interfaces will soon lose their SLoc arguments
and target queries can never emit diagnostics anymore (yay).  Removing this
also simplifies some of the core preprocessor which should make it slightly
faster.

Ted, I didn't simplify TripleProcessor, which can now have at most one
triple, and can probably just be removed.  Please poke at it when you have
time.

llvm-svn: 47930
2008-03-05 01:18:20 +00:00
Chris Lattner b080ed504e Fix PR2042. One remaining issue: we don't currently diagnose
int foobar(int);
 int foobar() {}

which requires ifdef'ing out a testcase in predefined-function.c.

llvm-svn: 47236
2008-02-17 19:31:09 +00:00
Chris Lattner 7b8134f5c6 Fix PR1999, by emitting a hard error only if an argument declarator is completely
missing.  Otherwise, it is an implicit int case, which is valid in c90 and invalid 
elsewhere, but accepted as an extension.

llvm-svn: 46938
2008-02-10 23:08:00 +00:00
Anders Carlsson 2e64d1a50f Behave correctly if a constraint expression is invalid.
llvm-svn: 46910
2008-02-09 19:57:29 +00:00
Steve Naroff e6016798bf Fix Parser::ParseObjCTryStmt() to allow for trailing @-keyword statements/expressions.
This bug fix is the result of not having 2-token lookahead to recognize specific @-keywords.

llvm-svn: 46768
2008-02-05 21:27:35 +00:00
Chris Lattner a347834869 make some diagnostics more terse, update testcases.
Fix Sema::ActOnInstanceMessage to correctly do things in terms of canonical 
types, fixing bogus errors like:

NSDistantObject.m:10383:120: error: bad receiver type 'typeof((id<NSMutableCopying>)self)'
    id mess = ({ id __inv__ = ((void *)0); id __mb__ = _NSMessageBuilder((id <NSMutableCopying>)self, &__inv__); (void)[(__typeof__((id <NSMutableCopying>)self))__mb__ mutableCopyWithZone:((void *)0)]; if (!objc_collecting_enabled()) object_dispose(__mb__); __inv__; });

llvm-svn: 46633
2008-02-01 06:57:39 +00:00
Chris Lattner 7f024fe0c6 Fix PR1965: missing diagnostics for parameters that are missing
type specifiers.  This required updating some (buggy) tests, and the
testcase was previously accidentally committed.

llvm-svn: 46603
2008-01-31 06:10:07 +00:00
Chris Lattner 77927cc33c Add support for dispatching an objc message to a variable
in an initializer list.

llvm-svn: 46367
2008-01-25 19:43:26 +00:00
Chris Lattner 8917c5ace2 First half of a fix for the "objc message send in initializer" bug. This only
handles message sends with typenames to start with.

llvm-svn: 46366
2008-01-25 19:37:24 +00:00
Fariborz Jahanian 9a5124a67e Don't ICE on missing interface declaration when declaring one of its protocols.
llvm-svn: 46141
2008-01-17 20:33:24 +00:00
Fariborz Jahanian 939776756f Recover from user typo not having proper @interface decl and a bad foreach decl.
llvm-svn: 45839
2008-01-10 20:33:58 +00:00
Fariborz Jahanian 2de9a0be09 Remove non-ascii chaaracter from diagnostic
llvm-svn: 45836
2008-01-10 18:10:31 +00:00
Fariborz Jahanian c644ee4992 Warn (as gcc does) when @end does not close anything.
llvm-svn: 45834
2008-01-10 17:58:07 +00:00
Fariborz Jahanian d5450b7f07 Limit type of foreach's element and collection to be a pointer to
objc object type.

llvm-svn: 45709
2008-01-07 18:14:04 +00:00
Fariborz Jahanian fef287cb67 Issue diagnostics if more than one declaration in objectove-c's foreach-stmt header.
llvm-svn: 45708
2008-01-07 17:52:35 +00:00
Chris Lattner 940cfebf90 add comments for the various AssignConvertType's, and split int->pointer from pointer->int.
llvm-svn: 45591
2008-01-04 18:22:42 +00:00
Chris Lattner 9bad62c72a Merge all the 'assignment' diagnostic code into one routine, decloning
it from several places.  This merges the diagnostics, making them more
uniform and fewer in number. This also simplifies and cleans up the code.

Some highlights:
1. This removes a bunch of very-similar diagnostics.
2. This renames AssignmentCheckResult -> AssignConvertType
3. This merges PointerFromInt + IntFromPointer which were always treated the same.
4. This updates a bunch of test cases that have minor changes to the produced diagnostics.

llvm-svn: 45589
2008-01-04 18:04:52 +00:00
Fariborz Jahanian 775d5d02af Patch to add semantics check for ObjC2's foreacn statement.
llvm-svn: 45561
2008-01-04 00:27:46 +00:00
Fariborz Jahanian 056e3a4e90 Issue diagnostic when objective-c's @interface is preceeded by a type specifier.
llvm-svn: 45491
2008-01-02 19:17:38 +00:00
Fariborz Jahanian 5e57e1890d Prevent crash on incorrect objc messaging expression.
llvm-svn: 45489
2008-01-02 18:09:46 +00:00
Chris Lattner 20bc6e06cd add a file I forgot to svn add.
llvm-svn: 45374
2007-12-27 21:46:27 +00:00
Chris Lattner 11221033be Fix a crash on a top-level objc string, patch by Nico Weber
llvm-svn: 45370
2007-12-27 20:29:42 +00:00
Chris Lattner 5e530bcee3 - Use Tok.isObjCAtKeyword instead of Tok.getIdentifierInfo()->getObjCKeywordID().
The later fails if the token is not an identifier.
 - Replace tabs with spaces.
 - Various other cleanups.

Patch by Nico Weber!

llvm-svn: 45368
2007-12-27 19:57:00 +00:00
Chris Lattner 2a70c95387 reenable this code, fix the testcase.
llvm-svn: 45205
2007-12-19 18:01:43 +00:00
Fariborz Jahanian 251a943ce9 Fixed a parsing bug whereby @optional/@required keyword is not followed by
a method declaration.

llvm-svn: 44870
2007-12-11 18:34:51 +00:00
Fariborz Jahanian b31a2f2a47 Patch to prevent crash on use of objc2 syntax.
llvm-svn: 44617
2007-12-05 18:16:33 +00:00
Ted Kremenek b061554caa Implemented initial support for "-triple" option to the clang driver. This
replaces the functionality previously provided by just "-arch" (which is still
supported but has different semantics).

The new behavior is as follows:

(1) If the user does not specify -triple:

   (a) If no -arch options are specified, the target triple used is the host
   triple (in llvm/Config/config.h).
   
   (b) If one or more -arch's are specified (and no -triple), then there is
       one triple for each -arch, where the specified arch is substituted
       for the arch in the host triple.  Example:
          host triple = i686-apple-darwin9
          command: clang  -arch ppc -arch ppc64 ...
          triples used: ppc-apple-darwin9  ppc64-apple-darwin9
          
(2) The user does specify a -triple (only one allowed):

  (a) If no -arch options are specified, the triple specified by -triple
      is used.  E.g clang -triple i686-apple-darwin9
      
  (b) If one or more -arch options are specified, then the triple specified
      by -triple is used as the primary target, and the arch's specified
      by -arch are used to create secondary targets.  For example:
      
      clang -triple i686-apple-darwin9 -arch ppc -arch ppc64
      
      has the following targets:
         i686-apple-darwin9  (primary target)
         ppc-apple-darwin9
         ppc64-apple-darwin9


Other changes related to the changes to the driver:

- TargetInfoImpl now includes the triple string.

- TargetInfo::getTargetTriple returns the triple for its primary target.

- test case test/Parser/portability.c has been updated because "-arch linux" is
  no longer valid ("linux" is an OS, not an arch); instead we use a bogus
  architecture "bogusW16W16" where WCharWidth=16 and WCharAlign=16.

llvm-svn: 44551
2007-12-03 22:06:55 +00:00
Anders Carlsson 091a059c55 GCC fails if there is a trailing colon but no clobbers.
llvm-svn: 44265
2007-11-21 23:27:34 +00:00
Chris Lattner 47791a4051 Parse "sizeof(arr)[0]" as a sizeof of an expr if arr
is an expression.

llvm-svn: 44065
2007-11-13 20:50:37 +00:00
Chris Lattner 36f81fb065 Fix a recovery bug Fariborz and I noticed yesterday. We were producing:
method.c:4:3: error: use of undeclared identifier 'BADIDENT'
        &BADIDENT, 0
         ^
method.c:5:2: error: expected '}'
};
 ^
method.c:3:14: error: to match this '{'
struct S A = {
             ^

now we only produce:

method.c:4:3: error: use of undeclared identifier 'BADIDENT'
        &BADIDENT, 0
         ^

llvm-svn: 43349
2007-10-25 17:27:01 +00:00
Chris Lattner 810c1db3f5 remove typedef.
llvm-svn: 43109
2007-10-18 00:38:23 +00:00
Fariborz Jahanian 76a9427783 Patch to parse @selector expressions.
llvm-svn: 43022
2007-10-15 23:39:13 +00:00
Fariborz Jahanian d52cd41630 Fixed a bug whereby, struct tag name matches a typedef/objc-class name
and hid them.

llvm-svn: 42915
2007-10-12 16:34:10 +00:00
Fariborz Jahanian 49c6425ee6 This patch implementa objective-c's @compatibilty-alias declaration.
llvm-svn: 42883
2007-10-11 23:42:27 +00:00
Fariborz Jahanian d797113659 Implemented parsing of objctive-c protocol conforming type used in
an identifier statement. Fixed up pretty priting to print this type 
correctly.

llvm-svn: 42866
2007-10-11 18:08:47 +00:00
Chris Lattner 5e4c75f4ef rename -parse-ast-print to -ast-print
rename -parse-ast-dump to -ast-dump
remove -parse-ast, which is redundant with -fsyntax-only

llvm-svn: 42852
2007-10-11 00:18:28 +00:00
Anders Carlsson db83d77c78 Emit a warning when the body of an if block is a NullStmt.
llvm-svn: 42840
2007-10-10 20:50:11 +00:00
Fariborz Jahanian 9081457cbf this patch accomodates clattner's comments on expression processing in @try-statement.
llvm-svn: 42611
2007-10-04 20:19:06 +00:00
Ted Kremenek 0883fd5817 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.

llvm-svn: 42365
2007-09-26 20:14:22 +00:00
Fariborz Jahanian 62fd2b4730 Patch to parse objective-c's @try-statement and @throw-statement.
llvm-svn: 42148
2007-09-19 19:14:32 +00:00
Fariborz Jahanian bd25f7d4a5 Patch for parsing objective-c style method calls.
llvm-svn: 41731
2007-09-05 23:08:20 +00:00
Fariborz Jahanian 7db004df78 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.

llvm-svn: 41723
2007-09-05 19:52:07 +00:00
Chris Lattner dfaf9f8c2f implement a fixme: __extension__ marker on decls in compound stmts.
llvm-svn: 41473
2007-08-27 01:01:57 +00:00
Chris Lattner 2dd1b72bde Fix test/Parser/if-scope-*.c. Patch by Neil Booth!
llvm-svn: 41471
2007-08-26 23:08:06 +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
Chris Lattner 6d5922fd66 reenable this.
llvm-svn: 41397
2007-08-25 05:31:19 +00:00
Chris Lattner a206358bb6 test the parser only, not sema.
llvm-svn: 41395
2007-08-25 05:26:51 +00:00
Chris Lattner 37e54f454a Fix a nasty C99 scope issue that Neil pointed out (for ifs)
This fixes test/Parser/control-scope.c

llvm-svn: 41263
2007-08-22 05:16:28 +00:00
Chris Lattner 85e9b4336a add a testcase I forgot to check in long ago
llvm-svn: 41219
2007-08-21 05:56:30 +00:00
Steve Naroff cdee44c12a 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. 

llvm-svn: 41127
2007-08-16 21:48:38 +00:00
Chris Lattner cccc311110 add support for a top-level __extension__ marker, implementing a todo.
llvm-svn: 41004
2007-08-10 20:57:02 +00:00
Chris Lattner 213ef35a89 fix this test to pass.
llvm-svn: 40996
2007-08-10 17:18:58 +00:00
Steve Naroff 12b0447bc6 Finish implementing __builtin_classify_type()...
llvm-svn: 40951
2007-08-08 22:15:55 +00:00
Steve Naroff 8a4cf97aa9 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.

llvm-svn: 40831
2007-08-05 02:16:31 +00:00
Chris Lattner 2f48d5e2ed fix hang in testsuite
llvm-svn: 40799
2007-08-04 00:18:28 +00:00
Steve Naroff 0104731e62 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.

llvm-svn: 40795
2007-08-03 22:40:33 +00:00
Steve Naroff 9efdabc565 Implement __builtin_choose_expr.
llvm-svn: 40794
2007-08-03 21:21:27 +00:00
Steve Naroff 7d451d614c 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

llvm-svn: 40789
2007-08-03 18:38:22 +00:00
Steve Naroff 236becbbc3 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.

llvm-svn: 40676
2007-08-01 17:20:42 +00:00
Steve Naroff 872da803b2 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.

llvm-svn: 40656
2007-07-31 23:56:32 +00:00
Steve Naroff ad373bdcfe 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.

llvm-svn: 40631
2007-07-31 12:34:36 +00:00
Steve Naroff 0d595ca0bb Finish up semantic analysis for vector components.
llvm-svn: 40584
2007-07-30 03:29:09 +00:00
Steve Naroff f8fd09e22b Implement syntax/semantic analysis for OCU Vector Components.
Next step, AST support...

llvm-svn: 40568
2007-07-27 22:15:19 +00:00
Chris Lattner 626246e93c don't expect to be able to reparse arbitrary system headers.
llvm-svn: 40511
2007-07-26 05:59:05 +00:00
Steve Naroff 44fd8ff400 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.

llvm-svn: 40475
2007-07-24 21:46:40 +00:00
Chris Lattner e34b2c298a Catch goto's with a missing identifier, patch by Neil Booth.
llvm-svn: 40381
2007-07-22 04:13:33 +00:00
Steve Naroff fbd098332c 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.

llvm-svn: 40032
2007-07-19 01:06:55 +00:00
Steve Naroff 1a2cf6b3b3 Implement semantic analysis for the cast operator.
llvm-svn: 39943
2007-07-16 23:25:18 +00:00
Chris Lattner 666115c848 Improve char literal pretty printing, patch by Keith Bauer!
llvm-svn: 39846
2007-07-13 23:58:20 +00:00
Chris Lattner cf9be2d315 update tests
llvm-svn: 39786
2007-07-12 16:52:08 +00:00
Chris Lattner d1c161786f -pedantic no longer defaults to on.
llvm-svn: 39785
2007-07-12 16:49:27 +00:00
Chris Lattner 1e52eee112 update test
llvm-svn: 39784
2007-07-12 16:48:52 +00:00
Bill Wendling 772996ab44 Submitted by: Bill Wendling
- The && at the end was causing this to fail. Removed.

llvm-svn: 39709
2007-06-29 09:54:25 +00:00
Bill Wendling 52b4b73442 Submitted by: Bill Wendling
Fixed checking to coincide with the correct lines.

llvm-svn: 39696
2007-06-27 18:18:03 +00:00
Bill Wendling 87e46687d9 Submitted by: Bill Wendling
Reviewed by: Chris Lattner

Split up lines to have only one expected output per line. Restored some
checks.

llvm-svn: 39688
2007-06-27 07:31:17 +00:00
Bill Wendling eb2def66be Submitted by: Bill Wendling
- Converted to use the -parse-ast-check flag.

llvm-svn: 39681
2007-06-27 04:30:12 +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
Bill Wendling cbf4709c03 Add const/volatile badness
llvm-svn: 39579
2007-06-03 09:02:28 +00:00
Bill Wendling 6811c0b5f3 Bug #:
Submitted by: Bill Wendling
Reviewed by:

C++ references testcase.

llvm-svn: 39497
2007-05-27 10:16:12 +00:00
Bill Wendling 82487e1ac3 Testcase for bool types.
llvm-svn: 39339
2007-02-13 01:52:09 +00:00
Chris Lattner a4792c1e64 new testcase that crashed clang
llvm-svn: 39315
2007-01-27 06:23:34 +00:00
Chris Lattner 41175f40a3 random testcase
llvm-svn: 39301
2007-01-25 07:42:11 +00:00
Chris Lattner 8eaca54d76 new testcase
llvm-svn: 39287
2007-01-23 20:16:22 +00:00
Chris Lattner 3e30f7c70f add a testcase for c++ casting operators, by Bill
llvm-svn: 39285
2007-01-23 06:12:15 +00:00
Chris Lattner 23f2e9e687 new testcase
llvm-svn: 39271
2007-01-23 01:32:33 +00:00
Chris Lattner ac71608b17 new testcase
llvm-svn: 39251
2007-01-21 06:56:08 +00:00
Chris Lattner 784b168c92 new testcase
llvm-svn: 39233
2006-12-02 07:59:33 +00:00
Chris Lattner 017865fb62 adjust test
llvm-svn: 39201
2006-11-21 04:06:06 +00:00
Chris Lattner 33ad2cacc9 Make Scope keep track of the kind of scope it is. Properly scope loop and
switch statements.  Make break/continue check that they are inside of an
appropriate control-flow construct.  This implements Parser/bad-control.c.

llvm-svn: 39136
2006-11-05 23:47:55 +00:00
Chris Lattner 19f4440f5b new testcase
llvm-svn: 39040
2006-10-25 03:14:54 +00:00
Chris Lattner 43ec2ce473 new testcase
llvm-svn: 39000
2006-10-17 03:00:45 +00:00
Chris Lattner aecc057c64 new testcase
llvm-svn: 38976
2006-10-14 07:54:12 +00:00
Chris Lattner 3ca67ba67f new testcase
llvm-svn: 38927
2006-08-15 05:11:49 +00:00
Chris Lattner 7bddb3fc61 add bare struct tag decls.
llvm-svn: 38899
2006-08-13 19:59:13 +00:00
Chris Lattner 5b6032ab3c new offsetof testcase
llvm-svn: 38892
2006-08-12 19:15:40 +00:00
Chris Lattner 3b51ddf438 new testcase
llvm-svn: 38889
2006-08-12 18:40:31 +00:00
Chris Lattner 2c5c421203 add test4
llvm-svn: 38886
2006-08-12 18:11:24 +00:00
Chris Lattner e66218bf49 Split the expression tests out of statements.c into expressions.c
llvm-svn: 38882
2006-08-12 17:19:28 +00:00
Chris Lattner 89d53752f5 Fix parsing of assignment expressions and handling of right-associative
things.

llvm-svn: 38881
2006-08-12 17:18:19 +00:00
Chris Lattner eb17652f5f Check that ?: parses its RHS as 'expression'.
llvm-svn: 38878
2006-08-12 17:04:23 +00:00
Chris Lattner 3401781548 Add another testcase
llvm-svn: 38870
2006-08-11 02:12:35 +00:00
Chris Lattner eddbcb2b12 Add sizeof/cast/compound_expr tests.
llvm-svn: 38867
2006-08-11 01:38:08 +00:00
Chris Lattner 2f9980ef14 Implement Parser/statements.c:test5: parsing decls that start with identifiers
in blocks.

llvm-svn: 38854
2006-08-10 18:39:24 +00:00
Chris Lattner 6dfd97806e Add support for simple labels.
llvm-svn: 38853
2006-08-10 18:31:37 +00:00
Chris Lattner f8afb62ef9 Add support for parsing declarations in blocks. This implements
Parser/statements.c:test4

llvm-svn: 38852
2006-08-10 18:26:31 +00:00
Chris Lattner 97353f2327 add test3
llvm-svn: 38850
2006-08-10 05:59:30 +00:00