Changeset e50e9ff for src/tests


Ignore:
Timestamp:
Aug 22, 2017, 11:42:06 AM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
90c4df0
Parents:
6ac5223 (diff), b3d413b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/tests
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/tests/.expect/32/KRfunctions.txt

    r6ac5223 re50e9ff  
    1515}
    1616struct S {
    17     int __i__i_1;
     17int __i__i_1;
    1818};
    1919static inline void ___constructor__F_P2sS_autogen___1(struct S *___dst__P2sS_1);
     
    7979    __attribute__ ((unused)) int (*___retval_f14__PA0A0i_1)[][((unsigned int )10)];
    8080}
     81int __f15__Fi_iii__1(int __a__i_1, int __b__i_1, int __c__i_1){
     82    __attribute__ ((unused)) int ___retval_f15__i_1;
     83}
    8184const int __fred__FCi___1(){
    8285    __attribute__ ((unused)) const int ___retval_fred__Ci_1;
  • src/tests/.expect/64/KRfunctions.txt

    r6ac5223 re50e9ff  
    7979    __attribute__ ((unused)) int (*___retval_f14__PA0A0i_1)[][((long unsigned int )10)];
    8080}
     81int __f15__Fi_iii__1(int __a__i_1, int __b__i_1, int __c__i_1){
     82    __attribute__ ((unused)) int ___retval_f15__i_1;
     83}
    8184const int __fred__FCi___1(){
    8285    __attribute__ ((unused)) const int ___retval_fred__Ci_1;
  • src/tests/KRfunctions.c

    r6ac5223 re50e9ff  
    1010// Created On       : Thu Feb 16 15:23:17 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 24 22:05:00 2017
    13 // Update Count     : 3
     12// Last Modified On : Sun Aug 20 07:34:17 2017
     13// Update Count     : 7
    1414//
    1515
     
    3737int ((* f13( a, b, c ))[])[10] int a, * b, c[]; {}
    3838int (((* f14( a, b, c ))[])[10]) int a, * b, c[]; {}
     39f15( a, b, c ) {}
    3940
    4041const fred() {
  • src/tests/except-0.c

    r6ac5223 re50e9ff  
    77#include <stdio.h>
    88#include <stdbool.h>
     9
     10#include "except-mac.h"
     11TRIVIAL_EXCEPTION(yin)
     12TRIVIAL_EXCEPTION(yang)
     13TRIVIAL_EXCEPTION(zen)
     14
    915
    1016// Local type to mark exits from scopes. (see ERROR)
     
    2329
    2430
    25 // Local Exception Types and manual vtable types.
    26 //#define TRIVIAL_EXCEPTION(name) //TRIVAL_EXCEPTION(yin)
    27 struct yin;
    28 struct yin_vtable {
    29         struct exception_t_vtable const * parent;
    30         size_t size;
    31     void (*copy)(yin *this, yin * other);
    32     void (*free)(yin *this);
    33     const char (*msg)(yin *this);
    34 };
    35 struct yin {
    36         struct yin_vtable const * parent;
    37 };
    38 void yin_msg(yin) {
    39         return "in";
    40 }
    41 yin_vtable _yin_vtable_instance = {
    42         &_exception_t_vtable_instance, sizeof(yin), ?{}, ^?{}, yin_msg
    43 }
    44 
    45 
    46 void terminate(exception * except_value) {
     31// Mark throws: make sure to only pass in exception types.
     32forall(dtype T)
     33void terminate(T * except_value) {
    4734        signal_exit a = {"terminate function"};
    48         throw except_value;
     35        THROW(except_value);
    4936        printf("terminate returned\n");
    5037}
    5138
    52 void resume(exception * except_value) {
     39forall(dtype T)
     40void resume(T * except_value) {
    5341        signal_exit a = {"resume function"};
    54         throwResume except_value;
     42        THROW_RESUME(except_value);
    5543        printf("resume returned\n");
    5644}
     
    6048        signal_exit a = {"bar function"};
    6149        try {
    62                 terminate(4);
    63         } catch (3) {
    64                 printf("bar caught exception 3.\n");
     50                terminate(&(zen){});
     51        } catch (yin * error) {
     52                printf("bar caught exception yin.\n");
    6553        }
    6654}
     
    7058        try {
    7159                bar();
    72         } catch (4) {
    73                 printf("foo caught exception 4.\n");
    74         } catch (2) {
    75                 printf("foo caught exception 2.\n");
     60        } catch (yang * error) {
     61                printf("foo caught exception yang.\n");
     62        } catch (zen * error) {
     63                printf("foo caught exception zen.\n");
    7664        }
    7765}
     
    8169        signal_exit a = {"beta function"};
    8270        try {
    83                 resume(4);
    84         } catchResume (3) {
    85                 printf("beta caught exception 3\n");
     71                zen x;
     72                resume(&x);
     73        } catchResume (yin * error) {
     74                printf("beta caught exception yin\n");
    8675        }
    8776}
     
    9180        try {
    9281                beta();
    93         } catchResume (2) {
    94                 printf("alpha caught exception 2\n");
    95         } catchResume (4) {
    96                 printf("alpha caught exception 4\n");
     82        } catchResume (yang * error) {
     83                printf("alpha caught exception yang\n");
     84        } catchResume (zen * error) {
     85                printf("alpha caught exception zen\n");
    9786        }
    9887}
     
    117106void fallback() {
    118107        try {
    119                 resume(2);
    120         } catch (2) {
    121                 printf("fallback caught termination 2\n");
     108                zen x;
     109                resume(&x);
     110        } catch (zen * error) {
     111                printf("fallback caught termination zen\n");
    122112        }
    123113}
     
    127117        signal_exit a = {"terminate_swap"};
    128118        try {
    129                 terminate(2);
    130         } catch (2) {
    131                 terminate(3);
     119                yin x;
     120                terminate(&x);
     121        } catch (yin * error) {
     122                yang y;
     123                terminate(&y);
    132124        }
    133125}
     
    137129        try {
    138130                terminate_swap();
    139         } catch (3) {
    140                 printf("terminate_swapped caught exception 3\n");
     131        } catch (yang * error) {
     132                printf("terminate_swapped caught exception yang\n");
    141133        }
    142134}
     
    146138        signal_exit a = {"resume_swap"};
    147139        try {
    148                 resume(2);
    149         } catchResume (2) {
    150                 resume(3);
     140                yin x;
     141                resume(&x);
     142        } catchResume (yin * error) {
     143                yang y;
     144                resume(&y);
    151145        }
    152146}
     
    155149        try {
    156150                resume_swap();
    157         } catchResume (3) {
    158                 printf("resume_swapped caught exception 3\n");
     151        } catchResume (yang * error) {
     152                printf("resume_swapped caught exception yang\n");
    159153        }
    160154}
     
    164158        try {
    165159                try {
    166                         terminate(2);
    167                 } catch (2) {
    168                         printf("reterminate 2 caught and "
    169                                "will rethrow exception 2\n");
     160                        zen x;
     161                        terminate(&x);
     162                } catch (zen * error) {
     163                        printf("reterminate zen caught and "
     164                               "will rethrow exception zen\n");
    170165                        throw;
    171166                }
    172         } catch (2) {
    173                 printf("reterminate 1 caught exception 2\n");
     167        } catch (zen * error) {
     168                printf("reterminate 1 caught exception zen\n");
    174169        }
    175170}
     
    179174        try {
    180175                try {
    181                         resume(2);
    182                 } catchResume (2) {
    183                         printf("reresume 2 caught and rethrows exception 2\n");
     176                        zen x;
     177                        resume(&x);
     178                } catchResume (zen * error) {
     179                        printf("reresume zen caught and rethrows exception zen\n");
    184180                        throwResume;
    185181                }
    186         } catchResume (2) {
    187                 printf("reresume 1 caught exception 2\n");
     182        } catchResume (zen * error) {
     183                printf("reresume 1 caught exception zen\n");
    188184        }
    189185}
     
    193189        // terminate block, call resume
    194190        try {
    195                 resume(3);
    196         } catch (3) {
    197                 printf("fum caught exception 3\n");
     191                zen x;
     192                resume(&x);
     193        } catch (zen * error) {
     194                printf("fum caught exception zen\n");
    198195        }
    199196}
     
    202199        // resume block, call terminate
    203200        try {
    204                 terminate(3);
    205         } catchResume (3) {
    206                 printf("foe caught exception 3\n");
     201                zen y;
     202                terminate(&y);
     203        } catchResume (zen * error) {
     204                printf("foe caught exception zen\n");
    207205        }
    208206}
     
    212210        try {
    213211                foe();
    214         } catch (3) {
    215                 printf("fy caught exception 3\n");
     212        } catch (zen * error) {
     213                printf("fy caught exception zen\n");
    216214                fum();
    217215        }
     
    222220        try {
    223221                fy();
    224         } catchResume (3) {
    225                 printf("fee caught exception 3\n");
     222        } catchResume (zen * error) {
     223                printf("fee caught exception zen\n");
    226224        }
    227225}
     
    242240        reresume(); printf("\n");
    243241        fee(); printf("\n");
     242
    244243        // Uncaught termination test.
    245         terminate(7);
    246 }
     244        printf("Throw uncaught.\n");
     245        yang z;
     246        terminate(&z);
     247}
  • src/tests/except-1.c

    r6ac5223 re50e9ff  
    55#include <stdio.h>
    66
     7#include "except-mac.h"
     8TRIVIAL_EXCEPTION(yin)
     9TRIVIAL_EXCEPTION(yang)
     10
    711int main()
    812{
    913        try {
    10                 throw 3;
     14                yin a;
     15                THROW(&a);
    1116        }
    12         catch( 3 ) {
     17        catch( yin * err ) {
    1318                printf("First Caught\n");
    1419                try {
    15                         throw 4;
     20                        yang b;
     21                        THROW(&b);
    1622                }
    17                 catch( 4 ) {
     23                catch( yang * err ) {
    1824                        printf("Both Caught\n");
    1925                }
     
    2329        try {
    2430                try {
    25                         throw 2;
     31                        yang c;
     32                        THROW(&c);
    2633                }
    27                 catch( 2 ) {
     34                catch( yang * err ) {
    2835                        printf("First Catch and rethrow\n");
    2936                        throw;
    3037                }
    3138        }
    32         catch( 2 ) {
     39        catch( yang * err ) {
    3340                printf("Second Catch\n");
    3441        }
     
    3744        try {
    3845                try {
    39                         throw 5;
     46                        yin d;
     47                        THROW(&d);
    4048                }
    41                 catch( 5 ) {
     49                catch( yin * err ) {
    4250                        printf("Throw before cleanup\n");
    43                         throw 6;
     51                        yang e;
     52                        THROW(&e);
    4453                }
    4554        }
    46         catch( 6 ) {
     55        catch( yang * err ) {
    4756                printf("Catch after cleanup\n");
    4857        }
     
    5160        try {
    5261                try {
    53                         throw 7;
     62                        yin f;
     63                        THROW(&f);
    5464                }
    55                 catch( 7 ) {
     65                catch( yin * err ) {
    5666                        printf("Caught initial throw.\n");
    5767                        try {
    58                                 throw 8;
     68                                yang g;
     69                                THROW(&g);
    5970                        }
    60                         catch( 8 ) {
     71                        catch( yang * err ) {
    6172                                printf("Caught intermediate throw.\n");
    6273                        }
     
    6475                }
    6576        }
    66         catch( 7 ) {
     77        catch( yin * err ) {
    6778                printf("Caught final throw.\n");
    6879        }
  • src/tests/except-2.c

    r6ac5223 re50e9ff  
    22
    33
    4 #include <string.h>
     4#include <stdlib>
     5#include "except-mac.h"
    56
    6 // Local Exception Types and manual vtable types.
    7 #define GLUE2(left, right) left##right
    8 #define GLUE3(left, middle, right) left##middle##right
    9 #define BASE_EXCEPT __cfaehm__base_exception_t
    10 #define TABLE(name) GLUE2(name,_vtable)
    11 #define INSTANCE(name) GLUE3(_,name,_vtable_instance)
    12 #define TRIVIAL_EXCEPTION(name) \
    13 struct name; \
    14 struct TABLE(name) { \
    15         struct TABLE(BASE_EXCEPT) const * parent; \
    16         size_t size; \
    17         void (*copy)(name *this, name * other); \
    18         void (*free)(name *this); \
    19         const char * (*msg)(name *this); \
    20 }; \
    21 extern TABLE(name) INSTANCE(name); \
    22 struct name { \
    23         struct TABLE(name) const * virtual_table; \
    24 }; \
    25 const char * name##_msg(name * this) { \
    26         return #name; \
    27 } \
    28 void name##_copy(name * this, name * other) { \
    29         this->virtual_table = other->virtual_table; \
    30 } \
    31 TABLE(name) INSTANCE(name) @= { \
    32         .parent : &INSTANCE(BASE_EXCEPT), \
    33         .size : sizeof(name), .copy : name##_copy, \
    34         .free : ^?{}, .msg : name##_msg \
    35 }; \
    36 void ?{}(name * this) { \
    37         this->virtual_table = &INSTANCE(name); \
    38 }
    397TRIVIAL_EXCEPTION(yin)
    408TRIVIAL_EXCEPTION(yang)
     
    5018};
    5119extern num_error_vtable INSTANCE(num_error);
     20
    5221struct num_error {
    5322        struct num_error_vtable const * virtual_table;
     
    5524        int num;
    5625};
     26
    5727void num_error_msg(num_error * this) {
    5828        if ( ! this->msg ) {
    59                 const char * base = "Num Error with code: X";
    60                 this->msg = strdup( base );
     29                static const char * base = "Num Error with code: X";
     30                this->msg = malloc(22);
     31                for (int i = 0 ; (this->msg[i] = base[i]) ; ++i);
    6132        }
    6233        this->msg[21] = '0' + this->num;
     
    9061        try {
    9162                yin black;
    92                 throw (BASE_EXCEPT *)&black;
     63                THROW(&black);
    9364        } catch ( yin * error ) {
    9465                printf("throw yin caught.\n");
     
    9768        try {
    9869                yang white;
    99                 throwResume (BASE_EXCEPT *)&white;
     70                THROW_RESUME(&white);
    10071                printf("> throwResume returned.\n");
    10172        } catchResume ( yang * error ) {
     
    10576        try {
    10677                num_error x = { 2 };
    107                 throw (BASE_EXCEPT *)&x;
     78                THROW(&x);
    10879        }
    10980        catch (num_error * error ; 3 == error->virtual_table->code( error ) ) {
Note: See TracChangeset for help on using the changeset viewer.