summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix reference-binding when we have a reference to const volatile type;Douglas Gregor2010-01-291-1/+2
| | | | | | | previously, we were allowing this to bind to a temporary. Now, we don't; add test-cases and improve diagnostics. llvm-svn: 94831
* Fix reference binding of const lvalue references to bit-fields, whichDouglas Gregor2010-01-291-3/+195
| | | | | | | | | | | | | | | | | requires a temporary. Previously, we were building an initialization sequence that bound to the bit-field as if it were a real lvalue. Note that we previously (and still) diagnose binding of non-const references to bit-fields, as we should. There's no real way to test that this code is correct, since reference binding does not *currently* have any representation in the AST. This fix should make it easier for that to happen, so I've verified this fix with... Added InitializationSequence::dump(), to print an initialization sequence for debugging purposes. llvm-svn: 94826
* Simplify InitListChecker::CheckReferenceTypeAnders Carlsson2010-01-291-11/+10
| | | | llvm-svn: 94793
* Pass access specifiers around in overload resolution.John McCall2010-01-261-14/+25
| | | | llvm-svn: 94485
* Code simplification; this should have no visible effects.Eli Friedman2010-01-251-33/+2
| | | | llvm-svn: 94427
* Use new initialization code when dealing with [dcl.init.aggr]p12. This fixes ↵Anders Carlsson2010-01-241-16/+28
| | | | | | the bug where array elements and member initializers weren't copied correctly. llvm-svn: 94340
* Change all InitializedEntity pointers over to be references.Anders Carlsson2010-01-231-137/+81
| | | | llvm-svn: 94335
* Start passing InitializedEntity to CheckDesignatedInitializer.Anders Carlsson2010-01-231-9/+22
| | | | llvm-svn: 94334
* More init work, adding more entity parameters.Anders Carlsson2010-01-231-10/+27
| | | | llvm-svn: 94332
* Use the new init code for member subobjects.Anders Carlsson2010-01-231-6/+18
| | | | llvm-svn: 94329
* Switch some array initialization over to the new init code.Anders Carlsson2010-01-231-7/+22
| | | | llvm-svn: 94327
* Baby steps towards migrating the InitListChecker over to the new ↵Anders Carlsson2010-01-231-33/+65
| | | | | | 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
* When an InitializedEntity is passed to CheckSingleInitializer, call the new ↵Anders Carlsson2010-01-231-22/+36
| | | | | | Sema::PerformCopyInitialization overload. llvm-svn: 94324
* Change CheckSingleInitializer to take/return OwningExprResults instead. No ↵Anders Carlsson2010-01-231-24/+46
| | | | | | functionality change. llvm-svn: 94316
* Separate EK_ArrayOrVectorElement into EK_ArrayElement and EK_VectorElement; ↵Anders Carlsson2010-01-231-9/+18
| | | | | | arrays and vectors are pretty different beasts in C++. Doug, please review/comment. llvm-svn: 94279
* Give UnresolvedSet the ability to store access specifiers for each declaration.John McCall2010-01-201-6/+5
| | | | | | | Change LookupResult to use UnresolvedSet. Also extract UnresolvedSet into its own header and make it templated over an inline capacity. llvm-svn: 93959
* Fix the CodeGen half of PR5911 by changing reference initialization toChandler Carruth2010-01-121-8/+12
| | | | | | | correctly look through arrays to see cv-qualifiers. Also enhances the routine for doing this to preserve more type sugaring for diagnostics. llvm-svn: 93252
* So I was sitting around, trying vainly to think of something to commit, and thenJohn McCall2010-01-121-7/+12
| | | | | | | | I said to myself, self, why don't you go add a couple of parameters to a method and then fail to use them, and I thought that sounded like a pretty good idea, so I did it. llvm-svn: 93233
* Introduce a specific representation for the ambiguous implicit conversionJohn McCall2010-01-121-6/+11
| | | | | | | sequence. Lots of small relevant changes. Fixes some serious problems with ambiguous conversions; also possibly improves associated diagnostics. llvm-svn: 93214
* Change the printing of OR_Deleted overload results to print all the candidates,John McCall2010-01-081-7/+8
| | | | | | | | | | | | | | | not just the viable ones. This is reasonable because the most common use of deleted functions is to exclude some implicit conversion during calls; users therefore will want to figure out why some other options were excluded. Started sorting overload results. Right now it just sorts by location in the translation unit (after putting viable functions first), but we can do better than that. Changed bool OnlyViable parameter to PrintOverloadCandidates to an enum for better self-documentation. llvm-svn: 92990
* Whenever we emit a typo-correction diagnostic, also emit a noteDouglas Gregor2010-01-071-0/+3
| | | | | | | pointing to the declaration that we found that has that name (if it is unique). llvm-svn: 92877
* Move the allocation of designators in DesignatedInitExpr to theDouglas Gregor2010-01-061-1/+1
| | | | | | ASTContext. Fixes <rdar://problem/7495428>. llvm-svn: 92867
* Typo correction for C99 designated field initializers, e.g.,Douglas Gregor2010-01-011-15/+53
| | | | | | | | | | test/FixIt/typo.c:19:4: error: field designator 'bunds' does not refer to any field in type 'struct Window'; did you mean 'bounds'? .bunds. ^~~~~ bounds llvm-svn: 92376
* Switch parameter-passing for calls via function pointers (where weDouglas Gregor2009-12-221-1/+5
| | | | | | don't have a FunctionDecl) over to InitializationSequence. llvm-svn: 91906
* Switch InitializedEntity from TypeLoc down to just QualTypes, since we don't ↵Douglas Gregor2009-12-221-73/+36
| | | | | | use the location information but we did spend a bunch of time building faked-up TypeLocs llvm-svn: 91905
* Switch initialization of parameters in a call over toDouglas Gregor2009-12-221-4/+19
| | | | | | | | | | | InitializationSequence (when a FunctionDecl is present). This required a few small fixes to initialization sequences: - Make sure to use the adjusted parameter type for initialization of function parameters. - Implement transparent union calling semantics in C llvm-svn: 91902
* Zap CheckInitializerTypes.Eli Friedman2009-12-221-112/+0
| | | | llvm-svn: 91884
* Switch compound literals over to InitializationSequence.Eli Friedman2009-12-221-1/+1
| | | | llvm-svn: 91882
* Switch file-scope assignment initialization over to InitializationSequence.Eli Friedman2009-12-221-1/+5
| | | | 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
* When filling in value initializations within an initializer list, beDouglas Gregor2009-12-221-65/+86
| | | | | | | sure to fill in the initialized member of a union when a member was explicitly designated. Fixes PR5843. llvm-svn: 91858
* Fix review comment; no visible change.Eli Friedman2009-12-201-28/+29
| | | | llvm-svn: 91797
* Switch default-initialization of variables of class type (or array thereof) ↵Douglas Gregor2009-12-201-1/+2
| | | | | | over to InitializationSequence. I could swear that this fixes a PR somewhere, but I couldn't figure out which one llvm-svn: 91796
* Initialization improvements: addition of string initialization and a fewEli Friedman2009-12-191-11/+32
| | | | | | | | 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
* Switch more of Sema::CheckInitializerTypes over toDouglas Gregor2009-12-191-80/+43
| | | | | | | | | | InitializationSequence. Specially, switch initialization of a C++ class type (either copy- or direct-initialization). Also, make sure that we create an elidable copy-construction when performing copy initialization of a C++ class variable. Fixes PR5826. llvm-svn: 91750
* Switch the initialization required by return statements over to theDouglas Gregor2009-12-181-32/+267
| | | | | | | | | | | | | | | | | | | | | | | | | | | | new InitializationSequence. This fixes some bugs (e.g., PR5808), changed some diagnostics, and caused more churn than expected. What's new: - InitializationSequence now has a "C conversion sequence" category and step kind, which falls back to - Changed the diagnostics for returns to always have the result type of the function first and the type of the expression second. CheckSingleAssignmentConstraints to peform checking in C. - Improved ASTs for initialization of return values. The ASTs now capture all of the temporaries we need to create, but intentionally do not bind the tempoary that is actually returned, so that it won't get destroyed twice. - Make sure to perform an (elidable!) copy of the class object that is returned from a class. - Fix copy elision in CodeGen to properly see through the subexpressions that occur with elidable copies. - Give "new" its own entity kind; as with return values and thrown objects, we don't bind the expression so we don't call a destructor for it. Note that, with this patch, I've broken returning move-only types in C++0x. We'll fix it later, when we tackle NRVO. llvm-svn: 91669
* When value-initializing a class with no user-defined constructors butDouglas Gregor2009-12-161-10/+34
| | | | | | | with a non-trivial default constructor, zero-initialize the storage and then call the default constructor. Fixes PR5800. llvm-svn: 91548
* In Sema::CheckInitializerTypes, replace a use of CheckReferenceInit with an ↵Douglas Gregor2009-12-161-5/+11
| | | | | | InitializationSequence llvm-svn: 91542
* Eliminate Sema::CheckValueInitialization; its callers now useDouglas Gregor2009-12-161-93/+120
| | | | | | | | | | | | | | InitializationSequence to perform the actual initialization. Also, introduced the notion of a tree of initialized entities, so that we can know where an initialization began when dealing with nested initializations (as occur when performing list initialization). This will, eventually, be useful for producing better diagnostics when list initialization fails, because we can show the path from the top-level object being initialized down to the actual subobject where initialization failed. llvm-svn: 91516
* Fix semantic diagnostics that embed English works, from Nicola Gigante!Douglas Gregor2009-12-161-7/+7
| | | | llvm-svn: 91503
* Switch the C++ new expression over to InitializationSequence, ratherDouglas Gregor2009-12-161-25/+122
| | | | | | | | | | | | | | | | | | | | | 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
* Implement value initialization in InitializationSequence; untestedDouglas Gregor2009-12-151-10/+56
| | | | | | WIP, yet again. llvm-svn: 91368
* Minor cleanups for constructor initialization in InitializationSequenceDouglas Gregor2009-12-141-2/+2
| | | | llvm-svn: 91325
* Constructor initialization for InitializationSequence. Untested WIP.Douglas Gregor2009-12-141-1/+144
| | | | llvm-svn: 91323
* Implement user-defined conversions in InitializationSequence. WPI thatDouglas Gregor2009-12-141-2/+120
| | | | | | isn't turned on anyway yet, so it cannot be tested. llvm-svn: 91294
* Silence some release build warnings.Chandler Carruth2009-12-131-0/+1
| | | | llvm-svn: 91234
* Un-namespace-qualify llvm_unreachable. It's a macro, so the qualification gaveJeffrey Yasskin2009-12-121-2/+2
| | | | | | no extra safety anyway. llvm-svn: 91207
* Fix a recent regression from the initialization changes.Eli Friedman2009-12-111-9/+12
| | | | llvm-svn: 91097
* Move initialization via initializer list over to InitializationSequences.Douglas Gregor2009-12-101-8/+121
| | | | llvm-svn: 91050
* Reimplement reference initialization (C++ [dcl.init.ref]) using theDouglas Gregor2009-12-091-4/+966
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | new notion of an "initialization sequence", which encapsulates the computation of the initialization sequence along with diagnostic information and the capability to turn the computed sequence into an expression. At present, I've only switched one CheckReferenceInit callers over to this new mechanism; more will follow. Aside from (hopefully) being much more true to the standard, the diagnostics provided by this reference-initialization code are a bit better than before. Some examples: p5-var.cpp:54:12: error: non-const lvalue reference to type 'struct Derived' cannot bind to a value of unrelated type 'struct Base' Derived &dr2 = b; // expected-error{{non-const lvalue reference to ... ^ ~ p5-var.cpp:55:9: error: binding of reference to type 'struct Base' to a value of type 'struct Base const' drops qualifiers Base &br3 = bc; // expected-error{{drops qualifiers}} ^ ~~ p5-var.cpp:57:15: error: ambiguous conversion from derived class 'struct Diamond' to base class 'struct Base': struct Diamond -> struct Derived -> struct Base struct Diamond -> struct Derived2 -> struct Base Base &br5 = diamond; // expected-error{{ambiguous conversion from ... ^~~~~~~ p5-var.cpp:59:9: error: non-const lvalue reference to type 'long' cannot bind to a value of unrelated type 'int' long &lr = i; // expected-error{{non-const lvalue reference to type ... ^ ~ p5-var.cpp:74:9: error: non-const lvalue reference to type 'struct Base' cannot bind to a temporary of type 'struct Base' Base &br1 = Base(); // expected-error{{non-const lvalue reference to ... ^ ~~~~~~ p5-var.cpp:102:9: error: non-const reference cannot bind to bit-field 'i' int & ir1 = (ib.i); // expected-error{{non-const reference cannot ... ^ ~~~~~~ p5-var.cpp:98:7: note: bit-field is declared here int i : 17; // expected-note{{bit-field is declared here}} ^ llvm-svn: 90992
OpenPOWER on IntegriCloud