summaryrefslogtreecommitdiffhomepage
path: root/CompilerDriver/cc2/regression-tests/mixed-parameter-passing-with-forward.cpp2
blob: dea5be5d65fa87b9d9986cb38892eda904b40f40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

#include <string>
#include <cstdlib>
#include <ctime>

copy_from: (copy _) = { }

parameter_styles: (
    in      _: std::string, // "in" is default
    copy    b: std::string,
    inout   _: std::string,
    move    d: std::string,
    forward e: std::string
    )
= {
    z: int = 12;

    z++;
    b += "plugh";

    if std::rand()%2 {
        z++;
        copy_from(b);   // definite last use
    }
    else {
        copy_from(b&);  // NB: better not move from this (why not?)
        copy_from(d);
        copy_from(z++);
        copy_from(e);
    }

    // std::move(z);

    copy_from(z);

    if std::time(nullptr)%2 == 0 {
        copy_from(z);
    }

}

main: () -> int = { }