aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX
AgeCommit message (Collapse)Author
2012-11-28C++ core issue 1344, PR10618: promote "addition of default argument makes thisRichard Smith
a special member" diagnostic from warning to error, and fix the cases where it produced diagnostics with incorrect wording. We don't support this as an extension, and we ban it even in C++98 mode. This breaks too much (for instance, the ABI-specified calling convention for a type can change if it acquires a copy constructor through the addition of a default argument). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168769 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-25Add a basic testcase for the "variable is not needed" warning and one thatRafael Espindola
regressed in r168519. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168563 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-19When adding a NamedDecl to a correction, add the underlying Decl (viaKaelyn Uhrain
getUnderlyingDecl()) so that derivatives of CorrectionCandidateCallback::ValidateCandidate(...) don't have to worry about being thrown by UsingDecls and such. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168317 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-16Take into account the zero sign bit for positive numbers when computing the bitRichard Trieu
width of an enum with negative values in IntRange. Include a test for -Wtautological-constant-out-of-range-compare where this had manifested. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168126 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15Teach the uninitialized field warning about anonymous structs and union members.Nick Lewycky
Fixes PR14073! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168031 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15Fix an off-by-one error by switching < to <= in ↵Richard Trieu
-Wtautological-constant-out-of-range-compare and added test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168023 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15Per [basic.lookup.classref]p3, in an expression of the form p->~type-name, theRichard Smith
type-name is looked up in the context of the complete postfix-expression. Don't forget to pass the scope into this lookup when the type-name is a template-id; it might name an alias template which can't be found within the class itself. Bug spotted by Johannes Schaub on #llvm. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168011 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14Improve -Wtautological-constant-out-of-range-compare by taking into accountRichard Trieu
type conversion between integers. This allows the warning to be more accurate. Also, turned the warning off in an analyzer test. The relavent test cases are covered by the tests in Sema. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167992 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14In ExpressionEvaluationContextRecord manage LambdaMangle with a sharedArgyrios Kyrtzidis
pointer, otherwise we will double free it when ExpressionEvaluationContextRecord gets copied. Fixes crash in rdar://12645424 & http://llvm.org/PR14252 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167946 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14Provide the correct mangling and linkage for certain unnamed nested classes.David Blaikie
This corrects the mangling and linkage of classes (& their member functions) in cases like this: struct foo { struct { void func() { ... } } x; }; we were accidentally giving this nested unnamed struct 'no' linkage where it should've had the linkage of the outer class. The mangling was incorrecty too, mangling as TU-wide unnamed type mangling of $_X rather than class-scoped mangling of UtX_. This also fixes -Wunused-member-function which would incorrectly diagnose 'func' as unused due to it having no linkage & thus appearing to be TU-local when in fact it might be correctly used in another TU. Similar mangling should be applied to function local classes in similar cases but I've deferred that for a subsequent patch. Review/discussion by Richard Smith, John McCall, & especially Eli Friedman. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167906 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13For classes that have the warn_unused_result attribute, don't apply theKaelyn Uhrain
attribute to the class' methods even when they return an instance of the class (e.g. assignment operators). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167873 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13A couple of small fixes to r167783Kaelyn Uhrain
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167791 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12Enable C++11 attribute syntax for warn_unused_result and allow it to beKaelyn Uhrain
applied to CXXRecordDecls, where functions with that return type will inherit the warn_unused_result attribute. Also includes a tiny fix (with no discernable behavior change for existing code) to re-sync AttributeDeclKind enum and err_attribute_wrong_decl_type with warn_attribute_wrong_decl_type since the enum is used with both diagnostic messages to chose the correct description. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167783 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-12Per discussion on cfe-dev, re-enable suppression of -Wimplicit-fallthrough ↵Ted Kremenek
on C, but also include dialects of C++ earlier than C++11. There was enough consensus that we *can* get a good language solution to have an annotation outside of C++11, and without this annotation this warning doesn't quite mean's completeness criteria for this kind of warning. For now, restrict this warning to C++11 (where an annotation exists), and make this the behavior for the LLVM 3.2 release. Afterwards, we will hammer out a language solution that we are all happy with. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167749 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-09Don't crash on calling static member overloaded operator, PR14120Nico Weber
Patch from Brian Brooks! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167604 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-08Fix a bug I found while preparing my devmtg talk: When passing NULL to aMatt Beaumont-Gay
function that takes a const Foo&, where Foo is convertible from a large number of pointer types, we print ALL the overloads, no matter the setting of -fshow-overloads. There is potential follow-on work in unifying the "print candidates, but not too many" logic between OverloadCandidateSet::NoteCandidates and ImplicitConversionSequence::DiagnoseAmbiguousConversion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167596 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-08PR14284: crash on ext-valid returning NULL from a void functionDavid Blaikie
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167565 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-07PR12713 - crash on invalid due to unmatched parens in decltypeDavid Blaikie
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167547 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-07PR11851 (and duplicates): Whenever a constexpr function is referenced,Richard Smith
instantiate it if it can be instantiated and implicitly define it if it can be implicitly defined. This matches g++'s approach. Remove some cases from SemaOverload which were marking functions as referenced when just planning how overload resolution would proceed; such cases are not actually references. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167514 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-06Fix assertion failure with auto and nested initializer list; PR14272.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167506 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-06Teach Clang parser to reject C++11 attributes that appertain to declaration ↵Michael Han
specifiers. We don't support any C++11 attributes that appertain to declaration specifiers so reject the attributes in parser until we support them; this also conforms to what g++ 4.8 is doing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167481 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-05Delete comment I forgot to delete in my last change.Nico Weber
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167418 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-05Use Richard's BE_THE_HEADER trick to simplify a test. No intended behavior ↵Nico Weber
change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167417 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-02Thread safety analysis: Fixed ICE caused by double delete when late parsedDeLesley Hutchins
attributes are attached to function declarations nested inside a class method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167321 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-02Change diagnostics for enums with fixed underlying type so in C++98 mode, we ↵Eli Friedman
cite C++11. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167273 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-01Fix an incorrect assert, the LHS can be an LValue.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167232 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-31Correctly reject gotos in function-level try blocks. PR14225.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167184 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-30Update test case.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167005 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-29Partially roll back r166898; it exposed a bug in the standard.Richard Smith
The problem is as follows: C++11 has contexts which are not potentially-evaluated, and yet in which we are required or encouraged to perform constant evaluation. In such contexts, we are not permitted to implicitly define special member functions for literal types, therefore we cannot evalaute those constant expressions. Punt on this in one more context for now by skipping checking constexpr variable initializers if they occur in dependent contexts. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166956 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-28Revert functional part of r166896 and just suppress ↵Richard Smith
-Wunneeded-internal-declaration for reference types for now. This needs more work; the cases we currently miss are a bit random. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166899 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-28When determining whether to try evaluating the initializer of a variable, checkRichard Smith
whether the initializer is value-dependent rather than whether we are in a dependent context. This allows us to detect some errors sooner, and fixes a crash-on-invalid if a dependent type leaks out to a non-dependent context in error recovery. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166898 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-28In -Wunneeded-internal-declaration, suppress the warning for variables whichRichard Smith
might have been used in constant expressions, rather than suppressing it for variables which are const. The important thing here is that such variables can have their values used without actually being marked as 'used'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166896 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-28Fix invalid jump scopes again. This time without trying to find out if anRafael Espindola
incomplete type has a destructor or not. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166895 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-28Add a testcase from the previous bootstrap problem.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166894 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-27Revert 166876 while I debug a bootstrap problem.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166878 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-27Reapply 166855 with an early exit on null QualTypes.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166876 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-27Add a reduced testcase of the last bootstrap failure.Rafael Espindola
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166866 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-27Revert r166855. I can reproduce the bootstrap failure and have a testcaseRafael Espindola
to reduce. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166863 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-27Add a test case for the stack overflow in rdar://12542261Argyrios Kyrtzidis
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166858 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-27Fix cases where we were not producing an error when a computed goto couldRafael Espindola
jump over destructor calls. Fixes pr13812. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166855 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-26In Parser::ParseDecltypeSpecifier, make sure the end location it returnsArgyrios Kyrtzidis
is at the end of parsed tokens when an error occurs, otherwise we'll hit an assertion when trying to annotate the decltype tokens. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166826 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24PR14171: Don't crash if we hit one of the paths where GetFullTypeForDeclaratorRichard Smith
rebuilds a function type, and that function type has parens around its name. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166644 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24Fix false positive in -Wunused-variable when a ctor call make involve cleanups.David Blaikie
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166625 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24Update regression tests for r166617.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166619 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24Don't print scope qualifiers for references to a type defined locally in a ↵Eli Friedman
function. Patch by Grzegorz Jablonski. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166617 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24Add an additional test for namespaces and -Wmissing-variable-declarations. ↵Eli Friedman
Move C++ test into SemaCXX. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166616 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24Add a test showing that nodebug is accepted in methods too. Patch byRafael Espindola
Paul Robinson. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166606 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23Fix pretty-printing pseudo-destructor calls. Patch by Grzegorz Jablonski.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166500 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23Fix -Wunused-value to not warn on expressions that have unresolved lookups dueMatt Beaumont-Gay
to dependent arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166468 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23Ugly ugly hack for libstdc++-4.6 and libstdc++-4.7 compatibility. TheseRichard Smith
libraries have an incorrect definition of std::common_type (inherited from a bug in the standard -- see LWG issue 2141), whereby they produce reference types when they should not. If we instantiate a typedef named std::common_type<...>::type, which is defined in a system header as decltype(... ? ... : ...), and the decltype produces a reference type, convert it to the non-reference type. (This doesn't affect any LWG2141-conforming implementation of common_type, such as libc++'s, because the default implementation of common_type<...>::type isn't supposed to produce a reference type.) This is horrible. I'm really sorry. :( Better ideas appreciated! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166455 91177308-0d34-0410-b5e6-96231b3b80d8