Annotation of researchv10no/cmd/lcc/ph/d46.c, revision 1.1

1.1     ! root        1: /* The Plum Hall Validation Suite for C
        !             2:  * Unpublished copyright (c) 1986-1991, Chiron Systems Inc and Plum Hall Inc.
        !             3:  * VERSION: 4
        !             4:  * DATE: 1993-01-01
        !             5:  * The "ANSI" mode of this suite corresponds to official ANSI C, X3.159-1989.
        !             6:  * As per your license agreement, your distribution is not to be moved or copied outside the Designated Site
        !             7:  * without specific permission from Plum Hall Inc.
        !             8:  */
        !             9: 
        !            10: 
        !            11: #include "flags.h"
        !            12: #ifndef SKIP46
        !            13: #define LIB_TEST 1
        !            14: #include "defs.h"
        !            15: 
        !            16: /*
        !            17:  * 4.6 - Non-Local jumps
        !            18:  */
        !            19: 
        !            20: #include <setjmp.h>
        !            21: void d4_6x();
        !            22: 
        !            23: static jmp_buf buffer;
        !            24: static int count = 0;
        !            25: void d4_6()
        !            26:        {
        !            27: #if ANSI
        !            28:        volatile int i;
        !            29: #else
        !            30:        int i;
        !            31: #endif
        !            32: 
        !            33:        Filename = "d46.c";
        !            34: 
        !            35:        /* 4.6.1.1 setjmp
        !            36:         */
        !            37: 
        !            38:        /* test in the context of an if */
        !            39:        if (setjmp(buffer) == 0)        
        !            40:                {
        !            41:                /* first time through */
        !            42:                iequals(__LINE__, count, 0);
        !            43:                d4_6x();
        !            44:                }
        !            45:        else
        !            46:                iequals(__LINE__, count, 1);
        !            47:        
        !            48: 
        !            49: 
        !            50: 
        !            51: 
        !            52: 
        !            53:        /* now make sure that it works in the context of a switch */
        !            54:        count = 0;
        !            55:        switch (setjmp(buffer))
        !            56:                {
        !            57:        case 0: /* initial call, no longjmp */
        !            58:                iequals(__LINE__, count, 0);
        !            59:                break;
        !            60:        case 2: /* after first longjmp call */
        !            61:                iequals(__LINE__, count, 1);
        !            62: #if ANSI
        !            63:                iequals(__LINE__, i++, 17);
        !            64: #else
        !            65:                iequals(-__LINE__, i++, 17);
        !            66: #endif
        !            67:                d4_6x();
        !            68:                break;
        !            69:        case 1: /* after second longjmp call */
        !            70:                /* longjmp with arg of 0 makes setjmp return non-zero */
        !            71:                iequals(__LINE__, count, 2);
        !            72: #if ANSI
        !            73:                iequals(__LINE__, i, 18);
        !            74: #else
        !            75:                iequals(-__LINE__, i, 18);
        !            76: #endif
        !            77:                return;
        !            78:                }
        !            79: 
        !            80:        i = 17;
        !            81:        d4_6x();
        !            82:        }
        !            83: 
        !            84: void d4_6x()
        !            85:        {
        !            86:        /* 4.6.1.2 longjmp
        !            87:         */
        !            88:        if (count++ == 0)
        !            89:                longjmp(buffer, 2);
        !            90:        else
        !            91:                longjmp(buffer, 0);
        !            92:        
        !            93:        /* this statement never reached */
        !            94:        complain(__LINE__);
        !            95:        }
        !            96:        
        !            97: 
        !            98: #else /* if SKIP46 */
        !            99: void d4_6() { pr_skip("d4_6: SKIPPED ENTIRELY\n"); }
        !           100: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.