| 1 |
// Check if ivars may be accessed via the C++ dot notation. |
| 2 |
// { dg-do run } |
| 3 |
// { dg-options "-fno-objc-call-cxx-cdtors" } |
| 4 |
// { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } |
| 5 |
|
| 6 |
#include "../objc-obj-c++-shared/TestsuiteObject.m" |
| 7 |
#include <stdlib.h> |
| 8 |
#define CHECK_IF(expr) if(!(expr)) abort() |
| 9 |
|
| 10 |
struct cxx_struct { |
| 11 |
int a, b; |
| 12 |
void set_values (int _a, int _b = 3) { |
| 13 |
a = _a; b = _b; |
| 14 |
} |
| 15 |
~cxx_struct (void) { |
| 16 |
a = b = 99; |
| 17 |
} |
| 18 |
}; |
| 19 |
|
| 20 |
@interface Manip : TestsuiteObject { |
| 21 |
int c; |
| 22 |
cxx_struct s; // { dg-warning "user-defined destructor" } |
| 23 |
// { dg-warning "constructors and destructors will not be invoked" "" { target *-*-* } .-1 } |
| 24 |
} |
| 25 |
- (void) manipulate_ivars; |
| 26 |
@end |
| 27 |
|
| 28 |
@implementation Manip |
| 29 |
- (void) manipulate_ivars { |
| 30 |
s.set_values (7); |
| 31 |
CHECK_IF (s.a == 7 && s.b == 3); |
| 32 |
s.~cxx_struct(); |
| 33 |
CHECK_IF (s.a == 99 && s.b == 99); |
| 34 |
} |
| 35 |
@end |
| 36 |
|
| 37 |
int main (void) |
| 38 |
{ |
| 39 |
Manip *obj = [Manip new]; |
| 40 |
[obj manipulate_ivars]; |
| 41 |
[obj free]; |
| 42 |
} |
| 43 |
|