summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Improve diagnostics when the parser encounters a declarator with anDouglas Gregor2009-10-131-0/+31
| | | | | | | | | | | | | | | | | | | | | | | unknown type name, e.g., foo::bar x; when "bar" does not refer to a type in "foo". With this change, the parser now calls into the action to perform diagnostics and can try to recover by substituting in an appropriate type. For example, this allows us to easily diagnose some missing "typename" specifiers, which we now do: test/SemaCXX/unknown-type-name.cpp:29:1: error: missing 'typename' prior to dependent type name 'A<T>::type' A<T>::type A<T>::f() { return type(); } ^~~~~~~~~~ typename Fixes PR3990. llvm-svn: 84053
* Unify our diagnostic printing for errors of the form, "we didn't likeDouglas Gregor2009-10-131-5/+4
| | | | | | | | | | what we found when we looked into <blah>", where <blah> is a DeclContext*. We can now format DeclContext*'s in nice ways, e.g., "namespace N", "the global namespace", "'class Foo'". This is part of PR3990, but we're not quite there yet. llvm-svn: 84028
* When explicitly specializing a member that is a template, mark theDouglas Gregor2009-10-131-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | template as a specialization. For example, this occurs with: template<typename T> struct X { template<typename U> struct Inner { /* ... */ }; }; template<> template<typename T> struct X<int>::Inner { T member; }; We need to treat templates that are member specializations as special in two contexts: - When looking for a definition of a member template, we look through the instantiation chain until we hit the primary template *or a member specialization*. This allows us to distinguish between the primary "Inner" definition and the X<int>::Inner definition, above. - When computing all of the levels of template arguments needed to instantiate a member template, don't add template arguments from contexts outside of the instantiation of a member specialization, since the user has already manually substituted those arguments. Fix up the existing test for p18, which was actually wrong (but we didn't diagnose it because of our poor handling of member specializations of templates), and add a new test for member specializations of templates. llvm-svn: 83974
* Improve the internal representation and semantic analysis of friendDouglas Gregor2009-10-131-3/+13
| | | | | | | | | | | | | | | function templates. This commit ensures that friend function templates are constructed as FunctionTemplateDecls rather than partial FunctionDecls (as they previously were). It then implements template instantiation for friend function templates, injecting the friend function template only when no previous declaration exists at the time of instantiation. Oh, and make sure that explicit specialization declarations are not friends. llvm-svn: 83970
* Permit explicit specialization of member functions of class templatesDouglas Gregor2009-10-121-3/+11
| | | | | | | | that are declarations (rather than definitions). Also, be sure to set the access specifiers properly when instantiating the declarations of member function templates. llvm-svn: 83911
* Diagnose the declaration of explicit specializations after an implicitDouglas Gregor2009-10-121-8/+16
| | | | | | | instantiation has already been required. To do so, keep track of the point of instantiation for anything that can be instantiated. llvm-svn: 83890
* Qualified lookup through using declarations. Diagnose a new type of ambiguity.John McCall2009-10-101-8/+22
| | | | | | | Split the various ambiguous result enumerators into their own enum. Tests for most of C++ [namespace.qual]. llvm-svn: 83700
* Refactor the LookupResult API to simplify most common operations. Require ↵John McCall2009-10-091-104/+48
| | | | | | | | | users to pass a LookupResult reference to lookup routines. Call out uses which assume a single result. llvm-svn: 83674
* Implement support for -Wunused-variable, from Oscar Bonilla!Douglas Gregor2009-10-081-0/+6
| | | | llvm-svn: 83577
* Add more testing for the properties of explicit specialization. Douglas Gregor2009-10-081-0/+2
| | | | | | | Also, eliminate a redundant diagnostic by marking a variable declared with incomplete type as an invalid declaration. llvm-svn: 83553
* Don't complain about out-of-line explicit specializations of memberDouglas Gregor2009-10-081-2/+4
| | | | | | | | function and member function templates that are not definitions. Add more tests to ensure that explicit specializations of member function templates prevent instantiation. llvm-svn: 83550
* Improve checking for specializations of member classes of classDouglas Gregor2009-10-081-3/+11
| | | | | | | | | | | templates, and keep track of how those member classes were instantiated or specialized. Make sure that we don't try to instantiate an explicitly-specialized member class of a class template, when that explicit specialization was a declaration rather than a definition. llvm-svn: 83547
* For instantiations of static data members of class templates, keepDouglas Gregor2009-10-081-4/+16
| | | | | | | | track of the kind of specialization or instantiation. Also, check the scope of the specialization and ensure that a specialization declaration without an initializer is not a definition. llvm-svn: 83533
* Refactoring around friend class templates. Better error message for friend ↵John McCall2009-10-071-57/+10
| | | | | | | | enums. Don't create a new declaration for friend classes if a declaration already exists. llvm-svn: 83505
* Type checking for specializations of member functions of classDouglas Gregor2009-10-071-12/+26
| | | | | | | | templates. Previously, these weren't handled as specializations at all. The AST for representing these as specializations is still a work in progress. llvm-svn: 83498
* Refactor the code that walks a C++ inheritance hierarchy, searchingDouglas Gregor2009-10-061-6/+37
| | | | | | | | | for bases, members, overridden virtual methods, etc. The operations isDerivedFrom and lookupInBases are now provided by CXXRecordDecl, rather than by Sema, so that CodeGen and other clients can use them directly. llvm-svn: 83396
* When the return type of a function is dependent, don't perform anyDouglas Gregor2009-10-011-1/+5
| | | | | | | | | | | | of the flow-control checks for falling off the end of a function, since the return type may instantiate to void. Similarly, if a return statement has an expression and the return type of the function is void, don't complain if the expression is type-dependent, since that type could instantiate to void. Fixes PR5071. llvm-svn: 83222
* Add an error for function parameters that have a qualified address space ↵Tanya Lattner2009-09-301-1/+12
| | | | | | since this is not allowed by the embedded c extension spec. llvm-svn: 83165
* Provide a custom diagnostic when code tries to use an unknown builtinDouglas Gregor2009-09-281-5/+6
| | | | llvm-svn: 83014
* Make sure that out-of-line function and variable definitions are notDouglas Gregor2009-09-281-2/+10
| | | | | | pushed into scope. Fixes PR5056. llvm-svn: 83003
* Teach Sema::isDeclInScope to handle overload sets constructed fromDouglas Gregor2009-09-281-4/+41
| | | | | | | | | | | | | | | | | functions that occur in multiple declaration contexts, e.g., because some were found via using declarations. Now, isDeclInScope will build a new overload set (when needed) containing only those declarations that are actually in scope. This eliminates a problem found with libstdc++'s <iostream>, where the presence of using In the longer term, I'd like to eliminate Sema::isDeclInScope in favor of better handling of the RedeclarationOnly flag in the name-lookup routines. That way, name lookup only returns the entities that matter, rather than taking the current two-pass approach of producing too many results and then filtering our the wrong results. It's not efficient, and I'm sure that we aren't filtering everywhere we should be. llvm-svn: 82954
* Rework the Parse-Sema interaction for friends to better support friendDouglas Gregor2009-09-261-6/+55
| | | | | | | | | class templates. We now treat friend class templates much more like normal class templates, except that they still get special name lookup rules. Fixes PR5057 and eliminates a bunch of spurious diagnostics in <iostream>. llvm-svn: 82848
* Use explicitly-specified template argument lists to help namingDouglas Gregor2009-09-251-8/+42
| | | | | | explicit template specializations, when available. llvm-svn: 82824
* Declarators can now properly represent template-ids, e.g., forDouglas Gregor2009-09-251-0/+11
| | | | | | | | | | | template void f<int>(int); ~~~~~~ Previously, we silently dropped the template arguments. With this change, we now use the template arguments (when available) as the explicitly-specified template arguments used to aid template argument deduction for explicit template instantiations. llvm-svn: 82806
* WIP implementation of explicit function template specialization. ThisDouglas Gregor2009-09-241-5/+21
| | | | | | | | | | | | | | | | | | | | | first implementation recognizes when a function declaration is an explicit function template specialization (based on the presence of a template<> header), performs template argument deduction + ambiguity resolution to determine which template is being specialized, and hooks There are many caveats here: - We completely and totally drop any explicitly-specified template arguments on the floor - We don't diagnose any of the extra semantic things that we should diagnose. - I haven't looked to see that we're getting the right linkage for explicit specializations On a happy note, this silences a bunch of errors that show up in libstdc++'s <iostream>, although Clang still can't get through the entire header. llvm-svn: 82728
* Refactor the representation of qualifiers to bring ExtQualType out of theJohn McCall2009-09-241-4/+6
| | | | | | | | Type hierarchy. Demote 'volatile' to extended-qualifier status. Audit our use of qualifiers and fix a few places that weren't dealing with qualifiers quite right; many more remain. llvm-svn: 82705
* Change all the Type::getAsFoo() methods to specializations of Type::getAs().John McCall2009-09-211-13/+13
| | | | | | | | | | | Several of the existing methods were identical to their respective specializations, and so have been removed entirely. Several more 'leaf' optimizations were introduced. The getAsFoo() methods which imposed extra conditions, like getAsObjCInterfacePointerType(), have been left in place. llvm-svn: 82501
* Merge uninstantiated default arguments more carefully, and try not toDouglas Gregor2009-09-171-1/+3
| | | | | | | complain about specializations of member functions that are not definitions. Fixes PR4995. llvm-svn: 82159
* Improved representation and support for friend class templates. Angst about ↵John McCall2009-09-161-1/+5
| | | | | | same. llvm-svn: 82088
* When implicitly declaring operators new, new[], delete, and delete[],Douglas Gregor2009-09-151-15/+19
| | | | | | | | | | | | give them the appropriate exception specifications. This, unfortunately, requires us to maintain and/or implicitly generate handles to namespace "std" and the class "std::bad_alloc". However, every other approach I've come up with was more hackish, and this standard requirement itself is quite the hack. Fixes PR4829. llvm-svn: 81939
* Perform the C++ specific semantic checks of a function declaration after ↵Anders Carlsson2009-09-131-41/+41
| | | | | | it's been merged with the previous declaration. This ensures that getPreviousDecl() will have the right value when ActOnConversionDeclarator is called. llvm-svn: 81720
* Rework the way we determine whether an externally visible symbol isDouglas Gregor2009-09-131-35/+2
| | | | | | | | generated for an inline function definition, taking into account C99 and GNU inline/extern inline semantics. This solution is simpler, cleaner, and fixes PR4536. llvm-svn: 81670
* Remove unnecessary ASTContext parameter from FunctionDecl::isBuiltinIDDouglas Gregor2009-09-121-3/+3
| | | | llvm-svn: 81590
* Remove unnecessary ASTContext parameters from isMain and isExternCDouglas Gregor2009-09-121-8/+9
| | | | llvm-svn: 81589
* Support elaborated dependent types and diagnose tag mismatches.John McCall2009-09-111-1/+11
| | | | llvm-svn: 81504
* Don't bother to perform any initialization for a variable declarationDouglas Gregor2009-09-091-4/+12
| | | | | | | of class type whose default constructor is trivial. Should un-break testing on x86_64-pc-linux-gnu. llvm-svn: 81405
* Improve handling of initialization by constructor, by ensuring thatDouglas Gregor2009-09-091-18/+15
| | | | | | | | such initializations properly convert constructor arguments and fill in default arguments where necessary. This also makes the ownership model more clear. llvm-svn: 81394
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-361/+361
| | | | llvm-svn: 81346
* Fix a thinkoDouglas Gregor2009-09-091-2/+8
| | | | llvm-svn: 81317
* Allow a declaration of an array to complete a prior, incompleteDouglas Gregor2009-09-091-0/+7
| | | | | | declaration of that array in C++. llvm-svn: 81309
* Fix PR4922, where Sema would complete tentative definitions in nondeterminsticChris Lattner2009-09-081-7/+16
| | | | | | | | | | order because it was doing so while iterating over a densemap. There are still similar problems in other places, for example WeakUndeclaredIdentifiers is still written to the PCH file in a nondeterminstic order, and we emit warnings about #pragma weak in nondeterminstic order. llvm-svn: 81236
* BuildCXXConstructExpr now takes a MultiExprArg.Anders Carlsson2009-09-071-1/+2
| | | | llvm-svn: 81160
* Start emitting ElaboratedTypes in C++ mode. Support the effort in variousJohn McCall2009-09-051-1/+1
| | | | | | | | ways: remove elab types during desugaring, enhance pretty-printing to allow tags to be suppressed without suppressing scopes, look through elab types when associating a typedef name with an anonymous record type. llvm-svn: 81065
* Correctly handle elaborated template ids. Still not handled properly for ↵John McCall2009-09-041-8/+1
| | | | | | friends. llvm-svn: 80977
* Patch to instantiate destructors used to destructFariborz Jahanian2009-09-031-1/+1
| | | | | | base and data members when they are needed. llvm-svn: 80967
* Borrow a friend class's previous declaration's access specifier regardless ofJohn McCall2009-09-021-5/+5
| | | | | | | | whether the current context is dependent. Thanks to Anders for pointing this out. llvm-svn: 80828
* When adding a friend class declaration to the lookup tables, use the access ↵John McCall2009-09-021-0/+5
| | | | | | | | | | specifier of any previous declaration in case we replace it in a class's declaration table. Fixes bug 4858. This sort of thing makes me reconsider putting friend declarations in declaration lists. llvm-svn: 80750
* Ensure that the tag decls of friend decls aren't added to the friending class'sJohn McCall2009-09-021-1/+9
| | | | | | | decl list, and remove some workarounds that were due to this. Thanks to Eli for pointing this out and providing the test case. llvm-svn: 80745
* Fix bug 4784 and allow friend declarations to properly extendJohn McCall2009-08-311-2/+3
| | | | | | existing declaration chains. llvm-svn: 80636
* Improve diagnostics for missing members. This renames the ↵Anders Carlsson2009-08-301-2/+4
| | | | | | err_typecheck_no_member to err_typecheck_no_member_deprecated. The idea is that err_typecheck_no_member_deprecated should be phased out and any call sites that reference it should call DiagnoseMissingMember instead. llvm-svn: 80469
OpenPOWER on IntegriCloud