view gcc/testsuite/objc.dg/ivar-scope-2.m @ 137:d22083d7f10b

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:16:42 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* Test instance variable scope.  */
/* Author: Dimitris Papavasiliou <dpapavas@gmail.com>.  */
/* { dg-do compile } */
/* { dg-additional-options "-fno-local-ivars" } */
#include <objc/objc.h>

@interface MyClass
{
  int someivar;
}
- (void) testscope;
- (void) testshadowing;
@end

@implementation MyClass
- (void) testscope
{
  int a;

  a = self->someivar;  /* No warning or error. */
  a = someivar;        /* { dg-error ".someivar. undeclared" } */
}

- (void) testshadowing
{
  int someivar = 1;
  int a;

  /* Since instance variables don't have local scope no shadowing
     should occur. */
  
  a = someivar; /* No warning. */
}
@end