summaryrefslogtreecommitdiffstats
path: root/test/CXX/special
Commit message (Collapse)AuthorAgeFilesLines
* Merging r155218:Bill Wendling2012-05-122-4/+52
| | | | | | | | | | | | | | | ------------------------------------------------------------------------ r155218 | rsmith | 2012-04-20 11:46:14 -0700 (Fri, 20 Apr 2012) | 5 lines Fix bug where a class's (deleted) copy constructor would be implicitly given a non-const reference parameter type if the class had any subobjects with deleted copy constructors. This causes a rejects-valid if the class's copy constructor is explicitly defaulted (as happens for some implementations of std::pair etc). ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@156682 91177308-0d34-0410-b5e6-96231b3b80d8
* Merging r155728:Bill Wendling2012-04-273-20/+20
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r155728 | rsmith | 2012-04-27 12:33:05 -0700 (Fri, 27 Apr 2012) | 4 lines PR12224 (sort of): Diagnose inheriting constructor declarations in C++11 mode. We do not support IRGen for these, and get some parts of the semantic analysis wrong. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@155731 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve diagnostics for invalid use of non-static members / this:Richard Smith2012-04-052-4/+4
| | | | | | | | | | | | | * s/nonstatic/non-static/ in the diagnostics, since the latter form outvoted the former by 28-2 in our diagnostics. * Fix the "use of member in static member function" diagnostic to correctly detect this situation inside a block or lambda. * Produce a more specific "invalid use of non-static member" diagnostic for the case where a nested class member refers to a member of a lexically-surrounding class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154073 91177308-0d34-0410-b5e6-96231b3b80d8
* PR10217 diagnostic fix: don't say 'copy constructor' when we meanRichard Smith2012-04-021-1/+1
| | | | | | | 'copy assignment operator'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153897 91177308-0d34-0410-b5e6-96231b3b80d8
* Finish PR10217: Ensure we say that a special member was implicitly, notRichard Smith2012-04-023-12/+10
| | | | | | | explicitly, deleted in all relevant cases, and explain why. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153894 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement DR1402: if a field or base class is not movable, the derived class'sRichard Smith2012-04-022-1/+100
| | | | | | | | | | | | move constructor/move assignment operator are not declared, rather than being defined as deleted, so move operations on the derived class fall back to copying rather than moving. If a move operation on the derived class is explicitly defaulted, the unmovable subobject will be copied instead of being moved. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153883 91177308-0d34-0410-b5e6-96231b3b80d8
* Basic semantic analysis support for inheriting constructor declarations inRichard Smith2012-04-023-1/+56
| | | | | | | dependent contexts. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153858 91177308-0d34-0410-b5e6-96231b3b80d8
* PR10217: Provide diagnostics explaining why an implicitly-deleted specialRichard Smith2012-03-305-75/+85
| | | | | | | member function is deleted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153773 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a pile of tests for unrestricted unions, and advertise support for them.Richard Smith2012-03-032-0/+83
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151992 91177308-0d34-0410-b5e6-96231b3b80d8
* Ensure that we delete default constructors in the right cases. Don't delete theRichard Smith2012-02-271-11/+16
| | | | | | | | default constructor of a union if it has a const member with no user-provided default constructor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151516 91177308-0d34-0410-b5e6-96231b3b80d8
* Ensure that we delete destructors in the right cases. Specifically:Richard Smith2012-02-261-0/+103
| | | | | | | | | | | | | | | - variant members with nontrivial destructors make the containing class's destructor deleted - check for a virtual destructor after checking for overridden methods in the base class(es) - check for an inaccessible operator delete for a class with a virtual destructor. Do not try to call an anonymous union field's destructor from the destructor of the containing class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151483 91177308-0d34-0410-b5e6-96231b3b80d8
* Special members which are defaulted or deleted on their first declaration areRichard Smith2012-02-261-5/+2
| | | | | | | | | | | | | | trivial if the implicit declaration would be. Don't forget to set the Trivial flag on the special member as well as on the class. It doesn't seem ideal that we have two separate mechanisms for storing this information, but this patch does not attempt to address that. This leaves us in an interesting position where the has_trivial_X trait for a class says 'yes' for a deleted but trivial X, but is_trivially_Xable says 'no'. This seems to be what the standard requires. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151465 91177308-0d34-0410-b5e6-96231b3b80d8
* When overload resolution picks an implicitly-deleted special memberDouglas Gregor2012-02-153-39/+42
| | | | | | | | | | | function, provide a specialized diagnostic that indicates the kind of special member function (default constructor, copy assignment operator, etc.) and that it was implicitly deleted. Add a hook where we can provide more detailed information later. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150611 91177308-0d34-0410-b5e6-96231b3b80d8
* Update constexpr implementation to match CWG's chosen approach for core issuesRichard Smith2012-02-131-3/+3
| | | | | | | | | | | | | | | | | | | | | 1358, 1360, 1452 and 1453. - Instantiations of constexpr functions are always constexpr. This removes the need for separate declaration/definition checking, which is now gone. - This makes it possible for a constexpr function to be virtual, if they are only dependently virtual. Virtual calls to such functions are not constant expressions. - Likewise, it's now possible for a literal type to have virtual base classes. A constexpr constructor for such a type cannot actually produce a constant expression, though, so add a special-case diagnostic for a constructor call to such a type rather than trying to evaluate it. - Classes with trivial default constructors (for which value initialization can produce a fully-initialized value) are considered literal types. - Classes with volatile members are not literal types. - constexpr constructors can be members of non-literal types. We do not yet use static initialization for global objects constructed in this way. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150359 91177308-0d34-0410-b5e6-96231b3b80d8
* constexpr: fix typo resulting in move constructors sometimes not beingRichard Smith2012-01-111-0/+5
| | | | | | | implicitly marked constexpr when they should be. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147955 91177308-0d34-0410-b5e6-96231b3b80d8
* Unrevert r147271, reverted in r147361.Richard Smith2011-12-301-2/+10
| | | | | | | | | | | | | Also temporarily remove the assumption from IR gen that we can emit IR for every constant we can fold, since it isn't currently true in C++11, to fix PR11676. Original comment from r147271: constexpr: perform zero-initialization prior to / instead of performing a constructor call when appropriate. Thanks to Eli for spotting this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147384 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r147271. This fixes PR11676.Rafael Espindola2011-12-301-10/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147362 91177308-0d34-0410-b5e6-96231b3b80d8
* constexpr: perform zero-initialization prior to / instead of performing aRichard Smith2011-12-251-2/+10
| | | | | | | constructor call when appropriate. Thanks to Eli for spotting this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147271 91177308-0d34-0410-b5e6-96231b3b80d8
* PR11614: Mark defaulted special constructors as constexpr if their implicitRichard Smith2011-12-222-0/+104
| | | | | | | definition would satisfy the constexpr requirements. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147128 91177308-0d34-0410-b5e6-96231b3b80d8
* Support decltype in pseudo destructors and dependent destructor calls.David Blaikie2011-12-161-5/+18
| | | | | | Reviewed by Eli Friedman. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146738 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix/test decltype dtor calls with invalid base expression.David Blaikie2011-12-121-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146354 91177308-0d34-0410-b5e6-96231b3b80d8
* Decltype in non-pseudo (& non-dependent) dtor calls.David Blaikie2011-12-081-0/+25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146155 91177308-0d34-0410-b5e6-96231b3b80d8
* When synthesizing an implicitly-defined copy or move constructor, orDouglas Gregor2011-11-282-0/+65
| | | | | | | | | when computing the exception specification of a copy or move constructor, ignore non-static data member initializers. Fixes PR11418 / <rdar://problem/10478642>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145269 91177308-0d34-0410-b5e6-96231b3b80d8
* Include named unions in union member init checkingDavid Blaikie2011-11-171-5/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144883 91177308-0d34-0410-b5e6-96231b3b80d8
* Compute whether a class is trivial correctly for template classes with an ↵Eli Friedman2011-11-151-2/+9
| | | | | | explicitly deleted or defaulted special member. PR11387. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144715 91177308-0d34-0410-b5e6-96231b3b80d8
* When we notice that a member function is defined with "= delete" or "=Douglas Gregor2011-11-072-12/+5
| | | | | | | | | | | | | default", make a note of which is used when creating the initial declaration. Previously, we would wait until later to handle default/delete as a definition, but this is too late: when adding the declaration, we already treated the declaration as "user-provided" when in fact it was merely "user-declared". Fixes PR10861 and PR10442, along with a bunch of FIXMEs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144011 91177308-0d34-0410-b5e6-96231b3b80d8
* Make test work with ARM C++ ABI.Eli Friedman2011-11-011-9/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143425 91177308-0d34-0410-b5e6-96231b3b80d8
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-1316-17/+17
| | | | | | | -std=c++0x. Patch by Ahmed Charles! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141900 91177308-0d34-0410-b5e6-96231b3b80d8
* Get rid of ShouldDeleteMoveConstructor.Sean Hunt2011-10-111-0/+85
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141650 91177308-0d34-0410-b5e6-96231b3b80d8
* Consolidate copy constructor deletion into ShouldDeleteSpecialMember.Sean Hunt2011-10-111-0/+90
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141645 91177308-0d34-0410-b5e6-96231b3b80d8
* Begin work consolidating ShouldDelete* functions.Sean Hunt2011-10-101-4/+0
| | | | | | | | | | | Begin with just default constructors. One note is that as a side effect of this, a conformance test was removed on the basis that this is almost certainly a defect as with most of union initialization. As it is, clang does not implement union initialization close to the standard as it's quite broken as written. I hope to write a paper addressing the issues eventually. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141528 91177308-0d34-0410-b5e6-96231b3b80d8
* In constructors, don't generate implicit initializers for members of ↵Richard Smith2011-09-191-0/+8
| | | | | | anonymous structs contained within anonymous unions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140015 91177308-0d34-0410-b5e6-96231b3b80d8
* PR10954: variant members should not be implicitly initialized in ↵Richard Smith2011-09-181-1/+29
| | | | | | | | | constructors if no mem-initializer is specified for them, unless an in-class initializer is specified. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139996 91177308-0d34-0410-b5e6-96231b3b80d8
* When performing a derived-to-base cast on the right-hand side of theDouglas Gregor2011-09-061-2/+22
| | | | | | | | | | | | | | | | | | synthesized move assignment within an implicitly-defined move assignment operator, be sure to treat the derived-to-base cast as an xvalue (rather than an lvalue). Otherwise, we'll end up getting the wrong constructor. Optimize a direct call to a trivial move assignment operator to an aggregate copy, as we do for trivial copy assignment operators, and update the the assertion in CodeGenFunction::EmitAggregateCopy() to cope with this optimization. Fixes PR10860. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139143 91177308-0d34-0410-b5e6-96231b3b80d8
* When defining the implicit move assignment operator, don't performDouglas Gregor2011-09-011-17/+29
| | | | | | | | | semantic analysis when taking the address of an xvalue. Instead, just build the unary operator directly, since it's safe to do so (from the IRgen and AST perspectives) for any glvalue. Fixes PR10822. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138935 91177308-0d34-0410-b5e6-96231b3b80d8
* Declare and define implicit move constructor and assignment operator.Sebastian Redl2011-08-303-2/+250
| | | | | | | | | This makes the code duplication of implicit special member handling even worse, but the cleanup will have to come later. For now, this works. Follow-up with tests for explicit defaulting and enabling the __has_feature flag to come. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138821 91177308-0d34-0410-b5e6-96231b3b80d8
* Disable the l-value to r-value conversion on C++ class types passedJohn McCall2011-08-271-0/+21
| | | | | | | | | | | | | to varargs functions in unevaluated contexts. AFAICT, there is no standards justification for this, but it matches what other compilers do and therefore preserves compatibility with certain template metaprogramming idioms. Should fix self-host. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138715 91177308-0d34-0410-b5e6-96231b3b80d8
* The lvalue-to-rvalue on structs in C++ is actually partJohn McCall2011-08-271-0/+37
| | | | | | | | | of default argument promotion and needs to happen unconditionally. This is particularly semantically important in C++0x. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138691 91177308-0d34-0410-b5e6-96231b3b80d8
* Expand test of C++0x [class.copymove]p15 to make sure we're actually calling ↵Douglas Gregor2011-08-101-0/+7
| | | | | | the copy constructor of a base/member from an explicitly-defaulted copy constructor, rather than the default constructor git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137220 91177308-0d34-0410-b5e6-96231b3b80d8
* When adding the base and member initializers for an implicitly-definedDouglas Gregor2011-08-101-0/+11
| | | | | | | | | special member function, make sure to classify an explicitly-defaulted copy constructor as a "copy" operation. Fixes PR10622. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137219 91177308-0d34-0410-b5e6-96231b3b80d8
* Properly implement the scope restriction on the NRVO forDouglas Gregor2011-07-061-0/+32
| | | | | | | | | | | | | | | | throw-expressions, such that we don't consider the NRVO when the non-volatile automatic object comes from outside the innermost try scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were incorrect but it didn't matter because IR generation doesn't actually apply the NRVO here. In C++0x, however, we were moving from an object when in fact we should have copied from it. Fixes PR10142 / <rdar://problem/9714312>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134548 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-113-0/+232
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132878 91177308-0d34-0410-b5e6-96231b3b80d8
* Start fixing up clang tests to work on the clang-native-arm-cortex-a9 builder.Eli Friedman2011-06-061-10/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132691 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR9941 for out-of-line template destructors too.Sebastian Redl2011-05-201-0/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131722 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR9941 again, this time for templates.Sebastian Redl2011-05-191-0/+29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131640 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r121528, fixing PR9941 by delaying the exception specification check ↵Sebastian Redl2011-05-191-0/+142
| | | | | | for destructors until the class is complete and destructors have been adjusted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131632 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r121528 as it breaks a simple testcase, which leads to, amongSean Hunt2011-05-181-127/+0
| | | | | | other things, libcxx not building. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131573 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement implicit exception specifications of destructors.Sebastian Redl2011-05-181-0/+127
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131528 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Disable inherited constructors for 2.9."Sebastian Redl2011-03-123-9/+3
| | | | | | It is only meant for the release branch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127542 91177308-0d34-0410-b5e6-96231b3b80d8
* Disable inherited constructors for 2.9.Sebastian Redl2011-03-123-3/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127541 91177308-0d34-0410-b5e6-96231b3b80d8