source: tests/raii/typeof-member.cfa @ 59627b3

Last change on this file since 59627b3 was 2f31773, checked in by Michael Brooks <mlbrooks@…>, 3 months ago

Improve inability to declare a struct member having a managed type via typeof.

Fix is evaluating typeof on both types in a cast; one was missing.

One layer of struct wrapping now works, with its test added. Multiple layers of wrapping still does not work.

  • Property mode set to 100644
File size: 866 bytes
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2023 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// typeof-member.cfa -- managed type declared as contained member via typeof
8//
9// Author           : Mike Brooks
10// Created On       : Tue Aug 13 12:00:00 2024
11// Last Modified By :
12// Last Modified On :
13// Update Count     :
14//
15
16// Note - array(...) expands as typeof(...).
17// So supporting member as typeof is necessary for having array as member.
18// The array type (arpk) is managed.
19
20struct A {
21    int x;
22};
23
24void  ?{}( A & ) { printf("custom A ctor called\n"); }
25void ^?{}( A & ) { printf("custom A dtor called\n"); }
26
27A foo( void );
28
29struct outer {
30    typeof( foo() ) a;
31};
32
33int main() {
34    outer b;
35    b.a.x = 5;
36    printf( "%d\n", b.a.x );
37    return 0;
38}
Note: See TracBrowser for help on using the repository browser.