[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pcc-list
Subject:    Re: statements-as-expressions bogus syntax errors
From:       Thorsten Glaser <tg () mirbsd ! de>
Date:       2008-10-30 14:27:10
Message-ID: Pine.BSM.4.64L.0810271757360.11422 () herc ! mirbsd ! org
[Download RAW message or body]

Anders Magnusson dixit:

> Thanks, fixed.  I had a small error in the yacc code for this
> type of expressions.

Now I get a lot of warnings of the type:
pcc  -O2 -I. -I'/usr/src/bin/mksh'  -DHAVE_EXPSTMT=1 -DHAVE_ATTRIBUTE=0 \
-DHAVE_ATTRIBUTE_BOUNDED=0 -DHAVE_ATTRIBUTE_USED=0 -DHAVE_SYS_PARAM_H=1 \
-DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_SYSMACROS_H=0 -DHAVE_LIBGEN_H=1 \
-DHAVE_LIBUTIL_H=0 -DHAVE_PATHS_H=1 -DHAVE_STDBOOL_H=1 -DHAVE_GRP_H=1 \
-DHAVE_ULIMIT_H=0 -DHAVE_VALUES_H=0 -DHAVE_STDINT_H=1 -DHAVE_RLIM_T=1 -DHAVE_SIG_T=1 \
-DHAVE_SYS_SIGNAME=1 -DHAVE_SYS_SIGLIST=1 -DHAVE_STRSIGNAL=0 -DHAVE_ARC4RANDOM=1 \
-DHAVE_ARC4RANDOM_PUSHB=1 -DHAVE_MKSTEMP=1 -DHAVE_NICE=1 -DHAVE_SETLOCALE_CTYPE=1 \
-DHAVE_LANGINFO_CODESET=1 -DHAVE_MKNOD=1 -DHAVE_REALPATH=1 -DHAVE_REVOKE=1 \
-DHAVE_SETMODE=1 -DHAVE_SETRESUGID=1 -DHAVE_SETGROUPS=1 -DHAVE_STRCASESTR=1 \
-DHAVE_STRLCPY=1 -DHAVE_ARC4RANDOM_DECL=1 -DHAVE_ARC4RANDOM_PUSHB_DECL=1 \
-DHAVE_FLOCK_DECL=1 -DHAVE_REVOKE_DECL=1 -DHAVE_SYS_SIGLIST_DECL=1 \
-DHAVE_PERSISTENT_HISTORY=1 -DHAVE_CONFIG_H -DCONFIG_H_FILENAME=\"sh.h\" -c \
                /usr/src/bin/mksh/edit.c
/usr/src/bin/mksh/edit.c, line 542: warning: illegal combination of pointer and \
                integer
/usr/src/bin/mksh/edit.c, line 642: warning: illegal combination of pointer and \
                integer
/usr/src/bin/mksh/edit.c, line 2471: warning: illegal combination of pointer and \
                integer
/usr/src/bin/mksh/edit.c, line 2544: warning: illegal combination of pointer and \
                integer
/usr/src/bin/mksh/edit.c, line 3108: warning: illegal combination of pointer and \
integer

  542         toglob = str_nsave(str, slen + 1, ATEMP); /* + 1 for "*" */

sh.h:

 1441 #define str_nsave(s,n,ap)       \
 1442         (!(s) || (n) < 0 ? NULL : str_nsave_((s), (n), (ap)))

 1434 #define str_nsave_(s,n,ap)      ({                              \
 1435         size_t str_save_sz = (n) + 1;                           \
 1436         char *str_save_rv = alloc(str_save_sz, (ap));           \
 1437         strlcpy(str_save_rv, (s), str_save_sz);                 \
 1438         (str_save_rv);                                          \
 1439 })


Interestingly enough, this expression lets SUNWcc choke too,
although Sun has provided a fix for it which I'm going to try
some time (on a Solaris box a friend made me a zone on, the
update is installed and it works, but the Linux/i386 binary
of SUNWcc run on MirBSD (and coerced to produce native MirBSD
binaries) exhibits it).

Now I don't really see the problem, except if pcc assumes the
"value type" of statements-as-expressions is integral. It isn't.
The type is the type of the last expression in the block.
(NULL is a cast to pointer macro on MirBSD.)


Regression tests on the binary produced pass though. And at
191600 Bytes, size is not too bad either.

bye,
//mirabilos
-- 
Sometimes they [people] care too much: pretty printers [and syntax highligh-
ting, d.A.] mechanically produce pretty output that accentuates irrelevant
detail in the program, which is as sensible as putting all the prepositions
in English text in bold font.	-- Rob Pike in "Notes on Programming in C"


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic