This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: cpp issues


On Wed, 24 Feb 1999 13:54:50 -0500 (EST), "Kaveh R. Ghazi" wrote:
>	Here's the testcase I've been using to test for cpp truncating
>long long expressions.  It only needs to be preprocessed, not compiled
>or executed.  However, I'm not sure how to set that up or what directory
>it should go into...  Pointers on testuite stuff would be appreciated. 

For a test like this, you want gcc/testsuite/gcc.dg.  This dir has a
test driver that can handle just running stuff through the
preprocessor, looking for errors on specific lines, etc.  It works
sorta like the g++.old-deja driver, but isn't as baroque.

I added the appropriate magic to your test and committed it as
gcc.dg/cpp-if3.c, it looks like this:

/* { dg-do preprocess } */
/* { dg-options -pedantic-errors } */

#define U_MAX 4294967295U
#define ULL_MAX 18446744073709551615ULL
#define LL_MAX 9223372036854775807LL
#define LL_MIN (-LL_MAX-1)

/* Check simple truncation. */
#if U_MAX == ULL_MAX || LL_MIN == 0 || LL_MAX == -1
#error "simple truncation"  /* { dg-bogus "trunc" "simple truncation" } */
#endif

/* Check left/right shifting with all bits set and with one bit set. */
#if !(~0ULL >> 63) || !(~0ULL << 63) || !(~0LL >> 63) || !(~0LL << 63) || \
  !(LL_MIN >> 63) || !(1LL << 63) || !(ULL_MAX >> 63) || !(1ULL << 63)
#error "bit shift truncation" /* { dg-bogus "trunc" "bit shift truncation" } */
#endif

/* Check math expressions. */
#if (2ULL * U_MAX < U_MAX) || (1ULL + U_MAX < U_MAX)
#error "math truncation"  /* { dg-bogus "trunc" "math truncation" } */
#endif

...and I get this from runtest:

Running /usr/home/zack/gnudev/egcs/gcc/testsuite/gcc.dg/dg.exp ...
FAIL: gcc.dg/cpp-if3.c simple truncation (test for bogus messages, line 11)
FAIL: gcc.dg/cpp-if3.c bit shift truncation (test for bogus messages, line 17)
FAIL: gcc.dg/cpp-if3.c math truncation (test for bogus messages, line 22)
FAIL: gcc.dg/cpp-if3.c (test for excess errors)

The "test for excess errors" failure is from the `integer constant out
of range' errors, that will go away when you apply your patch.

You might want to get the constants from limits.h instead of defining
them yourself, since the values you're using may not be right on all
systems.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]