summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/new-delete.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [c++20] Implement P1009R2: allow omitting the array bound in an arrayRichard Smith2019-05-061-2/+22
| | | | | | | | | | new expression. This was voted into C++20 as a defect report resolution, so we retroactively apply it to all prior language modes (though it can never actually be used before C++11 mode). llvm-svn: 360006
* Switch to gnu++14 as the default dialect.Tim Northover2017-12-091-5/+21
| | | | | | This is C++14 with conforming GNU extensions. llvm-svn: 320250
* [Test] Make Lit tests C++11 compatible #9Charles Li2017-02-241-9/+62
| | | | | | | | [Test] Make Lit tests C++11 compatible #9 Differential Revision: https://reviews.llvm.org/D20710 llvm-svn: 296184
* Warn when a reference is bound to an empty l-value (dereferenced null pointer).Nick Lewycky2016-05-141-2/+2
| | | | llvm-svn: 269572
* For variables with dependent type, don't crash on `var->::new` or `var->__super`Nico Weber2015-02-161-0/+8
| | | | | | | | | | | | | | | | | | | | | ParsePostfixExpressionSuffix() for '->' (or '.') postfixes first calls ActOnStartCXXMemberReference() to inform sema that a member reference is about to start, and that function lets the parser know if sema thinks that the base expression's type could allow a pseudo destructor from a semantic point of view (for example, if the the base expression has a dependent type). ParsePostfixExpressionSuffix() then calls ParseOptionalCXXScopeSpecifier() and passes MayBePseudoDestructor on to that function, expecting the function to set it to false if a pseudo destructor is impossible from a syntactic point of view (due to a lack of '~' sigil). However, ParseOptionalCXXScopeSpecifier() had early-outs for ::new and __super, so MayBePseudoDestructor stayed true, so we tried to parse a pseudo dtor, and then became confused since we couldn't find a '~'. Move the snippet in ParseOptionalCXXScopeSpecifier() that sets MayBePseudoDestructor to false above the early exits. Parts of this found by SLi's bot. llvm-svn: 229449
* Fix crash declaring global allocation function with zero parameters. Fixes ↵Nick Lewycky2014-06-071-0/+3
| | | | | | PR19968! llvm-svn: 210388
* PR18544: don't assert that 'operator new' is not declared inside a namespace;Richard Smith2014-01-191-0/+4
| | | | | | such an assert will fail in invalid code that does so! llvm-svn: 199617
* Issue a warning if a throwing operator new or operator new[] returns a nullRichard Smith2014-01-171-1/+1
| | | | | | | | pointer, since this invokes undefined behavior. Based on a patch by Artyom Skrobov! Handling of dependent exception specifications and some additional testcases by me. llvm-svn: 199452
* If a replaceable global operator new/delete is marked inline, don't warn ifRichard Smith2013-11-161-2/+7
| | | | | | | it's also __attribute__((used)), since that undoes the problematic part of 'inline'. llvm-svn: 194916
* Downgrade the Error on an 'inline' operator new or delete to an ExtWarn. SomeRichard Smith2013-11-161-1/+1
| | | | | | | projects are relying on such (questionable) practices, so we should give them a way to opt out of this diagnostic. llvm-svn: 194905
* Be more precise when diagnosing 'inline' on global replacement functionsDavid Majnemer2013-10-211-1/+1
| | | | llvm-svn: 193061
* Sema: Diagnose global replacement functions declared as inlineDavid Majnemer2013-10-201-0/+2
| | | | | | | | | | | This fixes PR17591. N.B. This actually goes beyond what the standard mandates by requiring the restriction to hold for declarations instead of definitions. This is believed to be a defect in the standard and an LWG issue has been submitted. llvm-svn: 193044
* Fix some confusing diagnostic wording. s/implicit default/implicit/ if we'reRichard Smith2013-06-131-2/+2
| | | | | | not actually talking about a default constructor. llvm-svn: 183885
* Refactor places which perform contextual implicit conversions to go through aRichard Smith2013-05-211-2/+2
| | | | | | | | | | | | | common function. The C++1y contextual implicit conversion rules themselves are not yet implemented, however. This also fixes a subtle bug where template instantiation context notes were dropped for diagnostics coming from conversions for integral constant expressions -- we were implicitly slicing a SemaDiagnosticBuilder into a DiagnosticBuilder when producing these diagnostics, and losing their context notes in the process. llvm-svn: 182406
* Add missing check for error return from DefaultLvalueConversion. Fixes ↵Eli Friedman2012-12-131-0/+11
| | | | | | <rdar://problem/12857416>. llvm-svn: 170056
* Disambiguation of '[[':Richard Smith2012-04-101-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * In C++11, '[[' is ill-formed unless it starts an attribute-specifier. Reject array sizes and array indexes which begin with a lambda-expression. Recover by parsing the lambda as a lambda. * In Objective-C++11, either '[' could be the start of a message-send. Fully disambiguate this case: it turns out that the grammars of message-sends, lambdas and attributes do not actually overlap. Accept any occurrence of '[[' where either '[' starts a message send, but reject a lambda in an array index just like in C++11 mode. Implement a couple of changes to the attribute wording which occurred after our attributes implementation landed: * In a function-declaration, the attributes go after the exception specification, not after the right paren. * A reference type can have attributes applied. * An 'identifier' in an attribute can also be a keyword. Support for alternative tokens (iso646 keywords) in attributes to follow. And some bug fixes: * Parse attributes after declarator-ids, even if they are not simple identifiers. * Do not accept attributes after a parenthesized declarator. * Accept attributes after an array size in a new-type-id. * Partially disamiguate 'delete' followed by a lambda. More work is required here for the case where the lambda-introducer is '[]'. llvm-svn: 154369
* Fix parsing of type-specifier-seq's. Types are syntactically allowed to beRichard Smith2012-03-121-1/+1
| | | | | | | | | | | | | | | | | | defined here, but not semantically, so new struct S {}; is always ill-formed, even if there is a struct S in scope. We also had a couple of bugs in ParseOptionalTypeSpecifier caused by it being under-loved (due to it only being used in a few places) so merge it into ParseDeclarationSpecifiers with a new DeclSpecContext. To avoid regressing, this required improving ParseDeclarationSpecifiers' diagnostics in some cases. This also required teaching ParseSpecifierQualifierList about constexpr... which incidentally fixes an issue where we'd allow the constexpr specifier in other bad places. llvm-svn: 152549
* Throw away stray CXXDefaultArgExprs. Fixes PR12061.Sebastian Redl2012-02-221-0/+40
| | | | | | I think there's a deeper problem here in the way TransformCXXConstructExpr works, but I won't tackle it now. llvm-svn: 151146
* Don't allow non-empty ParenListExprs as array-new initializers.Sebastian Redl2012-02-171-0/+14
| | | | | | Don't know what I was thinking there. Fixes PR12023. llvm-svn: 150804
* Revert "Revert "Make CXXNewExpr contain only a single initialier, and not ↵Sebastian Redl2012-02-161-0/+29
| | | | | | | | hold the used constructor itself."" This reintroduces commit r150682 with a fix for the Bullet benchmark crash. llvm-svn: 150685
* In C++11 mode, when an integral constant expression is desired and we have aRichard Smith2012-02-041-3/+3
| | | | | | | | | | | | | | | | | | value of class type, look for a unique conversion operator converting to integral or unscoped enumeration type and use that. Implements [expr.const]p5. Sema::VerifyIntegerConstantExpression now performs the conversion and returns the converted result. Some important callers of Expr::isIntegralConstantExpr have been switched over to using it (including all of those required for C++11 conformance); this switch brings a side-benefit of improved diagnostics and, in several cases, simpler code. However, some language extensions and attributes have not been moved across and will not perform implicit conversions on constant expressions of literal class type where an ICE is required. In passing, fix static_assert to perform a contextual conversion to bool on its argument. llvm-svn: 149776
* Don't allow a value of a scoped enumeration to be used as the first bound for anRichard Smith2012-02-041-2/+2
| | | | | | | array new expression. This lays some groundwork for the implicit conversion to integral or unscoped enumeration which C++11 ICEs undergo. llvm-svn: 149772
* Fix a rejects-valid in C++11: array new of a negative size, or overflowing arrayRichard Smith2012-02-041-1/+2
| | | | | | | | | | | | | | | | | new, is well-formed with defined semantics of throwing (a type which can be caught by a handler for) std::bad_array_new_length, unlike in C++98 where it is somewhere nebulous between undefined behavior and ill-formed. If the array size is an integral constant expression and satisfies one of these criteria, we would previous the array new expression, but now in C++11 mode, we merely issue a warning (the code is still rejected in C++98 mode, naturally). We don't yet implement new C++11 semantics correctly (see PR11644), but we do implement the overflow checking, and (for the default operator new) convert such expressions to an exception, so accepting such code now does not seem especially unsafe. llvm-svn: 149767
* Re-fix r136172 so it isn't an error; apparently, some people are fond of ↵Eli Friedman2011-07-261-1/+1
| | | | | | their undefined behavior. llvm-svn: 136183
* Diagnose trying to delete a pointer to an abstract class with a non-virtual ↵Eli Friedman2011-07-261-0/+7
| | | | | | | | destructor. PR10504. I'm not completely sure the standard allows us to reject this, but if it doesn't, it should. :) llvm-svn: 136172
* A couple minor issues with Sema for delete:Eli Friedman2011-07-261-0/+12
| | | | | | | | | 1. Attempting to delete an expression of incomplete class type should be an error, not a warning. 2. If someone tries to delete a pointer to an incomplete class type, make sure we actually emit the delete expression after we warn. llvm-svn: 136161
* Enforce access control for the destructor in a new[] expression and markJohn McCall2011-07-131-0/+8
| | | | | | | it as used. Otherwise, we can fail to instantiate or validate the destructor, which can lead to crashes in IR gen like PR10351. llvm-svn: 135073
* Implement access checking for the "delete" operator. Fixes PR9050,Douglas Gregor2011-02-011-0/+11
| | | | | | from Alex Miller! llvm-svn: 124663
* Make this error less specific but also less likely to cause confusion. FixesNick Lewycky2010-11-031-2/+8
| | | | | | PR7702. llvm-svn: 118181
* The paired 'operator delete' for a placement 'operator new' is always aJohn McCall2010-09-141-0/+18
| | | | | | | placement 'operator delete', even if there are no placement args (i.e. overload resolution selected an operator new with default arguments). llvm-svn: 113861
* make clang print types as "const int *" instead of "int const*",Chris Lattner2010-09-051-1/+1
| | | | | | | which is should have done from the beginning. As usual, the most fun with this sort of change is updating all the testcases. llvm-svn: 113090
* Improve wording of diagnostic complaining about a non-void* pointer as the ↵Douglas Gregor2010-08-271-0/+10
| | | | | | first parameter of operator delete llvm-svn: 112298
* Fix a crash on template delete operators.Chandler Carruth2010-08-081-0/+12
| | | | llvm-svn: 110542
* Remove a redundant and broken check. Fixes PR7810.Sebastian Redl2010-08-051-0/+11
| | | | llvm-svn: 110294
* When deleting a value of class type, make sure that type is completeDouglas Gregor2010-07-291-0/+11
| | | | | | before looking for conversions to pointer type. Fixes <rdar://problem/8248780>. llvm-svn: 109749
* Downgrade the "when type is in parentheses, array cannot have dynamicDouglas Gregor2010-07-131-1/+23
| | | | | | | | | | | | size" error for code like new (int [size]) to a warning, add a Fix-It to remove the parentheses, and make this diagnostic work properly when it occurs in a template instantiation. <rdar://problem/8018245>. llvm-svn: 108242
* Implement C++ DR299, which allows an implicit conversion from a classDouglas Gregor2010-06-301-0/+1
| | | | | | | | | | | type to an integral or enumeration type in the size of an array new expression, e.g., new int[ConvertibleToInt(10)]; This is a GNU and C++0x extension. llvm-svn: 107229
* Suppress diagnosing access violations while looking up deallocation functionsChandler Carruth2010-06-281-0/+24
| | | | | | | | | much as we already do for allocation function lookup. Explicitly check access for the function we actually select in one case that was previously missing, but being caught behind the blanket diagnostics for all overload candidates. This fixs PR7436. llvm-svn: 106986
* Downgrade deletion of a void* from an error (which is should be) to anDouglas Gregor2010-05-241-1/+1
| | | | | | | extension warning (which other compilers seem to use). Works around a known bug in Xalan. llvm-svn: 104509
* Correctly diagnose array 'new' with initialization arguments when the new ↵Anders Carlsson2010-05-161-0/+3
| | | | | | type is a typedef to an array type. llvm-svn: 103909
* When the type-id or new-type-id of a C++ "new" expression is a typedefDouglas Gregor2010-05-161-0/+10
| | | | | | | of an array type, use the outermost array bound as the number of elements to allocate. Fixes PR7147. llvm-svn: 103908
* The array form of 'new' can never have initializers.Anders Carlsson2010-05-031-1/+20
| | | | llvm-svn: 102917
* Turn access control on by default in -cc1.John McCall2010-04-091-0/+2
| | | | | | | | Remove -faccess-control from -cc1; add -fno-access-control. Make the driver pass -fno-access-control by default. Update a bunch of tests to be correct under access control. llvm-svn: 100880
* When pretty-printing tag types, only print the tag if we're in C (andJohn McCall2010-03-101-6/+6
| | | | | | | | | | therefore not creating ElaboratedTypes, which are still pretty-printed with the written tag). Most of these testcase changes were done by script, so don't feel too sorry for my fingers. llvm-svn: 98149
* Do not try to instantiate invalid declarations. It's a recipe forDouglas Gregor2010-02-161-4/+2
| | | | | | disaster. Fixes PR6161. llvm-svn: 96371
* Ensure that a operator delete overload is rocognized regardless of cv-quals.Chandler Carruth2010-02-081-0/+8
| | | | llvm-svn: 95553
* Teach the allocation function overload handling to deal with templates, andChandler Carruth2010-02-031-0/+7
| | | | | | | | | | | prevent a crash on templates when looking for an existing declaration of the predefined global operators. This fixes PR5918. Added an easy test case for the overload handling, but testing the crash is a bit trickier. Created a new test that can use multiple runs with a define to trigger which test case is used so we can test this type of issue. llvm-svn: 95220
* Fix the EntityKind order so that all entity kinds that can be copied (using ↵Anders Carlsson2010-01-231-1/+1
| | | | | | copy constructors) come first. Also, fix a bug where EK_New was left out of the err_init_conversion_failed diagnostic (It is now reported as 'new value'). Please review Doug :) llvm-svn: 94289
* Allow the first parameter of operator new to be a cv-qualifiedDouglas Gregor2009-12-221-2/+2
| | | | | | | | size_t. Also, fix an issue with initialization of parameters in calls, where we weren't removing the cv-qualifiers on the parameter type itself. Fixes PR5823. llvm-svn: 91941
* Switch the C++ new expression over to InitializationSequence, ratherDouglas Gregor2009-12-161-5/+5
| | | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud