summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-2/+2
| | | | llvm-svn: 140367
* Add list initialization for complex numbers in C. Essentially, this allows ↵Eli Friedman2011-09-191-5/+67
| | | | | | | | "_Complex float x = {1.0f, 2.0f};". See changes to docs/LanguageExtensions.html for a longer description. <rdar://problem/9397672>. llvm-svn: 140090
* Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear ↵Francois Pichet2011-09-171-3/+3
| | | | | | | | that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag. Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag. llvm-svn: 139987
* Rename the ARC cast kinds to start with "ARC".John McCall2011-09-101-1/+1
| | | | llvm-svn: 139466
* Extend the self-reference warning to catch when a constructor references ↵Richard Trieu2011-09-011-0/+8
| | | | | | | | | itself upon initialization, such as using itself within its own copy constructor. struct S {}; S s(s); llvm-svn: 138969
* Fix PR10694: Boolean conversions can be from pointers, and those conversionsJeffrey Yasskin2011-08-301-0/+5
| | | | | | aren't considered narrowing conversions. llvm-svn: 138838
* Print 'int' instead of 'const int' in the narrowing conversion error, since theJeffrey Yasskin2011-08-291-3/+3
| | | | | | | | | qualification of a type doesn't affect whether a conversion is a narrowing conversion. This doesn't work in template cases because SubstTemplateTypeParmType gets in the way. llvm-svn: 138735
* Refactor and fix checking for initialization of flexible array members. The ↵Eli Friedman2011-08-231-24/+45
| | | | | | | | old version had the checks scattered across the code, missed some checks, and had a couple nasty bugs in existing checks. Fixes PR10648 and another similar accepts-invalid bug. llvm-svn: 138398
* Remove function parameter which always used the default value.Eli Friedman2011-08-231-6/+3
| | | | llvm-svn: 138368
* Downgrade "err_init_list_variable_narrowing" into a warning in Microsoft ↵Francois Pichet2011-08-181-2/+2
| | | | | | mode even if c++0x is enabled. This necessary to parse MSVC code in C++0x mode. llvm-svn: 137904
* Conversions to bool count as integer conversions for the purposes ofJeffrey Yasskin2011-08-121-0/+1
| | | | | | the C++0x narrowing error. llvm-svn: 137512
* Add support for C++0x unicode string and character literals, from Craig Topper!Douglas Gregor2011-07-271-11/+21
| | | | llvm-svn: 136210
* This patch implements as much of the narrowing conversion error specified byJeffrey Yasskin2011-07-261-5/+216
| | | | | | | | | | | | | | | [dcl.init.list] as is possible without generalized initializer lists or full constant expression support, and adds a c++0x-compat warning in C++98 mode. The FixIt currently uses a typedef's basename without qualification, which is likely to be incorrect on some code. If it's incorrect on too much code, we should write a function to get the string that refers to a type from a particular context. The warning is currently off by default. I'll fix LLVM and clang before turning it on. llvm-svn: 136181
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-5/+5
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* This handles the missing cases of opencl vector literals.Tanya Lattner2011-07-151-1/+2
| | | | | | Test cases provided by Anton Lokhmot. llvm-svn: 135322
* Revert 135177 to fix PR10363.Rafael Espindola2011-07-141-225/+80
| | | | | | | | 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-80/+225
| | | | | | | | | | 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
* Remove InitializationSequence::ReferenceBinding, the last redundant sequence ↵Sebastian Redl2011-07-141-9/+7
| | | | | | kind. llvm-svn: 135175
* Check for deprecated/unavailable/etc attributes on fields that areDouglas Gregor2011-06-291-0/+15
| | | | | | initialized via initializer lists. Fixes <rdar://problem/9694686>. llvm-svn: 134099
* Add support for C++ namespace-aware typo correction, e.g., correctingDouglas Gregor2011-06-281-8/+12
| | | | | | | | | | | | | | | vector<int> to std::vector<int> Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes PR5776/<rdar://problem/8652971>. Thanks Kaelyn! llvm-svn: 134007
* ARC writeback isn't supposed to apply to local indirect pointers,John McCall2011-06-271-12/+21
| | | | | | only to pointers to locals. But it should work inside blocks, too. llvm-svn: 133969
* Changes ParenListExpr to always require a type.Manuel Klimek2011-06-221-13/+3
| | | | | | | Removes dead code found in the process. Adds a test to verify that ParenListExprs do not have NULL types. llvm-svn: 133637
* When binding a reference to an Automatic Reference Counting temporary,Douglas Gregor2011-06-221-0/+7
| | | | | | | | | retain/release the temporary object appropriately. Previously, we would only perform the retain/release operations when the reference would extend the lifetime of the temporary, but this does the wrong thing across calls. llvm-svn: 133620
* Give MaterializeTemporaryExpr the exact type of the lvalue it bindsDouglas Gregor2011-06-221-1/+3
| | | | | | to, including cv-qualifications. llvm-svn: 133618
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | MaterializeTemporaryExpr captures a reference binding to a temporary value, making explicit that the temporary value (a prvalue) needs to be materialized into memory so that its address can be used. The intended AST invariant here is that a reference will always bind to a glvalue, and MaterializeTemporaryExpr will be used to convert prvalues into glvalues for that binding to happen. For example, given const int& r = 1.0; The initializer of "r" will be a MaterializeTemporaryExpr whose subexpression is an implicit conversion from the double literal "1.0" to an integer value. IR generation benefits most from this new node, since it was previously guessing (badly) when to materialize temporaries for the purposes of reference binding. There are likely more refactoring and cleanups we could perform there, but the introduction of MaterializeTemporaryExpr fixes PR9565, a case where IR generation would effectively bind a const reference directly to a bitfield in a struct. Addresses <rdar://problem/9552231>. llvm-svn: 133521
* Be sure to try a final ARC-production even in Objective-C++.John McCall2011-06-161-0/+2
| | | | llvm-svn: 133215
* Automatic Reference Counting.John McCall2011-06-151-27/+288
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Implement Objective-C Related Result Type semantics.Douglas Gregor2011-06-111-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Related result types apply Cocoa conventions to the type of message sends and property accesses to Objective-C methods that are known to always return objects whose type is the same as the type of the receiving class (or a subclass thereof), such as +alloc and -init. This tightens up static type safety for Objective-C, so that we now diagnose mistakes like this: t.m:4:10: warning: incompatible pointer types initializing 'NSSet *' with an expression of type 'NSArray *' [-Wincompatible-pointer-types] NSSet *array = [[NSArray alloc] init]; ^ ~~~~~~~~~~~~~~~~~~~~~~ /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:72:1: note: instance method 'init' is assumed to return an instance of its receiver type ('NSArray *') - (id)init; ^ It also means that we get decent type inference when writing code in Objective-C++0x: auto array = [[NSMutableArray alloc] initWithObjects:@"one", @"two",nil]; // ^ now infers NSMutableArray* rather than id llvm-svn: 132868
* Drop most of InitializationSequence::SequenceKind's values. They didn't ↵Sebastian Redl2011-06-051-56/+12
| | | | | | | | really contain any information that the step array didn't contain too. This makes debugging dumps a bit less informative, but probably not significantly so. The advantage is that the redundancy is gone, so the code is easier to understand. ReferenceBinding is still there, because it is used in some unclear code. llvm-svn: 132667
* Remove more references to FailedSequence.Sebastian Redl2011-06-051-3/+3
| | | | llvm-svn: 132666
* Remove all references to InitializationSequence::FailedSequence from outside ↵Sebastian Redl2011-06-051-1/+1
| | | | | | SemaInit.cpp. Replace them with the boolean conversion or the new Failed() function. This is a first step towards removing InitializationSequence::SequenceKind. No functionality change. llvm-svn: 132664
* Implement defaulting of destructors.Alexis Hunt2011-05-121-0/+15
| | | | llvm-svn: 131260
* Make it so that we actually generate definitions for explicitlyAlexis Hunt2011-05-121-1/+1
| | | | | | | | | | defaulted default constructors. As it happens, making sure that we handle out-of-line defaulted functions properly will involved making sure that we actually parse them correctly, so that's coming after. llvm-svn: 131224
* Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" andAlexis Hunt2011-05-091-1/+2
| | | | | | | modify the semantics slightly to accomodate default constructors (I hope). llvm-svn: 131087
* Fix delegating constructors stylistic issues.Alexis Hunt2011-05-031-2/+1
| | | | | | Material bugfixes to come this afternoon. llvm-svn: 130782
* Fully implement delegating constructors!Alexis Hunt2011-05-011-7/+10
| | | | | | | | | | As far as I know, this implementation is complete but might be missing a few optimizations. Exceptions and virtual bases are handled correctly. Because I'm an optimist, the web page has appropriately been updated. If I'm wrong, feel free to downgrade its support categories. llvm-svn: 130642
* Don't waste memory if the initializer expression is empty.Argyrios Kyrtzidis2011-04-281-4/+8
| | | | llvm-svn: 130420
* PR4304: Add warning for designators in strict c89 mode.Eli Friedman2011-04-241-0/+3
| | | | llvm-svn: 130117
* Use the ArrayFiller to fill out "holes" in the array initializer due to ↵Argyrios Kyrtzidis2011-04-211-1/+6
| | | | | | | | designated initializers, avoiding to create separate Exprs for each one. llvm-svn: 129933
* ForArgyrios Kyrtzidis2011-04-211-7/+16
| | | | | | | | | | | | | | double data[20000000] = {0}; we would blow out the memory by creating 20M Exprs to fill out the initializer. To fix this, if the initializer list initializes an array with more elements than there are initializers in the list, have InitListExpr store a single 'ArrayFiller' expression that specifies an expression to be used for value initialization of the rest of the elements. Fixes rdar://9275920. llvm-svn: 129896
* In C++, when initializing an array from a pascal string, it's OK if the arrayAnders Carlsson2011-04-141-0/+9
| | | | | | | is 1 element smaller than the string, because we can just strip off the last null character. This matches GCC. llvm-svn: 129490
* PR9669: implement correct checking for [dcl.init.string]p2.Eli Friedman2011-04-111-5/+14
| | | | llvm-svn: 129260
* Use ExprResult& instead of Expr *& in SemaJohn Wiegley2011-04-081-67/+90
| | | | | | | | | | | | | | | | | | | | | | | | | This patch authored by Eric Niebler. Many methods on the Sema class (e.g. ConvertPropertyForRValue) take Expr pointers as in/out parameters (Expr *&). This is especially true for the routines that apply implicit conversions to nodes in-place. This design is workable only as long as those conversions cannot fail. If they are allowed to fail, they need a way to report their failures. The typical way of doing this in clang is to use an ExprResult, which has an extra bit to signal a valid/invalid state. Returning ExprResult is de riguour elsewhere in the Sema interface. We suggest changing the Expr *& parameters in the Sema interface to ExprResult &. This increases interface consistency and maintainability. This interface change is important for work supporting MS-style C++ properties. For reasons explained here <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013180.html>, seemingly trivial operations like rvalue/lvalue conversions that formerly could not fail now can. (The reason is that given the semantics of the feature, getter/setter method lookup cannot happen until the point of use, at which point it may be found that the method does not exist, or it may have the wrong type, or overload resolution may fail, or it may be inaccessible.) llvm-svn: 129143
* Implement delegating constructors partially.Alexis Hunt2011-02-261-0/+7
| | | | | | | | | | | This successfully performs constructor lookup and verifies that a delegating initializer is the only initializer present. This does not perform loop detection in the initialization, but it also doesn't codegen delegating constructors at all, so this won't cause runtime infinite loops yet. llvm-svn: 126552
* Remove the FIXME I introduced last night, and pull the logic forChandler Carruth2011-02-251-3/+8
| | | | | | | | | | marking selected overloads into the callers. This allows a few callers to skip it altogether (they would have anyways because they weren't interested in successful overloads) or defer until after further checks take place much like the check required for PR9323 to avoid marking unused copy constructors. llvm-svn: 126503
* Rough fix for PR9323 that prevents Clang from marking copy constructorChandler Carruth2011-02-251-1/+3
| | | | | | | | | | | | | | | | declarations as referenced when in fact we're not going to even form a call in the AST. This is significant because we attempt to allow as an extension classes with intentionally private and undefined copy constructors to have temporaries bound to references, and so shouldn't warn about the lack of definition for that copy constructor when the class is internal. Doug, John wasn't really satisfied with the presence of overloading at all. This is a stop-gap and there may be a better solution. If you can give me some hints for how you'd prefer to see this solved, I'll happily switch things over. llvm-svn: 126480
* Implement the GNU C extension which permits the initialization of anDouglas Gregor2011-02-221-4/+101
| | | | | | array from a constant array compound literal. Fixes PR9261. llvm-svn: 126230
* Reorganize subelement initialization checking, no functionality change.John McCall2011-02-211-70/+82
| | | | llvm-svn: 126116
* Small optimization: avoid redundant checks of whether a type is an arrayJohn McCall2011-02-211-21/+25
| | | | | | when checking an initialization. llvm-svn: 126115
* implement a tiny amount of codegen support for gnu array range Chris Lattner2011-02-191-2/+7
| | | | | | | | designators: allowing codegen when the element initializer is a constant or something else without a side effect. This unblocks enough to let process.c in the linux kernel build, PR9257. llvm-svn: 126056
OpenPOWER on IntegriCloud