aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaInit.cpp
AgeCommit message (Collapse)Author
2012-01-05The value of a const weak variable is not an integer constant.John McCall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147575 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-29Change the diagnostics which said 'accepted as an extension' to instead sayRichard Smith
'is an extension'. The former is inappropriate and confusing when building with -Werror/-pedantic-errors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147357 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-22Fix build under -Wswitch by adding support for FK_ListConstructorOverloadFailedNick Lewycky
to initialization sequence dumping. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147171 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-22Overloading for initializer list construction.Sebastian Redl
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147156 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-22List-initialization via constructor part 1. Still needs: pretty-printing, ↵Sebastian Redl
overloading, initializer_list. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147145 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-20Revert r146766, and add a testcase for which it introduced a wrong-code bug.Richard Smith
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146961 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-16Fix an inconsistency in the syntactic form of InitListExpr in case of ↵Nicola Gigante
initialization that involves a ConstructorConversion git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146766 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-16C++11 constexpr: Add note stacks containing backtraces if constant evaluationRichard Smith
fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit argument to driver and frontend, to control the maximum number of notes so produced (default 10). Fix APValue printing to be able to pretty-print all APValue types, and move the testing for this functionality from a unittest to a -verify test now that it's visible in clang's output. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146749 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-29Revert r145244. It causes us to create broken ASTs with missing type informationRichard Smith
for some cast expressions. Original commit message: Removed useless ImplicitCast nodes in explicit cstyle and static casts git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145447 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-28Removed useless ImplicitCast nodes in explicit cstyle and static castsNicola Gigante
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145244 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-27Reference initialization with initializer lists.Sebastian Redl
This supports single-element initializer lists for references according to DR1288, as well as creating temporaries and binding to them for other initializer lists. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145186 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-23Add feature to diagnostics that will provide more information on functionRichard Trieu
pointer mismatch. Cases covered are: initialization, assignment, and function arguments. Additional text will give the extra information about the nature of the mismatch: different classes for member functions, wrong number of parameters, different parameter type, different return type, and function qualifier mismatch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145114 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-19Fixed HadMultipleCandidates loading.Abramo Bagnara
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144995 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-16Added missing ImplicitCastExpr around conversion operator call.Abramo Bagnara
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144850 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-15Resolve placeholder expressions before trying to deduceJohn McCall
'auto'. Introduce a convenience method to make this a bit easier, and use it elsewhere. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144605 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-13When reference binding array rvalues, such as those created by compoundPeter Collingbourne
literals of array type, materialise a temporary. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144483 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-29Rename Expr::Evaluate to Expr::EvaluateAsRValue to make it clear that it willRichard Smith
implicitly perform an lvalue-to-rvalue conversion if used on an lvalue expression. Also improve the documentation of Expr::Evaluate* to indicate which of them will accept expressions with side-effects. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143263 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-25Restore r142914 and r142915, now with missing file and apparentJohn McCall
GCC compiler workaround. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142931 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-25Revert r142914 and r142915, due to possibly missing file.NAKAMURA Takumi
r142914: "Introduce a placeholder type for "pseudo object"" r142915: "Pull the pseudo-object stuff into its own file." git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142921 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-25Introduce a placeholder type for "pseudo object"John McCall
expressions: expressions which refer to a logical rather than a physical l-value, where the logical object is actually accessed via custom getter/setter code. A subsequent patch will generalize the AST for these so that arbitrary "implementing" sub-expressions can be provided. Right now the only client is ObjC properties, but this should be generalizable to similar language features, e.g. Managed C++'s __property methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142914 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-21Don't try to set the "array filler" in a InitListExpr twice.Argyrios Kyrtzidis
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142695 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-19-Wc++98-compat: diagnose if a reference is bound to a prvalue which does notRichard Smith
have an unambiguous accessible copying constructor; this is ill-formed in C++98. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142533 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-18-Wc++98-compat and -Wc++98-compat-pedantic warnings for Sema, part 2.Richard Smith
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142426 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17Teach the ARC compiler to not require __bridge casts whenJohn McCall
passing/receiving CF objects at +0 to/from Objective-C methods or audited C functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142219 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-16Diagnose when omitting braces in direct list-initialization in C++0x.Sebastian Redl
This also applies to C99-style aggregate literals, should they be used in C++11, since they are effectively identical to constructor call list-initialization syntax. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142147 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-16In the verify-only pass, check that items that don't have an initializer in ↵Sebastian Redl
an init list can be value-initialized, at least when designated initializers are not involved. No test case yet, since early failures cannot be distinguished from late failures until overload resolution works. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142146 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14Change operator<< for raw_ostream and NamedDecl to take a reference instead ↵Benjamin Kramer
of a pointer. Passing a pointer was a bad idea as it collides with the overload for void*. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141971 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-10Constant expression evaluation refactoring:Richard Smith
- Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions, and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert behaviour. - Factor out evaluation of bitfield bit widths. - Fix a few places which would evaluate an expression twice: once to determine whether it is a constant expression, then again to get the value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141561 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-10Per C++ [class.bit]p2, unnamed bit-fields are not members. Fixes PR10289.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141549 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-09Initialize the HadMultipleCandidates flag.Benjamin Kramer
Found by valgrind. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141510 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05Added a flag to identify resolved overloaded function references.Abramo Bagnara
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141171 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-04Remove a nonsensical bit of code from ↵Eli Friedman
InitListChecker::getStructuredSubobjectInit which was increasing the reserved size for an init list past its maximum possible size. Fixes PR11056, a case where we were reserving a bunch of memory for arrays that was never actually used. (No testcase because I don't think we have any way to actually write a testcase for this; the chosen value of NumElements has no effects on anything other than performance and memory usage.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141106 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-27Get rid of useless helper Sema::CastCategory.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140642 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-27PR11009: Fix a FIXME which was leading to an assertion failure with rvalue ↵Eli Friedman
references. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140594 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-26CheckStringInit has side effects; make sure we don't run it in VerifyOnly ↵Eli Friedman
mode, at least for the moment. <rdar://problem/10185490>. Sebastian, please take a look at this; I'm not entirely sure it is the right thing to do. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140552 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-26Fix a typo in the new VerifyOnly handling in SemaInit. No visible ↵Eli Friedman
difference at the moment, as far as I can tell. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140546 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-25Add a missing increment to avoid infinite looping in the regression test.Benjamin Kramer
Also make sure we set the error flag when correcting a typo. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140466 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-24Treat list-initialization of scalars as a first-class citizen in C++11.Sebastian Redl
Allow empty initializer lists for scalars, which mean value-initialization. Constant evaluation for single-element and empty initializer lists for scalars. Codegen for empty initializer lists for scalars. Test case comes in next commit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140459 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-24Give InitListChecker a verification-only mode, where it neither emits ↵Sebastian Redl
diagnostics nor builds a semantic (structured) initializer list, just reports on whether it can match the given list to the target type. Use this mode for doing init list checking in the initial step of initialization, which will eventually allow us to do overload resolution based on the outcome. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140457 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-24In Initialization, add step kind SK_ListConstructorCall (list-initializationSebastian Redl
resolves to a constructor call in C++11) and failure kind FK_ListInitializationFailed (early InitListChecker run failed). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140456 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-24Inline Sema::CheckInitList into its only user.Sebastian Redl
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140455 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-24Fix typos and non-doxygen-ness in a few comments.Sebastian Redl
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140454 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-23Switch assert(0/false) llvm_unreachable.David Blaikie
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140367 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-19Add list initialization for complex numbers in C. Essentially, this allows ↵Eli Friedman
"_Complex float x = {1.0f, 2.0f};". See changes to docs/LanguageExtensions.html for a longer description. <rdar://problem/9397672>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140090 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-17Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear ↵Francois Pichet
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139987 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-10Rename the ARC cast kinds to start with "ARC".John McCall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139466 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01Extend the self-reference warning to catch when a constructor references ↵Richard Trieu
itself upon initialization, such as using itself within its own copy constructor. struct S {}; S s(s); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138969 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30Fix PR10694: Boolean conversions can be from pointers, and those conversionsJeffrey Yasskin
aren't considered narrowing conversions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138838 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-29Print 'int' instead of 'const int' in the narrowing conversion error, since theJeffrey Yasskin
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138735 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23Refactor and fix checking for initialization of flexible array members. The ↵Eli Friedman
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138398 91177308-0d34-0410-b5e6-96231b3b80d8