Commit Graph

1022 Commits

Author SHA1 Message Date
Eli Friedman bd0e67362c Correct the order of the parameters to CheckAssignmentConstraints in
cleanup attribute checking.  The difference isn't normally visible, but it
can make a difference...

llvm-svn: 70104
2009-04-26 01:30:08 +00:00
Eli Friedman ab2784f2c1 Fix for PR4074: allow subscripting non-lvalue arrays in C90 mode.
I wasn't originally going to use this approach, but cases like 
test/Sema/expr-comma.c make things difficult.

llvm-svn: 70096
2009-04-25 23:46:54 +00:00
Eli Friedman 7524de1da2 Change isNullPointerConstant to be strict; hopefully this won't cause
any issues now that we have our own tgmath.h.

llvm-svn: 70090
2009-04-25 22:37:12 +00:00
Eli Friedman bb967cc98d Make VerifyIntegerConstantExpr print extension warnings for non-ICEs.
Overall, I'm not particularly happy with the current situation regarding 
constant expression diagnostics, but I plan to improve it at some point.

llvm-svn: 70089
2009-04-25 22:26:58 +00:00
Chris Lattner c71d08bc22 fix PR4073 by making designated initializer checking code use
VerifyIntegerConstantExpression instead of isIntegerConstantExpr.
This makes it ext-warn but tolerate things that fold to a constant
but that are not valid i-c-e's.

There must be a bug in the i-c-e computation though, because it
doesn't catch this case even with pedantic.

This also switches the later code to use EvaluateAsInt which is
simpler and handles everything that evaluate does.

llvm-svn: 70081
2009-04-25 21:59:05 +00:00
Chris Lattner b28fe9eae6 improve a diagnostic to make more sense.
llvm-svn: 70062
2009-04-25 18:52:45 +00:00
Chris Lattner edfa8d4557 Change SemaType's "GetTypeForDeclarator" and "ConvertDeclSpecToType" to
always return a non-null QualType + error bit.  This fixes a bunch of 
cases that didn't check for null result (and could thus crash) and eliminates
some crappy code scattered throughout sema.

This also improves the diagnostics in the recursive struct case to eliminate
a bogus second error.  It also cleans up the case added to function.c by forming
a proper function type even though the declarator is erroneous, allowing the
parameter to be added to the function.  Before:

t.c:2:1: error: unknown type name 'unknown_type'
unknown_type f(void*P)
^
t.c:4:3: error: use of undeclared identifier 'P'
  P+1;
  ^

After:
t.c:2:1: error: unknown type name 'unknown_type'
unknown_type f(void*P)
^

llvm-svn: 70023
2009-04-25 08:47:54 +00:00
Chris Lattner f6d1c9c7f0 This is a pretty big cleanup for how invalid decl/type are handle.
This gets rid of a bunch of random InvalidDecl bools in sema, changing
us to use the following approach:

1. When analyzing a declspec or declarator, if an error is found, we 
   set a bit in Declarator saying that it is invalid.
2. Once the Decl is created by sema, we immediately set the isInvalid
   bit on it from what is in the declarator.  From this point on, sema
   consistently looks at and sets the bit on the decl.

This gives a very clear separation of concerns and simplifies a bunch
of code.  In addition to this, this patch makes these changes:

1. it renames DeclSpec::getInvalidType() -> isInvalidType().
2. various "merge" functions no longer return bools: they just set the
   invalid bit on the dest decl if invalid.
3. The ActOnTypedefDeclarator/ActOnFunctionDeclarator/ActOnVariableDeclarator
   methods now set invalid on the decl returned instead of returning an
   invalid bit byref.
4. In SemaType, refering to a typedef that was invalid now propagates the
   bit into the resultant type.  Stuff declared with the invalid typedef
   will now be marked invalid.
5. Various methods like CheckVariableDeclaration now return void and set the
   invalid bit on the decl they check.


There are a few minor changes to tests with this, but the only major bad
result is test/SemaCXX/constructor-recovery.cpp.  I'll take a look at this
next.

llvm-svn: 70020
2009-04-25 08:06:05 +00:00
Chris Lattner 9af40c1e14 fix PR4049, a crash on invalid, by making sema install the right number of
parameters in a functiondecl, even if the decl is invalid and has a confusing
Declarator.  On the testcase, we now emit one beautiful diagnostic:

t.c:2:1: error: unknown type name 'unknown_type'
unknown_type f(void*)
^

GCC 4.0 produces:

t.c:2: error: syntax error before ‘f’
t.c: In function ‘f’:
t.c:2: error: parameter name omitted

and GCC 4.2:

t.c:2: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘f’

llvm-svn: 70016
2009-04-25 06:12:16 +00:00
Chris Lattner ae4ee5be22 in:
typedef void foo(void);

We get a typedef for a functiontypeproto with no arguments, not
one with one argument and type void.  This means the code being
removed in SemaDecl is dead.

llvm-svn: 70013
2009-04-25 05:51:56 +00:00
Eli Friedman d3a5a9d7fa Add handling for complex->int, int->complex float, and float->complex
int.  Note that constant int->complex float and float->complex int casts
were being miscompiled.

llvm-svn: 69821
2009-04-22 19:23:09 +00:00
Chris Lattner dc00437fa0 change implicit int warnings to point to the identifier, not the
start of the declspec.  The fixit still goes there, and we underline
the declspec.  This helps when the start of the declspec came from a
macro that expanded from a system header.  For example, we now produce:

t.c:2:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
static x;
~~~~~~ ^

llvm-svn: 69777
2009-04-22 05:27:59 +00:00
Chris Lattner ed462a8d44 Fix rdar://6814950 - stdint.h isn't "-pedantic -std=c89" clean,
by marking the predefines buffer as a system header.  The problem 
with stdint is that it was getting problems like this:

/Volumes/Projects/cvs/llvm/Debug/lib/clang/1.0/include/stdint.h:43:9: warning: 'long long' is an extension when C99 mode is not enabled
typedef __INT64_TYPE__ int64_t;
        ^
<built-in>:73:29: note: instantiated from:
#define __INT64_TYPE__ long long
                            ^

We correctly silence warnings in system headers, but only if the 
spelling location of the token came from the system header.  This is
designed so that if you use a system macro in your code that you don't
get punished for its definition.  This is all cool except that the 
predefines buffer wasn't considered a system header.

llvm-svn: 69770
2009-04-22 03:42:19 +00:00
Chris Lattner f8dc07369a Fix some mishandling of the attr(gnu_inline) mode when used with
extern.  Previously we would warn about it and ignore the attribute.
This is incorrect, it should be handled as a c89 "extern inline" 
function.  Many thanks to Matthieu Castet for pointing this out and
beating me over the head until I got it.

PR3988: extern inline function are not externally visible
llvm-svn: 69756
2009-04-22 00:03:30 +00:00
Mike Stump 3cfd5614e7 Resolve merge conflict better.
llvm-svn: 69748
2009-04-21 23:03:34 +00:00
Mike Stump d79b5a85b0 Tighten up blocks type checking. This was discussed back in the
r56595 timeframe, but left undone.  Radar 6812711

llvm-svn: 69745
2009-04-21 22:51:42 +00:00
Chris Lattner 41b8694777 Fix rdar://6814047, a crash on invalid in blocks code I noticed when
working on the previous fix.

llvm-svn: 69742
2009-04-21 22:38:46 +00:00
Chris Lattner 497d7b0c8a fix marking of nested blocks with the "hasBlockDeclRefExprs" to
mark exactly the blocks which have references that are "live through".
This fixes a rejects valid: 
rdar://6808730 - [sema] [blocks] block rejected at global scope

llvm-svn: 69738
2009-04-21 22:26:47 +00:00
Douglas Gregor beecd58e21 Explictly track tentative definitions within Sema, then hand those
tentative definitions off to the ASTConsumer at the end of the
translation unit. 

Eliminate CodeGen's internal tracking of tentative definitions, and
instead hook into ASTConsumer::CompleteTentativeDefinition. Also,
tweak the definition-deferal logic for C++, where there are no
tentative definitions.

Fixes <rdar://problem/6808352>, and will make it much easier for
precompiled headers to cope with tentative definitions in the future.

llvm-svn: 69681
2009-04-21 17:11:58 +00:00
Chris Lattner 1f02e054a9 Fix PR4027 + rdar://6808859, we were rejecting implicit casts of
aggregates even though we already accept explicit ones.  Easy fix.

llvm-svn: 69661
2009-04-21 05:19:11 +00:00
Chris Lattner ddf6ca0355 the __gnuc_inline__ attribute is actually named __gnu_inline__,
PR4023

llvm-svn: 69618
2009-04-20 19:12:28 +00:00
Chris Lattner f9b00eb7dc clean up anonymous bitfield diagnostics, PR4017
llvm-svn: 69608
2009-04-20 17:29:38 +00:00
Eli Friedman 3a1e692fed Some cleanup and bug-fixing for address-of checking. This causes a couple of
minor accepts-invalid regressions, but we weren't really rejecting them for 
the right reason.  We really need a more general solution to detect all the 
cases of the promotion of arrays with a register storage class.

llvm-svn: 69586
2009-04-20 08:23:18 +00:00
Eli Friedman daea3f62b5 Print an error for uses of __thread on targets which don't support it.
llvm-svn: 69553
2009-04-19 21:48:33 +00:00
Eli Friedman 08a375b954 Tests for __thread specifier.
llvm-svn: 69543
2009-04-19 20:29:08 +00:00
Chris Lattner 45542ea107 run the jump checker on blocks, even though they don't have gotos,
they do allow switches.

llvm-svn: 69510
2009-04-19 05:28:12 +00:00
Chris Lattner 9fecd743ca add a new Sema::CurFunctionNeedsScopeChecking bool that is used to avoid
calling into the jump checker when a function or method is known to contain
no VLAs or @try blocks.

llvm-svn: 69509
2009-04-19 05:21:20 +00:00
Chris Lattner de6240cd45 apparently gotos aren't allowed at all in blocks. Stub out a testcase for when/if they are.
llvm-svn: 69507
2009-04-19 04:51:27 +00:00
Chris Lattner 4be550ec68 more testcases of variably modified types.
llvm-svn: 69506
2009-04-19 04:48:07 +00:00
Chris Lattner c67540501f second half of indirect jump checking: make sure that any
address taken labels are in function scope

llvm-svn: 69499
2009-04-19 01:16:06 +00:00
Chris Lattner 0bf2dd2ed4 First half of jump scope checking for indirect goto.
llvm-svn: 69498
2009-04-19 01:05:26 +00:00
Chris Lattner 19bd27f493 add some testcases that we do not correctly handle.
llvm-svn: 69492
2009-04-18 23:07:55 +00:00
Chris Lattner f7fcb516de reimplement DeclStmt handling so that we correctly handle intermixed
VLA's and statement expressions.

llvm-svn: 69491
2009-04-18 23:01:20 +00:00
Chris Lattner a0cfd6b610 rearrange.
llvm-svn: 69490
2009-04-18 22:56:52 +00:00
Chris Lattner fb5ef701d5 add testcases for some more scary/horrible things that work.
llvm-svn: 69488
2009-04-18 22:42:18 +00:00
Chris Lattner 1d4fc1bc6d unconditionally check for goto correctness. This is because switch
statements don't end up in the LabelMap so we don't have a quick way
to filter them.  We could add state to Sema (a "has vla" and "has 
jump" bit) to try to filter this out, but that would be sort of gross
and I'm not convinced it is the best way.  Thoughts welcome.

llvm-svn: 69476
2009-04-18 21:00:42 +00:00
Chris Lattner b0cb5b2db2 merge two tests.
llvm-svn: 69466
2009-04-18 20:12:56 +00:00
Chris Lattner 96b3139773 abstract the SwitchStack for blocks just like we do the goto labels.
This fixes a crash on invalid (test10). rdar://6805469

llvm-svn: 69465
2009-04-18 20:10:59 +00:00
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 07f62f1881 improve wording of scope violation error messages.
llvm-svn: 69456
2009-04-18 18:42:55 +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
Chris Lattner 9f3e711503 add another testcase
llvm-svn: 69432
2009-04-18 07:54:11 +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 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
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
Chris Lattner 70a42144ca adjust for the new -Wvector-conversions option
llvm-svn: 69366
2009-04-17 18:39:25 +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
Steve Naroff a0c32704e2 Fix <rdar://problem/6765383> clang-6: clang does not appear to support declaring a static Block 'const'.
llvm-svn: 69306
2009-04-16 19:02:57 +00:00
Daniel Dunbar c7ba533378 Add warning when a tentative array definition is assumed to have one element.
- Also, fixed one to actually be one (instead of zero). :)

llvm-svn: 69226
2009-04-15 21:35:27 +00:00
Steve Naroff 439a3e4106 Fix <rdar://problem/6786597> varargs not supported for Blocks under clang.
Teach Sema::SemaBuiltinVAStart() about blocks.

llvm-svn: 69201
2009-04-15 19:33:47 +00:00
Steve Naroff 6f84266619 Revert previous patch (will commit a fix soon).
llvm-svn: 69178
2009-04-15 16:58:41 +00:00
Steve Naroff 635168aa33 Fix <rdar://problem/6789707> "warning: 'extern' variable has an initializer" not correct for __private_extern__.
llvm-svn: 69167
2009-04-15 15:20:03 +00:00
Douglas Gregor d5846a1eb5 Implement support for designated initializers that refer to members of
anonymous structs or unions. Fixes PR3778.

llvm-svn: 69153
2009-04-15 06:41:24 +00:00
Daniel Dunbar c2223ab255 Improve "assignment to cast" diagnostic.
- Strip off extra parens when looking for casts.
 - Change the location info to point at the cast (instead of the
   assignment).

For example, on
  
  int *b;
  #define a ((void*) b)
  void f0() {
    a = 10;
  }
  
we now emit:
  
  /tmp/t.c:4:3: error: assignment to cast is illegal, lvalue casts are not supported
    a = 10;
    ^ ~
  /tmp/t.c:2:12: note: instantiated from:
  #define a ((void*) b)
            ~^~~~~~~~~~
  
instead of:
  
  /tmp/t.c:4:5: error: expression is not assignable
    a = 10;
    ~ ^

llvm-svn: 69114
2009-04-15 00:08:05 +00:00
Daniel Dunbar 9351c02bef Strip paren expressions when trying to diagnose "cast as lvalue"
extension.

llvm-svn: 69100
2009-04-14 23:26:44 +00:00
Chris Lattner a723ba97db Fix a regression in a previous patch that broke implicit
int in a bitfield.  Shantonu found this in a gcc testsuite file.

llvm-svn: 69074
2009-04-14 21:16:09 +00:00
Chris Lattner 4225e23e62 implement some sema for gnuc_inline attribute. Reject always_inline and no_inline on objc methods.
llvm-svn: 69051
2009-04-14 17:02:11 +00:00
Daniel Dunbar 0ca1660129 Audit __private_extern__ handling.
- Exposed quite a few Sema issues and a CodeGen crash.

 - See FIXMEs in test case, and in SemaDecl.cpp (PR3983).

I'm skeptical that __private_extern__ should actually be a storage
class value. I think that __private_extern__ basically amounts to
  extern A __attribute__((visibility("hidden")))
and would be better off handled (a) as that, or (b) with an extra bit
in the VarDecl.

llvm-svn: 69020
2009-04-14 02:25:56 +00:00
Eli Friedman 337cd3a536 PR3461: reject initializer for incomplete type. Based on patch by Tim
Northover.

llvm-svn: 68991
2009-04-13 21:28:54 +00:00
Chris Lattner 5c6160d019 fix rdar://6774906, a crash handling implicit conversions between pointers
in different address spaces.

llvm-svn: 68941
2009-04-13 06:04:39 +00:00
Chris Lattner 14bdb78430 fix a valgrind problem I noticed while developing another patch,
if a decl is invalid, it isn't added to the Decls array, so we
need to pass in Decls.size() to avoid reading uninit memory.

llvm-svn: 68913
2009-04-12 20:51:10 +00:00
Chris Lattner 9edfeed6b8 add radar number
llvm-svn: 68864
2009-04-11 17:26:58 +00:00
Steve Naroff ea4c780da1 Sema::CheckConditionalOperands(): Soften pointer/integer mismatch from error->warning.
Fixes <rdar://problem/6762239> [sema] gcc incompatibility; error on incompatible operand types in ?:.

llvm-svn: 68617
2009-04-08 17:05:15 +00:00
Douglas Gregor b53c0c29c0 -Wmissing-prototypes shouldn't complain about main() missing a prototype.
Fixes <rdar://problem/6759522>

llvm-svn: 68611
2009-04-08 15:21:36 +00:00
Daniel Dunbar d18049ab1d Driver: Manually translate a number of -f with no- variants options to
clang.
 - We will eventually want some more driver infrastructre for this
   probably.

 - For now, the clang-cc interface stays relatively the same, but we
   don't accept multiple instances anymore, or the [no-] variants
   directly.

llvm-svn: 68550
2009-04-07 21:16:11 +00:00
Eli Friedman 574c745370 Diagnose uses of function specifiers on declarations which don't declare
functions.  Fixes PR3941.

llvm-svn: 68541
2009-04-07 19:37:57 +00:00
Chris Lattner a8d2dbd181 Daniel convinced me that accepting "const va_list" arguments to va_arg is
a really really bad idea.  Now that we emit an error about the unpromoted
type, users should be able to understand what is going on.

llvm-svn: 68447
2009-04-06 17:07:34 +00:00
Chris Lattner 56382aa890 in va_arg diagnostics, print out the unpromoted type. This makes the
diagnostic use the va_list typedef more often, see the difference in the 
changed testcase.

llvm-svn: 68441
2009-04-05 15:49:53 +00:00
Chris Lattner 3f5cd77db2 Add a warning for questionable va_args usage.
llvm-svn: 68435
2009-04-05 00:59:53 +00:00
Chris Lattner 9e658eccab GCC compatibility: gcc allows applying va_args to const
va_lists for some reason.  This fixes rdar://6726818

llvm-svn: 68434
2009-04-05 00:52:59 +00:00
Douglas Gregor 68bc53967e Move the fix-it tests into their own subdirectory
llvm-svn: 68325
2009-04-02 17:19:13 +00:00
Douglas Gregor d8e97def58 When calling a function without a prototype for which we have a
definition, warn if there are too many/too few function call
arguments.

llvm-svn: 68318
2009-04-02 15:37:10 +00:00
Douglas Gregor 3b3e0b3c1e Make darned sure that the -fixit tests are testing what we want them to test
llvm-svn: 68289
2009-04-02 04:59:27 +00:00
Douglas Gregor 7e70204613 Update comments in fixit tests
llvm-svn: 68279
2009-04-02 03:20:30 +00:00
Douglas Gregor 578dae57ca Introduce a "-fixit" mode to clang-cc that applies code-modification hints.
llvm-svn: 68268
2009-04-02 01:08:08 +00:00
Mike Stump 21c81fdce4 We no longer expect an warning as this is now valid.
llvm-svn: 68263
2009-04-02 00:04:12 +00:00
Douglas Gregor 170512fa78 Add some more code modification hints
llvm-svn: 68261
2009-04-01 23:51:29 +00:00
Douglas Gregor e3e01a20d0 Add code modification hints to various parsing-related diagnostics.
Plus, reword a extension warnings to avoid talking about "ISO C" when
the extension might also be available in C++ or C++0x. 

llvm-svn: 68257
2009-04-01 22:41:11 +00:00
Daniel Dunbar 7fdda1d695 Split PTH tests from carbon.c into separate test.
llvm-svn: 68223
2009-04-01 18:25:32 +00:00
Douglas Gregor 7c15b9c9a0 Add testcase for -Wmissing-prototypes
llvm-svn: 68212
2009-04-01 16:38:48 +00:00
Ted Kremenek 455de13de1 Re-enable PTH testing for cocoa.h and carbon.h. This tests that PTH works on
real-world header files and these tests have caught serious bugs in the past.

llvm-svn: 68204
2009-04-01 15:28:20 +00:00
Daniel Dunbar 386ef885bb Pull clang-cc code for generating PTH files based on the input type.
- <rdar://problem/6741594> [pth] don't abuse -x to drive pth
   generation

 - Simpler, and fixes PR3915.

Cleanup test cases for PTH:
 - Update to use -emit-pth

 - Removed PTH test of carbon.c and cocoa.mm; these didn't actually
   verify anything, and since PTH is token based the extra coverage
   (over cocoa.m) isn't particularly helpful.

 - Split PTH tests in cocoa.m to cocoa-pth.m, solely to increase
   available parallelism when running tests.

Ted, could you update the PTH test cases (include-pth.c and
cocoa-pth.m) to have some sort of positive check that the PTH is
getting used? "# of PTH cache hits" or "tokens read from PTH cache"
statistics would work great. :)

llvm-svn: 68189
2009-04-01 05:09:09 +00:00
Mike Stump cafa0a9746 Fix block comparisons. Radar 6732116.
llvm-svn: 68171
2009-04-01 01:17:39 +00:00
Steve Naroff 1bf3b718cd Add -Wdeprecated-declarations to driver and add a test case.
llvm-svn: 68117
2009-03-31 17:28:26 +00:00
Steve Naroff f2a880ca22 Incorporate feedback from Eli.
llvm-svn: 68107
2009-03-31 10:29:45 +00:00
Chris Lattner 5d68896c7b Codegen sometimes crashes on comparisons that aren't legal, just
disable this feature for now, to err on the side of rejecting instead
of sometimes crashing.  rdar://6326239

llvm-svn: 68088
2009-03-31 07:46:52 +00:00
Steve Naroff 7b753d21b5 Implement UCN support for C string literals (C99 6.4.3) and add some very basic tests. Chris Goller has graciously offered to write some test to help validate UCN support.
From a front-end perspective, I believe this code should work for ObjC @-strings. At the moment, I believe we need to tweak the code generation for @-strings (which doesn't appear to handle them). Will be investigating.

llvm-svn: 68076
2009-03-30 23:46:03 +00:00
Chris Lattner efb0f111f1 hoist checks for ; and in out of ParseInitDeclaratorListAfterFirstDeclarator
into ParseSimpleDeclaration, and improve a diagnostic.

llvm-svn: 68009
2009-03-29 17:18:04 +00:00
Douglas Gregor 5c7c9cb678 Make our diagnostics about the obsolete GNU designated-initializer
syntax into extension warnings, and provide code-modification hints
showing how to fix the problem.

llvm-svn: 67885
2009-03-28 00:41:23 +00:00
Eli Friedman 7044b76707 Finish off semantic analysis for regparm, and remove the warning. Also
remove a redundant error in CodeGen.

llvm-svn: 67868
2009-03-27 21:06:47 +00:00
Chris Lattner 9eac931b5f Fix rdar://6719156 - clang should emit a better error when blocks are disabled but are used anyway
by changing blocks from being disabled in the parser to being disabled
in Sema.

llvm-svn: 67816
2009-03-27 04:18:06 +00:00
Eli Friedman 6568eef9f9 Sanity-check argument to indirect goto.
llvm-svn: 67746
2009-03-26 07:32:37 +00:00
Douglas Gregor ac1fb65d0c Make sure to use RequireCompleteType rather than testing for
incomplete types. RequireCompleteType is needed when the type may be
completed by instantiating a template.

llvm-svn: 67643
2009-03-24 19:52:54 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Eli Friedman 94c25c66b5 Fix PR3868 by making Evaluate handle cases like "(long)&a + 4".
llvm-svn: 67593
2009-03-24 01:14:50 +00:00
Eli Friedman 703a77f313 Fix a couple of tests.
llvm-svn: 67592
2009-03-24 01:11:18 +00:00
Ted Kremenek fd14fade2f Implement '#pragma unused'.
llvm-svn: 67569
2009-03-23 22:28:25 +00:00
Douglas Gregor 893c2c963a Fix PR3855. When we encounter an incompatible redeclaration of a
library function, accept this declaration and pretend that we do not
know that this is a library function. autoconf depends on this
(broken) behavior.

llvm-svn: 67541
2009-03-23 17:47:24 +00:00
Douglas Gregor d6b05f705b Tighten up the determination of whether a function declaration has a
prototype. Thanks Eli!

llvm-svn: 67533
2009-03-23 16:26:51 +00:00
Douglas Gregor d4eca014e0 Thanks to Eli for pointing out my misreading of 6.2.2p5
llvm-svn: 67530
2009-03-23 16:17:01 +00:00
Eli Friedman 6400433980 Minor enhancements to Evaluate.
llvm-svn: 67503
2009-03-23 04:38:34 +00:00
Eli Friedman 80160bd483 Partial implementation of PR3342: break out pointer sign
incompatibilities in assignments from other pointer incompatibilities.  
Based off of the patch in PR3342.  (This doesn't implement -Wno-pointer-sign,
but I don't know the driver code very well.)

llvm-svn: 67494
2009-03-22 23:59:44 +00:00
Eli Friedman e8dd7b3228 Adjust isModifiableLvalue to give a slightly more useful diagnostic for
attempting to illegally modify a BlockDeclRefExpr.

llvm-svn: 67491
2009-03-22 23:26:56 +00:00
Eli Friedman 7fa3faa417 Fix code to mark block variables as const to actually work. Fix
isObjCObjectPointerType to work with qualified types.  Adjust test for 
changes.

If the SemaExpr changes are wrong or break existing code, feel free to 
delete the "ExprTy.addConst();" line and revert my changes to 
test/Sema/block-literal.c.

llvm-svn: 67489
2009-03-22 23:00:19 +00:00
Eli Friedman 38f8493752 Add testcase for incomplete call/return types for calls.
llvm-svn: 67486
2009-03-22 22:03:03 +00:00
Ted Kremenek dfd72c2b44 Fix <rdar://problem/6704086> by allowing the format string checking in Sema to
allow non-literal format strings that are variables that (a) permanently bind to
a string constant and (b) whose string constants are resolvable within the same
translation unit.

llvm-svn: 67404
2009-03-20 21:35:28 +00:00
Ted Kremenek 9ffbe41a6c Fix <rdar://problem/6703892> by not warning about self-comparisons of enum
constants.

llvm-svn: 67390
2009-03-20 18:35:45 +00:00
Douglas Gregor 07d8e3a500 Allow flexible array initializers that are not surrounded by
braces. We now build the appropriate fully-structured initializer list
for such things. Per PR3618, verified that we're getting the right
code generation.

llvm-svn: 67353
2009-03-20 00:32:56 +00:00
Douglas Gregor 3731162ade Variables marked as "extern" can actually have internal linkage if
there is a previous declaration marked "static". This fixes PR3645.

llvm-svn: 67336
2009-03-19 22:01:50 +00:00
Douglas Gregor 3729f240af If a function is declared as, e.g.,
F f;

where F is a typedef of a function type, then the function "f" has a
prototype. This is a slight tweak to Chris's suggested fix in
PR3817. Fixes PR3817 and PR3840.

llvm-svn: 67313
2009-03-19 18:14:46 +00:00
Chris Lattner 9363e3106e don't crash when sentinel attribute is used on function without a prototype,
discovered as part of PR3817

llvm-svn: 67127
2009-03-17 23:03:47 +00:00
Anders Carlsson 6caa9dd693 Check signedness of bitfield sizes.
llvm-svn: 67045
2009-03-16 18:19:21 +00:00
Chris Lattner cda4d7e196 introduce a new -fheinous-gnu-extensions flag that enables really
really horrible extensions that are disabled by default but that can
be accepted by -fheinous-gnu-extensions (but which always emit a 
warning when enabled).

As our first instance of this, implement PR3788/PR3794, which allows
non-lvalues in inline asms in contexts where lvalues are required. bleh.

llvm-svn: 66910
2009-03-13 17:38:01 +00:00
Steve Naroff cfb6cf4c02 Reimplement fix for <rdar://problem/6451399> problems with labels and blocks.
This solution is much simpler (and doesn't add any per-scope overhead, which concerned Chris). 

The only downside is the LabelMap is now declared in two places (Sema and BlockSemaInfo). My original fix tried to unify the LabelMap in "Scope" (which would support nested functions in general). In any event, this fixes the bug given the current language definition. If/when we decide to support GCC style nested functions, this will need to be tweaked.

llvm-svn: 66896
2009-03-13 16:03:38 +00:00
Steve Naroff 846b1ec40f Remove ActiveScope (revert http://llvm.org/viewvc/llvm-project?view=rev&revision=65694 and http://llvm.org/viewvc/llvm-project?view=rev&revision=66741).
Will replace with something better today...

llvm-svn: 66893
2009-03-13 15:38:40 +00:00
Chris Lattner 14311925f2 fix PR3258 by rejecting invalid numeric operands.
llvm-svn: 66618
2009-03-11 00:23:13 +00:00
Chris Lattner 3fa25c683f checking for symbolic operands as well as % at end of string.
llvm-svn: 66614
2009-03-11 00:06:36 +00:00
Chris Lattner a41b847401 reject invalid escape characters in extended-asm strings with a nice diagnostic.
llvm-svn: 66605
2009-03-10 23:51:40 +00:00
Douglas Gregor 0760fa1618 Add type checking for tentative definitions at the end of the
translation unit.

Thread the various declarations of variables via
VarDecl::getPreviousDeclaration.

llvm-svn: 66601
2009-03-10 23:43:53 +00:00
Douglas Gregor 8145742349 Partial fix for PR3310, concerning type-checking for tentative
definitions. We were rejecting tentative definitions of incomplete
(which is bad), and now we don't.

This fix is partial because we don't do the end-of-translation-unit
initialization for tentative definitions that don't ever have any
initializers specified.

llvm-svn: 66584
2009-03-10 21:58:27 +00:00
Chris Lattner ed9f14c4c9 do not warn about -=/=- confusion with macros, thanks to rdogra for a testcase.
llvm-svn: 66416
2009-03-09 07:11:10 +00:00
Chris Lattner 40dc267160 undefined -> unspecified. Thanks Mike.
llvm-svn: 66388
2009-03-08 19:52:14 +00:00
Chris Lattner 222b8bd6ad implement PR3753, warning about comparisons with a string literal.
llvm-svn: 66387
2009-03-08 19:39:53 +00:00
Chris Lattner 36c39c9b0a refine the "use of unary operator that may be intended as compound assignment (+=)"
warning to only trigger when there is whitespace or something else after the + as
suggested by Eli.

llvm-svn: 66370
2009-03-08 06:51:10 +00:00
Douglas Gregor 65530cb62e Tweak warning text from the last commit
llvm-svn: 66309
2009-03-06 23:46:13 +00:00
Douglas Gregor 3e06dbf48c Downgrade complaints about the use of variable-sized types within a
struct to an extension warning to match the behavior of GNU C, which
addresses the Sema part of PR3671.

llvm-svn: 66308
2009-03-06 23:41:27 +00:00
Douglas Gregor d9f92e2a06 Clean up some error messages with anonymous structs/unions and member declaration parsing. Fixes PR3680
llvm-svn: 66305
2009-03-06 23:28:18 +00:00
Douglas Gregor 2e7cba6208 Use the 'declaration does not declare anything' error when we see an anonymous struct/union declaration outside of a struct or union in C
llvm-svn: 66303
2009-03-06 23:06:59 +00:00
Douglas Gregor a74a29771f Implement GNU C semantics for K&R function definitions that follow a
prototype of the same function, where the promoted parameter types in
the K&R definition are not compatible with the types in the
prototype. Fixes PR2821.

llvm-svn: 66301
2009-03-06 22:43:54 +00:00
Daniel Dunbar e03c6102cc Handle #pragma pack(0). I left this out of diagnostic because users should
really use pack() instead.
 - <rdar://problem/6650243> clang warns about '#pragma pack(0)'

llvm-svn: 66287
2009-03-06 20:45:54 +00:00
Douglas Gregor d45b93bdd6 Implement the GNU semantics for forward declarations of enum types in
C and C++. Fixes PR3688.

llvm-svn: 66282
2009-03-06 18:34:03 +00:00
Daniel Dunbar 5cb85ebe94 Add Parse/Sema support for weak_import attribute.
- Also, diagnose weak applied to types.

llvm-svn: 66259
2009-03-06 06:39:57 +00:00
Chris Lattner 73bf7b42b6 fix PR3607 and a fixme, by checking bitfield constraints
more consistently.

llvm-svn: 66210
2009-03-05 22:45:59 +00:00
Eli Friedman 9ad7244f5b Check that the return type for function definitions is complete.
llvm-svn: 66027
2009-03-04 07:30:59 +00:00
Eli Friedman 4735374e39 PR3691: Add support for complex modes. I also tossed in support for XF
while I was at it.  There are still a lot of diagnostics missing from 
this code, and it isn't completely correct for anything other than x86, but 
it should work correctly on x86 for valid cases.

llvm-svn: 65935
2009-03-03 06:41:03 +00:00
Chris Lattner 5a9a892e48 fix PR#
llvm-svn: 65906
2009-03-03 00:00:26 +00:00
Chris Lattner e29509a6e1 fix PR2639
llvm-svn: 65869
2009-03-02 20:58:48 +00:00
Douglas Gregor 5a80bd1504 Rework the way we find locally-scoped external declarations when we
need them to evaluate redeclarations or call a function that hasn't
already been declared. We now keep a DenseMap of these locally-scoped
declarations so that they are not visible but can be quickly found,
e.g., when we're looking for previous declarations or before we go
ahead and implicitly declare a function that's being called. Fixes
PR3672.

llvm-svn: 65792
2009-03-02 00:19:53 +00:00
Anders Carlsson 6c885805cd Fix invalid VLAs/VMs in Sema::ActOnVariableDeclarator, so that the variable will have the right type by the time the initializer is checked. This ensures that code like
int a[(int)(1.0 / 1.0) = { 1 } will work.

Eli, please review.
 

llvm-svn: 65725
2009-02-28 21:56:50 +00:00
Steve Naroff d123bd05ca Fix <rdar://problem/6451399> problems with labels and blocks.
- Move the 'LabelMap' from Sema to Scope. To avoid layering problems, the second element is now a 'StmtTy *', which makes the LabelMap a bit more verbose to deal with.
- Add 'ActiveScope' to Sema. Managed by ActOnStartOfFunctionDef(), ObjCActOnStartOfMethodDef(), ActOnBlockStmtExpr().
- Changed ActOnLabelStmt(), ActOnGotoStmt(), ActOnAddrLabel(), and ActOnFinishFunctionBody() to use the new ActiveScope.
- Added FIXME to workaround in ActOnFinishFunctionBody() (for dealing with C++ nested functions).  

llvm-svn: 65694
2009-02-28 16:48:43 +00:00
Eli Friedman cba899ff7b Check a few more kinds of declarations that make a scope.
llvm-svn: 65680
2009-02-28 06:22:14 +00:00
Eli Friedman f69d09bae5 Start of checking for gotos which jump to an illegal destination.
As far as I know, this catches all cases of jumping into the scope of a 
variable with a variably modified type (excluding statement 
expressions) in C.  This is missing some stuff we probably want to check
(other kinds of variably modified declarations, statement expressions, 
indirect gotos/addresses of labels in a scope, ObjC @try/@finally, cleanup 
attribute), the diagnostics aren't very good, and it's not particularly 
efficient, but it's a decent start.

This patch is a slightly modified version of the patch I attached to
PR3259, and it fixes that bug.  I was sort of planning on improving 
it, but I think it's okay as-is, especially since it looks like CodeGen 
doesn't have any use for this sort of data structure.  The only 
significant change I can think of from the version I attached to PR3259 
is that this version skips running the checking code when a function 
doesn't contain any labels.

This patch doesn't cover case statements, which also need similar 
checking; I'm not sure how we should deal with that. Extending the goto 
checking to also check case statements wouldn't be too hard; it's just a 
matter of keeping track of the scope of the closest switch and checking that
the scope of every case is the same as the scope of the switch.  That said, 
it would likely be a performance hit to run this check on every 
function (it's an extra pass over the entire function), so we probably want
some other solution.

llvm-svn: 65678
2009-02-28 05:41:13 +00:00
Eli Friedman a1c7b6c5f6 Fix obvious shortcoming in the implementations of Evaluate for
integer __real__ and __imag__.  Not sure how I missed this.

llvm-svn: 65677
2009-02-28 03:59:05 +00:00
Chris Lattner 7b0ec8a9df upgrade various 'implicit int' warnings from an ext-warn to warning when not
in C89 mode.  This makes it enabled by default instead of only enabled with
-pedantic.  Clang defaults to c99 mode, so people will see this more often
than with GCC, but they can always use -std=c89 if they really want c89.

llvm-svn: 65647
2009-02-27 18:53:28 +00:00
Ted Kremenek 9723bcf60f When checking printf-arguments for functions with '__attribute__ ((format (printf, X, Y)))'
set HasVAListArg to true when 'Y' is 0 (i.e., ignore the data arguments).

This fixes <rdar://problem/6623513>.

llvm-svn: 65642
2009-02-27 17:58:43 +00:00
Daniel Dunbar 13454cfcb0 Oops, Ted beat me to it. I'll just play angry god and remove his version!
llvm-svn: 65638
2009-02-27 17:10:38 +00:00
Daniel Dunbar 8d42281150 Add coverage of "member of anonymous union redeclares ..." diagnostic.
llvm-svn: 65637
2009-02-27 17:07:01 +00:00
Ted Kremenek dd34e06eeb Add test case for PR 3675.
llvm-svn: 65635
2009-02-27 16:48:08 +00:00
Eli Friedman 988a16b9b8 Change the AST generated for offsetof a bit so that it looks like a
normal expression, and change Evaluate and IRGen to evaluate it like a 
normal expression.  This simplifies the code significantly, and fixes 
PR3396.

llvm-svn: 65622
2009-02-27 06:44:11 +00:00
Eli Friedman 8d03f59479 Some additional ICE tests.
llvm-svn: 65614
2009-02-27 04:46:32 +00:00
Chris Lattner 09e592ea33 rename test
llvm-svn: 65587
2009-02-26 23:36:18 +00:00
Chris Lattner 7ec0bb6bc0 ok, not as broken as I thought, just confusing. This allows
initialization of wchar_t arrays with wide strings, and generalizes
wchar_size.c to work on all targets.

llvm-svn: 65586
2009-02-26 23:36:02 +00:00
Eli Friedman adf40d4bef Fix for PR3663/3669: use TryToFixInvalidVariablyModifiedType for
variable declarations where applicable.  Also, a few fixes to 
TryToFixInvalidVariablyModifiedType for issues that this exposed.

llvm-svn: 65500
2009-02-26 03:58:54 +00:00
Anders Carlsson f2f2e7f6a1 Use CheckAssignmentConstraints for checking the cleanup attr function. Fixes PR3656.
llvm-svn: 65461
2009-02-25 17:19:08 +00:00
Douglas Gregor 739ef0c183 C99 DR #316 implies that the function parameter types that are known
only from a function definition (that does not have a prototype) are
only used to determine the compatible with other declarations of that
same function. In particular, when referencing the function we pretend
as if it does not have a prototype. Implement this behavior, which
fixes PR3626.

llvm-svn: 65460
2009-02-25 16:33:18 +00:00
Douglas Gregor eddf4333fd When we're declaring an object or function with linkage, teach name
lookup to skip over names without linkage. This finishes
<rdar://problem/6127293>.

llvm-svn: 65386
2009-02-24 20:03:32 +00:00
Douglas Gregor 5d68a20949 Extend the implicit declaration and checking against out-of-scope
external declarations to also support external variable
declarations. Unified the code for these two cases into two new
subroutines.

Note that we fail to diagnose cases like the one Neil pointed
out, where a visible non-external declaration hides an external
declaration by the same name. That will require some reshuffling of
name lookup.

llvm-svn: 65385
2009-02-24 19:23:27 +00:00
Douglas Gregor de681d43eb In C, when we see a function declaration within a local scope, export
that declaration to global scope so that it can be found from other
scopes. This allows us to diagnose redeclaration errors for external
declarations across scopes. We also warn when name lookup finds such
an out-of-scope declaration. This is part of <rdar://problem/6127293>;
we'll also need to do the same thing for variables.

llvm-svn: 65373
2009-02-24 04:26:15 +00:00
Douglas Gregor e62c0a45dd Improve merging of function declarations. Specifically:
- When we are declaring a function in local scope, we can merge with
    a visible declaration from an outer scope if that declaration
    refers to an entity with linkage. This behavior now works in C++
    and properly ignores entities without linkage.
  - Diagnose the use of "static" on a function declaration in local
    scope.
  - Diagnose the declaration of a static function after a non-static
    declaration of the same function.
  - Propagate the storage specifier to a function declaration from a
    prior declaration (PR3425)
  - Don't name-mangle "main"

llvm-svn: 65360
2009-02-24 01:23:02 +00:00
Chris Lattner d13b8b55ca fix rdar://6611778, a redefinition of an interface was causing an
assertion when the ivars and method list was reset into the existing
interface.  To fix this, mark decls as invalid when they are redefined,
and don't insert ivars/methods into invalid decls.

llvm-svn: 65340
2009-02-23 22:00:08 +00:00
Eli Friedman 3ae5911042 A few small improvements to Evaluate for stuff I noted in FIXMEs.
llvm-svn: 65305
2009-02-23 04:23:56 +00:00
Eli Friedman fd85266342 Fix test to be legal on 64-bit systems.
llvm-svn: 65270
2009-02-22 07:40:57 +00:00
Eli Friedman 7bfab36877 Throw the switch to exclusively use Evaluate (along with the small
helper isConstantInitializer) to check whether an initializer is 
constant.  This passes tests, but it's possible that it'll cause 
regressions with real-world code.

Future work:
1. The diagnostics obtained this way are lower quality at the moment; 
some work both here and in Evaluate is needed for accurate diagnostics.
2. We probably need some extra code when we're in -pedantic mode so we 
can strictly enforce the rules in C99 6.6p7.
3. Dead code cleanup (this should wait until after 2, because we might 
want to re-use some of the code).

llvm-svn: 65265
2009-02-22 06:45:27 +00:00
Eli Friedman 3f8c01a110 Fix for PR3433: map __alignof__ to preferred alignment. (This was
partially done in r65258.)

llvm-svn: 65260
2009-02-22 03:31:23 +00:00
Eli Friedman 19a546c15b Improvements to ASTContext::getDeclAlignInBytes; fixes the testcase in
PR3254 and part of PR3433.

The isICE changes are necessary to keep the computed results 
consistent with Evaluate.

llvm-svn: 65258
2009-02-22 02:56:25 +00:00
Eli Friedman 2194bb78ec Sanity fix for PR3642: if we're treating a diagnostic as an error, it's
required to actually be an error for correctness.  The attached testcase 
now gives an error instead of mysteriously crashing.

Now, it's possible we actually want to support the given usage, but I 
haven't looked at the relevant code closely.

llvm-svn: 65253
2009-02-22 00:20:44 +00:00
Daniel Dunbar 9cbbd99c4b Force arch for these test cases.
llvm-svn: 65252
2009-02-21 23:45:41 +00:00
Daniel Dunbar 79e042a8b5 Evaluation of unary deref could call integer evaluator on non-integral
expr; hilarity ensued.
 - PR3640.

llvm-svn: 65234
2009-02-21 18:14:20 +00:00
Anders Carlsson c4c6031859 Always try to fold array sizes, and warn if we could fold something that isn't an ICE. This makes us compatible with GCC.
llvm-svn: 65140
2009-02-20 18:53:20 +00:00
Eli Friedman 0b8337c30b Add support for * (unary dereference) operator to ExprConstant.
llvm-svn: 65105
2009-02-20 01:57:15 +00:00
Eli Friedman ce98257691 Suppress constant initializer checking when the declaration isn't valid.
This prevents emitting diagnostics which are almost certainly useless.

(Note that the test is checking that we emit only one diagnostic.)

llvm-svn: 65101
2009-02-20 01:34:21 +00:00
Chris Lattner 810d330cd3 Fix a long standard problem with clang retaining "too much" sugar
information about types.  We often print diagnostics where we say 
"foo_t" is bad, but the user doesn't know how foo_t is declared 
(because it is a typedef).  Fix this by expanding sugar when present
in a diagnostic (and not one of a few special cases, like vectors).

Before:
t.m:5:2: error: invalid operands to binary expression ('typeof(P)' and 'typeof(F)')
 MAX(P, F);
 ^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                             ^

After:
t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float'))
 MAX(P, F);
 ^~~~~~~~~
t.m:1:78: note: instantiated from:
#define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                             ^

llvm-svn: 65081
2009-02-19 23:45:49 +00:00
Daniel Dunbar 96f8677e11 Arguments to unordered comparison builtins may need implicit casts.
- <rdar://problem/6094103> sema fails to promote type arguments to __builtin_isgreater (and friends)

llvm-svn: 65059
2009-02-19 19:28:43 +00:00
Anders Carlsson 880971241b Add sema support for the noinline attribute.
llvm-svn: 65055
2009-02-19 19:16:48 +00:00
Zhongxing Xu e6e76aa571 fix test case
llvm-svn: 65037
2009-02-19 08:45:23 +00:00
Anders Carlsson 0756c97dae Emit the correct diagnostics when we constant fold an array size to a negative value.
llvm-svn: 65023
2009-02-19 06:30:50 +00:00
Anders Carlsson 0bbcfa6bb9 Make sure to check the value of the constant expression, as suggested by Daniel.
llvm-svn: 65021
2009-02-19 06:19:15 +00:00
Anders Carlsson ef56fbaa39 Handle the GNU void* and function pointer arithmetic extensions for constant expressions as well.
llvm-svn: 65013
2009-02-19 04:55:58 +00:00
Douglas Gregor 120951391c Make error-message check platform-agnostic
llvm-svn: 64985
2009-02-19 00:03:13 +00:00
Douglas Gregor 1cba5fe1d1 Downgrade the "excess elements in initializer" errors to warnings *in
C*. They're required errors in C++.

llvm-svn: 64964
2009-02-18 22:23:55 +00:00
Douglas Gregor 222e5e4ad2 Return true on errors, return true on errors, return true on errors
llvm-svn: 64957
2009-02-18 22:00:45 +00:00
Douglas Gregor 171c45ab0c Downgrade complaints about calling unavailable functions to a warning
(as GCC does), except when we've performed overload resolution and
found an unavailable function: in this case, we actually error.

Merge the checking of unavailable functions with the checking for
deprecated functions. This unifies a bit of code, and makes sure that
we're checking for unavailable functions in the right places. Also,
this check can cause an error. We may, eventually, want an option to
make "unavailable" warnings into errors.

Implement much of the logic needed for C++0x deleted functions, which
are effectively the same as "unavailable" functions (but always cause
an error when referenced). However, we don't have the syntax to
specify deleted functions yet :)

llvm-svn: 64955
2009-02-18 21:56:37 +00:00
Daniel Dunbar aac5bf19a5 __attribute__((aligned)) was being ignored!
This knocks out another 8 gcc/compat/i386 & x86_64 failures.

llvm-svn: 64947
2009-02-18 20:06:09 +00:00
Chris Lattner f638b97fe0 use the full spelling of a string literal token so that trigraphs
and escaped newlines don't throw off the offset computation.

On this testcase:
  printf("abc\
def"
         "%*d", (unsigned) 1, 1);

Before:
t.m:5:5: warning: field width should have type 'int', but argument has type 'unsigned int'
def"
    ^

after:
t.m:6:12: warning: field width should have type 'int', but argument has type 'unsigned int'
         "%*d", (unsigned) 1, 1);
           ^    ~~~~~~~~~~~~

llvm-svn: 64930
2009-02-18 18:34:12 +00:00
Chris Lattner df18c6a9af add c testcase for string literal diagnostic improvement.
llvm-svn: 64929
2009-02-18 18:25:31 +00:00
Douglas Gregor 94349fd8cb Allow "overloadable" functions in C to be declared as variadic without
any named parameters, e.g., this is accepted in C:

  void f(...) __attribute__((overloadable));

although this would be rejected:

  void f(...);

To do this, moved the checking of the "ellipsis without any named
arguments" condition from the parser into Sema (where it belongs anyway).

llvm-svn: 64902
2009-02-18 07:07:28 +00:00
Douglas Gregor b2809a0a1b Don't allow calls to functions marked "unavailable". There's more work
to do in this area, since there are other places that reference
FunctionDecls.

Don't allow "overloadable" functions (in C) to be declared without a
prototype.

llvm-svn: 64897
2009-02-18 06:34:51 +00:00
Eli Friedman 1e3a02f090 Fix test on platforms where size_t != unsigned long.
llvm-svn: 64867
2009-02-18 00:52:29 +00:00
Daniel Dunbar 4750e63486 isICE was evaluating ?: incorrectly with missing-gcc-LHS extension.
Add assert to isICE that, on success, result must be the same as
EvaluateAsInt()... this enforces a minimum level of sanity.

llvm-svn: 64865
2009-02-18 00:47:45 +00:00
Douglas Gregor 13c6362a43 Proof that attribute __overloadable__ works as well as overloadable
llvm-svn: 64781
2009-02-17 18:51:14 +00:00
Douglas Gregor 7a0febe66d Remove the error about redefining library functions. It's causing too
much pain when compiling the Linux kernel (PR3592).

llvm-svn: 64767
2009-02-17 16:03:01 +00:00
Douglas Gregor a908e7fccc Static variables and functions won't collide with standard library
functions, so if we're declaring a static we should implicitly declare
a library function by the same name (e.g., malloc, strdup). Fixes PR3592.

llvm-svn: 64736
2009-02-17 03:23:10 +00:00
Chris Lattner 8a04c5ad03 add support for -fno-math-errno, and validate that it affects sema properly.
llvm-svn: 64708
2009-02-17 00:35:09 +00:00
Chris Lattner a89050c788 sema no longer explodes, yay!
llvm-svn: 64707
2009-02-17 00:32:04 +00:00
Daniel Dunbar 6e8c07d0ea Diagnose non-power-of-2 arguments to attribute aligned.
llvm-svn: 64700
2009-02-16 23:37:57 +00:00
Chris Lattner a377833888 diagnose uses of deprecated typenames and tags.
We now pass all the deprecation tests in the objc.dg suite.

llvm-svn: 64679
2009-02-16 22:07:16 +00:00
Chris Lattner 6c7ce109e0 enhance ExtVectorElementExpr to allow V->xxyy to work like (*V).xxyy
llvm-svn: 64667
2009-02-16 21:11:58 +00:00