Commit Graph

715 Commits

Author SHA1 Message Date
Douglas Gregor e711f7052e Add hook to add attributes to function declarations that we know
about, whether they are builtins or not. Use this to add the
appropriate "format" attribute to NSLog, NSLogv, asprintf, and
vasprintf, and to translate builtin attributes (from Builtins.def)
into actual attributes on the function declaration.

Use the "printf" format attribute on function declarations to
determine whether we should do format string checking, rather than
looking at an ad hoc list of builtins and "known" function names.

Be a bit more careful about when we consider a function a "builtin" in
C++.

llvm-svn: 64561
2009-02-14 18:57:46 +00:00
Chris Lattner aff301478a new tests, it would be nice to not warn on the second one.
llvm-svn: 64549
2009-02-14 08:27:44 +00:00
Chris Lattner 237f27573f Several related changes:
1) implement parser and sema support for reading and verifying attribute(warnunusedresult).
2) rename hasLocalSideEffect to isUnusedResultAWarning, inverting the sense
   of its result.
3) extend isUnusedResultAWarning to directly return the loc and range 
   info that should be reported to the user.  Make it substantially more
   precise in some cases than what was previously reported.
4) teach isUnusedResultAWarning about CallExpr to decls that are 
   pure/const/warnunusedresult, fixing a fixme.
5) change warn_attribute_wrong_decl_type to not pass in english strings, instead,
   pass in integers and use %select.

llvm-svn: 64543
2009-02-14 07:37:35 +00:00
Douglas Gregor 538c3d8459 Make it possible for builtins to expression FILE* arguments, so that
we can define builtins such as fprintf, vfprintf, and
__builtin___fprintf_chk. Give a nice error message when we need to
implicitly declare a function like fprintf.

llvm-svn: 64526
2009-02-14 01:52:53 +00:00
Douglas Gregor ac5d4c5f8e Extend builtin "attribute" syntax to include a notation for
printf-like functions, both builtin functions and those in the
C library. The function-call checker now queries this attribute do
determine if we have a printf-like function, rather than scanning
through the list of "known functions IDs". However, there are 5
functions they are not yet "builtins", so the function-call checker
handles them specifically still:

  - fprintf and vfprintf: the builtins mechanism cannot (yet)
    express FILE* arguments, so these can't be encoded.
  - NSLog: the builtins mechanism cannot (yet) express NSString*
    arguments, so this (and NSLogv) can't be encoded.
  - asprintf and vasprintf: these aren't part of the C99 standard
    library, so we really shouldn't be defining them as builtins in
    the general case (and we don't seem to have the machinery to make
    them builtins only on certain targets and depending on whether
    extensions are enabled).

llvm-svn: 64512
2009-02-14 00:32:47 +00:00
Douglas Gregor b9063fc1b3 Implicitly declare certain C library functions (malloc, strcpy, memmove,
etc.) when we perform name lookup on them. This ensures that we
produce the correct signature for these functions, which has two
practical impacts:

  1) When we're supporting the "implicit function declaration" feature
  of C99, these functions will be implicitly declared with the right
  signature rather than as a function returning "int" with no
  prototype. See PR3541 for the reason why this is important (hint:
  GCC always predeclares these functions).
 
  2) If users attempt to redeclare one of these library functions with
  an incompatible signature, we produce a hard error.

This patch does a little bit of work to give reasonable error
messages. For example, when we hit case #1 we complain that we're
implicitly declaring this function with a specific signature, and then
we give a note that asks the user to include the appropriate header
(e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In
case #2, we show the type of the implicit builtin that was incorrectly
declared, so the user can see the problem. We could do better here:
for example, when displaying this latter error message we say
something like:

  'strcpy' was implicitly declared here with type 'char *(char *, char
  const *)'

but we should really print out a fake code line showing the
declaration, like this:

  'strcpy' was implicitly declared here as:

    char *strcpy(char *, char const *)

This would also be good for printing built-in candidates with C++
operator overloading.

The set of C library functions supported by this patch includes all
functions from the C99 specification's <stdlib.h> and <string.h> that
(a) are predefined by GCC and (b) have signatures that could cause
codegen issues if they are treated as functions with no prototype
returning and int. Future work could extend this set of functions to
other C library functions that we know about.

llvm-svn: 64504
2009-02-13 23:20:09 +00:00
Daniel Dunbar 311bf2916b Warn about attribute used ignored on "extern int a
__attribute__((used))".

llvm-svn: 64499
2009-02-13 22:48:56 +00:00
Chris Lattner 303284acfc If x is an invalid field decl, don't construct an expression for P->x,
just silently return an error to avoid bogus diagnostics.

llvm-svn: 64491
2009-02-13 22:08:30 +00:00
Daniel Dunbar fee07a0b47 Sema/AST support for attribute used. Patch by Anders Johnson (with small tweaks & test case)!
llvm-svn: 64478
2009-02-13 19:23:53 +00:00
Anders Carlsson 6ee8a7dac5 Start warning about unknown attributes.
llvm-svn: 64447
2009-02-13 08:22:04 +00:00
Anders Carlsson 76187b4d68 Add sema support for the nodebug attribute.
llvm-svn: 64441
2009-02-13 06:46:13 +00:00
Eli Friedman 1efaaeaa69 Initial implementation of arbitrary fixed-width integer types.
Currently only used for 128-bit integers.

Note that we can't use the fixed-width integer types for other integer 
modes without other changes because glibc headers redefines (u)int*_t 
and friends using the mode attribute.  For example, this means that uint64_t
has to be compatible with unsigned __attribute((mode(DI))), and 
uint64_t is currently defined to long long.  And I have a feeling we'll 
run into issues if we try to define uint64_t as something which isn't 
either long or long long.

This doesn't get the alignment right in most cases, including 
the 128-bit integer case; I'll file a PR shortly.  The gist of the issue 
is that the targets don't really expose the information necessary to 
figure out the alignment outside of the target description, so there's a 
non-trivial amount of work involved in getting it working right.  That 
said, the alignment used is conservative, so the only issue with the 
current implementation is ABI compatibility.

This makes it trivial to add some sort of "bitwidth" attribute to make 
arbitrary-width integers; I'll do that in a followup.

We could also use this for stuff like the following for compatibility 
with gcc, but I have a feeling it would be a better idea for clang to be 
consistent between C and C++ modes rather than follow gcc's example for 
C mode.
struct {unsigned long long x : 33;} x;
unsigned long long a(void) {return x.x+1;}

llvm-svn: 64434
2009-02-13 02:31:07 +00:00
Douglas Gregor 633b73783f Tighten checking of the "overloadable" attribute. If any function by a
given name in a given scope is marked as "overloadable", every
function declaration and definition with that same name and in that
same scope needs to have the "overloadable" attribute. Essentially,
the "overloadable" attribute is not part of attribute merging, so it
must be specified even for redeclarations. This keeps users from
trying to be too sneaky for their own good:

  double sin(double) __attribute__((overloadable)); // too sneaky
  #include <math.h>

Previously, this would have made "sin" overloadable, and therefore
given it a mangled name. Now, we get an error inside math.h when we
see a (re)declaration of "sin" that doesn't have the "overloadable"
attribute.

llvm-svn: 64414
2009-02-13 00:26:38 +00:00
Douglas Gregor 41e3fc1ff5 Add missing test for the "overloadable" attribute
llvm-svn: 64396
2009-02-12 19:25:19 +00:00
Douglas Gregor a9add4ea76 Fix a bug with designated initializers where we were stepping out of a
union subobject initialization before checking whether the next
initiailizer was actually a designated initializer. This led to
spurious "excess elements in union initializer" errors. Thanks to
rdivacky for reporting the bug!

llvm-svn: 64392
2009-02-12 19:00:39 +00:00
Daniel Dunbar 6d0402d468 Fix va_arg bug noticed by Eli, __builtin_va_arg is not an l-value
designating an object.

llvm-svn: 64371
2009-02-12 09:21:08 +00:00
Douglas Gregor 4d0bd8bfc9 Add test for overloading with _Complex in C
llvm-svn: 64347
2009-02-12 00:57:03 +00:00
Chris Lattner 54ef713d22 testcase for rdar://6096412 which already works.
llvm-svn: 64289
2009-02-11 06:22:30 +00:00
Douglas Gregor 09cfcff492 GNU allows structs with flexible array members to be placed inside
arrays and other structs/unions as an extension. Downgrade our error
to a warning. Fixes PR3540.

llvm-svn: 64239
2009-02-10 21:49:46 +00:00
Douglas Gregor aef040a28e When handling "the rest" of a designated array subobject, maybe sure
to tell it that it wasn't (directly) designated. This way, we unwind
back to the explicit initializer list properly rather than getting
stuck in the wrong subobject. Fixes llvm.org/PR3519

llvm-svn: 64155
2009-02-09 19:45:19 +00:00
Sebastian Redl 95ea38fa1a Fix redundant errors for redefinitions with multiple existing definitions.
llvm-svn: 64081
2009-02-08 10:49:44 +00:00
Sebastian Redl aa400d83e6 Make the test cases failing due to exact diagnostic matching XFAIL.
llvm-svn: 64080
2009-02-08 10:28:44 +00:00
Mike Stump f876bc9388 Fixup expected errors.
llvm-svn: 64074
2009-02-08 07:59:54 +00:00
Anders Carlsson 723f55d697 Improve Sema of the cleanup attribute somewhat.
llvm-svn: 64047
2009-02-07 23:16:50 +00:00
Sebastian Redl 2175b6a767 Make one expected-diag directive match exactly one actual diagnostic.
This uncovers some bugs, so several test cases now fail.

llvm-svn: 64025
2009-02-07 19:52:04 +00:00
Sebastian Redl 1d8cb2e0d0 Use our new snazzy stdint.h to make a testcase 64-bit portable.
llvm-svn: 63985
2009-02-07 00:23:52 +00:00
Douglas Gregor fc4f8a1834 Implement semantic analysis for the GNU flexible array initialization
extension. The interaction with designated initializers is a
bit... interesting... but we follow GNU's lead and don't permit too
much crazy code in this area.

Also, make the "excess initializers" error message a bit more
informative.

Addresses PR2561: http://llvm.org/bugs/show_bug.cgi?id=2561

llvm-svn: 63785
2009-02-04 22:46:25 +00:00
Mike Stump 82f071faa7 Add support for blocks with explicit return types.
llvm-svn: 63784
2009-02-04 22:31:32 +00:00
Douglas Gregor 4ab311dc30 Note the Radar number that corresponds to PR3137
llvm-svn: 63754
2009-02-04 19:10:27 +00:00
Eli Friedman cddff7fd62 Test for PR3137.
llvm-svn: 63749
2009-02-04 18:50:00 +00:00
Douglas Gregor 8761da5f68 Simplify the way in which we inject the names of tag definitions and
elaborated-type-specifier declarations into outer scopes while
retaining their proper lexical scope. This way is simpler and more
consistent with the way DeclContexts work, and also fixes

  http://llvm.org/bugs/show_bug.cgi?id=3430

llvm-svn: 63581
2009-02-03 00:34:39 +00:00
Nuno Lopes 7cffb63a9d emit diagnostic when casting a ptr to a small int when doing static initialization (addresses Eli's comments I believe)
llvm-svn: 63562
2009-02-02 22:57:15 +00:00
Nuno Lopes 026bcde14b fix TryToFixInvalidVariablyModifiedType to reject negative array sizes
llvm-svn: 63557
2009-02-02 22:32:08 +00:00
Douglas Gregor 0e8fc3c773 Add iterators to LookupResult, allowing one to iterate over the
non-ambiguous name lookup results without allocating any memory, e.g.,
for sets of overloaded functions.

llvm-svn: 63549
2009-02-02 21:35:47 +00:00
Nuno Lopes 598afdcfe7 allow cast from array to int to be considered as constant
llvm-svn: 63519
2009-02-02 16:07:41 +00:00
Nuno Lopes 8877f99f9d fix PR3459: improve compatibility with gcc when checking for constant exprs
llvm-svn: 63517
2009-02-02 15:00:55 +00:00
Anders Carlsson 12beab7085 Forgot to add this test.
llvm-svn: 63484
2009-01-31 19:07:49 +00:00
Anders Carlsson f6e6057e92 Fix typo noticed by Chris.
llvm-svn: 63449
2009-01-30 23:26:40 +00:00
Anders Carlsson db5a9b675c Turn on -flax-vector-conversions by default, issue a warning whenever one is done. Add a -fnolax-vector-conversions option. Fixes PR2862.
llvm-svn: 63447
2009-01-30 23:17:46 +00:00
Douglas Gregor d42a0fb41b Upgrade the "excess elements in array initializer" warning to an
error, since both C99 and C++ consider it an error. For reference, GCC
makes this a warning while G++ makes it an error.

llvm-svn: 63435
2009-01-30 22:26:29 +00:00
Douglas Gregor d5576dee1c Closed out a few radars that were addressed by designated initializers
llvm-svn: 63398
2009-01-30 17:42:28 +00:00
Douglas Gregor bf7207a11f Make CodeGen produce an error if we come across a non-constant initializer list that involves the GNU array-range designator extension
llvm-svn: 63327
2009-01-29 19:42:23 +00:00
Douglas Gregor 35a52fabf4 Add another devilish testcase for designated initializers
llvm-svn: 63262
2009-01-29 01:10:11 +00:00
Douglas Gregor f6d2752f12 Eliminate infinite looping in a wacky case with designated initializers. Simplifies (somewhat) the actually checking of the initializer expression following the designators
llvm-svn: 63257
2009-01-29 00:39:20 +00:00
Douglas Gregor 17bd094a6b Improvements to code-generation and semantic analysis of designated
initializers.

  - We now initialize unions properly when a member other than the
    first is named by a designated initializer.
  - We now provide proper semantic analysis and code generation for
    GNU array-range designators *except* that side effects will occur
    more than once. We warn about this.

llvm-svn: 63253
2009-01-28 23:36:17 +00:00
Douglas Gregor 347f7eabb9 Code generation support for C99 designated initializers.
The approach I've taken in this patch is relatively straightforward,
although the code itself is non-trivial. Essentially, as we process
an initializer list we build up a fully-explicit representation of the
initializer list, where each of the subobject initializations occurs
in order. Designators serve to "fill in" subobject initializations in
a non-linear way. The fully-explicit representation makes initializer
lists (both with and without designators) easy to grok for codegen and
later semantic analyses. We keep the syntactic form of the initializer
list linked into the AST for those clients interested in exactly what
the user wrote.

Known limitations:
  - Designating a member of a union that isn't the first member may
    result in bogus initialization (we warn about this)
  - GNU array-range designators are not supported (we warn about this)

llvm-svn: 63242
2009-01-28 21:54:33 +00:00
Daniel Dunbar 804c0441c2 Handle complex types in ASTContext::mergeTypes
llvm-svn: 63238
2009-01-28 21:22:12 +00:00
Nuno Lopes b81d94ff58 add test for PR2502, which was already fixed some time ago
llvm-svn: 63160
2009-01-28 00:44:33 +00:00
Anders Carlsson 570c357ded If an input constraint refers to an output constraint, it should have the same constraint info as the output constraint. Fixes PR3417
llvm-svn: 63127
2009-01-27 20:38:24 +00:00
Eli Friedman 8b7c52658b Fix for PR2100: merge types for variables.
llvm-svn: 62947
2009-01-24 23:49:55 +00:00
Eli Friedman 588395702f Correct test; sorry for any inconvenience.
llvm-svn: 62946
2009-01-24 23:44:26 +00:00
Eli Friedman 52cc016f21 PR3062: statement expressions should be illegal at file scope. I don't
think this has any significant effects at the moment, but it could 
matter if we start constant-folding statement expressions like gcc does.

llvm-svn: 62943
2009-01-24 23:09:00 +00:00
Chris Lattner 5eca6ada3a Implement C99 6.5.3.4p1, rejecting sizeof(bitfield)
llvm-svn: 62936
2009-01-24 21:29:22 +00:00
Chris Lattner 8dff017695 Fix PR3386 by handling GCC's rules for alignof, which are substantially
different than those for sizeof.  Reject alignof(bitfield) like gcc does.

llvm-svn: 62928
2009-01-24 20:17:12 +00:00
Daniel Dunbar 134a02586e Fix invalid evaluation of _Complex float (real & imaginary parts had
mismatched semantics).
 - Enforce this in APValue.

llvm-svn: 62924
2009-01-24 19:08:01 +00:00
Anders Carlsson a0b892113a Handle the 'e' constraint. Fixes PR3385
llvm-svn: 62923
2009-01-24 18:03:09 +00:00
Anders Carlsson b66a312f93 Ignore parens when determining if an expr is a string literal. Fixes PR3382.
llvm-svn: 62922
2009-01-24 17:47:50 +00:00
Douglas Gregor 7a95b08fce More APSInt appeasement
llvm-svn: 62884
2009-01-23 22:22:29 +00:00
Douglas Gregor 51650d380b Hopefully the last of the APSInt signedness issues with initializers. Fixes PR clang/3378
llvm-svn: 62876
2009-01-23 21:04:18 +00:00
Douglas Gregor 5da47ad57b Allow subtraction of function pointer types in C, as a GNU extension. Fixes rdar://problem/6520707
llvm-svn: 62859
2009-01-23 19:03:35 +00:00
Douglas Gregor 583cf0ac57 Make sure all of the isUnsigned flags line up when comparing initializer values, to really really fix PR clang/3377
llvm-svn: 62858
2009-01-23 18:58:42 +00:00
Douglas Gregor 033d1257ca Properly manage the bit-widths of APInts/APSInts in array initialization.
Fixes PR clang/3377

llvm-svn: 62851
2009-01-23 16:54:12 +00:00
Douglas Gregor 9aa8904a46 Handle any undeclared parameters in a K&R-style function with a
special action, inside function prototype scope. This avoids confusion
when we try to inject these parameters into the scope of the function
body before the function itself has been added to the surrounding
scope. Fixes <rdar://problem/6097326>.

llvm-svn: 62849
2009-01-23 16:23:13 +00:00
Douglas Gregor f6cd928bf4 Support arithmetic on pointer-to-function types as a GNU
extension. Addresses clang PR/3371.

llvm-svn: 62823
2009-01-23 00:36:41 +00:00
Douglas Gregor d7fb85e8ad Reimplement the handling of the "current object" in designator
initializers, so that we are within the appropriate subobject after
we've processed a multi-designator designation. We're matching GCC and
EDG's behavior on all examples I've found thus far.

*Huge* thanks to Eli Friedman for pointing out my fundamental
misunderstanding of "current object" in the C99 spec.

llvm-svn: 62812
2009-01-22 23:26:18 +00:00
Douglas Gregor e4a0bb7a20 Initial implementation of semantic analysis and ASTs for C99
designated initializers. This implementation should cover all of the
constraints in C99 6.7.8, including long, complex designations and
computing the size of incomplete array types initialized with a
designated initializer. Please see the new test-case and holler if you
find cases where this doesn't work.

There are still some wrinkles with GNU's anonymous structs and
anonymous unions (it isn't clear how these should work; we'll just
follow GCC's lead) and with designated initializers for the members of a
union. I'll tackle those very soon.

CodeGen is still nonexistent, and there's some leftover code in the
parser's representation of designators that I'll also need to clean up.

llvm-svn: 62737
2009-01-22 00:58:24 +00:00
Anders Carlsson dc6ceca4ba Fix an inline asm sema bug that I introduced.
llvm-svn: 62666
2009-01-21 06:27:20 +00:00
Anders Carlsson 224fca8982 Improvements to Sema of asm statements. Fixes <rdar://problem/6156893>
llvm-svn: 62609
2009-01-20 20:49:22 +00:00
Eli Friedman 08c5dabf1b Fix for PR3350: add special-casing for "references" to va_lists in
builtins.

Also, a minor tweak to va_copy for consistency.

llvm-svn: 62574
2009-01-20 07:46:22 +00:00
Douglas Gregor dd430f7ec9 Centralize error reporting of improper uses of incomplete types in the
new DiagnoseIncompleteType. It provides additional information about
struct/class/union/enum types when possible, either by pointing to the
forward declaration of that type or by pointing to the definition (if
we're in the process of defining that type). 
Fixes <rdar://problem/6500531>.

llvm-svn: 62521
2009-01-19 19:26:10 +00:00
Anders Carlsson a79203be85 Add sema support for symbolic names in inline asm statements.
llvm-svn: 62441
2009-01-18 01:56:57 +00:00
Nate Begeman bb70bf6dbb Update support for vector component access on ExtVectors.
llvm-svn: 62440
2009-01-18 01:47:54 +00:00
Douglas Gregor 051d8fd809 Warn about typedefs of enums without any declarator name. Fixes rdar://problem/6503878
llvm-svn: 62397
2009-01-17 02:55:50 +00:00
Douglas Gregor dee1be8e95 Teach DeclContext how to find the primary declaration for any TagDecl
even when we are still defining the TagDecl. This is required so that
qualified name lookup of a class name within its definition works (see
the new bits in test/SemaCXX/qualified-id-lookup.cpp).

As part of this, move the nested redefinition checking code into
ActOnTag. This gives us diagnostics earlier (when we try to perform
the nested redefinition, rather than when we try to complete the 2nd
definition) and removes some code duplication.

llvm-svn: 62386
2009-01-17 00:42:38 +00:00
Nuno Lopes 6be2939d5d add support for initializing static vars with a cast to union (gcc extension)
llvm-svn: 62261
2009-01-15 16:44:45 +00:00
Seo Sanghyeon 39a3ebf8f0 PR2746: Implement GCC cast to union extension
llvm-svn: 62255
2009-01-15 04:51:39 +00:00
Fariborz Jahanian f2a3120b77 Patch to keep clang honest that it does not yet support
explicit return type on block literals.

llvm-svn: 62240
2009-01-14 19:39:53 +00:00
Anders Carlsson bc12e92068 Use the unqualified type for GCCs struct/union cast extension
llvm-svn: 62170
2009-01-13 17:00:51 +00:00
Ted Kremenek 94a5f6f949 Fix test case (incomplete "expected-warning" line)
llvm-svn: 62119
2009-01-12 23:09:55 +00:00
Ted Kremenek 6dfeb55897 Patch by Roman Divacky:
Extend string-literal checking for printf() format string to handle conditional
ternary operators where both sides are literals.

This fixes PR 3319: http://llvm.org/bugs/show_bug.cgi?id=3319

llvm-svn: 62117
2009-01-12 23:09:09 +00:00
Douglas Gregor c6f58fe266 Implement support for anonymous structs and unions in C. Both C and
C++ handle anonymous structs/unions in the same way. Addresses several
bugs:

  <rdar://problem/6259534>
  <rdar://problem/6481130>
  <rdar://problem/6483159>

The test case in PR clang/1750 now passes with -fsyntax-only, but
CodeGen for inline assembler still fails.

llvm-svn: 62112
2009-01-12 22:49:06 +00:00
Douglas Gregor 45a33ecce1 Properly set the scope of non-fields declared within a struct, union,
or enum to be outside that struct, union, or enum. Fixes several
regressions: 

  <rdar://problem/6487662>
  <rdar://problem/6487669>
  <rdar://problem/6487684>
  <rdar://problem/6487702>
  PR clang/3305
  PR clang/3312

There is still some work to do in Objective-C++, but this requires
that each of the Objective-C entities (interfaces, implementations,
etc.) to be introduced into the context stack with
PushDeclContext/PopDeclContext. This will be a separate fix, later.

llvm-svn: 62091
2009-01-12 18:45:55 +00:00
Chris Lattner 5cdc94d282 testcase that works now with r62061
llvm-svn: 62062
2009-01-12 00:08:58 +00:00
Douglas Gregor 658b9550bb When we see a reference to a struct, class, or union like "struct X"
that is neither a definition nor a forward declaration and where X has
not yet been declared as a tag, introduce a declaration
into the appropriate scope (which is likely *not* to be the current
scope). The rules for the placement of the declaration differ slightly
in C and C++, so we implement both and test the various corner
cases. This implementation isn't 100% correct due to some lingering
issues with the function prototype scope (for a function parameter
list) not being the same scope as the scope of the function
definition. Testcase is FIXME'd; this probably isn't an important issue.

Addresses <rdar://problem/6484805>.

llvm-svn: 62014
2009-01-09 22:42:13 +00:00
Douglas Gregor 020713e308 Replace DeclContext's vector of ScopedDecl pointers with a linked list
of ScopedDecls (using the new ScopedDecl::NextDeclInScope
pointer). Performance-wise:

  - It's a net win in memory utilization, since DeclContext is now one
    pointer smaller than it used to be (std::vectors are typically 3
    pointers; we now use 2 pointers) and 
  - Parsing Cocoa.h with -fsyntax-only (with a Release-Asserts Clang)
    is about 1.9% faster than before, most likely because we no longer
    have the memory allocations and copying associated with the
    std::vector.

I'll re-enable serialization of DeclContexts once I've sorted out the
NextDeclarator/NextDeclInScope question.

llvm-svn: 62001
2009-01-09 19:42:16 +00:00
Ted Kremenek 339153d3be Re-enable PTH testing for Cocoa.h and Carbon.h (and include testing for Objective-C++).
llvm-svn: 61965
2009-01-09 00:41:48 +00:00
Ted Kremenek cb5a95f3a4 Temporarily revert r61956 and r61957 (PTH tests failing).
llvm-svn: 61960
2009-01-09 00:27:29 +00:00
Ted Kremenek 510b4da49d Enhance -fsyntax-only test of Carbon.h to also include testing for PTH.
llvm-svn: 61958
2009-01-08 23:42:56 +00:00
Douglas Gregor 82ac25e4a7 Unify the code for defining tags in C and C++, so that we always
introduce a Scope for the body of a tag. This reduces the number of
semantic differences between C and C++ structs and unions, and will
help with other features (e.g., anonymous unions) in C. Some important
points:

  - Fields are now in the "member" namespace (IDNS_Member), to keep
    them separate from tags and ordinary names in C. See the new test
    in Sema/member-reference.c for an example of why this matters. In
    C++, ordinary and member name lookup will find members in both the
    ordinary and member namespace, so the difference between
    IDNS_Member and IDNS_Ordinary is erased by Sema::LookupDecl (but
    only in C++!). 
  - We always introduce a Scope and push a DeclContext when we're
    defining a tag, in both C and C++. Previously, we had different
    actions and different Scope/CurContext behavior for enums, C
    structs/unions, and C++ structs/unions/classes. Now, it's one pair
    of actions. (Yay!)

There's still some fuzziness in the handling of struct/union/enum
definitions within other struct/union/enum definitions in C. We'll
need to do some more cleanup to eliminate some reliance on CurContext
before we can solve this issue for real. What we want is for something
like this:

  struct X {
    struct T { int x; } t;
  };

to introduce T into translation unit scope (placing it at the
appropriate point in the IdentifierResolver chain, too), but it should
still have struct X as its lexical declaration
context. PushOnScopeChains isn't smart enough to do that yet, though,
so there's a FIXME test in nested-redef.c

llvm-svn: 61940
2009-01-08 20:45:30 +00:00
Sebastian Redl a2b5e31cb1 Diagnose declarations that don't declare anything, and fix PR3020.
Examples:
int;
typedef int;

llvm-svn: 61454
2008-12-28 15:28:59 +00:00
Sebastian Redl 85cd7bac29 Fix filename typo.
llvm-svn: 61453
2008-12-28 14:19:27 +00:00
Anton Korobeynikov b46e3a8d3b Complete the test after adding handling of merged attributes on decls.
llvm-svn: 61438
2008-12-26 00:52:17 +00:00
Anton Korobeynikov d72f47aa05 Add full dllimport / dllexport support: both sema checks and codegen.
Patch by Ilya Okonsky

llvm-svn: 61437
2008-12-26 00:52:02 +00:00
Anton Korobeynikov 3112c877c1 Testcase for stdcall/fastcall sema checks.
Patch by Ilya Okonsky!

llvm-svn: 61436
2008-12-26 00:51:21 +00:00
Chris Lattner b6ec4e75ad Clean up the C89/C++ warnings about C99 array features to not
emit duplicate diags (some in parser and some in sema) and to
warn about use of typequals in array sizes.  This implements 
PR2759.

llvm-svn: 61197
2008-12-18 06:50:14 +00:00
Chris Lattner 27e5beff70 Merge function-return.c into function.c
Fix PR2790 by making a warning an EXTWARN instead of EXTENSION.
Add a new EXTENSION warning for "return (some void expression);"

llvm-svn: 61187
2008-12-18 02:01:17 +00:00
Chris Lattner 3d72297909 diagnose C99 6.9.1p5, C arguments in definitions that are lacking
a name.  This implements PR3208.

llvm-svn: 61127
2008-12-17 07:32:46 +00:00
Eli Friedman bb2b3be9e1 Make error handling for va_start a bit more robust. Fixes PR3213.
llvm-svn: 61055
2008-12-15 22:05:35 +00:00
Douglas Gregor c811d8f055 Create new EnumDecl nodes for redeclarations of enums, linking them
together in the same way that we link RecordDecl/CXXRecordDecl nodes. 

Unify ActOnTag and ActOnTagStruct.

Fixes PR clang/2753.

llvm-svn: 61034
2008-12-15 16:32:14 +00:00
Chris Lattner 04397358ec Implement the final (hopefully) wrinkle to i-c-e + builtin_constant_p
processing: it allows arbitrary foldable constants as the operand of ?: when
builtin_constant_p is the condition.

llvm-svn: 60954
2008-12-12 18:00:51 +00:00