summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fold -Wreturn-stack-address into general initialization lifetimeRichard Smith2018-07-231-2/+2
| | | | | | checking. llvm-svn: 337743
* Restructure checking for, and warning on, lifetime extension.Richard Smith2018-07-171-4/+5
| | | | | | | | | | | | | This change implements C++ DR1696, which makes initialization of a reference member of a class from a temporary object ill-formed. The standard wording here is imprecise, but we interpret it as meaning that any time a mem-initializer would result in lifetime extension, the program is ill-formed. This reinstates r337226, reverted in r337255, with a fix for the InitializedEntity alignment problem that was breaking ARM buildbots. llvm-svn: 337329
* Temporarily revert r337226 "Restructure checking for, and warning on, ↵Florian Hahn2018-07-171-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | lifetime extension." This change breaks on ARM because pointers to clang::InitializedEntity are only 4 byte aligned and do not have 3 bits to store values. A possible solution would be to change the fields in clang::InitializedEntity to enforce a bigger alignment requirement. The error message is llvm/include/llvm/ADT/PointerIntPair.h:132:3: error: static_assert failed "PointerIntPair with integer size too large for pointer" static_assert(IntBits <= PtrTraits::NumLowBitsAvailable, include/llvm/ADT/PointerIntPair.h:73:13: note: in instantiation of template class 'llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> >' requested here Value = Info::updateInt(Info::updatePointer(0, PtrVal), llvm/include/llvm/ADT/PointerIntPair.h:51:5: note: in instantiation of member function 'llvm::PointerIntPair<const clang::InitializedEntity *, 3, (anonymous namespace)::LifetimeKind, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *>, llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> > >::setPointerAndInt' requested here setPointerAndInt(PtrVal, IntVal); ^ llvm/tools/clang/lib/Sema/SemaInit.cpp:6237:12: note: in instantiation of member function 'llvm::PointerIntPair<const clang::InitializedEntity *, 3, (anonymous namespace)::LifetimeKind, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *>, llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> > >::PointerIntPair' requested here return {Entity, LK_Extended}; Full log here: http://lab.llvm.org:8011/builders/clang-cmake-armv7-global-isel/builds/1330 http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/1394 llvm-svn: 337255
* Restructure checking for, and warning on, lifetime extension.Richard Smith2018-07-171-4/+5
| | | | | | | | | | This change implements C++ DR1696, which makes initialization of a reference member of a class from a temporary object ill-formed. The standard wording here is imprecise, but we interpret it as meaning that any time a mem-initializer would result in lifetime extension, the program is ill-formed. llvm-svn: 337226
* P0620 follow-up: deducing `auto` from braced-init-list in new exprZhihao Yuan2017-12-111-1/+1
| | | | | | | | | | | | | | | | | | | Summary: This is a side-effect brought in by p0620r0, which allows other placeholder types (derived from `auto` and `decltype(auto)`) to be usable in a `new` expression with a single-clause //braced-init-list// as its initializer (8.3.4 [expr.new]/2). N3922 defined its semantics. References: http://wg21.link/p0620r0 http://wg21.link/n3922 Reviewers: rsmith, aaron.ballman Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39451 llvm-svn: 320401
* Give a better error if auto deduction fails due to inconsistent element ↵Richard Smith2017-08-301-1/+7
| | | | | | types in a braced initializer list. llvm-svn: 312085
* Fix bug where types other than 'cv auto', 'cv auto &', and 'cv auto &&' couldRichard Smith2017-01-051-0/+10
| | | | | | incorrectly be deduced from an initializer list in pathological cases. llvm-svn: 291191
* Add missing "original call argument has same type as deduced parameter type"Richard Smith2017-01-051-3/+13
| | | | | | check for deductions from elements of a braced-init-list. llvm-svn: 291190
* Fix failure to treat overloaded function in braced-init-list as a ↵Richard Smith2017-01-041-3/+7
| | | | | | | | | | | | | non-deduced context. Previously, if an overloaded function in a braced-init-list was encountered in template argument deduction, and the overload set couldn't be resolved to a particular function, we'd immediately produce a deduction failure. That's not correct; this situation is supposed to result in that particular P/A pair being treated as a non-deduced context, and deduction can still succeed if the type can be deduced from elsewhere. llvm-svn: 291014
* Revert accidentally-committed file.Richard Smith2017-01-041-2/+2
| | | | llvm-svn: 290997
* Factor out duplicated code and simplify.Richard Smith2017-01-041-2/+2
| | | | | | No functionality change intended. llvm-svn: 290996
* Fix deduction of pack elements after a braced-init-list.Richard Smith2017-01-041-0/+14
| | | | | | | | | | Previously, if the arguments for a parameter pack contained a braced-init-list, we would abort deduction (keeping the pack deductions from prior arguments) at the point when we reached the braced-init-list, resulting in wrong deductions and rejects-valids. We now just leave a "hole" in the pack for such an argument, which needs to be filled by another deduction of the same pack. llvm-svn: 290933
* Fix crash on invalid initialization with std::initializer_listReid Kleckner2015-12-091-0/+25
| | | | | | | It is possible for CheckListElementTypes to fail without filling in any initializer list elements. llvm-svn: 255176
* N3922: direct-list-initialization of an auto-typed variable no longer deduces aRichard Smith2015-11-111-2/+4
| | | | | | | | | | | | | | | | | | | std::initializer_list<T> type. Instead, the list must contain a single element and the type is deduced from that. In Clang 3.7, we warned by default on all the cases that would change meaning due to this change. In Clang 3.8, we will support only the new rules -- per the request in N3922, this change is applied as a Defect Report against earlier versions of the C++ standard. This change is not entirely trivial, because for lambda init-captures we previously did not track the difference between direct-list-initialization and copy-list-initialization. The difference was not previously observable, because the two forms of initialization always did the same thing (the elements of the initializer list were always copy-initialized regardless of the initialization style used for the init-capture). llvm-svn: 252688
* Consolidate and unify initializer list deductionHubert Tong2015-06-251-0/+7
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch reduces duplication in the template argument deduction code for handling deduction from initializer lists in a function call. This extends the fix for PR12119 to also apply to the case where the corresponding parameter is a trailing parameter pack. Test Plan: A test for deduction from nested initializer lists where the corresponding parameter is a trailing parameter pack is added in `clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp`. Reviewers: fraggamuffin, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D10681 llvm-svn: 240612
* Add a warning for direct-list-initialization of a variable with a deduced typeRichard Smith2015-02-111-0/+1
| | | | | | | | (or of a lambda init-capture, which is sort-of such a variable). The semantics of such constructs will change when we implement N3922, so we intend to warn on this in Clang 3.6 then change the semantics in Clang 3.7. llvm-svn: 228792
* PR22367: Don't forget to create a CXXFunctionalCastExpr aroundRichard Smith2015-01-281-0/+15
| | | | | | | | | list-initialization that gets converted to some form other than an InitListExpr. CXXTemporaryObjectExpr is a special case here, because it represents a fused CXXFunctionalCastExpr + CXXConstructExpr. That, in itself, is probably a design error... llvm-svn: 227377
* Track the difference betweenRichard Smith2014-07-171-0/+5
| | | | | | | | | | | | -- a constructor list initialization that unpacked an initializer list into constructor arguments and -- a list initialization that created as std::initializer_list and passed it as the first argument to a constructor in the AST. Use this flag while instantiating templates to provide the right semantics for the resulting initialization. llvm-svn: 213224
* When list-initializing an object of class type, if we pick an initializer listRichard Smith2014-07-161-0/+16
| | | | | | | | | constructor (and pass it an implicitly-generated std::initializer_list object), be sure to mark the resulting construction as list-initialization. This fixes an assert in template instantiation where we previously thought we'd got direct non-list initialization without any parentheses. llvm-svn: 213201
* Implement DR990 and DR1070. Aggregate initialization initializes uninitializedRichard Smith2014-06-031-0/+8
| | | | | | | | | elements from {}, rather than value-initializing them. This permits calling an initializer-list constructor or constructing a std::initializer_list object. (It would also permit initializing a const reference or rvalue reference if that weren't explicitly prohibited by other rules.) llvm-svn: 210091
* PR18013: Don't assert diagnosing a bad std::initializer_list construction.Richard Smith2013-11-211-0/+5
| | | | llvm-svn: 195384
* When creating an implicit conversion sequence for a reference of type T from anRichard Smith2013-09-061-0/+7
| | | | | | | | initializer list containing a single element of type T, be sure to mark the sequence as a list conversion sequence so that it is known to be worse than an implicit conversion sequence that initializes a std::initializer_list object. llvm-svn: 190115
* PR12086, PR15117Richard Smith2013-06-121-1/+1
| | | | | | | | | | | | | | | | | | | Introduce CXXStdInitializerListExpr node, representing the implicit construction of a std::initializer_list<T> object from its underlying array. The AST representation of such an expression goes from an InitListExpr with a flag set, to a CXXStdInitializerListExpr containing a MaterializeTemporaryExpr containing an InitListExpr (possibly wrapped in a CXXBindTemporaryExpr). This more detailed representation has several advantages, the most important of which is that the new MaterializeTemporaryExpr allows us to directly model lifetime extension of the underlying temporary array. Using that, this patch *drastically* simplifies the IR generation of this construct, provides IR generation support for nested global initializer_list objects, fixes several bugs where the destructors for the underlying array would accidentally not get invoked, and provides constant expression evaluation support for std::initializer_list objects. llvm-svn: 183872
* Fix crash-on-invalid if list-initialization works, but we bail out whenRichard Smith2013-05-231-0/+10
| | | | | | building the resulting expression because it invokes a deleted constructor. llvm-svn: 182624
* Replace "failed template argument deduction" diagnostic with something usefulRichard Smith2013-01-311-0/+9
| | | | | | in the one case where we've already factored out a reason code. llvm-svn: 174036
* Fix overload resolution for the initialization of a multi-dimensionalRichard Smith2012-12-091-0/+8
| | | | | | | | | | array from a braced-init-list. There seems to be a core wording wart here (it suggests we should be testing whether the elements of the init list are implicitly convertible to the array element type, not whether there is an implicit conversion sequence) but our prior behavior appears to be a bug, not a deliberate effort to implement the standard as written. llvm-svn: 169690
* Fix assertion failure with auto and nested initializer list; PR14272.Eli Friedman2012-11-061-0/+4
| | | | llvm-svn: 167506
* When testing whether we can perform copy or move initialization, beDouglas Gregor2012-07-311-0/+12
| | | | | | sure to supply an initialization location. Fixes <rdar://problem/11951661>. llvm-svn: 161084
* Allow a conversion from the empty initializer list {} to anDouglas Gregor2012-04-041-0/+9
| | | | | | | std::initializer_list<T> so long as <T> is known. This conversion has identity rank. llvm-svn: 154065
* When performing template argument deduction for an initializer list,Douglas Gregor2012-04-041-0/+16
| | | | | | | | | | | | | | | | | be sure to perform the argument type adjustments in [temp.deduct.call]p2, e.g., array decay. And, when performing these deductions in the context of 'auto', make sure that we're deducing the P' in std::initializer_list<P'> rather than the whole initializer list. Together, this makes code like for( auto s : {"Deferred", "New", "Open", "Review"}) { } work properly. llvm-svn: 153998
* Support deducing template arguments from nested initializer lists. PR12119.Sebastian Redl2012-03-151-0/+13
| | | | llvm-svn: 152848
* Fix parsing and processing initializer lists in return statements and as ↵Sebastian Redl2012-02-221-0/+1
| | | | | | direct member initializers. llvm-svn: 151155
* Emit a warning when list-initializing a std::initializer_list member.Sebastian Redl2012-02-191-0/+9
| | | | llvm-svn: 150933
* Proper initializer list support for new expressions and type construct ↵Sebastian Redl2012-02-121-0/+5
| | | | | | expressions. Array new still missing. llvm-svn: 150346
* Minor fixups for auto deduction of initializer lists.Sebastian Redl2012-01-231-0/+5
| | | | | | | | Fix some review comments. Add a test for deduction when std::initializer_list isn't available yet. Fix redundant error messages. This fixes and outstanding FIXME too. llvm-svn: 148735
* Auto deduction support for std::initializer_list, including for-range ↵Sebastian Redl2012-01-171-0/+8
| | | | | | | | support. This means you can now write: for (int i : {1, 4, 512, 23, 251}) {} llvm-svn: 148353
* Template argument deduction for std::initializer_list arguments from ↵Sebastian Redl2012-01-171-0/+22
| | | | | | initializer lists. llvm-svn: 148352
* Basic overloading support for std::initializer_list.Sebastian Redl2012-01-171-0/+29
| | | | llvm-svn: 148350
* Sema support for initialization of std::initializer_list from initializer lists.Sebastian Redl2012-01-171-0/+60
This does not yet support CodeGen. llvm-svn: 148349
OpenPOWER on IntegriCloud