ivars.c: Add a check for classes without instance variables...

2015-01-09  Dimitris Papavasiliou  <dpapavas@gmail.com>

	* ivars.c: Add a check for classes without instance
	variables, which have a NULL ivar list pointer.

2015-01-09  Dimitris Papavasiliou  <dpapavas@gmail.com>

	* objc.dg/gnu-api-2-class.m: Add a test case
	for the above change.

From-SVN: r219396
This commit is contained in:
Dimitris Papavasiliou 2015-01-09 17:55:57 +00:00 committed by Mike Stump
parent d2286af3d3
commit 100bfe4a97
4 changed files with 24 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2015-01-09 Dimitris Papavasiliou <dpapavas@gmail.com>
* objc.dg/gnu-api-2-class.m: Add a test case
for the above change.
2015-01-09 Sebastian Huber <sebastian.huber@embedded-brains.de>
* gcc.dg/typeof-2.c: Add checks for non-atomic types.

View File

@ -239,6 +239,19 @@ int main(int argc, void **args)
abort ();
}
printf ("Testing class_copyIvarList () on class with no instance variables...\n");
{
unsigned int count;
Ivar * list = class_copyIvarList (objc_getClass ("MyOtherSubClass"),
&count);
if (count != 0)
abort ();
if (list != NULL)
abort ();
}
printf ("Testing class_copyMethodList ()...\n");
{
unsigned int count;

View File

@ -1,3 +1,8 @@
2015-01-09 Dimitris Papavasiliou <dpapavas@gmail.com>
* ivars.c: Add a check for classes without instance
variables, which have a NULL ivar list pointer.
2015-01-05 Jakub Jelinek <jakub@redhat.com>
Update copyright years.

View File

@ -179,7 +179,7 @@ struct objc_ivar ** class_copyIvarList (Class class_, unsigned int *numberOfRetu
struct objc_ivar **returnValue = NULL;
struct objc_ivar_list* ivar_list;
if (class_ == Nil || CLS_IS_IN_CONSTRUCTION (class_))
if (class_ == Nil || CLS_IS_IN_CONSTRUCTION (class_) || !class_->ivars)
{
if (numberOfReturnedIvars)
*numberOfReturnedIvars = 0;