Commit Graph

52 Commits

Author SHA1 Message Date
John McCall d3be2c83d5 The paired 'operator delete' for a placement 'operator new' is always a
placement 'operator delete', even if there are no placement args (i.e.
overload resolution selected an operator new with default arguments).

llvm-svn: 113861
2010-09-14 21:34:24 +00:00
Chris Lattner 53fa04909c make clang print types as "const int *" instead of "int const*",
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
2010-09-05 00:04:01 +00:00
Douglas Gregor 7bddb3cac3 Improve wording of diagnostic complaining about a non-void* pointer as the first parameter of operator delete
llvm-svn: 112298
2010-08-27 21:39:15 +00:00
Chandler Carruth 9b41823177 Fix a crash on template delete operators.
llvm-svn: 110542
2010-08-08 07:04:00 +00:00
Sebastian Redl e0351b970d Remove a redundant and broken check. Fixes PR7810.
llvm-svn: 110294
2010-08-05 00:45:34 +00:00
Douglas Gregor f65f490ae9 When deleting a value of class type, make sure that type is complete
before looking for conversions to pointer type. Fixes <rdar://problem/8248780>.

llvm-svn: 109749
2010-07-29 14:44:35 +00:00
Douglas Gregor f2753b3b4e Downgrade the "when type is in parentheses, array cannot have dynamic
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
2010-07-13 15:54:32 +00:00
Douglas Gregor 4799d03ce8 Implement C++ DR299, which allows an implicit conversion from a class
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
2010-06-30 00:20:43 +00:00
Chandler Carruth b6f991787b Suppress diagnosing access violations while looking up deallocation functions
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
2010-06-28 00:30:51 +00:00
Douglas Gregor bb3348ed33 Downgrade deletion of a void* from an error (which is should be) to an
extension warning (which other compilers seem to use). Works around a
known bug in Xalan.

llvm-svn: 104509
2010-05-24 17:01:56 +00:00
Anders Carlsson e6ae81b0a2 Correctly diagnose array 'new' with initialization arguments when the new type is a typedef to an array type.
llvm-svn: 103909
2010-05-16 16:24:20 +00:00
Douglas Gregor cda95f47e5 When the type-id or new-type-id of a C++ "new" expression is a typedef
of an array type, use the outermost array bound as the number of
elements to allocate. Fixes PR7147.

llvm-svn: 103908
2010-05-16 16:01:03 +00:00
Anders Carlsson c6bb0e117f The array form of 'new' can never have initializers.
llvm-svn: 102917
2010-05-03 15:45:23 +00:00
John McCall 3155f573f5 Turn access control on by default in -cc1.
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
2010-04-09 19:03:51 +00:00
John McCall 85f9055955 When pretty-printing tag types, only print the tag if we're in C (and
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
2010-03-10 11:27:22 +00:00
Douglas Gregor 71ad477ab3 Do not try to instantiate invalid declarations. It's a recipe for
disaster. Fixes PR6161.

llvm-svn: 96371
2010-02-16 19:28:15 +00:00
Chandler Carruth 75cc359fdc Ensure that a operator delete overload is rocognized regardless of cv-quals.
llvm-svn: 95553
2010-02-08 18:54:05 +00:00
Chandler Carruth 935384217d Teach the allocation function overload handling to deal with templates, and
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
2010-02-03 11:02:14 +00:00
Anders Carlsson 8e01dcf6f6 Fix the EntityKind order so that all entity kinds that can be copied (using 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
2010-01-23 05:47:27 +00:00
Douglas Gregor 684d7bdc43 Allow the first parameter of operator new to be a cv-qualified
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
2009-12-22 23:42:49 +00:00
Douglas Gregor 85dabae6ad Switch the C++ new expression over to InitializationSequence, rather
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
2009-12-16 01:38:02 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Anders Carlsson 7e0b207e54 More improvements to checking allocation and deallocation functions.
llvm-svn: 91244
2009-12-13 17:53:43 +00:00
Anders Carlsson c50b340108 Look through using declarations when searching for allocation overloads.
llvm-svn: 90961
2009-12-09 07:39:44 +00:00
Anders Carlsson 26a807d37a When we're trying to define an implicit virtual destructor, make sure that we have a valid delete operator.
llvm-svn: 90156
2009-11-30 21:24:50 +00:00
Eli Friedman 794d4d8127 Fix test on Linux.
llvm-svn: 88889
2009-11-16 05:14:40 +00:00
Anders Carlsson 2c9e274e57 If we find a deallocation function in the class scope, but it is a placement function we should not look for a deallocation function in the global scope.
llvm-svn: 88851
2009-11-15 16:43:15 +00:00
Anders Carlsson 654e5c7cf8 Diagnose ambiguity of operator delete and operator delete[]. Sebastian, please review.
llvm-svn: 88747
2009-11-14 03:17:38 +00:00
Fariborz Jahanian c3091c9118 Make test more platform independent (per Sebastian's comment).
llvm-svn: 86888
2009-11-11 22:45:41 +00:00
Fariborz Jahanian 4e088941ad Diagnose illegally typed operator new/new[].
llvm-svn: 86755
2009-11-10 23:47:18 +00:00
Sebastian Redl d7b3d7dd79 Remove the Skip parameter from GetTypeForDeclarator and dependents. Take the opportunity to improve an error message and fix PR4498.
llvm-svn: 85068
2009-10-25 21:45:37 +00:00
Douglas Gregor 80a6cc5800 Find operators new/delete in base classes. FIXME -= 2;
llvm-svn: 83119
2009-09-30 00:03:47 +00:00
Douglas Gregor 98496dc3eb The C++ delete expression strips cv-qualifiers from the pointed-to type. My previous fix eliminated this behavior, so bring it back again.
llvm-svn: 83113
2009-09-29 21:38:53 +00:00
Douglas Gregor bb3e12fc0b Handle C++ delete expressions when the overloaded delete operator is a
"usual deallocation function" with two arguments. CodeGen will have to
handle this case specifically, since the value for the second argument
(the size of the allocated object) may have to be computed at run
time.

Fixes the Sema part of PR4782.

llvm-svn: 83080
2009-09-29 18:16:17 +00:00
Anders Carlsson 8ab20bb144 Cast the array size expr to a size_t
llvm-svn: 82594
2009-09-23 00:37:25 +00:00
Fariborz Jahanian c34c179f4b Perform overload resolution when selecting a pointer conversion
function for delete of a class expression and issue
good diagnostic when result is ambiguous.

llvm-svn: 81870
2009-09-15 17:21:47 +00:00
Douglas Gregor 0fea62d0c7 For a C++ delete expression where the operand is of class type that
has a single conversion to pointer-to-object type, implicitly convert
to that pointer-to-object type (C++ [expr.delete]p1).

llvm-svn: 81401
2009-09-09 23:39:55 +00:00
Anders Carlsson 2418712039 Fix an off by one error when trying to perform copy initialization of operator new and operator delete arguments. Sebastian, please review.
llvm-svn: 72670
2009-05-31 19:49:47 +00:00
Sebastian Redl 4d226cf45f When there are any member new operators, global versions aren't looked up at all.
llvm-svn: 71780
2009-05-14 18:11:41 +00:00
Douglas Gregor ac1fb65d0c Make sure to use RequireCompleteType rather than testing for
incomplete types. RequireCompleteType is needed when the type may be
completed by instantiating a template.

llvm-svn: 67643
2009-03-24 19:52:54 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Sebastian Redl 1df2bbe7f9 Update new expression to make use of Declarator::getSourceRange().
References are not objects; implement this in Type::isObjectType().

llvm-svn: 64152
2009-02-09 18:24:27 +00:00
Sebastian Redl 2175b6a767 Make one expected-diag directive match exactly one actual diagnostic.
This uncovers some bugs, so several test cases now fail.

llvm-svn: 64025
2009-02-07 19:52:04 +00:00
Douglas Gregor dd430f7ec9 Centralize error reporting of improper uses of incomplete types in the
new DiagnoseIncompleteType. It provides additional information about
struct/class/union/enum types when possible, either by pointing to the
forward declaration of that type or by pointing to the definition (if
we're in the process of defining that type). 
Fixes <rdar://problem/6500531>.

llvm-svn: 62521
2009-01-19 19:26:10 +00:00
Sebastian Redl 33a3101d43 Code cleanup in new handling.
llvm-svn: 60557
2008-12-04 22:20:51 +00:00
Sebastian Redl f84512a360 Fix some diagnostics and enhance test cases. Now tests member new and ambiguous overloads.
llvm-svn: 60542
2008-12-04 17:24:46 +00:00
Sebastian Redl faf6808e7a Overload resolution for the operator new function. Member version is still untested.
llvm-svn: 60503
2008-12-03 20:26:15 +00:00
Sebastian Redl db36b9b962 Make the parser handle ::new and ::delete correctly.
llvm-svn: 60421
2008-12-02 16:35:44 +00:00
Sebastian Redl 351bb78a10 Handle new by passing the Declaration to the Action, not a processed type.
llvm-svn: 60413
2008-12-02 14:43:59 +00:00
Douglas Gregor 3ff3cf5f21 Test another error message, make sure to verify C++ new and delete tests
llvm-svn: 60007
2008-11-25 04:08:05 +00:00