diff options
author | Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> | 2023-03-17 20:24:30 +0000 |
---|---|---|
committer | Sigrid Solveig Haflínudóttir <sigrid@ftrv.se> | 2023-03-17 20:24:30 +0000 |
commit | 5664fb3540ae0dccec628720574520122193ab1b (patch) | |
tree | 406ae618e82d7b106aff6365b0da198ae8334b26 /sys/src/cmd/cc | |
parent | 655d7e26e72a486b783820fe161a7a06eaa92078 (diff) |
cc: add __func__ support
Diffstat (limited to 'sys/src/cmd/cc')
-rw-r--r-- | sys/src/cmd/cc/c99 | 2 | ||||
-rw-r--r-- | sys/src/cmd/cc/cc.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/cc/cc.y | 2 | ||||
-rw-r--r-- | sys/src/cmd/cc/dcl.c | 24 |
4 files changed, 28 insertions, 1 deletions
diff --git a/sys/src/cmd/cc/c99 b/sys/src/cmd/cc/c99 index d1c8d23be..4f663a631 100644 --- a/sys/src/cmd/cc/c99 +++ b/sys/src/cmd/cc/c99 @@ -18,6 +18,7 @@ Done: 11, 30, 31, 32. restrict, inline 12. Allow declarations anywhere. 15. for loop declarations +23. __func__ identifier 28. structs ending in incomplete type. Unneeded (already had): @@ -42,5 +43,4 @@ Unwanted: 5. __STDC_IEC_559__, __STDC_IEC_559_COMPLEX__, __STDC_ISO_10646__ 13. Digraph tokens -23. __func__ identifier diff --git a/sys/src/cmd/cc/cc.h b/sys/src/cmd/cc/cc.h index 663250fa7..7f77e368d 100644 --- a/sys/src/cmd/cc/cc.h +++ b/sys/src/cmd/cc/cc.h @@ -583,6 +583,7 @@ Type* dotag(Sym*, int, int); void edecl(int, Type*, Sym*); Type* fnproto(Node*); Type* fnproto1(Node*); +void fndecls(Node*, int); void markdcl(void); Type* paramconv(Type*, int); void pdecl(int, Type*, Sym*); diff --git a/sys/src/cmd/cc/cc.y b/sys/src/cmd/cc/cc.y index 8e0f9b012..f50bf3531 100644 --- a/sys/src/cmd/cc/cc.y +++ b/sys/src/cmd/cc/cc.y @@ -95,11 +95,13 @@ xdecl: pdecl { argmark($2, 1); + fndecls($2, 0); } block { Node *n; + fndecls($2, 1); n = revertdcl(); if(n) $6 = new(OLIST, n, $6); diff --git a/sys/src/cmd/cc/dcl.c b/sys/src/cmd/cc/dcl.c index 8e335d53d..46a7430cd 100644 --- a/sys/src/cmd/cc/dcl.c +++ b/sys/src/cmd/cc/dcl.c @@ -732,6 +732,30 @@ loop: } void +fndecls(Node *f, int pass) +{ + static Sym *funcsym; + Node *n; + + if(pass == 0){ + n = new(ONAME, Z, Z); + n->type = typ(TARRAY, garbt(types[TCHAR], BCONSTNT)); + n->type->width = 0; + n->sym = slookup("__func__"); + n->sym->type = n->type; + funcsym = dodecl(adecl, CLOCAL, n->type, n)->sym; + }else if(funcsym->aused){ + n = new(OSTRING, Z, Z); + n->cstring = f->left->sym->name; + n->type = copytyp(funcsym->type); + n->type->width = strlen(n->cstring)+1; + n->etype = TARRAY; + n->class = CSTATIC; + doinit(funcsym, funcsym->type, 0L, n); + } +} + +void markdcl(void) { Decl *d; |