summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Partial fix for PR6022, where we were complaining when a friendDouglas Gregor2010-01-161-1/+2
| | | | | | | | function template declared within a class template did not match a function in another scope. We really need to rework how friends-in-templates are semantically checked. llvm-svn: 93642
* Generalize handling for unreachable code warnings to all binary operators.Mike Stump2010-01-151-16/+13
| | | | llvm-svn: 93584
* Refine location reporting for unreachable code warnings for comma expressions.Mike Stump2010-01-151-12/+45
| | | | llvm-svn: 93574
* Refine unreachable warnings. WIP.Mike Stump2010-01-151-4/+87
| | | | llvm-svn: 93500
* When performing qualified name lookup into the current instantiation,Douglas Gregor2010-01-151-1/+2
| | | | | | | | | | | | | do not look into base classes if there are any dependent base classes. Instead, note in the lookup result that we couldn't look into any dependent bases. Use that new result kind to detect when this case occurs, so that we can fall back to treating the type/value/etc. as a member of an unknown specialization. Fixes an issue where we were resolving lookup at template definition time and then missing an ambiguity at template instantiation time. llvm-svn: 93497
* fix grammaroChris Lattner2010-01-141-1/+1
| | | | llvm-svn: 93452
* When qualified lookup into the current instantiation fails (because itDouglas Gregor2010-01-141-1/+11
| | | | | | | | finds nothing), and the current instantiation has dependent base classes, treat the qualified lookup as if it referred to an unknown specialization. Fixes PR6031. llvm-svn: 93433
* Don't assume a random access iterator, instead just use CFG::iterator.Mike Stump2010-01-141-3/+3
| | | | | | Thanks Ted. llvm-svn: 93413
* Avoid snowballing errors into additional warnings. To do better, we'dMike Stump2010-01-141-2/+4
| | | | | | | | need an error term for the CFG. I suspect we'll always have to cope with getCFG returning 0, though, I'd love to see even that possibility removed. llvm-svn: 93411
* Reimplement constructor declarator parsing to cope with template-idsDouglas Gregor2010-01-131-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that name constructors, the endless joys of out-of-line constructor definitions, and various other corner cases that the previous hack never imagined. Fixes PR5688 and tightens up semantic analysis for constructor names. Additionally, fixed a problem where we wouldn't properly enter the declarator scope of a parenthesized declarator. We were entering the scope, then leaving it when we saw the ")"; now, we re-enter the declarator scope before parsing the parameter list. Note that we are forced to perform some tentative parsing within a class (call it C) to tell the difference between C(int); // constructor and C (f)(int); // member function which is rather unfortunate. And, although it isn't necessary for correctness, we use the same tentative-parsing mechanism for out-of-line constructors to improve diagnostics in icky cases like: C::C C::f(int); // error: C::C refers to the constructor name, but // we complain nicely and recover by treating it as // a type. llvm-svn: 93322
* Implement semantic checking for C++ literal operators.Alexis Hunt2010-01-131-1/+6
| | | | | | | This now rejects literal operators that don't meet the requirements. Templates are not yet checked for. llvm-svn: 93315
* Add an unreachable code checker.Mike Stump2010-01-131-28/+62
| | | | llvm-svn: 93287
* C++0x [dcl.typedef]p4, take 3, where we actually figure out what "thatDouglas Gregor2010-01-111-1/+1
| | | | | | | is not also a typedef-name" actually means. For anyone keeping score, that's John: 2, Doug: 0. llvm-svn: 93196
* Use isa<ElaboratedType> rather than getAs<ElaboratedType>, since theDouglas Gregor2010-01-111-1/+1
| | | | | | | latter may (eventually) perform multiple levels of desugaring (thus breaking the newly-added tests) and the former is faster. Thanks, John! llvm-svn: 93192
* Allow redefinitions of typedef-names within class scope when the typeDouglas Gregor2010-01-111-4/+29
| | | | | | | | | they redefine is a class-name but not a typedef-name, per C++0x [dcl.typedef]p4. The code in the test was valid C++98 and is valid C++0x, but an unintended consequence of DR56 made it ill-formed in C++03 (which we were luck enough to implement). Fixes PR5455. llvm-svn: 93188
* Whenever we emit a typo-correction diagnostic, also emit a noteDouglas Gregor2010-01-071-0/+6
| | | | | | | pointing to the declaration that we found that has that name (if it is unique). llvm-svn: 92877
* Make sure that the key-function computation produces the correctDouglas Gregor2010-01-061-10/+27
| | | | | | | | result for a nested class whose first non-pure virtual member function has an inline body. Previously, we were checking for the key function before we had seen the (delayed) inline body. llvm-svn: 92839
* Make our marking of virtual members functions in a class beDouglas Gregor2010-01-061-0/+10
| | | | | | | | | | | | | | | | | | | | | deterministic and work properly with templates. Once a class that needs a vtable has been defined, we now do one if two things: - If the class has no key function, we place the class on a list of classes whose virtual functions will need to be "marked" at the end of the translation unit. The delay until the end of the translation unit is needed because we might see template specializations of these virtual functions. - If the class has a key function, we do nothing; when the key function is defined, the class will be placed on the aforementioned list. At the end of the translation unit, we "mark" all of the virtual functions of the classes on the list as used, possibly causing template instantiation and other classes to be added to the list. This gets LLVM's lib/Support/CommandLine.cpp compiling again. llvm-svn: 92821
* Improve key-function computation for templates. In particular:Douglas Gregor2010-01-051-1/+1
| | | | | | | | | | | | | | | | - All classes can have a key function; templates don't change that. non-template classes when computing the key function. - We always mark all of the virtual member functions of class template instantiations. - The vtable for an instantiation of a class template has weak linkage. We could probably use available_externally linkage for vtables of classes instantiated by explicit instantiation declarations (extern templates), but GCC doesn't do this and I'm not 100% that the ABI permits it. llvm-svn: 92753
* Avoid warnings for functions that return a value using MS-style inlineMike Stump2010-01-041-0/+8
| | | | | | | | | | | | | assembly code. This avoids changing the bahvior when normal asm("") statements are used. The type of code affected would be: void* t4(void) { __asm mov eax, fs:[0x10] } I hope people like this version, if not, let me know. llvm-svn: 92531
* Implement typo correction for a variety of Objective-C-specificDouglas Gregor2010-01-031-1/+25
| | | | | | | | | | | | | | constructs: - Instance variable lookup ("foo->ivar" and, in instance methods, "ivar") - Property name lookup ("foo.prop") - Superclasses - Various places where a class name is required - Protocol names (e.g., id<proto>) This seems to cover many of the common places where typos could occur. llvm-svn: 92449
* when making a decl for __builtin_fabsf() make sure toChris Lattner2009-12-301-0/+4
| | | | | | | | attach the appropriate attributes to it. I don't think this manifests as any real change though, we're still not getting the right LLVM IR attributes out of codegen. llvm-svn: 92316
* Typo correction for type names when they appear in declarations, e.g., givenDouglas Gregor2009-12-301-1/+32
| | | | | | | | | | | | | | | | | | | | | | | | tring str2; we produce the following diagnostic + fix-it: typo.cpp:15:1: error: unknown type name 'tring'; did you mean 'string'? tring str2; ^~~~~ string To make this really useful, we'll need to introduce typo correction in many more places (wherever we do name lookup), and implement declaration-vs-expression heuristics that cope with typos better. However, for now this will handle the simple cases where we already get good "unknown type name" diagnostics. The LookupVisibleDecls functions are intended to be used by code completion as well as typo correction; that refactoring will happen later. llvm-svn: 92308
* Typedefs can be redeclared. That seems like something we should record inJohn McCall2009-12-301-3/+9
| | | | | | the AST lest we run into some crazy canonicalization bug like PR5874. llvm-svn: 92283
* Tweak the text of several main() diagnostics and punch a hole specifically forJohn McCall2009-12-241-2/+12
| | | | | | | | | | Darwin's sekrit fourth argument. This should probably be factored to let targets make target-specific decisions about what main() should look like. Fixes rdar://problem/7414990 or if different platforms have radically different ideas of what they want in llvm-svn: 92128
* allow the noreturn attribute to be used in class methodsNuno Lopes2009-12-231-1/+3
| | | | llvm-svn: 92090
* Switch file-scope assignment initialization over to InitializationSequence.Eli Friedman2009-12-221-13/+16
| | | | llvm-svn: 91881
* Eliminate the ASTContext argument to CXXConstructorDecl::isCopyConstructor, ↵Douglas Gregor2009-12-221-1/+1
| | | | | | since the context is available in the Decl llvm-svn: 91862
* Fix for PR5840: fix the kind of name lookup used for classes inEli Friedman2009-12-211-2/+6
| | | | | | | | | | Sema::getTypeName. "LookupNestedNameSpecifierName" isn't quite the right kind of lookup, though; it doesn't ignore namespaces. Someone more familiar with the lookup code should fix this properly. llvm-svn: 91809
* Make sure we instantiate the destructor for variables initialized byEli Friedman2009-12-201-0/+9
| | | | | | assignment. llvm-svn: 91798
* Switch default-initialization of variables of class type (or array thereof) ↵Douglas Gregor2009-12-201-20/+11
| | | | | | over to InitializationSequence. I could swear that this fixes a PR somewhere, but I couldn't figure out which one llvm-svn: 91796
* Revert accidental commitDouglas Gregor2009-12-201-11/+20
| | | | llvm-svn: 91795
* Fix CMake build on windows, from Cedric VenetDouglas Gregor2009-12-201-20/+11
| | | | llvm-svn: 91794
* Don't inject the class name until that magical lbrace.John McCall2009-12-201-24/+29
| | | | | | | | | | | | | | | | Because of the rules of base-class lookup* and the restrictions on typedefs, it was actually impossible for this to cause any problems more serious than the spurious acceptance of template <class T> class A : B<A> { ... }; instead of template <class T> class A : B<A<T> > { ... }; but I'm sure we can all agree that that is a very important restriction which is well worth making another Parser->Sema call for. (*) n.b. clang++ does not implement these rules correctly; we are not ignoring non-type names llvm-svn: 91792
* Refactor to remove more dependencies on PreDeclaratorDC. I seem to have madeJohn McCall2009-12-191-11/+35
| | | | | | | the redeclaration problems in the [temp.explicit]p3 testcase worse, but I can live with that; they'll need to be fixed more holistically anyhow. llvm-svn: 91771
* Don't use EnterDeclaratorContext when rebuilding a type in the currentJohn McCall2009-12-191-2/+5
| | | | | | instantiation, since we're not using a Scope object for that anyway. llvm-svn: 91770
* Initialization improvements: addition of string initialization and a fewEli Friedman2009-12-191-17/+13
| | | | | | | | small bug fixes in SemaInit, switch over SemaDecl to use it more often, and change a bunch of diagnostics which are different with the new initialization code. llvm-svn: 91767
* Pull Sema::isAcceptableLookupResult into SemaLookup. Extract the criteria intoJohn McCall2009-12-181-18/+16
| | | | | | | | | | | | | | | different functions and pick the function at lookup initialization time. In theory we could actually divide the criteria functions into N different functions for the N cases, but it's so not worth it. Among other things, lets us invoke LookupQualifiedName without recomputing IDNS info every time. Do some refactoring in SemaDecl to avoid an awkward special case in LQN that was only necessary for redeclaration testing for anonymous structs/unions --- which could be done more efficiently with a scoped lookup anyway. llvm-svn: 91676
* Revert r91073.Mike Stump2009-12-171-5/+0
| | | | llvm-svn: 91629
* implement PR3962: diagnose more faulty cases of usage of the restrict ↵Nuno Lopes2009-12-171-1/+9
| | | | | | qualifier. this also removes a FIXME llvm-svn: 91601
* revert part of my last patch, and mark only the c++ global new operator as ↵Nuno Lopes2009-12-171-5/+0
| | | | | | noalias. the rest will be infered by llvm optz llvm-svn: 91600
* Make sure C-specific enum warning doesn't trigger in C++.Eli Friedman2009-12-161-1/+1
| | | | llvm-svn: 91563
* implement PR5654: add -fassume-sane-operator-new, which is enabled by ↵Nuno Lopes2009-12-161-0/+5
| | | | | | | | default, and adds the malloc attribute to the global function new() and to the overloaded new operators. feel free to chage the name to this lengthy argument llvm-svn: 91543
* Switch the C++ new expression over to InitializationSequence, ratherDouglas Gregor2009-12-161-14/+14
| | | | | | | | | | | | | | | | | | | | | than using its own partial implementation of initialization. Switched CheckInitializerTypes over to InitializedEntity/InitializationKind, to help move us closer to InitializationSequence. Added InitializedEntity::getName() to retrieve the name of the entity, for diagnostics that care about such things. Implemented support for default initialization in InitializationSequence. Clean up the determination of the "source expressions" for an initialization sequence in InitializationSequence::Perform. Taught CXXConstructExpr to store more location information. llvm-svn: 91492
* ShouldDestroyTemporaries? I don't think so.Anders Carlsson2009-12-151-2/+1
| | | | llvm-svn: 91450
* This patch should fix PR2461. It allows clang to apply the noreturnMike Stump2009-12-151-5/+4
| | | | | | | | | attribute to function pointers. It also fixes Sema to check function pointers for the noreturn attribute when checking for fallthrough. Patch by Chip Davis, with a slight fix to pass the testsuite. llvm-svn: 91408
* Fix the handling of dependent enums per C++ DR 502.Eli Friedman2009-12-111-4/+18
| | | | llvm-svn: 91089
* Don't complain about falling off the end of a function with an asmMike Stump2009-12-101-0/+5
| | | | | | | block, if the function is supposed to return a value as we don't know exactly what the asm code does. llvm-svn: 91073
* Clean up enum constants so that they're finally sane. Fixes PR3173 and aEli Friedman2009-12-101-14/+4
| | | | | | recently introduced crash. llvm-svn: 91070
* Improve the diagnostic when a new declaration conflicts with a using shadowJohn McCall2009-12-101-0/+9
| | | | | | | | declaration. Rename note_using_decl to note_using, which is possibly less confusing. Add a test for non-class-scope using decl collisions and be sure to note the case we can't diagnose yet. llvm-svn: 91057
OpenPOWER on IntegriCloud