summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/aggregate-initialization.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Use zeroinitializer for (trailing zero portion of) large array initializersRichard Smith2018-05-231-0/+6
| | | | | | | | more reliably. This re-commits r333044 with a fix for PR37560. llvm-svn: 333141
* Revert r333044 "Use zeroinitializer for (trailing zero portion of) large ↵Hans Wennborg2018-05-231-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | array initializers" It caused asserts, see PR37560. > Use zeroinitializer for (trailing zero portion of) large array initializers > more reliably. > > Clang has two different ways it emits array constants (from InitListExprs and > from APValues), and both had some ability to emit zeroinitializer, but neither > was able to catch all cases where we could use zeroinitializer reliably. In > particular, emitting from an APValue would fail to notice if all the explicit > array elements happened to be zero. In addition, for large arrays where only an > initial portion has an explicit initializer, we would emit the complete > initializer (which could be huge) rather than emitting only the non-zero > portion. With this change, when the element would have a suffix of more than 8 > zero elements, we emit the array constant as a packed struct of its initial > portion followed by a zeroinitializer constant for the trailing zero portion. > > In passing, I found a bug where SemaInit would sometimes walk the entire array > when checking an initializer that only covers the first few elements; that's > fixed here to unblock testing of the rest. > > Differential Revision: https://reviews.llvm.org/D47166 llvm-svn: 333067
* Use zeroinitializer for (trailing zero portion of) large array initializersRichard Smith2018-05-231-0/+6
| | | | | | | | | | | | | | | | | | | | | | | more reliably. Clang has two different ways it emits array constants (from InitListExprs and from APValues), and both had some ability to emit zeroinitializer, but neither was able to catch all cases where we could use zeroinitializer reliably. In particular, emitting from an APValue would fail to notice if all the explicit array elements happened to be zero. In addition, for large arrays where only an initial portion has an explicit initializer, we would emit the complete initializer (which could be huge) rather than emitting only the non-zero portion. With this change, when the element would have a suffix of more than 8 zero elements, we emit the array constant as a packed struct of its initial portion followed by a zeroinitializer constant for the trailing zero portion. In passing, I found a bug where SemaInit would sometimes walk the entire array when checking an initializer that only covers the first few elements; that's fixed here to unblock testing of the rest. Differential Revision: https://reviews.llvm.org/D47166 llvm-svn: 333044
* Suppress -Wmissing-braces warning when aggregate-initializing a struct with ↵Richard Smith2017-10-031-1/+31
| | | | | | | | | | a single field that is itself an aggregate. In C++, such initialization of std::array<T, N> types is guaranteed to work by the standard, is completely idiomatic, and the "suggested" alternative from Clang was technically invalid. llvm-svn: 314838
* Fix defaulted-functions-in-C++98 extension to give the functions the sameRichard Smith2016-12-211-2/+0
| | | | | | | | effect they would have in C++11. In particular, they do not prevent value-initialization from performing zero-initialization, nor do they prevent a struct from being an aggregate. llvm-svn: 290229
* [c++17] P0135R1: Guaranteed copy elision.Richard Smith2016-12-061-3/+9
| | | | | | | | When an object of class type is initialized from a prvalue of the same type (ignoring cv qualifications), use the prvalue to initialize the object directly instead of inserting a redundant elidable call to a copy constructor. llvm-svn: 288866
* Fix crash in access check for aggregate initialization of base classes. It'sRichard Smith2016-03-081-2/+66
| | | | | | | not obvious how to access-check these, so pick a conservative rule until we get feedback from CWG. llvm-svn: 262966
* Implemented delayed processing of 'unavailable' checking, just like with ↵Ted Kremenek2013-12-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 'deprecated'. Fixes <rdar://problem/15584219> and <rdar://problem/12241361>. This change looks large, but all it does is reuse and consolidate the delayed diagnostic logic for deprecation warnings with unavailability warnings. By doing so, it showed various inconsistencies between the diagnostics, which were close, but not consistent. It also revealed some missing "note:"'s in the deprecated diagnostics that were showing up in the unavailable diagnostics, etc. This change also changes the wording of the core deprecation diagnostics. Instead of saying "function has been explicitly marked deprecated" we now saw "'X' has been been explicitly marked deprecated". It turns out providing a bit more context is useful, and often we got the actual term wrong or it was not very precise (e.g., "function" instead of "destructor"). By just saying the name of the thing that is deprecated/deleted/unavailable we define this issue away. This diagnostic can likely be further wordsmithed to be shorter. llvm-svn: 197627
* List-initialization via constructor part 1. Still needs: pretty-printing, ↵Sebastian Redl2011-12-221-11/+11
| | | | | | overloading, initializer_list. llvm-svn: 147145
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-131-1/+1
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* Implement the suggested resolution of WG21 N3307 issue 19: When determining ↵Richard Smith2011-09-051-3/+3
| | | | | | whether a class is an aggregate in C++0x, treat all functions which are neither deleted nor defaulted as user-provided, not just special member functions. The wording of the standard only defines the term "user-provided" for special member functions, but the intent seems to be that any function can be user-provided. llvm-svn: 139111
* Revert 135177 to fix PR10363.Rafael Espindola2011-07-141-7/+8
| | | | | | | | Revert "For C++11, do more checking of initializer lists up-front, enabling some subset of the final functionality. C just leaves the function early. C++98 runs through the same code path, but has no changed functionality either." This reverts commit ac420c5053d6aa41d59f782caad9e46e5baaf2c2. llvm-svn: 135210
* For C++11, do more checking of initializer lists up-front, enabling some ↵Sebastian Redl2011-07-141-8/+7
| | | | | | | | | | subset of the final functionality. C just leaves the function early. C++98 runs through the same code path, but has no changed functionality either. This is a first baby step towards supporting generalized initializer lists. This also removes an aggregate test case that was just plain wrong, assuming that non-aggregates couldn't be initialized with initializer lists in C++11 mode. llvm-svn: 135177
* Clean up trivial default constructors now.Alexis Hunt2011-05-091-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | hasTrivialDefaultConstructor() really really means it now. Also implement a fun standards bug regarding aggregates. Doug, if you'd like, I can un-implement that bug if you think it is truly a defect. The bug is that non-special-member constructors are never considered user-provided, so the following is an aggregate: struct foo { foo(int); }; It's kind of bad, but the solution isn't obvious - should struct foo { foo (int) = delete; }; be an aggregate or not? Lastly, add a missing initialization to FunctionDecl. llvm-svn: 131101
* Introduce Type::isStructureOrClassType(), which does the obviousDouglas Gregor2010-04-261-0/+13
| | | | | | | | thing. Audit all uses of Type::isStructure(), changing those calls to isStructureOrClassType() as needed (which is alsmost everywhere). Fixes the remaining failure in Boost.Utility/Swap. llvm-svn: 102386
* Improve our handling of user-defined conversions as part of overloadDouglas Gregor2010-04-171-2/+2
| | | | | | | | | | | | | | | | | resolution. There are two sources of problems involving user-defined conversions that this change eliminates, along with providing simpler interfaces for checking implicit conversions: - It eliminates a case of infinite recursion found in Boost. - It eliminates the search for the constructor needed to copy a temporary generated by an implicit conversion from overload resolution. Overload resolution assumes that, if it gets a value of the parameter's class type (or a derived class thereof), there is a way to copy if... even if there isn't. We now model this properly. llvm-svn: 101680
* When pretty-printing tag types, only print the tag if we're in C (andJohn McCall2010-03-101-6/+6
| | | | | | | | | | therefore not creating ElaboratedTypes, which are still pretty-printed with the written tag). Most of these testcase changes were done by script, so don't feel too sorry for my fingers. llvm-svn: 98149
* Use new initialization code when dealing with [dcl.init.aggr]p12. This fixes ↵Anders Carlsson2010-01-241-1/+28
| | | | | | the bug where array elements and member initializers weren't copied correctly. llvm-svn: 94340
* Use the new init code for member subobjects.Anders Carlsson2010-01-231-0/+3
| | | | llvm-svn: 94329
* Switch some array initialization over to the new init code.Anders Carlsson2010-01-231-0/+3
| | | | llvm-svn: 94327
* Baby steps towards migrating the InitListChecker over to the new ↵Anders Carlsson2010-01-231-0/+4
| | | | | | initialization code. Pass an InitializedEntity pointer through to most init checker functions. Right now, it's ignored everywhere except when initializing vectors in C++. llvm-svn: 94325
* Add testcase for PR5817, although the bug was already fixedDouglas Gregor2010-01-061-0/+4
| | | | llvm-svn: 92858
* Switch file-scope assignment initialization over to InitializationSequence.Eli Friedman2009-12-221-4/+4
| | | | llvm-svn: 91881
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Sema-check virtual declarations. Complete dynamic_cast checking.Sebastian Redl2008-11-061-1/+3
| | | | llvm-svn: 58804
* Keep track of whether a C++ class is an aggregate. Don't allow ↵Douglas Gregor2008-11-051-0/+26
initialization of non-aggregates with initializer lists. llvm-svn: 58757
OpenPOWER on IntegriCloud