OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [obj-c++.dg/] [private-1.mm] - Diff between revs 308 and 338

Only display areas with differences | Details | Blame | View Log

Rev 308 Rev 338
/* Test errors for accessing @private and @protected variables.  */
/* Test errors for accessing @private and @protected variables.  */
/* Based on work by: Nicola Pero .  */
/* Based on work by: Nicola Pero .  */
/* { dg-do compile } */
/* { dg-do compile } */
#include 
#include 
@interface MySuperClass
@interface MySuperClass
{
{
@private
@private
  int _private;
  int _private;
@protected
@protected
  int _protected;
  int _protected;
@public
@public
  int _public;
  int _public;
}
}
- (void) test;
- (void) test;
@end
@end
@implementation MySuperClass
@implementation MySuperClass
- (void) test
- (void) test
{
{
  _private = 12;   /* Ok  */
  _private = 12;   /* Ok  */
  _protected = 12; /* Ok  */
  _protected = 12; /* Ok  */
  _public = 12;    /* Ok  */
  _public = 12;    /* Ok  */
}
}
@end
@end
@interface MyClass : MySuperClass
@interface MyClass : MySuperClass
@end
@end
@implementation MyClass
@implementation MyClass
- (void) test
- (void) test
{
{
  /* Private variables simply don't exist in the subclass.  */
  /* Private variables simply don't exist in the subclass.  */
  _private = 12; /* { dg-error "._private. was not declared in this scope" } */
  _private = 12; /* { dg-error "._private. was not declared in this scope" } */
  _protected = 12; /* Ok  */
  _protected = 12; /* Ok  */
  _public = 12;    /* Ok  */
  _public = 12;    /* Ok  */
}
}
@end
@end
int main (void)
int main (void)
{
{
  MyClass *m = nil;
  MyClass *m = nil;
  if (m != nil)
  if (m != nil)
    {
    {
      int access;
      int access;
      access = m->_private;   /* { dg-error "is @private" }  */
      access = m->_private;   /* { dg-error "is @private" }  */
      access = m->_protected; /* { dg-error "is @protected" }  */
      access = m->_protected; /* { dg-error "is @protected" }  */
      access = m->_public;    /* Ok  */
      access = m->_public;    /* Ok  */
    }
    }
  return 0;
  return 0;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.