Work around an ORCA/C preprocessor bug that was causing shell conditionals not to work properly.

The bug is that an #if condition may be mis-evaluated if it immediately follows a use of a function-like macro. I also modified a couple other places that could possibly trigger the bug (including a possibly more reliable fix for the instance of this problem I worked around earlier in include/xatonum.h).
This commit is contained in:
Stephen Heumann 2014-12-04 11:42:48 -06:00
parent dc2193b997
commit 2d16296748
3 changed files with 6 additions and 12 deletions

View File

@ -44,6 +44,9 @@
# define __const const
#endif
/* used by unit test machinery to run registration functions before calling main() */
#define INIT_FUNC __attribute__ ((constructor))
#define UNUSED_PARAM __attribute__ ((__unused__))
#define NORETURN __attribute__ ((__noreturn__))
/* "The malloc attribute is used to tell the compiler that a function
@ -81,9 +84,6 @@
# define UNUSED_PARAM_RESULT
#endif
/* used by unit test machinery to run registration functions before calling main() */
#define INIT_FUNC __attribute__ ((constructor))
/* -fwhole-program makes all symbols local. The attribute externally_visible
* forces a symbol global. */
#if __GNUC_PREREQ(4,1)

View File

@ -28,6 +28,8 @@ type xato##T##_range(const char *str, type l, type u) FAST_FUNC; \
type xato##T##_sfx(const char *str, const struct suffix_mult *sfx) FAST_FUNC; \
type xato##T(const char *str) FAST_FUNC; \
DECLARE_STR_CONV(long, l, ul)
/* Provides inline definitions of functions */
/* (useful for mapping them to the type of the same width) */
@ -79,14 +81,6 @@ static ALWAYS_INLINE \
narrow xato##N(const char *str) \
{ return xato##W(str); } \
DECLARE_STR_CONV(long, l, ul)
/* Without the explicit !defined(__ORCAC__) check, ORCA/C's preprocessor was
* falsely treating the following #if as true. I think this occurs because
* the preprocessor state is somehow corrupted. The added check seems to work
* around the bug; hopefully the corruption doesn't cause any other problems.
*/
/* Same for int -> [long] long */
#if !defined(__ORCAC__) && UINT_MAX == ULONG_MAX
DEFINE_EQUIV_STR_CONV(int, i, l, u, ul)

View File

@ -7833,7 +7833,7 @@ static int run_list(struct pipe *pi)
}
}
last_followup = pi->followup;
IF_HAS_KEYWORDS(last_rword = rword;)
IF_HAS_KEYWORDS(last_rword = rword); /* ; outside to avoid ORCA/C bug */
#if ENABLE_HUSH_IF
if (cond_code) {
if (rword == RES_THEN) {