Commit Graph

2848 Commits

Author SHA1 Message Date
Chris Lattner 36dec99d12 Improve switch diagnostic to emit the "jump" message on the
specific bad case instead of on the switch.  Putting it on the
switch means you don't know what case is the problem. For 
example:

scope-check.c:54:3: error: illegal switch case into protected scope
  case 2:
  ^
scope-check.c:53:9: note: jump bypasses initialization of variable length array
    int a[x];
        ^

llvm-svn: 69462
2009-04-18 19:50:02 +00:00
Chris Lattner 7535f41c66 first step to getting switches giving "jump into vla scope" errors.
llvm-svn: 69461
2009-04-18 19:42:37 +00:00
Chris Lattner 8560addfa6 add some block goto test cases.
llvm-svn: 69460
2009-04-18 19:32:54 +00:00
Chris Lattner a2ac7aab6e make sure to verify that the "non pch" runs worked.
llvm-svn: 69457
2009-04-18 18:45:36 +00:00
Chris Lattner 07f62f1881 improve wording of scope violation error messages.
llvm-svn: 69456
2009-04-18 18:42:55 +00:00
Chris Lattner e227091199 rename test
llvm-svn: 69455
2009-04-18 18:41:40 +00:00
Chris Lattner d66f172ab1 more fun with line markers: the digit string is required to be interpreted
as decimal, even if it starts with 0.  Also, since things like 0x1 are
completely illegal, don't even bother using numericliteralparser for them.

llvm-svn: 69454
2009-04-18 18:35:15 +00:00
Douglas Gregor f21701b70c Fix test to output LLVM to a temporary file, which we grep as part of the test
llvm-svn: 69448
2009-04-18 15:48:37 +00:00
Chris Lattner 960cc525ec rewrite the goto scope checking code to be more efficient, simpler,
produce better diagnostics, and be more correct in ObjC cases (fixing
rdar://6803963).

An example is that we now diagnose:

int test1(int x) {
  goto L;
  int a[x];
  int b[x];
  L:
  return sizeof a;
}

with:

scope-check.c:15:3: error: illegal goto into protected scope
  goto L;
  ^
scope-check.c:17:7: note: scope created by variable length array
  int b[x];
      ^
scope-check.c:16:7: note: scope created by variable length array
  int a[x];
      ^

instead of just saying "invalid jump".  An ObjC example is:

void test1() {
  goto L;
  @try {
L: ;
  } @finally {
  }
}

t.m:6:3: error: illegal goto into protected scope
  goto L;
  ^
t.m:7:3: note: scope created by @try block
  @try {
  ^

There are a whole ton of fixme's for stuff to do, but I believe that this
is a monotonic improvement over what we had.

llvm-svn: 69437
2009-04-18 09:36:27 +00:00
Daniel Dunbar 41595d43d5 Use getAsPointerType instead of using getCanonicalType directly.
- <rdar://problem/6803995>

llvm-svn: 69435
2009-04-18 08:54:40 +00:00
Chris Lattner 9f3e711503 add another testcase
llvm-svn: 69432
2009-04-18 07:54:11 +00:00
Chris Lattner c2e868fd14 fix incorrect lowering of __builtin_ia32_shufpd, rdar://6803924
llvm-svn: 69428
2009-04-18 07:01:54 +00:00
Chris Lattner 032f7665d0 rename file.
llvm-svn: 69427
2009-04-18 07:00:54 +00:00
Chris Lattner 85e4dd4055 don't dump .ll file in this dir.
llvm-svn: 69426
2009-04-18 07:00:06 +00:00
Chris Lattner 24ad8621a4 __builtin_prefetch should be declared as "void __builtin_prefetch(const void *)",
not "const void __builtin_prefetch(void *)".  This fixes PR3912.

llvm-svn: 69425
2009-04-18 06:51:21 +00:00
Chris Lattner 974e1f40b3 rename test
llvm-svn: 69424
2009-04-18 06:49:47 +00:00
Chris Lattner 35dd5056fc fix PR3927 by being more careful about the pp test for identifier.
llvm-svn: 69423
2009-04-18 06:44:18 +00:00
Chris Lattner 5ca5d40cf4 second half of PR3940: #line requires simple digit sequence.
llvm-svn: 69422
2009-04-18 06:38:24 +00:00
Douglas Gregor 652d82a096 Store the type ID for __builtin_va_list in the PCH file, so that the
AST context's __builtin_va_list type will be set when the PCH file is
loaded. This fixes the crash when CodeGen'ing a va_arg expression
pulled in from a PCH file.

llvm-svn: 69421
2009-04-18 05:55:16 +00:00
Chris Lattner 751f045e32 this is really just a recommendation, not a requirement.
llvm-svn: 69416
2009-04-18 02:25:14 +00:00
Chris Lattner 2425bcb49a enforce requirements imposed by C90 6.8 TC1, fixing PR3919.
llvm-svn: 69415
2009-04-18 02:23:25 +00:00
Chris Lattner bc63de144f Fix PR3938 by taking into account C99 6.10p4.
llvm-svn: 69413
2009-04-18 01:34:22 +00:00
Chris Lattner b547394ba5 convert test to -verify style.
llvm-svn: 69412
2009-04-18 01:33:54 +00:00
Chris Lattner c17925da61 Substantially restructure function-like macro argument parsing.
Highlights: PP::isNextPPTokenLParen() no longer eats the ( 
when present.  We now simplify slightly the logic parsing
macro arguments.  We now handle PR3937 and other related cases
correctly.

llvm-svn: 69411
2009-04-18 01:13:56 +00:00
Douglas Gregor e3dcb2ddd1 FunctionDecl::getBody() is getting an ASTContext argument for use in
lazy PCH deserialization. Propagate that argument wherever it needs to
be. No functionality change, except that I've tightened up a few PCH
tests in preparation.

llvm-svn: 69406
2009-04-18 00:02:19 +00:00
Chris Lattner b40289b2b8 Fix two problems from PR3916, and one problem I noticed while hacking
on the code.

llvm-svn: 69404
2009-04-17 23:56:52 +00:00
Chris Lattner ca556cb3e3 implement PR3940: #line numbers not fully checked
llvm-svn: 69403
2009-04-17 23:37:49 +00:00
Chris Lattner 0003c27f5e #line is allowed to have macros that expand to nothing after them.
llvm-svn: 69401
2009-04-17 23:30:53 +00:00
Chris Lattner 6fdd57cba8 fix a crash compiling code with its own definition of objc_assign_weak.
rdar://6800430

llvm-svn: 69392
2009-04-17 22:12:36 +00:00
Chris Lattner 2581fc3fa9 tweak redefinition of a typedef a bit to fix a couple of problems:
1. We had logic in sema to decide whether or not to emit the error
   based on manually checking whether in a system header file.
2. we were allowing redefinitions of typedefs in class scope in C++
   if in header file.
3. there was no way to force typedef redefinitions to be accepted
   by the C compiler, which annoys me when stripping linemarkers out
   of .i files.

The fix is to split the C++ class typedef redefinition path from the
C path, and change the C path to be a warning that normally maps to
error.  This causes it to properly be ignored in system headers, 
etc. and gives us a way to control it.  Passing 
-Wtypedef-redefinition now turns the error into a warning.

One behavior change is that we now diagnose cases where you redefine
a typedef in your .c file that was defined in a header file.  This
seems like reasonable behavior, and the diagnostic now indicates that
it can be controlled with -Wtypedef-redefinition.

llvm-svn: 69391
2009-04-17 22:04:20 +00:00
Douglas Gregor ba6e557378 Fix two embarrassing PCH bugs:
1) Accidentally used delete [] on an array of statements that was allocated with ASTContext's allocator
  2) Deserialization of names with multiple declarations (e.g., a struct and a function) used the wrong mangling constant, causing it to view declaration IDs as Decl*s.

403.gcc builds and links properly.

llvm-svn: 69390
2009-04-17 21:46:47 +00:00
Douglas Gregor f994f062fd PCH support for inline assembly statements.
This completes support for all of C (+ extensions). We can (again)
build a PCH file for Carbon.h.

llvm-svn: 69385
2009-04-17 20:57:14 +00:00
Douglas Gregor 5ceb1a2dd9 PCH tests for va_arg expressions. Verified that the blocks test does create a BlockDeclRefExpr
llvm-svn: 69376
2009-04-17 20:06:59 +00:00
Chris Lattner fbbf539c45 fix a crash on invalid by making ActOnDeclarator create decl with
a dummy *function* type when it is recovering and knows it needs 
a function.  rdar://6802350 - clang crash on invalid input

llvm-svn: 69374
2009-04-17 19:32:54 +00:00
Douglas Gregor c95701da6c PCH support for blocks
llvm-svn: 69373
2009-04-17 19:21:43 +00:00
Douglas Gregor af97671954 PCH support for GNU statement expressions
llvm-svn: 69370
2009-04-17 19:05:30 +00:00
Douglas Gregor 779d865b48 PCH support for indirect gotos and address-of-label expressions.
llvm-svn: 69369
2009-04-17 18:58:21 +00:00
Chris Lattner 70a42144ca adjust for the new -Wvector-conversions option
llvm-svn: 69366
2009-04-17 18:39:25 +00:00
Douglas Gregor 6cc68a47b5 PCH support for labels and goto.
llvm-svn: 69364
2009-04-17 18:18:49 +00:00
Chris Lattner 10dae30049 Fix rdar://6800926 - crash compiling non-fragile _Bool bitfield ivar,
the functional change here is changing ConvertType -> ConvertTypeForMem
so that we handle i1 fields properly as memory.

llvm-svn: 69361
2009-04-17 17:46:19 +00:00
Chris Lattner ead1e0002f clean up run lines.
llvm-svn: 69359
2009-04-17 17:43:56 +00:00
Douglas Gregor 915b6c663d PCH support for declaration statements, and a test for PredefinedExpr
llvm-svn: 69356
2009-04-17 16:55:36 +00:00
Douglas Gregor f961e5921f PCH support for return statements.
Optimize PCH encoding for switch-case statements slightly, by making
the switch-case numbering local to a particular statement.

llvm-svn: 69355
2009-04-17 16:34:57 +00:00
Sebastian Redl 5775af1afd Implement lvalue test for conditional expressions.
Add a few commented lines to the test case that point out things that don't work yet.

llvm-svn: 69354
2009-04-17 16:30:52 +00:00
Anders Carlsson 6dc3575220 Add support for the __has_trivial_destructor type trait.
llvm-svn: 69345
2009-04-17 02:34:54 +00:00
Daniel Dunbar 3f4a2c286e Support QA_OVERRIDE_GCC3_OPTIONS
- Cover your eyes...

 - This is a simple but effective way to allow developers to build a
   project with clang while manipulating the command line, without
   having to edit the project itself.

llvm-svn: 69342
2009-04-17 01:54:00 +00:00
Daniel Dunbar c3e7cff6d3 Attributes on block functions were not being set.
- <rdar://problem/6800351> clang not producing correct large struct
   return code for Blocks

llvm-svn: 69337
2009-04-17 00:48:04 +00:00
Douglas Gregor 71517c47e6 PCH support for do-while and for loops
llvm-svn: 69334
2009-04-17 00:29:51 +00:00
Douglas Gregor e24cbc0f4b PCH support for while and continue statements
llvm-svn: 69332
2009-04-17 00:16:09 +00:00
Mike Stump 5c3285b6fb Fixup semantic analysis for nested blocks, and allow block literal
expressions that can be of static duration to be returned.
Radar 6786551

llvm-svn: 69331
2009-04-17 00:09:41 +00:00