summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/constructor-initializer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix PR 10758: Infinite recursion when dealing with copy-initializationAlex Lorenz2017-05-161-0/+19
| | | | | | | | | | | | | | | | | | This commit fixes a bug that's tracked by PR 10758 and duplicates like PR 30343. The bug causes clang to crash with a stack overflow while recursing infinitely trying to perform copy-initialization on a type without a copy constructor but with a constructor that accepts another type that can be constructed using the original type. The commit fixes this bug by detecting the recursive behavior and failing correctly with an appropriate error message. It also tries to provide a meaningful diagnostic note about the constructor which leads to this behavior. rdar://28483944 Differential Revision: https://reviews.llvm.org/D25051 llvm-svn: 303156
* [Lit Test] Updated 34 Lit tests to be C++11 compatible.Charles Li2015-11-171-4/+15
| | | | | | | Added expected diagnostics new to C++11. Expanded RUN line to: default, C++98/03 and C++11. llvm-svn: 253371
* PR6037Nathan Sidwell2015-01-191-2/+3
| | | | | | Warn on inaccessible direct base llvm-svn: 226423
* Update error message text.Serge Pavlov2015-01-181-1/+1
| | | | | | | | | Previously if an enumeration was used in a nested name specifier in pre-C++11 language dialect, error message was 'XXX is not a class, namespace, or scoped enumeration'. This patch removes the word 'scoped' as in C++11 any enumeration may be used in this context. llvm-svn: 226410
* Improve diagnostic for using non-class/namespace/scoped enum in a nested ↵David Blaikie2014-02-091-1/+1
| | | | | | | | | | | | | | | name specifier. Rather than simply saying "X is not a class or namespace", clarify what X is by providing the aka type in the case where X is a type, or pointing to the named declaration if there's an unambiguous one to refer to. In the ambiguous case, the ambiguities are already enumerated (though could be clarified by describing what kind of entities they are) Included a few FIXMEs in tests where some further improvements could be made. llvm-svn: 201038
* Don't mark record decls invalid when one of its methods is invalid, PR18284.Nico Weber2013-12-211-3/+2
| | | | | | | | | | | | | | | Without this patch, record decls with invalid out-of-line method delcs would sometimes be marked invalid, but not always. With this patch, they are consistently never marked invalid. (The code to do this was added in http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20100809/033154.html , but the test from that revision is still passing.) As far as I can tell, this was the only place where a class was marked invalid after its definition was complete. llvm-svn: 197848
* <rdar://problem/13267210> Ensure that Sema::CompareReferenceRelationship ↵Douglas Gregor2013-03-261-2/+4
| | | | | | | | | | | | | returns consistent results with invalid types. When Sema::RequireCompleteType() is given a class template specialization type that then fails to instantiate, it returns 'true'. On subsequent invocations, it can return false. Make sure that this difference doesn't change the result of Sema::CompareReferenceRelationship, which is expected to remain stable while we're checking an initialization sequence. llvm-svn: 178088
* Teach the uninitialized field warning about anonymous structs and union members.Nick Lewycky2012-11-151-0/+6
| | | | | | Fixes PR14073! llvm-svn: 168031
* Make warnings about uninitialized fields include the field name.Hans Wennborg2012-09-211-8/+8
| | | | | | | | | | | This makes the wording more informative, and consistent with the other warnings about uninitialized variables. Also, me and David who reviewed this couldn't figure out why we would need to do a lookup to get the name of the variable; so just print the name directly. llvm-svn: 164366
* Get rid of an early return in Sema::ActOnFields which doesn't make sense ↵Eli Friedman2012-08-081-2/+2
| | | | | | | | | anymore. Fixes a crash (<rdar://problem/11067144>), and generally seems to improve recovery in other cases. llvm-svn: 161474
* Use a proper visitor to recursively check for uninitialized use in constructors.Richard Trieu2012-06-141-3/+6
| | | | llvm-svn: 158477
* Improve diagnostics a bit for bad member initializers, and fix an obscure ↵Eli Friedman2012-02-221-0/+12
| | | | | | bug involving packs. Fixes PR12049. llvm-svn: 151130
* Include named unions in union member init checkingDavid Blaikie2011-11-171-1/+1
| | | | llvm-svn: 144883
* When checking for uninitialized fields in member initializers, special case ↵Anders Carlsson2010-10-061-0/+29
| | | | | | static variables and enums. Fixes PR8075. llvm-svn: 115732
* Do not warn with -Wuninitialized when the member is used in a sizeof or ↵Argyrios Kyrtzidis2010-09-211-1/+5
| | | | | | | | address-of expression. Fixes rdar://8331312. llvm-svn: 114426
* Don't try to initialize a reference with a constructed temporary if eitherJohn McCall2010-08-171-0/+14
| | | | | | of the classes is invalid. A class is invalid if a base is invalid. llvm-svn: 111227
* Reapply r107235, this time with both my typo fixed, and a logical bug fixed.Chandler Carruth2010-06-301-0/+17
| | | | | | | | | | Previously we relied on the presence of a member which needs no initialization to prevent us from creating an additional initialization of the outer anonymous union field. We have already correctly marked that field as initialized by the member of the union (repeatedly due to the original bug this patch fixes) so we simply need to bail out. llvm-svn: 107242
* Revert r107235, it had a silly typo in it, and fixing the typo breaks somethingChandler Carruth2010-06-301-17/+0
| | | | | | | else. Get the build bots happy while I debug. Very sorry for the delay fixing this... llvm-svn: 107239
* Fix PR7402: We were creating implicit member initializers for every field in anChandler Carruth2010-06-301-0/+17
| | | | | | | | | | | anonymous union under the presumption that they didn't do anything. While this is true, our checks for redundant initialization of an anonymous union still fire when these overlap with explicit user initialization. A cleaner approach is to avoid initializing multiple members of a union altogether, but this still is in a rather fuzzy are especially when C++0x allows non-POD types into unions. llvm-svn: 107235
* Land this test.Anders Carlsson2010-04-251-1/+16
| | | | llvm-svn: 102292
* Revert enough of my patches to fix self-host again :(Anders Carlsson2010-04-251-16/+1
| | | | llvm-svn: 102289
* DefineImplicitCopyConstructor now uses SetBaseOrMemberInitializers to create ↵Anders Carlsson2010-04-241-1/+16
| | | | | | implicit base initializers. (Member initializers are still handled by CodeGenFunction::SynthesizeCXXCopyConstructor for now). llvm-svn: 102279
* Recommit my change to how C++ does elaborated type lookups, now withJohn McCall2010-04-231-0/+7
| | | | | | two bugfixes which fix selfhost and (hopefully) the nightly tests. llvm-svn: 102198
* Fix a think-o that broke self-host.Anders Carlsson2010-04-231-0/+11
| | | | llvm-svn: 102165
* Diagnose more cases of initializing distinct members of an anonymous unionJohn McCall2010-04-101-2/+3
| | | | | | | member. Use a better diagnostic for this case. Also fix a bug with nested anonymous structs/unions for -Wreorder; this last was PR6575. llvm-svn: 100923
* Diagnose misordered initializers in constructor templates immediately instead ofJohn McCall2010-04-101-4/+3
| | | | | | | | | | when they're instantiated. Merge the note into the -Wreorder warning; it doesn't really contribute much, and it was splitting a thought across diagnostics anyway. Don't crash in the parser when a constructor's initializers end in a comma and there's no body; the recovery here is still terrible, but anything's better than a crash. llvm-svn: 100922
* Turn access control on by default in -cc1.John McCall2010-04-091-1/+2
| | | | | | | | Remove -faccess-control from -cc1; add -fno-access-control. Make the driver pass -fno-access-control by default. Update a bunch of tests to be correct under access control. llvm-svn: 100880
* When pretty-printing tag types, only print the tag if we're in C (andJohn McCall2010-03-101-5/+5
| | | | | | | | | | 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
* Rework base and member initialization in constructors, with severalDouglas Gregor2010-01-311-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (necessarily simultaneous) changes: - CXXBaseOrMemberInitializer now contains only a single initializer rather than a set of initialiation arguments + a constructor. The single initializer covers all aspects of initialization, including constructor calls as necessary but also cleanup of temporaries created by the initializer (which we never handled before!). - Rework + simplify code generation for CXXBaseOrMemberInitializers, since we can now just emit the initializer as an initializer. - Switched base and member initialization over to the new initialization code (InitializationSequence), so that it - Improved diagnostics for the new initialization code when initializing bases and members, to match the diagnostics produced by the previous (special-purpose) code. - Simplify the representation of type-checked constructor initializers in templates; instead of keeping the fully-type-checked AST, which is rather hard to undo at template instantiation time, throw away the type-checked AST and store the raw expressions in the AST. This simplifies instantiation, but loses a little but of information in the AST. - When type-checking implicit base or member initializers within a dependent context, don't add the generated initializers into the AST, because they'll look like they were explicit. - Record in CXXConstructExpr when the constructor call is to initialize a base class, so that CodeGen does not have to infer it from context. This ensures that we call the right kind of constructor. There are also a few "opportunity" fixes here that were needed to not regress, for example: - Diagnose default-initialization of a const-qualified class that does not have a user-declared default constructor. We had this diagnostic specifically for bases and members, but missed it for variables. That's fixed now. - When defining the implicit constructors, destructor, and copy-assignment operator, set the CurContext to that constructor when we're defining the body. llvm-svn: 94952
* Improve the reporting of non-viable overload candidates by noting the reasonJohn McCall2010-01-131-1/+1
| | | | | | | | why the candidate is non-viable. There's a lot we can do to improve this, but it's a good start. Further improvements should probably be integrated with the bad-initialization reporting routines. llvm-svn: 93277
* Improve the diagnostics used to report implicitly-generated class membersJohn McCall2010-01-061-5/+2
| | | | | | | | | as parts of overload sets. Also, refer to constructors as 'constructors' rather than functions. Adjust a lot of tests. llvm-svn: 92832
* 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
* Don't gratuitously mark the default constructors of base or member ↵Douglas Gregor2009-11-151-0/+15
| | | | | | initializers as used llvm-svn: 88847
* Unify the codepaths used to verify base and member initializers for explicitlyEli Friedman2009-11-091-4/+7
| | | | | | | | | | | | | | | | and implicitly defined constructors. This has a number of benefits: 1. Less code. 2. Explicit and implicit constructors get the same diagnostics. 3. The AST explicitly contains constructor calls from implicit default constructors. This allows handing some cases that previously weren't handled correctly in IRGen without any additional code. Specifically, implicit default constructors containing calls to constructors with default arguments are now handled correctly. llvm-svn: 86500
* Diagnose using a field to initialize itself. Patch by Brandon Pearcy!John McCall2009-11-041-0/+33
| | | | llvm-svn: 86061
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-7/+7
| | | | llvm-svn: 81346
* Top-level semicolons are allowed in C++0x. Fixes PR4755.Douglas Gregor2009-08-241-1/+0
| | | | llvm-svn: 79912
* Fixed test.Fariborz Jahanian2009-07-291-1/+1
| | | | llvm-svn: 77506
* fix test (broken in r77224)Benjamin Kramer2009-07-271-1/+1
| | | | llvm-svn: 77241
* Fixes broken test by accident.Fariborz Jahanian2009-07-241-1/+2
| | | | llvm-svn: 77001
* More Sema check for constructor's member initializer along Fariborz Jahanian2009-07-241-2/+8
| | | | | | with type conversion to fix ir-gen crash. llvm-svn: 77000
* Diagnose when base classes and members to be intializedFariborz Jahanian2009-07-231-0/+20
| | | | | | with constructors don't have a matching constructor. llvm-svn: 76913
* Add constructor used to initialize base/member inFariborz Jahanian2009-07-231-0/+1
| | | | | | | CXXBaseOrMemberInitializer AST node. Needed by its clients to do the initialization. llvm-svn: 76826
* Sema check on out of order object initialization ofFariborz Jahanian2009-07-091-4/+6
| | | | | | class object's base and members under -Wreorder flag. llvm-svn: 75168
* Patch to support optional nested-name-specifier in in ctor-initializerFariborz Jahanian2009-06-301-0/+19
| | | | | | list. llvm-svn: 74571
* Diagnose multiple initialization of anonymous unionFariborz Jahanian2009-06-301-0/+8
| | | | | | fields in the ctor-initializer list. llvm-svn: 74554
* More diagnostics related to initialization of direct basesFariborz Jahanian2009-06-301-0/+12
| | | | | | in ctor-initializer list. llvm-svn: 74541
* Improve handling of base initializers. We now parse initializers in out of ↵Anders Carlsson2009-03-251-0/+9
| | | | | | | | | | | | | | | | | | | | | | line decls, such as: class C { C() { } int a; }; C::C() : a(10) { } We also diagnose when initializers are used on declarations that aren't constructors: t.cpp:1:10: error: only constructors take base initializers void f() : a(10) { } ^ Doug and/or Sebastian: I'd appreciate a review, especially the nested-name-spec test results (from the looks of it we now match gcc in that test.) llvm-svn: 67672
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Fix a long standard problem with clang retaining "too much" sugar Chris Lattner2009-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | information about types. We often print diagnostics where we say "foo_t" is bad, but the user doesn't know how foo_t is declared (because it is a typedef). Fix this by expanding sugar when present in a diagnostic (and not one of a few special cases, like vectors). Before: t.m:5:2: error: invalid operands to binary expression ('typeof(P)' and 'typeof(F)') MAX(P, F); ^~~~~~~~~ t.m:1:78: note: instantiated from: #define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) ^ After: t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float')) MAX(P, F); ^~~~~~~~~ t.m:1:78: note: instantiated from: #define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) ^ llvm-svn: 65081
OpenPOWER on IntegriCloud