source: tests/poly-selection.cfa @ 09ee131

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 09ee131 was fcd0b9d7, checked in by Michael Brooks <mlbrooks@…>, 4 years ago

PolyCost? calculation result becomes 0 or 1 per type, avoiding double-couting. Fixes #235?

PolyCost? calculation is documented as "Count of parameters and return values bound to some poly type." Before this fix, the cost calculation, looking inside one parameter or return, counted each occurrence of a poly type that it found there. This caused an incorrect increase in PolyCost? on cases like #235 where several type variables are used in the declaration of one parameter.

libcfa/src/concurrency/thread.cfa: Changing a decl-use pattern to keep resolution consistent (no behaviour is changed). The management of defaultResumptionHandler in the thread constructor was benefitting from bug #235 to disambiguate assignment to local variable vs assignment to declared function (due to #234). After this change, the code works around that false ambiguity by using a different name for the local variable.

tests/avl*: Adding a missing assertion on the custom destructor definition. Previously, the destructor definition was benefiting from bug #235 to avoid the missing-assertion-on-custom-dtor problem described in #227.

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[978e5eb]1//
2// Cforall Version 1.0.0 Copyright (C) 2015 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// poly-selection.cfa -- tests that show correct candidates selected, given interesting cases of
8//                       forall/overload polymoprphism
9//
10// Author           : Michael Brooks
11// Created On       : Mon Jan 18 15:00:00 2021
12// Last Modified By : Michael Brooks
13// Last Modified On : Mon Jan 18 15:00:00 2021
14// Update Count     : 1
15//
16
17void testSpecializationFromGenericOverBareTyvar() {
18    forall( dtype T )
19    void friend( T & ) {
20        printf("friending generically\n");
21    }
22
23    forall(dtype T)
24    struct thing {
25        int x;
26    };
27
28    forall( dtype T )
29    void friend( thing(T) & ) {
30        printf("friending specifically\n");
31    }
32
33    float x;           friend( x );
34    thing(float) y;    friend( y );
35}
36
[fcd0b9d7]37void testSpecializationFromGenericAccessibleWithExtraTyvars() {
38
39    forall( dtype T, dtype U )
40    struct map {};
41
42    forall( dtype T )
43    void f( T & ) {
44        printf("f-generic\n");
45    }
46
47    forall( dtype T )
48    void f( map(T, T) & ) {
49        printf("f-specific\n");
50    }
51
52    float one;
53    map(float, float) two;
54    f(one);
55    f(two);
56}
[978e5eb]57
58int main() {
59    testSpecializationFromGenericOverBareTyvar();
[fcd0b9d7]60    printf("-\n");
61    testSpecializationFromGenericAccessibleWithExtraTyvars();
[978e5eb]62}
Note: See TracBrowser for help on using the repository browser.