Граф коммитов

809 Коммитов

Автор SHA1 Сообщение Дата
Steve Naroff 14108da7f7 This patch includes a conceptually simple, but very intrusive/pervasive change.
The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches.

This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic.

By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. 

Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75314 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-10 23:34:53 +00:00
Fariborz Jahanian 082b02e840 Implemented memmove_collectable API for Next runtime
when struct variables with GC'able members are copied into.
Will provide a test case later.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74984 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-08 01:18:33 +00:00
Sebastian Redl 23c7d06136 Implement checking of exception spec compatibility for overriding virtual functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74943 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 20:29:57 +00:00
Douglas Gregor 6bec78d58b Tighten up the conditions under which we build an implicit function
declaration for a builtin.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74917 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 17:00:05 +00:00
Douglas Gregor c29f77b769 Make ASTContext explicitly keep track of the declaration for the C
FILE type, rather than using name lookup to find FILE within the
translation unit. Within precompiled headers, FILE is treated as yet
another "special type" (like __builtin_va_list).

This change should provide a performance improvement (not verified),
since the lookup into the translation unit declaration 
forces the (otherwise unneeded) construction of a large hash table.
More importantly, with precompiled headers, the construction
of that table requires deserializing most of the top-level
declarations from the precompiled header, which are then unused.

Fixes PR 4509.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74911 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-07 16:35:42 +00:00
Douglas Gregor 7e7eb3da05 Keep track of the Expr used to describe the size of an array type,
from Enea Zaffanella!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74831 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 15:59:29 +00:00
Argyrios Kyrtzidis 17945a0f64 De-ASTContext-ify DeclContext.
Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating".
Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 02:36:12 +00:00
Argyrios Kyrtzidis 6fb0aee4f9 Remove the ASTContext parameter from the getBody() methods of Decl and subclasses.
Timings showed no significant difference before and after the commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74504 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 02:35:26 +00:00
Argyrios Kyrtzidis 40b598eea1 Remove the ASTContext parameter from the attribute-related methods of Decl.
The implementations of these methods can Use Decl::getASTContext() to get the ASTContext.

This commit touches a lot of files since call sites for these methods are everywhere.
I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74501 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-30 02:34:44 +00:00
Fariborz Jahanian f8d736ca54 Renamed MarcDestructorReferenced -> MarkDestructorReferenced
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74386 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-27 15:05:11 +00:00
Fariborz Jahanian 8d2b35630d Patch to mark destructors when they are used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74359 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-26 23:49:16 +00:00
Douglas Gregor e53060fa78 Improved semantic analysis and AST respresentation for function
templates.

For example, this now type-checks (but does not instantiate the body
of deref<int>):

  template<typename T> T& deref(T* t) { return *t; }

  void test(int *ip) {
    int &ir = deref(ip);
  }

Specific changes/additions:
  * Template argument deduction from a call to a function template.
  * Instantiation of a function template specializations (just the
  declarations) from the template arguments deduced from a call.
  * FunctionTemplateDecls are stored directly in declaration contexts
  and found via name lookup (all forms), rather than finding the
  FunctionDecl and then realizing it is a template. This is
  responsible for most of the churn, since some of the core
  declaration matching and lookup code assumes that all functions are
  FunctionDecls.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74213 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 22:08:12 +00:00
Argyrios Kyrtzidis 16f19306f9 Set the end range location of a FunctionDecl to the right paren.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74195 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-25 18:22:24 +00:00
Douglas Gregor 52591bf224 Make sure that the template parameter lists get from the parser down to ActOnFunctionDeclarator for function template definitions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74040 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-24 00:54:41 +00:00
Anders Carlsson e98da2e7af Support for [class.local]p4.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74030 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-24 00:28:53 +00:00
Douglas Gregor c5c903acd8 When declaring a function template, create a FunctionTemplateDecl node
and associate it with the FunctionDecl.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74028 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-24 00:23:40 +00:00
Douglas Gregor e542c862bd Start propagating template parameter lists to the right places to
handle function templates. There's no actual code for function
templates yet, but at least we complain about typedef templates.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74021 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 23:11:28 +00:00
Douglas Gregor 2e01cdacc5 Eliminate DeclPtrTy() arguments to ActOnDeclarator that are just a very, very weird way to pass "false". No functionality change
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74007 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-23 21:43:56 +00:00
Fariborz Jahanian b7f4cc09ea Remove ImplicitMustBeDefined, use universal 'Used' flag
instead. Do the implicit default ctor checking in MarkDeclarationReferenced.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73888 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-22 17:30:33 +00:00
Douglas Gregor 9cfbe48a7a Parsing and AST support for using declarations, from John Thompson!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73812 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-20 00:51:54 +00:00
Douglas Gregor e0762c9211 Keep track of when declarations are "used" according to C and
C++. This logic is required to trigger implicit instantiation of
function templates and member functions of class templates, which will
be implemented separately.

This commit includes support for -Wunused-parameter, printing warnings
for named parameters that are not used within a function/Objective-C
method/block. Fixes <rdar://problem/6505209>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73797 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 23:52:42 +00:00
Fariborz Jahanian f8dcb866d3 Patch for implementation of C++'s object model. This is
work in progress.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73782 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-19 19:55:27 +00:00
Douglas Gregor 68584ed35a Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73702 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-18 16:11:24 +00:00
Douglas Gregor c19ee3eb08 Diagnose class members that shadow a template parameter. Fixes
<rdar://problem/6952203>. 

To do this, we actually remove a not-quite-correct optimization in the
C++ name lookup routines. We'll revisit this optimization for the
general case once more C++ is working.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73659 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 23:37:01 +00:00
Argyrios Kyrtzidis 179fe1a47d Fix some erroneous comments due to trigger-happy copy&paste.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73657 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 23:19:02 +00:00
Argyrios Kyrtzidis 1d1755348d Factor out some common code into Sema::EnterDeclaratorContext/ExitDeclaratorContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73655 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 23:15:40 +00:00
Argyrios Kyrtzidis f5cecfbdcd Move CXXMethodDecl::OutOfLineDefinition into Decl::OutOfLine.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73651 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 22:49:50 +00:00
Douglas Gregor 9cdda0cf85 Support dependent extended vector types and template instantiation
thereof. Patch by Anders Johnsen!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73641 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 21:51:59 +00:00
Chris Lattner 86df27bbdb move GetBuiltinType from Builtin::Context to ASTContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73316 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-14 00:45:47 +00:00
Eli Friedman d7dad72aa5 PR4350: Make sure we don't create invalid printf attributes. This isn't
visible anywhere normally because the printf format checks for 
this case, and we don't print out attribute values anywhere.  Original 
patch by Roberto Bagnara.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73157 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-10 04:01:38 +00:00
Fariborz Jahanian 496b5a894c Use of DeclContext for objc's ivars. No functionality
change. More to follow.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72951 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-05 18:16:35 +00:00
Eli Friedman dec7c76981 Address review comments for #pragma weak.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72926 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-05 06:28:29 +00:00
Eli Friedman c49f19b6d3 Start of a Sema implementation for #pragma weak. This isn't really the
right approach, but I'm still not sure what the best way to go about this is.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72912 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-05 02:44:36 +00:00
Eli Friedman 340a4e500f Fix up this compatibility hack to be more compatible with gcc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72901 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-04 23:03:07 +00:00
Eli Friedman bc4e29f307 PR4287: allow a variadic prototype to make a subsequent K&R style
definition variadic.  I'm not completely sure it's legal, but the 
standard can be interpreted as making it legal, and gcc seems to think 
it's legal, so I didn't add an extension warning.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72689 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-01 09:24:59 +00:00
Sebastian Redl 3cc9726a49 Disallow exception specs on typedefs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72664 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-31 11:47:27 +00:00
Anders Carlsson f5dcd38858 AddInitializerToDecl needs to take a full expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72640 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 21:37:25 +00:00
Anders Carlsson 0f5f2c669e Remove VarDecl from CheckInitializerTypes now that CXXConstructExpr doesn't need to take a VarDecl anymore. (It still does, but it won't for long)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72630 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 20:41:30 +00:00
Anders Carlsson d12ef8d142 Add a member lookup criteria constructor for searching for overridden virtual member functions. Use this instead of regular name lookup when checking for overriding functions so we will see declarations that would otherwise be hidden. Fixes 6902298.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72601 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 00:52:53 +00:00
Douglas Gregor 4fe0c8e9c7 Refactor and clean up the AST printer, so that it uses a DeclVisitor,
walks through DeclContexts properly, and prints more of the
information available in the AST. The functionality is still available
via -ast-print, -ast-dump, etc., and also via the new member functions
Decl::dump() and Decl::print().



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72597 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-30 00:08:05 +00:00
Sebastian Redl ef65f06e8e Reject incomplete types in exception specs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72580 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 18:02:33 +00:00
Douglas Gregor 8e92bf33ba Now that we have declared/defined tag types within DeclGroups,
instantiation of tags local to member functions of class templates
(and, eventually, function templates) works when the tag is defined as
part of the decl-specifier-seq, e.g.,

  struct S { T x, y; } s1;

Also, make sure that we don't try to default-initialize a dependent
type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72568 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 14:25:00 +00:00
Eli Friedman c1dc653b08 If a declarator group declares a type, make sure to add that declaration
to the DeclGroup.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72559 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-29 01:49:24 +00:00
Douglas Gregor 402abb55fc When we parse a tag specifier, keep track of whether that tag
specifier resulted in the creation of a new TagDecl node, which
happens either when the tag specifier was a definition or when the tag
specifier was the first declaration of that tag type. This information
has several uses, the first of which is implemented in this commit:

  1) In C++, one is not allowed to define tag types within a type
  specifier (e.g., static_cast<struct S { int x; } *>(0) is
  ill-formed) or within the result or parameter types of a
  function. We now diagnose this.

  2) We can extend DeclGroups to contain information about any tags
  that are declared/defined within the declaration specifiers of a
  variable, e.g.,

    struct Point { int x, y, z; } p;

  This will help improve AST printing and template instantiation,
  among other things.

  3) For C99, we can keep track of whether a tag type is defined
  within the type of a parameter, to properly cope with cases like,
  e.g.,

    int bar(struct T2 { int x; } y) {
      struct T2 z;
    }

  We can also do similar things wherever there is a type specifier,
  e.g., to keep track of where the definition of S occurs in this
  legal C99 code:

    (struct S { int x, y; } *)0

  



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72555 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-28 23:31:59 +00:00
Sebastian Redl 465226e23a Reintroduce the home for exception specs, and make Sema fill it. However, keep the spec out of the canonical type this time. Net effect is currently nothing, because the spec isn't checked anywhere.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72498 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 22:11:52 +00:00
Douglas Gregor d0c8737996 Add some more tests for instantiation of declaration references. Also,
improve some error recovery with explicit template instantiation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72484 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 17:30:49 +00:00
Anders Carlsson 2078bb9c93 Create CXXConstructExprs when constructing via copy initialization.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72474 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-27 16:10:08 +00:00
Douglas Gregor 78d1583d0b When evaluating a VarDecl as a constant or determining whether it is
an integral constant expression, maintain a cache of the value and the
is-an-ICE flag within the VarDecl itself. This eliminates
exponential-time behavior of the Fibonacci template metaprogram.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72428 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-26 18:54:04 +00:00
Jay Foad beaaccd8e2 Use v.data() instead of &v[0] when SmallVector v might be empty.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72210 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-21 09:52:38 +00:00
Douglas Gregor 52b2fe2d70 Simplify struct/class tag mismatch warning, per Sebastian's suggestion
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72027 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-18 18:46:22 +00:00
Anders Carlsson 758a422bc1 Add OldMD to the list of methods NewMD overrides
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71969 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-16 23:59:08 +00:00
Anders Carlsson 425bfdee21 Fix another case where the extern-ness of extern "C" wasn't being captured.
This makes me think that we should make hasExternalStorage perform this check...



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71962 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-16 22:05:23 +00:00
Eli Friedman 88d936b245 Avoid calling mergeTypes in C++. I think these are the correct C++
alternatives, but please correct me if I'm wrong.

I eventually plan to assert in mergeTypes that we aren't in C++ mode 
because composite types are fundamentally not a part of C++. The 
remaining callers for code in the regression tests are 
Sema::WarnConflictingTypedMethods and CodeGenFunction::EmitFunctionProlog;
I'm not quite sure what the correct approach is for those callers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71946 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-16 13:54:38 +00:00
Eli Friedman 88f7b576dd PR2044: reject declarations of functions returning variably modified
types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71941 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-16 12:15:55 +00:00
Mike Stump c6e35aae23 Implement a FIXME, we now pass in the locations of the braces for enums.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71930 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-16 07:06:02 +00:00
Douglas Gregor e2c31ff0bc Call ActOnStartOfFunctionDecl/ActOnFinishFunctionBody when
instantiating the definition of a function from a template.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71869 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-15 17:59:04 +00:00
Anders Carlsson 77b7f1d4fb Check that the function being overridden is virtual.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71802 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 22:15:41 +00:00
Anders Carlsson a75e8534f2 Improvements to the FunctionDecl getters/setters.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71800 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 21:46:00 +00:00
Douglas Gregor 501c5ce63c In C++, warn when something previously declared as a "struct" is later
declared as a "class", or vice-versa. This warning is under the
control of -Wmismatched-tags, which is off by default.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71773 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 16:41:31 +00:00
Anders Carlsson d7ba27dc56 Add return type checking for overriding virtual functions. We currently don't check covariance but that's next.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71759 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 01:09:04 +00:00
Douglas Gregor 3f5b61c394 Implement explicit instantiations of member classes of class templates, e.g.,
template<typename T>
  struct X {
    struct Inner;
  };

  template struct X<int>::Inner;

This change is larger than it looks because it also fixes some
a problem with nested-name-specifiers and tags. We weren't requiring
the DeclContext associated with the scope specifier of a tag to be
complete. Therefore, when looking for something like "struct
X<int>::Inner", we weren't instantiating X<int>. 

This, naturally, uncovered a problem with member pointers, where we
were requiring the left-hand side of a member pointer access
expression (e.g., x->*) to be a complete type. However, this is wrong:
the semantics of this expression does not require a complete type (EDG
agrees).

Stuart vouched for me. Blame him.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71756 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-14 00:28:11 +00:00
Chris Lattner 01ad39e42d eli correctly points out that this code is dead, just rip it out for
now until someone does it right


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71638 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-13 04:52:12 +00:00
Douglas Gregor 4d9a16f36d Implement parsing for explicit instantiations of class templates, e.g.,
template class X<int>;

This also cleans up the propagation of template information through
declaration parsing, which is used to improve some diagnostics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71608 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 23:25:50 +00:00
Chris Lattner d4b19d5241 improve the diagnostic for uses of the GCC "global variable in a register" extension.
This implements rdar://6880449 - improve diagnostic for usage of "global register variable" GCC extension



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71599 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 21:44:00 +00:00
Chris Lattner 0afeaa3ff8 Method who have definitions in structs/classes are semantically inline.
Per the FIXME, it might be interesting to track whether the inline keyword
was also used on the method, but for now we don't do this.  Testcase pending.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71589 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-12 20:55:07 +00:00
Douglas Gregor 42af25f865 Implement the notions of the "current instantiation" and "unknown
specialization" within a C++ template, and permit name lookup into the
current instantiation. For example, given:

  template<typename T, typename U>
  struct X {
    typedef T type;

    X* x1;  // current instantiation
    X<T, U> *x2; // current instantiation
    X<U, T> *x3; // not current instantiation
    ::X<type, U> *x4; // current instantiation
    X<typename X<type, U>::type, U>: *x5; // current instantiation
  };



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71471 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-11 19:58:34 +00:00
Douglas Gregor 7da97d0f31 Implement the semantics of the injected-class-name within a class
template. The injected-class-name is either a type or a template,
depending on whether a '<' follows it. As a type, the
injected-class-name's template argument list contains its template
parameters in declaration order.

As part of this, add logic for canonicalizing declarations, and be
sure to canonicalize declarations used in template names and template
arguments. 

A TagType is dependent if the declaration it references is dependent.

I'm not happy about the rather complicated protocol needed to use
ASTContext::getTemplateSpecializationType.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71408 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-10 22:57:19 +00:00
Sebastian Redl bfa2fcba54 Back out r70506 (exception spec in AST) again. We won't have exception specs until we've had a lot more discussion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71125 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-06 23:27:55 +00:00
Douglas Gregor ed4ec8f6d1 One can use "class" and "struct" interchangeably to refer to a class
in C++. Fixes <rdar://problem/6815995>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70784 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03 17:18:57 +00:00
Daniel Dunbar ad04e6737e Fix invalid error about duplicate declaration of padding bit field in
an interface.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70652 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-03 01:08:28 +00:00
Mike Stump c975bb04da Add Sema checking for __block on vm declarations. Radar 6441502
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70601 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 23:41:47 +00:00
Anders Carlsson f1b1d59a3f Replace a bunch of static_cast + release with takeAs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70566 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 19:30:39 +00:00
Douglas Gregor 180bb63b48 Finish a thought in CheckVariableDeclaration's comment. No functionality change
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70544 91177308-0d34-0410-b5e6-96231b3b80d8
2009-05-01 15:47:09 +00:00
Anders Carlsson 4649cac75c Rework the way we handle constructor decls to be less hacky and fix PR3948 completely.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70516 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 22:41:11 +00:00
Sebastian Redl 7b9a2ee5a4 Make a home for exception specs in the AST. Now Sema can hook them up.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 19:20:55 +00:00
Mike Stump ea000bf621 Sema checking for incorrect placement of __block. Radar 6441502
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70452 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 00:19:40 +00:00
Sebastian Redl 7dc813462d Have the parser communicate the exception specification to the action.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70389 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29 17:30:04 +00:00
Chris Lattner 65e6a093b1 Fix PR4092 by improving error recovery in two ways:
1. In a struct field redefinition, don't mark the struct erroneous.  The
   field is erroneous, but the struct is otherwise well formed.
2. Don't emit diagnostics about functions that are known to be broken already.

Either fix is sufficient to silence the second diagnostic in the example,
but the combination is better :)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70371 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-29 05:12:23 +00:00
Douglas Gregor 9f9bf258f8 Improve compatibility with GCC regarding inline semantics in GNU89
mode and in the presence of __gnu_inline__ attributes. This should fix
both PR3989 and PR4069.

As part of this, we now keep track of all of the attributes attached
to each declaration even after we've performed declaration
merging. This fixes PR3264.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70292 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 06:37:30 +00:00
Eli Friedman f01fdff97b Get rid of some useless uses of NoExtensions. The philosophy here is
that if we're going to print an extension warning anyway, 
there's no point to changing behavior based on NoExtensions: it will 
only make error recovery worse.

Note that this doesn't cause any behavior change because NoExtensions 
isn't used by the current front-end.  I'm still considering what to do about
the remaining use of NoExtensions in IdentifierTable.cpp.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70273 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-28 00:51:18 +00:00
Sebastian Redl 13e8854b18 Track down return statements in the handlers of a function-try-block of constructors. Meh ...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70256 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 21:33:24 +00:00
Chris Lattner d0359af511 Change our silencing of C typedef redefinition handling to what we had
before r69391: typedef redefinition is an error by default, but if
*either* the old or new definition are from a system header, we silence
it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70177 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-27 01:46:12 +00:00
Sebastian Redl d3a413d3b8 Implement function-try-blocks. However, there's a very subtle bug that I can't track down.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70155 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-26 20:35:05 +00:00
Chris Lattner 740782a783 improve a diagnostic to make more sense.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70062 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 18:52:45 +00:00
Chris Lattner 84bb944dee with the fixes for better invalid decl/type propagation, this code
is no longer needed: a function type and a function declarator are
always known to line up.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70060 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 18:38:18 +00:00
Chris Lattner 5153ee66d6 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)
^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70023 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 08:47:54 +00:00
Chris Lattner 6e4750188e change a couple more c++ sema methods to be based on isinvalid bits.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70022 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 08:35:12 +00:00
Chris Lattner 6540180c2f various "is invalid" cleanups for C++ ctors/dtors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70021 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 08:28:21 +00:00
Chris Lattner eaaebc7cf1 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.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70020 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 08:06:05 +00:00
Chris Lattner 2dbd285f50 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’



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70016 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 06:12:16 +00:00
Chris Lattner 1ad9b28e32 rename getNumParmVarDeclsFromType back to getNumParams(),
remove a special case that was apparently for typeof() and
generalize the code in SemaDecl that handles typedefs to 
handle any sugar type (including typedef, typeof, etc).
Improve comment to make it more clear what is going on.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70015 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 06:03:53 +00:00
Chris Lattner 7cbeef278d 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70013 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 05:51:56 +00:00
Chris Lattner 584be45eb9 set NewFD->setInvalidDecl() in one place, sharing code and ensuring that
functions with prototypes get the bit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70011 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-25 05:44:12 +00:00
Chris Lattner 5cb10d3b1a fix the sizeof error recovery issue (sizeof-interface.m:attributeRuns)
by correctly propagating the fact that the type was invalid up to the
attributeRuns decl, then returning an ExprError when attributeRuns is
formed (like we do for normal declrefexprs).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69998 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24 22:30:50 +00:00
Douglas Gregor 516ff43cc4 Eliminate Sema::ObjCAliasDecls. This is based on Steve's fix, but also
updates name lookup so that we see through @compatibility_alias
declarations to their underlying interfaces.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69950 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-24 02:57:34 +00:00
Douglas Gregor 319ac896a0 PCH support for all of the predefined Objective-C types, such as id,
SEL, Class, Protocol, CFConstantString, and
__objcFastEnumerationState. With this, we can now run the Objective-C
methods and properties PCH tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69932 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 22:29:11 +00:00
Douglas Gregor b3efa98e32 Fix handling of C99 "extern inline" semantics when dealing with
multiple declarations of the function. Should fix PR3989 and
<rdar://problem/6818429>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69905 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 18:22:55 +00:00
Douglas Gregor 8f36aba016 The ivars in an ObjCImplementationDecl are now stored in the
DeclContext rather than in a separate list. This makes PCH
(de-)serialization trivial, so that ivars can be loaded lazily.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69857 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-23 03:23:08 +00:00
Douglas Gregor 21e072b7fa Eliminate Sema::KnownFunctionIDs, so that Sema doesn't end up pulling
in a bunch of declarations from the PCH file. We're down to loading
very few declarations in Carbon-prefixed "Hello, World!":

*** PCH Statistics:
  6/20693 types read (0.028995%)
  7/59230 declarations read (0.011818%)
  50/44914 identifiers read (0.111324%)
  0/32954 statements read (0.000000%)
  5/6187 macros read (0.080815%)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69825 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-22 20:56:09 +00:00
Douglas Gregor b6c8c8bd8d 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69681 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21 17:11:58 +00:00
Chris Lattner df9bcd568c clean up anonymous bitfield diagnostics, PR4017
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69608 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-20 17:29:38 +00:00
Eli Friedman 4fb71b0cc3 Print an error for uses of __thread on targets which don't support it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69553 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 21:48:33 +00:00
Eli Friedman 63054b39a2 Add more thorough/correct checking for invalid __thread specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69542 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 20:27:55 +00:00
Chris Lattner 38c5ebd7b1 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69509 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 05:21:20 +00:00
Chris Lattner 5af280ce21 move jump scope checking and related code out into its own file, SemaDecl.cpp is
already too large.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69505 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 04:46:21 +00:00
Chris Lattner e52a693787 rewrite an O(N^2) algorithm to be O(n).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69500 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 01:32:00 +00:00
Chris Lattner b5cf1ea6f4 second half of indirect jump checking: make sure that any
address taken labels are in function scope


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69499 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 01:16:06 +00:00
Chris Lattner 04ea2b633a First half of jump scope checking for indirect goto.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69498 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-19 01:05:26 +00:00
Chris Lattner 2b7b2ca64a reimplement DeclStmt handling so that we correctly handle intermixed
VLA's and statement expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69491 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 23:01:20 +00:00
Chris Lattner 5223af8f05 the scope checker does work with objc methods, add testcase.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69487 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 22:37:38 +00:00
Chris Lattner dabbad04ee I didn't understand how @catches were chained. Now that I get it, fix
the scope checker to not think @catches are nested in each other, eliminating
some bogus notes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69486 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 22:35:34 +00:00
Chris Lattner cd99d9eac2 forgot to commit this before.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69480 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 21:55:17 +00:00
Chris Lattner 07e775d5a1 reject invalid jumps among pieces of @try blocks. This seems to work
reasonably well except for the problem that @catches are nested within
each other in the AST, giving the ugly diagnostics in L8.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69477 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 21:28:52 +00:00
Chris Lattner b565937252 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69476 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 21:00:42 +00:00
Chris Lattner 4f2aac33fe fix two error paths out of ParseBlockLiteralExpression to
call ActOnBlockError so that CurBlock gets popped.  This
fixes a crash on test/block-syntax-error.c when this new
assertion is enabled.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69464 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 20:05:34 +00:00
Chris Lattner ea29a3a0d6 refactor some code, adding a new getLabelMap() accessor method
so that clients can't poke the function-local one when they really
want the current block label.  No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69463 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 20:01:55 +00:00
Chris Lattner a9768b72bb 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];
        ^




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69462 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 19:50:02 +00:00
Chris Lattner 366920a45e first step to getting switches giving "jump into vla scope" errors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69461 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 19:42:37 +00:00
Chris Lattner e32f74c7af fix error recovery in the case of a jump to a label with no definition
to create a well formed AST instead of a dangling pointer.  This resolves
several fixme's.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69459 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 19:30:02 +00:00
Chris Lattner a5251fcf79 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69437 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 09:36:27 +00:00
Chris Lattner 9b0ed03691 don't evaluate ->child_end() every time through the loop, or *i frequently within it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69431 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 07:53:55 +00:00
Chris Lattner e80f767a1d split code out into a new CheckFunctionJumpScopes routine,
add some comments, change type from void* -> Stmt*, use
smallvector instead of vector.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69430 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 07:47:21 +00:00
Chris Lattner ab09436eb9 make scope checking be static functions instead of sema methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69429 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 07:36:39 +00:00
Douglas Gregor 7297134f12 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69406 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-18 00:02:19 +00:00
Chris Lattner 32b06752d0 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69391 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-17 22:04:20 +00:00
Chris Lattner 23a48cc69e 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69374 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-17 19:32:54 +00:00
Anders Carlsson 072abefcdd Add support for the __has_trivial_destructor type trait.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69345 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-17 02:34:54 +00:00
Anders Carlsson 930e8d0c2f If a class has a non-trivial constructor that doesn't take any arguments, we will now make an implicit CXXTemporaryObjectExpr. So
struct S {
  S();
};

void f() {
 S s;
}

's' here will implicitly be declared as.

S s = S();



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69326 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 23:50:50 +00:00
Chris Lattner 6a7334d810 use getDiagnosticLevel instead of getDiagnosticMapping, which
is about to become private.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69262 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 03:59:32 +00:00
Anders Carlsson 347ba89dec Add support for the __has_trivial_constructor type trait.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69245 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-16 00:08:20 +00:00
Steve Naroff 3bf4497962 Fixup http://llvm.org/viewvc/llvm-project?rev=69165&view=rev (based on feedback from Eli).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69184 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 17:31:31 +00:00
Steve Naroff 1b6823d48d Revert previous patch (will commit a fix soon).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69178 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 16:58:41 +00:00
Steve Naroff ee3899e1ca Fix <rdar://problem/6789707> "warning: 'extern' variable has an initializer" not correct for __private_extern__.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69167 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 15:20:03 +00:00
Steve Naroff b25ddfb155 Fix <rdar://problem/6791490> [clang10 regression] [sema] invalid illegal jump diagnostic.
caused by: <rdar://problem/6252084> [sema] jumps into Obj-C exception blocks should be disallowed.

Sema::RecursiveCalcLabelScopes() and Sema::RecursiveCalcJumpScopes() need to pop the ScopeStack within the statement iteration loop (was outside the loop).

Eli, please review (thanks).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69165 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-15 14:38:36 +00:00
Steve Naroff 1fc5194039 Fix <rdar://problem/6252084> [sema] jumps into Obj-C exception blocks should be disallowed.
This builds on Eli's work from http://llvm.org/viewvc/llvm-project?view=rev&revision=65678.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69073 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 20:53:38 +00:00
Mike Stump f0c9083c04 Use hasAttr instead of getAttr for conditionals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69021 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 02:45:29 +00:00
Daniel Dunbar 5466c7b0ca 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69020 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 02:25:56 +00:00
Mike Stump f33651c2d7 Fixup CodeGen for __weak __block variables. Radar 6756266
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69010 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-14 00:57:29 +00:00
Eli Friedman a31fecaf63 PR3461: reject initializer for incomplete type. Based on patch by Tim
Northover.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68991 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-13 21:28:54 +00:00
Douglas Gregor 841b53c502 Make the selection of type declarations in Sema::getTypeName
deterministic when faced with an ambiguity. This eliminates the
annoying test/SemaCXX/using-directive.cpp failure.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68952 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-13 15:14:38 +00:00
Chris Lattner 6491f47670 fix another case that assumed that GetTypeForDeclarator would never return null.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68918 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-12 22:15:02 +00:00
Chris Lattner 798d5696ef fix code that incorrectly assumed that GetTypeForDeclarator cannot
return null.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68916 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-12 22:12:06 +00:00
Chris Lattner 4c97d762d8 Diagnose invalid uses of tagged types with a missing tag. For example, in:
struct xyz { int y; };
enum abc { ZZZ };

static xyz b;
abc c;

we used to produce:

t2.c:4:8: error: unknown type name 'xyz'
static xyz b;
       ^
t2.c:5:1: error: unknown type name 'abc'
abc c;
^

we now produce:

t2.c:4:8: error: use of tagged type 'xyz' without 'struct' tag
static xyz b;
       ^
       struct
t2.c:5:1: error: use of tagged type 'abc' without 'enum' tag
abc c;
^
enum

GCC produces the normal:
t2.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘b’
t2.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c’

rdar://6783347


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68914 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-12 21:49:30 +00:00
Chris Lattner 5186872629 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68913 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-12 20:51:10 +00:00
Chris Lattner bfc861e703 a few cleanups to StatementCreatesScope: unnest the whole thing,
exit at the first decl found that creates a scope, don't evaluate
decl_end() every iteration.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68908 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-12 20:09:42 +00:00
Chris Lattner f97e8fa296 simplify code to use adjustParameterType, apply objc arg attributes
to their arguments.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68876 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-11 19:34:56 +00:00
Chris Lattner bb74982f30 diagnose attempts to return objc interfaces by-value from C functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68873 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-11 19:17:25 +00:00
Chris Lattner 2dd979fbd5 Improve the 'cannot pass objc interface by value' diagnostic:
1) improve localizability by not passing english strings in.
2) improve location for arguments.
3) print the objc type being passed.

Before:
method-bad-param.m:15:1: error: Objective-C type cannot be passed by value
-(void) my_method:(foo) my_param
^

after:
method-bad-param.m:15:25: error: Objective-C interface type 'foo' cannot be passed by value
-(void) my_method:(foo) my_param
                        ^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68872 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-11 19:08:56 +00:00
Douglas Gregor e1d918e9fe Compare the predefines buffer in the PCH file with the predefines
buffer generated for the current translation unit. If they are
different, complain and then ignore the PCH file. This effectively
checks for all compilation options that somehow would affect
preprocessor state (-D, -U, -include, the dreaded -imacros, etc.).

When we do accept the PCH file, throw away the contents of the
predefines buffer rather than parsing them, since all of the results
of that parsing are already stored in the PCH file. This eliminates
the ugliness with the redefinition of __builtin_va_list, among other
things.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68838 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 23:10:45 +00:00
Douglas Gregor 8038d5182b Various minor fixes to PCH reading and writing, with general
cleanup. Aside from a minor tweak to the PCH file format, no
functionality change. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68793 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10 17:25:41 +00:00
Douglas Gregor 2cf2634ffd Implementation of pre-compiled headers (PCH) based on lazy
de-serialization of abstract syntax trees.

PCH support serializes the contents of the abstract syntax tree (AST)
to a bitstream. When the PCH file is read, declarations are serialized
as-needed. For example, a declaration of a variable "x" will be
deserialized only when its VarDecl can be found by a client, e.g.,
based on name lookup for "x" or traversing the entire contents of the
owner of "x".

This commit provides the framework for serialization and (lazy)
deserialization, along with support for variable and typedef
declarations (along with several kinds of types). More
declarations/types, along with important auxiliary structures (source
manager, preprocessor, etc.), will follow.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68732 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-09 22:27:44 +00:00
Douglas Gregor 6ab3524f72 Propagate the ASTContext to various AST traversal and lookup functions.
No functionality change (really).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68726 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-09 21:40:53 +00:00
Eli Friedman d296836d0d Add some FIXMEs for missing checks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68725 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-09 21:26:42 +00:00
Douglas Gregor 2c2d9dc382 -Wmissing-prototypes shouldn't complain about main() missing a prototype.
Fixes <rdar://problem/6759522>



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68611 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-08 15:21:36 +00:00
Eli Friedman 85a5319ea4 Diagnose uses of function specifiers on declarations which don't declare
functions.  Fixes PR3941.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68541 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-07 19:37:57 +00:00
Douglas Gregor 261034861d Clean up -fixit output slightly
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68278 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 03:14:12 +00:00
Douglas Gregor a3a835149e Add some more code modification hints
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68261 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-01 23:51:29 +00:00
Douglas Gregor 31a19b6989 Make parsing a semantic analysis a little more robust following Sema
failures that involve malformed types, e.g., "typename X::foo" where
"foo" isn't a type, or "std::vector<void>" that doens't instantiate
properly.

Similarly, be a bit smarter in our handling of ambiguities that occur
in Sema::getTypeName, to eliminate duplicate error messages about
ambiguous name lookup.

This eliminates two XFAILs in test/SemaCXX, one of which was crying
out to us, trying to tell us that we were producing repeated error
messages.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68251 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-01 21:51:26 +00:00
Douglas Gregor 8499f3f5ff Implement -Wmissing-prototypes. Fixes PR3911.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68110 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-31 16:35:03 +00:00
Chris Lattner 682bf92db4 Push DeclGroup much farther throughout the compiler. Now the various
productions (except the already broken ObjC cases like @class X,Y;) in 
the parser that can produce more than one Decl return a DeclGroup instead
of a Decl, etc.

This allows elimination of the Decl::NextDeclarator field, and exposes
various clients that should look at all decls in a group, but which were
only looking at one (such as the dumper, printer, etc).  These have been
fixed.

Still TODO:

1) there are some FIXME's in the code about potentially using
DeclGroup for better location info.
2) ParseObjCAtDirectives should return a DeclGroup due to @class etc.
3) I'm not sure what is going on with StmtIterator.cpp, or if it can
   be radically simplified now.
4) I put a truly horrible hack in ParseTemplate.cpp.

I plan to bring up #3/4 on the mailing list, but don't plan to tackle
#1/2 in the short term.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68002 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-29 16:50:03 +00:00
Chris Lattner b28317a8e5 Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for a
pointer.  Its purpose in life is to be a glorified void*, but which does not
implicitly convert to void* or other OpaquePtr's with a different UID.

Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>.  Change the 
entire parser/sema interface to use DeclPtrTy instead of DeclTy*.  This
makes the C++ compiler enforce that these aren't convertible to other opaque
types.

We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc,
but I don't plan to do that in the short term.

The one outstanding known problem with this patch is that we lose the 
bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to
bitmangle the success bit into the low bit of DeclPtrTy.  I will rectify
this with a subsequent patch.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67952 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-28 19:18:32 +00:00
Douglas Gregor 332975661d Improve recovery when a constructor fails to type-check. Test case from Anders
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67818 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-27 04:38:56 +00:00
Anders Carlsson 0cf8830a45 Factor the member access specifier setting code into its own function. No intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67725 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-26 01:19:02 +00:00
Anders Carlsson 50713450f6 Check that the access specifier of a member redeclaration is the same as the original declaration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67722 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-26 00:24:17 +00:00
Douglas Gregor befc20e1dc The injected-class-name of class templates and class template
specializations can be treated as a template. Finally, we can parse
and process the first implementation of Fibonacci I wrote!

Note that this code does not handle all of the cases where
injected-class-names can be treated as templates. In particular,
there's an ambiguity case that we should be able to handle (but
can't), e.g.,

  template <class T> struct Base { }; 
  template <class T> struct Derived : Base<int>, Base<char> {
    typename Derived::Base b;       // error: ambiguous
    typename Derived::Base<double> d;  // OK 
  };




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67720 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-26 00:10:35 +00:00
Anders Carlsson 1329c27462 Tighten the setAccess assert. We now allow AS_none if the decl contex is not a C++ record decl.
Also, fix fallout from the change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67717 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-25 23:38:06 +00:00
Douglas Gregor 3d7a12a505 Implement template instantiation for static data members of class
templates, including in-class initializers. For example:

  template<typename T, T Divisor>
  class X {
  public:
    static const T value = 10 / Divisor;
  };

instantiated with, e.g.,

  X<int, 5>::value

to get the value '2'.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67715 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-25 23:32:15 +00:00
Douglas Gregor 06c0fecd19 Pass access specifiers through to member classes and member enums.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67710 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-25 22:00:53 +00:00
Douglas Gregor d475b8d9e6 Instantiation for member classes of class templates. Note that only
the declarations of member classes are instantiated when the owning
class template is instantiated. The definitions of such member classes
are instantiated when a complete type is required.

This change also introduces the injected-class-name into a class
template specialization.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67707 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-25 21:17:03 +00:00
Douglas Gregor c9b5b4074b Predicate to detect when a RecordDecl is really the injected-class-name
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67687 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-25 15:59:44 +00:00
Douglas Gregor e7450f5dbd Make sure to use RequireCompleteType rather than testing for
incomplete types. RequireCompleteType is needed when the type may be
completed by instantiating a template.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67643 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24 19:52:54 +00:00
Anders Carlsson 8211effbd3 More work on diagnosing abstract classes. We can now handle cases like
class C {
  void g(C c);

  virtual void f() = 0;
};

In this case, C is not known to be abstract when doing semantic analysis on g. This is done by recursively traversing the abstract class and checking the types of member functions. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67594 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-24 01:19:16 +00:00
Douglas Gregor 2dc0e64e57 Template instantiation for the declarations of member functions within
a class template. At present, we can only instantiation normal
methods, but not constructors, destructors, or conversion operators.

As ever, this contains a bit of refactoring in Sema's type-checking. In
particular:

  - Split ActOnFunctionDeclarator into ActOnFunctionDeclarator
    (handling the declarator itself) and CheckFunctionDeclaration
    (checking for the the function declaration), the latter of which
    is also used by template instantiation.
  - We were performing the adjustment of function parameter types in
    three places; collect those into a single new routine.
  - When the type of a parameter is adjusted, allocate an
    OriginalParmVarDecl to keep track of the type as it was written.
  - Eliminate a redundant check for out-of-line declarations of member
    functions; hide more C++-specific checks on function declarations
    behind if(getLangOptions().CPlusPlus).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67575 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 23:06:20 +00:00
Anders Carlsson 11f21a08cd More improvements to abstract type checking. Handle arrays correctly, and make sure to check parameter types before they decay.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67550 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 19:10:31 +00:00
Anders Carlsson b9bbe49f51 It's an error to try to allocate an abstract object using new.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67542 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 17:49:10 +00:00
Douglas Gregor 374e156647 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67541 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 17:47:24 +00:00
Douglas Gregor d1659a6bd9 Tighten up the determination of whether a function declaration has a
prototype. Thanks Eli!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67533 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 16:26:51 +00:00
Douglas Gregor 38179b29df Thanks to Eli for pointing out my misreading of 6.2.2p5
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67530 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-23 16:17:01 +00:00
Anders Carlsson 4681ebd429 Disallow abstract types where appropriate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67476 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-22 20:18:17 +00:00
Anders Carlsson 67e4dd2e99 Keep track of whether a class is abstract or not. This is currently only used for the __is_abstract type trait.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67461 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-22 01:52:17 +00:00
Douglas Gregor 5ef122e944 Variables marked as "extern" can actually have internal linkage if
there is a previous declaration marked "static". This fixes PR3645.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67336 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-19 22:01:50 +00:00
Douglas Gregor d874def0f9 Add a clarifying comment about HasPrototype's computation
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67316 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-19 18:33:54 +00:00
Douglas Gregor 13d7a32774 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67313 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-19 18:14:46 +00:00
Douglas Gregor 5953d8b37f Introduce a new expression type, UnresolvedDeclRefExpr, that describes
dependent qualified-ids such as

  Fibonacci<N - 1>::value

where N is a template parameter. These references are "unresolved"
because the name is dependent and, therefore, cannot be resolved to a
declaration node (as we would do for a DeclRefExpr or
QualifiedDeclRefExpr). UnresolvedDeclRefExprs instantiate to
DeclRefExprs, QualifiedDeclRefExprs, etc.

Also, be a bit more careful about keeping only a single set of
specializations for a class template, and instantiating from the
definition of that template rather than a previous declaration. In
general, we need a better solution for this for all TagDecls, because
it's too easy to accidentally look at a declaration that isn't the
definition.

We can now process a simple Fibonacci computation described as a
template metaprogram.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67308 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-19 17:26:29 +00:00
Douglas Gregor e625893617 Extend the use of QualifiedNameType to the creation of class template
specialization names. This way, we keep track of sugared types like

  std::vector<Real>

I believe we are now using QualifiedNameTypes everywhere we can. Next
step: QualifiedDeclRefExprs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67268 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-19 00:39:20 +00:00
Douglas Gregor e4e5b054b4 Introduce a representation for types that we referred to via a
qualified name, e.g., 

  foo::x

so that we retain the nested-name-specifier as written in the source
code and can reproduce that qualified name when printing the types
back (e.g., in diagnostics). This is PR3493, which won't be complete
until finished the other tasks mentioned near the end of this commit.

The parser's representation of nested-name-specifiers, CXXScopeSpec,
is now a bit fatter, because it needs to contain the scopes that
precede each '::' and keep track of whether the global scoping
operator '::' was at the beginning. For example, we need to keep track
of the leading '::', 'foo', and 'bar' in
 
  ::foo::bar::x

The Action's CXXScopeTy * is no longer a DeclContext *. It's now the
opaque version of the new NestedNameSpecifier, which contains a single
component of a nested-name-specifier (either a DeclContext * or a Type
*, bitmangled). 

The new sugar type QualifiedNameType composes a sequence of
NestedNameSpecifiers with a representation of the type we're actually
referring to. At present, we only build QualifiedNameType nodes within
Sema::getTypeName. This will be extended to other type-constructing
actions (e.g., ActOnClassTemplateId).

Also on the way: QualifiedDeclRefExprs will also store a sequence of
NestedNameSpecifiers, so that we can print out the property
nested-name-specifier. I expect to also use this for handling
dependent names like Fibonacci<I - 1>::value.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67265 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-19 00:18:19 +00:00
Douglas Gregor ca5e77fefc The scope representation can now be either a DeclContext pointer or a
Type pointer. This allows our nested-name-specifiers to retain more
information about the actual spelling (e.g., which typedef did the
user name, or what exact template arguments were used in the
template-id?). It will also allow us to have dependent
nested-name-specifiers that don't map to any DeclContext.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67140 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-18 00:36:05 +00:00
Chris Lattner 0d48bf9eb5 pull a nested conditional + comment out into its own variable,
no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67128 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-17 23:17:04 +00:00
Douglas Gregor 879fd49f99 Implement instantiation of enums within class templates. This isn't
quite as great as it sounds, because, while we can refer to the
enumerator values outside the template, e.g.,

  adder<long, 3, 4>::value

we can't yet refer to them with dependent names, so no Fibonacci
(yet). 

InstantiateClassTemplateSpecialization is getting messy; next commit
will put it into a less-ugly state.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67092 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-17 19:05:46 +00:00
Anders Carlsson f257b61905 Check signedness of bitfield sizes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67045 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-16 18:19:21 +00:00
Steve Naroff caaacecb2b 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...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66893 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 15:38:40 +00:00
Douglas Gregor df0325110b Implement template instantiation for builtin binary operators
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66835 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-12 22:46:12 +00:00
Ted Kremenek eaab20669b API fix: All "bodies" for functions, Objective-C methods, blocks, are assumed to
be CompoundStmts. I think this is a valid assumption, and felt that the API
should reflect it. Others please validate this assumption to make sure I didn't
break anything.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66814 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-12 18:33:24 +00:00
Douglas Gregor 656de633ac Fix various problems with matching out-of-line definitions of static
class members to the corresponding in-class declaration.

Diagnose the erroneous use of 'static' on out-of-line definitions of
class members. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66740 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-11 23:52:16 +00:00
Douglas Gregor 021c3b372c Move most of the checking from ActOnCXXMemberDeclarator to other, more general routines. This is a step toward separating the checking logic from Declarators, which in turn is required for template instantiation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66734 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-11 23:00:04 +00:00
Douglas Gregor 4dd55f511d Make sure that we set the access specifier for an instantiated FieldDecl, and that the aggregate and POD flags for an instantiated class template are updated based on instantiation of a FieldDecl
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66701 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-11 20:50:30 +00:00
Douglas Gregor 2d2e9cfdc1 Eliminate CXXClassVarDecl. It doesn't add anything
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66696 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-11 20:22:50 +00:00
Douglas Gregor 3cf538d5c4 Implement basic template instantiation for fields. Reshuffle checking
for FieldDecls so that the parser and the template instantiation make
use of the same semantic checking module.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66685 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-11 18:59:21 +00:00
Douglas Gregor 4fdf1faedb Add basic, hackish support for instantiation of typedefs in a class
template. More importantly, start to sort out the issues regarding
complete types and nested-name-specifiers, especially the question of:
when do we instantiate a class template specialization that occurs to
the left of a '::' in a nested-name-specifier?




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66662 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-11 16:48:53 +00:00
Douglas Gregor 275a369f00 Add type checking for tentative definitions at the end of the
translation unit.

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66601 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-10 23:43:53 +00:00
Douglas Gregor a03aca82de 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66584 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-10 21:58:27 +00:00
Anders Carlsson 4843e584b5 Address Doug's comments wrt the mangler and fix Eli's test case
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66549 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-10 17:07:44 +00:00
Douglas Gregor 86447ec25f Rename DiagnoseIncompleteType to RequireCompleteType, and update the documentation to reflect the fact that we can instantiate templates here
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66421 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-09 16:13:40 +00:00
Douglas Gregor e4f3e069e5 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66308 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 23:41:27 +00:00
Douglas Gregor a71c129fb8 Use the 'declaration does not declare anything' error when we see an anonymous struct/union declaration outside of a struct or union in C
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66303 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 23:06:59 +00:00
Douglas Gregor c837656ca6 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66301 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 22:43:54 +00:00
Douglas Gregor 9fa14a5478 Improve recovery from ill-formed scope specifiers. Fixes PR3670.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66286 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 19:06:37 +00:00
Douglas Gregor 80711a22fa Implement the GNU semantics for forward declarations of enum types in
C and C++. Fixes PR3688.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66282 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 18:34:03 +00:00
Chris Lattner 8b963ef99b refactor C++ bitfield checking a bit (haha)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66213 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-05 23:01:03 +00:00
Chris Lattner 2479366059 fix PR3607 and a fixme, by checking bitfield constraints
more consistently.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66210 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-05 22:45:59 +00:00
Chris Lattner 21ff9c99d3 When parsing a function body, add it to the crash stack, giving us something
like:

Stack dump:
0.	t.c:5:10: in compound statement ('{}')
1.	t.c:3:12: in compound statement ('{}')
2.	t.c:3:12: parsing function body 'foo'
3.	clang t.c 
Abort



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66118 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-05 01:25:28 +00:00
Eli Friedman 7f0f5dce3a Check that the return type for function definitions is complete.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66027 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 07:30:59 +00:00
Chris Lattner 0b2b6e1cb1 Switch attributes to be allocated from the declcontext bump pointer just like
decls.  This reduces the number of calls to malloc on cocoa.h with pth and
-disable-free from 15958 to 12444 times (down ~3500).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66023 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 06:34:08 +00:00
Chris Lattner cc5814732e add an a Attr::Destroy method and force clients to go through it. As part of
this, make DeclBase::Destroy destroy attributes instead of the DeclBase dtor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66020 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 06:05:19 +00:00
Douglas Gregor 2943aed177 Implement the basics of implicit instantiation of class templates, in
response to attempts to diagnose an "incomplete" type. This will force
us to use DiagnoseIncompleteType more regularly (rather than looking at
isIncompleteType), but that's also a good thing.

Implicit instantiation is still very simplistic, and will create a new
definition for the class template specialization (as it should) but it
only actually instantiates the base classes and attaches
those. Actually instantiating class members will follow. 

Also, instantiate the types of non-type template parameters before
checking them,  allowing, e.g., 

  template<typename T, T Value> struct Constant; 
 
to work properly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65924 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-03 04:44:36 +00:00
Douglas Gregor 6393519272 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65792 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-02 00:19:53 +00:00
Anders Carlsson 0db28c5926 Whoops, actually remove the VLA/VM check in FinalizeDeclaratorGroup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65737 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-28 23:31:06 +00:00
Anders Carlsson 1a7acfa0de 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.
 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65725 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-28 21:56:50 +00:00
Chris Lattner f306f86d2b Fix a crash in test/Parser/control-scope.c that testrunner didn't
notice because it was a negative test with a fix suggested by
Jean-Daniel Dupas.  Convert the test from a negative to a positive
test to catch stuff like this.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65708 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-28 19:37:57 +00:00
Steve Naroff f3cf897379 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).  


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65694 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-28 16:48:43 +00:00
Eli Friedman 709fa15def Check a few more kinds of declarations that make a scope.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65680 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-28 06:22:14 +00:00
Eli Friedman 8f17b66c8d 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65678 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-28 05:41:13 +00:00
Eli Friedman 3b8a36aea7 Fix minor memory leak. Add comment describing what we need to do for
strict constant initializer checking.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65612 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-27 04:17:12 +00:00
Douglas Gregor 72564e7327 Create a new TypeNodes.def file that enumerates all of the types,
giving them rough classifications (normal types, never-canonical
types, always-dependent types, abstract type representations) and
making it far easier to make sure that we've hit all of the cases when
decoding types. 

Switched some switch() statements on the type class over to using this
mechanism, and filtering out those things we don't care about. For
example, CodeGen should never see always-dependent or non-canonical
types, while debug info generation should never see always-dependent
types. More switch() statements on the type class need to be moved 
over to using this approach, so that we'll get warnings when we add a
new type then fail to account for it somewhere in the compiler.

As part of this, some types have been renamed:

  TypeOfExpr -> TypeOfExprType
  FunctionTypeProto -> FunctionProtoType
  FunctionTypeNoProto -> FunctionNoProtoType

There shouldn't be any functionality change...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65591 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26 23:50:07 +00:00
Eli Friedman 2129828098 Zap the Sema constant initializer checking code that we aren't using
anymore.  If we want to reuse bits and pieces to add strict checking for 
constant initializers, we can dig them out of SVN history; the existing 
code won't be useful as-is.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65502 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26 04:47:58 +00:00
Eli Friedman bc592e6e56 Fix for PR3663/3669: use TryToFixInvalidVariablyModifiedType for
variable declarations where applicable.  Also, a few fixes to 
TryToFixInvalidVariablyModifiedType for issues that this exposed.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65500 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26 03:58:54 +00:00
Douglas Gregor 2224f84658 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.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65460 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-25 16:33:18 +00:00
Chris Lattner dd8e006520 move some initialization checking code from SemaDecl.cpp
to SemaInit.cpp, no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65394 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 22:27:37 +00:00
Chris Lattner eaf2bb89eb first wave of fixes for @encode sema support. This is part of PR3648.
The big difference here is that (like string literal) @encode has 
array type, not pointer type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65391 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 22:18:39 +00:00
Chris Lattner 111c2ee5fe some minor cleanups, handle ObjCEncodeExpr in a couple places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65389 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 21:54:33 +00:00
Douglas Gregor d6f7e9dccd When we're declaring an object or function with linkage, teach name
lookup to skip over names without linkage. This finishes
<rdar://problem/6127293>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65386 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 20:03:32 +00:00
Douglas Gregor 8f30105fda 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65385 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 19:23:27 +00:00
Douglas Gregor 25d944af5d 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65373 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 04:26:15 +00:00
Douglas Gregor 04495c859f 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"



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65360 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 01:23:02 +00:00
Chris Lattner 1829a6db2e 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65340 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 22:00:08 +00:00
Eli Friedman 578a97249c 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).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65265 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-22 06:45:27 +00:00
Fariborz Jahanian 7b5b3170d9 Warn on use of __weak attribute on local
variable (objc2 gc specific).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65240 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-21 19:44:02 +00:00
Eli Friedman 61125c81cc Slight tweak to last commit: make sure to copy CVR qualifiers for fixed
pointer types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65210 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-21 00:58:02 +00:00
Eli Friedman 1ca4813dda Re-fix r65140 correctly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65208 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-21 00:44:51 +00:00
Steve Naroff ccef371a67 Fix <rdar://problem/6500554> missing objc error message.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65198 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 22:59:16 +00:00
Chris Lattner 38af2deb27 add plumbing to get ASTContext& down to allocation/deallocation points in ObjCList,
but don't start using it yet.  Renamed some methods to be more consistent.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65168 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 21:35:13 +00:00
Chris Lattner 7a21bd046f move the @implementation ivar list to being an ObjCList, which prevents
it from being leaked, among other things.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65150 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 20:41:34 +00:00
Anders Carlsson 540b146d01 Always try to fold array sizes, and warn if we could fold something that isn't an ICE. This makes us compatible with GCC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65140 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 18:53:20 +00:00
Steve Naroff 63359c80b0 Fix <rdar://problem/6586239> bitfield constraints not enforced (for ObjC)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65128 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 17:57:11 +00:00
Eli Friedman da153239bb 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.)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65101 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20 01:34:21 +00:00
Chris Lattner 83aa61f600 GetTypeForDeclarator can return null on error now, handle this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65076 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19 23:13:55 +00:00
Anders Carlsson 1c17689a67 Emit the correct diagnostics when we constant fold an array size to a negative value.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65023 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19 06:30:50 +00:00
Fariborz Jahanian f6123ca578 Couple of helpers for objc's gc attributes.
No change in functionality.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64989 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19 00:22:47 +00:00
Douglas Gregor c2b6a82393 Return true on errors, return true on errors, return true on errors
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64957 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 22:00:45 +00:00
Douglas Gregor 48f3bb9f78 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 :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64955 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 21:56:37 +00:00