view test/scope.c @ 935:7672a37e7545 default tip

Raspbery PI ARM support begin
author kono
date Sat, 24 Dec 2016 03:02:57 +0000
parents 5313ed059cee
children
line wrap: on
line source

/* 

    gcc -g -std=gnu99 test/scope.c

 */

#include <stdio.h>
// #define INLINE inline
#ifdef INLINE
#else
#define INLINE
#endif


INLINE
void
f(int *i,void *label)
{
    static int k = 3;
    {
        static int k = 3;
        *i =  k++;
    }
    k--;
    printf("#0024:f %d\n",k);
} 

INLINE
int
g(int m,int n)
{
    int k=m,i=n-3;
    if (m==2) return 0;
    if (k==2||k==3||k==i) {
        if (k==2||k==3||k==4) {
            printf("#0035:k,i=%d,%d\n",k,i);
        }
    }
    return m+n;
}

INLINE
static int
main0()
{
    int i,k;
    void *exit = &&exit0;
    i = 3;k=10;

        printf("#0049:%s,%s,%d\n",
            __FILE__,
            __FUNCTION__,
            __LINE__
            );


    for(int k=0;k<10;k++) { 
        int i;
        i = 4;
        if (k==2||k==3||k==i) {
            if (k==2||k==3||k==4) {
                const int m=g(k,i);
                printf("#0062:m=%d\n",m);
            }
        }
        if (({
            __label__ exit0; 
            int i; 
                f(&i,&&exit0); 
                if (i==5) 
                    goto exit0;
                printf("#0071:2nd inner %d %d %0x\n",i,k,&&exit1==exit);
            exit0:
            i;
            })!=7) {
            goto exit1;
        } else
            goto *exit;
        /* not reached */
        i = ({ int k=3; k; });
exit1:
        printf("#0081:inner %d %d %0x\n",i,k,&&exit1==exit);
    }
    k++;
exit0:
    printf("#0085:outer %d %d %0x\n",i,k,&&exit0==exit);
    return 0;
}

int
main()
{
    return main0();
}