aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-09-12 17:10:35 +0200
committerlemon <lsof@mailbox.org>2025-09-12 17:10:35 +0200
commit89710916cfa82f50be0092347744a5e06a3b5420 (patch)
tree02cff596fad2f6b4ea577ad35bc77d53dcb4a413 /test
parentc8af181799015ea39b8868ef5d07b10ed255e799 (diff)
c: function-local static vars
Diffstat (limited to 'test')
-rw-r--r--test/pp.c5
-rw-r--r--test/pp.h3
-rw-r--r--test/reloc.c7
-rw-r--r--test/test3.c2
4 files changed, 14 insertions, 3 deletions
diff --git a/test/pp.c b/test/pp.c
index f850c08..1c1549f 100644
--- a/test/pp.c
+++ b/test/pp.c
@@ -5,7 +5,8 @@
int
main(void)
{
- printf("%s\n",STR ( ok /1 "\n"\n ;.&
- 05.5));
+ printf("%s %s\n",STR ( ok /1 "\n"n ;.&
+ 05.5), STR(ADD(1,2)));
hi(ADD(Foo, SQR(Bar+1)));
+ printf("%s %s\n", str(Foo), xstr(Foo));
}
diff --git a/test/pp.h b/test/pp.h
index 5ac7aac..029c6ee 100644
--- a/test/pp.h
+++ b/test/pp.h
@@ -16,6 +16,9 @@ void hi(int x) {
#define ADD(a,b) (a)+(b)
#define STR(h) #h
+#define xstr(s1) str(s1)
+#define str(s) #s
+
#endif
extern int printf(const char *, ...);
diff --git a/test/reloc.c b/test/reloc.c
new file mode 100644
index 0000000..70cba28
--- /dev/null
+++ b/test/reloc.c
@@ -0,0 +1,7 @@
+
+
+float get_value(unsigned x)
+{
+ static const float values [] = {1.1f, 1.2f, 1.3f, 1.4f};
+ return x < 4 ? values[x] : 0.0f;
+}
diff --git a/test/test3.c b/test/test3.c
index a5d165f..b99a543 100644
--- a/test/test3.c
+++ b/test/test3.c
@@ -27,7 +27,7 @@ struct bitset { unsigned long long u; };
void
bscopy(struct bitset dst[/*siz*/], const struct bitset src[/*siz*/], unsigned siz)
{
- while (siz--) dst++->u = src++->u;
+ for (; siz; --siz, ++dst, ++src) dst->u = src->u;
}