OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc.dg/] [private-2.m] - Blame information for rev 324

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 309 jeremybenn
/* Test warnings for shadowing instance variables.  */
2
/* Author: Nicola Pero <nicola@brainstorm.co.uk>.  */
3
/* { dg-do compile } */
4
#include <objc/objc.h>
5
 
6
@interface MySuperClass
7
{
8
@private
9
  int private;
10
 
11
@protected
12
  int protected;
13
 
14
@public
15
  int public;
16
}
17
- (void) test;
18
@end
19
 
20
@implementation MySuperClass
21
- (void) test
22
{
23
  /* FIXME: I wonder if the warnings shouldn't be better generated
24
     when the variable is declared, rather than used!  */
25
  int private = 12;
26
  int protected = 12;
27
  int public = 12;
28
  int a;
29
 
30
  a = private;    /* { dg-warning "hides instance variable" } */
31
  a = protected;  /* { dg-warning "hides instance variable" } */
32
  a = public;     /* { dg-warning "hides instance variable" } */
33
}
34
@end
35
 
36
 
37
@interface MyClass : MySuperClass
38
@end
39
 
40
@implementation MyClass
41
- (void) test
42
{
43
  int private = 12;
44
  int protected = 12;
45
  int public = 12;
46
  int a;
47
 
48
  /* The private variable can be shadowed without warnings, because
49
   * it's invisible, and not accessible, to the subclass!  */
50
  a = private;   /* Ok  */
51
  a = protected; /* { dg-warning "hides instance variable" } */
52
  a = public;    /* { dg-warning "hides instance variable" } */
53
}
54
@end

powered by: WebSVN 2.1.0

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