changeset 459:9fc266d4010f

*** empty log message ***
author kono
date Thu, 02 Dec 2004 02:50:45 +0900
parents 0bc9f3273aa7
children 2859bb9d5fb3
files test/inline.c
diffstat 1 files changed, 139 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/inline.c	Thu Dec 02 02:50:45 2004 +0900
@@ -0,0 +1,139 @@
+const int a = 5,b = -3;
+int kkkk = 333;
+static const int as = 5,bs = -3;
+const char hoo[] = "test";
+static const char haa[] = "test";
+static inline const int f(int k);
+
+extern int printf(char *,...);
+
+static inline const int f(int k)
+{
+    return k+1;
+}
+
+inline int in1(int i,int j)
+{
+   if (i>j) return j;
+   else return i;
+}
+
+static
+inline int ins(int i,int j)
+{
+   printf("#0023:%d %d\n",i,j);
+   if (f(i)>j) return j;
+   else return i;
+}
+
+static
+inline int ins1(int i,int j)
+{
+   printf("#0023:%d %d\n",i,j);
+   if (f(i)>j) return j;
+   else return i;
+}
+
+inline int in2(int p,int i,int j)
+{
+    int k = 0,m;
+    do {
+	k += 3;
+    } while ( k < j);
+    printf("#0034: %d do %d\n",p,k);
+
+    while (k < j) {
+	k -= 3;
+    } while ( k < j);
+    printf("#0039: %d while %d\n",p,k);
+
+    m = 0;
+    for(k=0;k<j;k++) {
+	m += k;
+    }
+    printf("#0045: %d for %d\n",p,m);
+
+    switch(i) {
+    case 1: k = 1;
+	break;
+    case 2: k = 2;
+	break;
+    case 3: k = 3;
+	break;
+    case 4: k = 4;
+	break;
+    default: k = 5;
+    }
+    printf("#0058: %d switch %d\n",p,k);
+
+    for(k=0;k<j;k++) {
+	i += k;
+	if (k<3) continue;
+    }
+    printf("#0064: %d for %d\n",p,i);
+    goto hoge;
+hage:
+    goto hage;
+hoge:
+    return 0;
+
+}
+
+int (*fnp)(int i,int j);
+
+int (*fnp3)(int i,int j,int k);
+
+void
+a0(int k,int j)
+{
+    int k1,j1;
+    const int v=3,x=6;
+    // a = 10;
+
+    k1 = in1(a,b);
+    printf("#0081:%d %d %d\n",a,b,k1);
+    j1 = in1(k,j-6)+f(k1);
+    printf("#0083:%d %d %s\n",k1,j1,hoo);
+    k1 = &v-&x>0? &v-&x : &x-&v;
+    printf("#0085:v-x: %d\n",k1);
+
+    k1 = ins(a,b);
+    j1 = ins(k,j-6)+f(k1);
+    printf("#0089:%d %d %s\n",k1,j1,haa);
+
+    k1 = ins(as,bs);
+    j1 = ins(k,j-6)+f(k1);
+    printf("#0093:%d %d %s\n",k1,j1,haa);
+
+    k1 = ins(v,x);
+    j1 = ins(k,j-6)+f(v);
+    printf("#0097:%d %d %s\n",k1,j1,haa);
+
+    k1 = fnp(v,x);
+    j1 = ins1(k,j-6)+f(v);
+    printf("#0097:%d %d %s\n",k1,j1,haa);
+}
+
+void
+a1(int k,int j)
+{
+    in2(1,k,j);
+    in2(2,3,10);
+    in2(3,k,10);
+    in2(4,2,j);
+    in2(5,2,1);
+    in2(6,0,2);
+    fnp3(6,0,2);
+}
+
+int
+main()
+{
+     fnp = ins1;
+     a0(5,6);
+     a0(-9,6);
+     fnp3 = in2;
+     a1(9,10);
+     return 0;
+}
+