summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX
Commit message (Collapse)AuthorAgeFilesLines
* Have Sema::ActOnStartOfFunctionDef return the declaration that was passed it.Argyrios Kyrtzidis2012-12-141-2/+2
| | | | | | | | | | | | | | | | | | | | This fixes the missing warning here: struct S { template <typename T> void meth() { char arr[3]; arr[4] = 0; // warning: array index 4 is past the end of the array } }; template <typename T> void func() { char arr[3]; arr[4] = 0; // no warning } llvm-svn: 170180
* Using CanQualType::getAs<ArrayType> is unsafe; fix the code currently using it,Eli Friedman2012-12-131-0/+3
| | | | | | and make sure additional uses don't get introduced. <rdar://problem/12858424>. llvm-svn: 170081
* Add missing check for error return from DefaultLvalueConversion. Fixes ↵Eli Friedman2012-12-131-0/+11
| | | | | | <rdar://problem/12857416>. llvm-svn: 170056
* Virtual method overrides can no longer have mismatched calling conventions. ↵Aaron Ballman2012-12-092-0/+69
| | | | | | This fixes PR14339. llvm-svn: 169705
* Fix overload resolution for the initialization of a multi-dimensionalRichard Smith2012-12-092-1/+18
| | | | | | | | | | array from a braced-init-list. There seems to be a core wording wart here (it suggests we should be testing whether the elements of the init list are implicitly convertible to the array element type, not whether there is an implicit conversion sequence) but our prior behavior appears to be a bug, not a deliberate effort to implement the standard as written. llvm-svn: 169690
* Finish implementing 'selected constructor' rules for triviality in C++11. InRichard Smith2012-12-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | the cases where we can't determine whether special members would be trivial while building the class, we eagerly declare those special members. The impact of this is bounded, since it does not trigger implicit declarations of special members in classes which merely *use* those classes. In order to determine whether we need to apply this rule, we also need to eagerly declare move operations and destructors in cases where they might be deleted. If a move operation were supposed to be deleted, it would instead be suppressed, and we could need overload resolution to determine if we fall back to a trivial copy operation. If a destructor were implicitly deleted, it would cause the move constructor of any derived classes to be suppressed. As discussed on cxx-abi-dev, C++11's selected constructor rules are also retroactively applied as a defect resolution in C++03 mode, in order to identify that class B has a non-trivial copy constructor (since it calls A's constructor template, not A's copy constructor): struct A { template<typename T> A(T &); }; struct B { mutable A a; }; llvm-svn: 169673
* Thread-safety analysis: check member access on guarded non-primitive types.DeLesley Hutchins2012-12-081-1/+62
| | | | llvm-svn: 169669
* Properly compute triviality for explicitly-defaulted or deleted special members.Richard Smith2012-12-083-19/+23
| | | | | | | | | | | | | | Remove pre-standard restriction on explicitly-defaulted copy constructors with 'incorrect' parameter types, and instead just make those special members non-trivial as the standard requires. This required making CXXRecordDecl correctly handle classes which have both a trivial and a non-trivial special member of the same kind. This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the new triviality computation technology. llvm-svn: 169667
* clang/test: Remove "REQUIRES:LP64" in two tests. Each of them have explicit ↵NAKAMURA Takumi2012-12-071-1/+0
| | | | | | triple. llvm-svn: 169587
* Sema: Don't emit a warning when __func__ is used in a lambda outside of a ↵Benjamin Kramer2012-12-061-0/+4
| | | | | | | | function. Fixes PR14518. llvm-svn: 169510
* Don't use dyn_cast on a Type* which might not be canonical. Fixes an ↵Richard Smith2012-12-061-0/+15
| | | | | | extremely obscure record layout bug. llvm-svn: 169467
* Thread-safety analysis: check locks on method calls, operator=, andDeLesley Hutchins2012-12-051-1/+110
| | | | | | copy constructors. llvm-svn: 169350
* Make -Wtautological-constant-out-of-range-compare behave sanely for enums ↵Eli Friedman2012-11-301-1/+8
| | | | | | | | with a signed fixed type. <rdar://problem/12780159>. llvm-svn: 169051
* Reject uses of __int128 on platforms that don't support it. Also move the uglyRichard Smith2012-11-291-1/+1
| | | | | | | 'getPointerWidth(0) >= 64' test to be a method on TargetInfo, ready to be properly cleaned up. llvm-svn: 168856
* The declaration of a special member can require overload resolution to beRichard Smith2012-11-291-1/+68
| | | | | | | | | | | performed, to determine whether that special member is deleted or constexpr. That overload resolution process can in turn trigger the instantiation of a template, which can do anything, including triggering the declaration of that very same special member function. When this happens, do not try to recursively declare the special member -- that's impossible. Instead, only try to realise the truth. There is no special member. llvm-svn: 168847
* Per C++11 [except.spec]p2, rvalue references are not permitted in exception ↵Richard Smith2012-11-281-0/+2
| | | | | | specifications. llvm-svn: 168824
* PR14388: An array or function type in an exception specification should beRichard Smith2012-11-281-0/+23
| | | | | | | decayed to a pointer type. Patch by WenHan Gu, with a little tweaking and additional testcases by me. llvm-svn: 168822
* C++ core issue 1344, PR10618: promote "addition of default argument makes thisRichard Smith2012-11-282-15/+37
| | | | | | | | | | | | 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). llvm-svn: 168769
* Add a basic testcase for the "variable is not needed" warning and one thatRafael Espindola2012-11-251-0/+27
| | | | | | regressed in r168519. llvm-svn: 168563
* When adding a NamedDecl to a correction, add the underlying Decl (viaKaelyn Uhrain2012-11-191-0/+14
| | | | | | | | getUnderlyingDecl()) so that derivatives of CorrectionCandidateCallback::ValidateCandidate(...) don't have to worry about being thrown by UsingDecls and such. llvm-svn: 168317
* Take into account the zero sign bit for positive numbers when computing the bitRichard Trieu2012-11-161-0/+10
| | | | | | | width of an enum with negative values in IntRange. Include a test for -Wtautological-constant-out-of-range-compare where this had manifested. llvm-svn: 168126
* Teach the uninitialized field warning about anonymous structs and union members.Nick Lewycky2012-11-151-0/+6
| | | | | | Fixes PR14073! llvm-svn: 168031
* Fix an off-by-one error by switching < to <= in ↵Richard Trieu2012-11-151-0/+1
| | | | | | -Wtautological-constant-out-of-range-compare and added test case. llvm-svn: 168023
* Per [basic.lookup.classref]p3, in an expression of the form p->~type-name, theRichard Smith2012-11-152-1/+11
| | | | | | | | | | 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. llvm-svn: 168011
* Improve -Wtautological-constant-out-of-range-compare by taking into accountRichard Trieu2012-11-141-0/+114
| | | | | | | | | 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. llvm-svn: 167992
* In ExpressionEvaluationContextRecord manage LambdaMangle with a sharedArgyrios Kyrtzidis2012-11-141-0/+43
| | | | | | | | | pointer, otherwise we will double free it when ExpressionEvaluationContextRecord gets copied. Fixes crash in rdar://12645424 & http://llvm.org/PR14252 llvm-svn: 167946
* Provide the correct mangling and linkage for certain unnamed nested classes.David Blaikie2012-11-141-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 167906
* For classes that have the warn_unused_result attribute, don't apply theKaelyn Uhrain2012-11-131-0/+6
| | | | | | | attribute to the class' methods even when they return an instance of the class (e.g. assignment operators). llvm-svn: 167873
* A couple of small fixes to r167783Kaelyn Uhrain2012-11-131-1/+1
| | | | llvm-svn: 167791
* Enable C++11 attribute syntax for warn_unused_result and allow it to beKaelyn Uhrain2012-11-121-1/+31
| | | | | | | | | | | | | 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. llvm-svn: 167783
* Per discussion on cfe-dev, re-enable suppression of -Wimplicit-fallthrough ↵Ted Kremenek2012-11-121-0/+3
| | | | | | | | | | | | | | 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. llvm-svn: 167749
* Don't crash on calling static member overloaded operator, PR14120Nico Weber2012-11-091-0/+10
| | | | | | Patch from Brian Brooks! llvm-svn: 167604
* Fix a bug I found while preparing my devmtg talk: When passing NULL to aMatt Beaumont-Gay2012-11-081-0/+21
| | | | | | | | | | | | 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. llvm-svn: 167596
* PR14284: crash on ext-valid returning NULL from a void functionDavid Blaikie2012-11-081-0/+2
| | | | llvm-svn: 167565
* PR12713 - crash on invalid due to unmatched parens in decltypeDavid Blaikie2012-11-071-0/+7
| | | | llvm-svn: 167547
* PR11851 (and duplicates): Whenever a constexpr function is referenced,Richard Smith2012-11-072-9/+7
| | | | | | | | | 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. llvm-svn: 167514
* Fix assertion failure with auto and nested initializer list; PR14272.Eli Friedman2012-11-061-0/+4
| | | | llvm-svn: 167506
* Teach Clang parser to reject C++11 attributes that appertain to declaration ↵Michael Han2012-11-061-1/+1
| | | | | | | | | 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. llvm-svn: 167481
* Delete comment I forgot to delete in my last change.Nico Weber2012-11-051-2/+0
| | | | llvm-svn: 167418
* Use Richard's BE_THE_HEADER trick to simplify a test. No intended behavior ↵Nico Weber2012-11-052-95/+53
| | | | | | change. llvm-svn: 167417
* Thread safety analysis: Fixed ICE caused by double delete when late parsedDeLesley Hutchins2012-11-021-0/+22
| | | | | | attributes are attached to function declarations nested inside a class method. llvm-svn: 167321
* Change diagnostics for enums with fixed underlying type so in C++98 mode, we ↵Eli Friedman2012-11-021-3/+3
| | | | | | cite C++11. llvm-svn: 167273
* Fix an incorrect assert, the LHS can be an LValue.Rafael Espindola2012-11-011-0/+12
| | | | llvm-svn: 167232
* Correctly reject gotos in function-level try blocks. PR14225.Eli Friedman2012-10-311-2/+16
| | | | llvm-svn: 167184
* Update test case.Ted Kremenek2012-10-301-1/+1
| | | | llvm-svn: 167005
* Partially roll back r166898; it exposed a bug in the standard.Richard Smith2012-10-291-4/+23
| | | | | | | | | | | | | 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. llvm-svn: 166956
* Revert functional part of r166896 and just suppress ↵Richard Smith2012-10-281-2/+3
| | | | | | -Wunneeded-internal-declaration for reference types for now. This needs more work; the cases we currently miss are a bit random. llvm-svn: 166899
* When determining whether to try evaluating the initializer of a variable, checkRichard Smith2012-10-282-1/+20
| | | | | | | | | 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. llvm-svn: 166898
* In -Wunneeded-internal-declaration, suppress the warning for variables whichRichard Smith2012-10-281-1/+14
| | | | | | | | 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'. llvm-svn: 166896
* Fix invalid jump scopes again. This time without trying to find out if anRafael Espindola2012-10-281-0/+58
| | | | | | incomplete type has a destructor or not. llvm-svn: 166895
OpenPOWER on IntegriCloud