* gcc.dg/cpp/macro3.c,macro4.c,strp1.c: Update.

From-SVN: r39153
This commit is contained in:
Neil Booth 2001-01-20 09:34:13 +00:00 committed by Neil Booth
parent 673b13e2f6
commit 29aad310b0
4 changed files with 18 additions and 35 deletions

View File

@ -1,3 +1,7 @@
2001-01-20 Neil Booth <neil@daikokuya.demon.co.uk>
* gcc.dg/cpp/macro3.c,macro4.c,strp1.c: Update.
2001-01-19 Jakub Jelinek <jakub@redhat.com> 2001-01-19 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/execute/20010119-1.c: New test. * gcc.c-torture/execute/20010119-1.c: New test.

View File

@ -5,23 +5,17 @@
Varargs test source Jamie Lokier. Varargs test source Jamie Lokier.
All adapted for the testsuite by Neil Booth, Oct 2000. */ All adapted for the testsuite by Neil Booth, Oct 2000. */
int c(int x)
{
return x;
}
int a(int x)
{
return x;
}
/* Tests various macro abuse is correctly expanded. */ /* Tests various macro abuse is correctly expanded. */
static int d = 4;
#define c(x) d #define c(x) d
#define d(x) c(2) #define d(x) c(2)
/* Every GCC <= 2.96 appears to fail this. */ #if 0
/* This macro chain above sucks up the whole file once it starts, so
I've commented it out. The example is left for idle amusement :-) */
#define a(x) b( #define a(x) b(
#define b(x) a( #define b(x) a(
#endif
#define apply(...) apply2 (__VA_ARGS__) #define apply(...) apply2 (__VA_ARGS__)
#define half(x) ((x) / 2) #define half(x) ((x) / 2)
@ -32,12 +26,8 @@ extern void exit (int);
int main() int main()
{ {
/* Expands to c(2). */ /* Expands to c(2) then d. */
if (c(c)(c) != 2) if (c(c)(c) != 4)
abort ();
/* Expands to a(2). */
if (a(a)x)2) != 2)
abort (); abort ();
if (apply (half, 200) != 100) if (apply (half, 200) != 100)

View File

@ -1,24 +1,13 @@
/* Copyright (C) 2000 Free Software Foundation, Inc. */ /* Copyright (C) 2000 Free Software Foundation, Inc. */
/* { dg-do run } */ /* { dg-do preprocess } */
/* Test source Neil Booth. GCC <= 2.96 don't get this right. */ /* Test source Neil Booth. */
extern void abort (void);
int glue (int x, int y)
{
return x + y;
}
#define glue(x, y) x ## y #define glue(x, y) x ## y
#define xglue(x, y) glue (x, y) #define xglue(x, y) glue (x, y)
int main () /* Should expand to glue (1, 2), then 12. */
{ #if glue (xgl, ue) (1, 2) != 12
/* Should expand to glue (1, 2) as the second "glue" is nested. */ #error glue macro
if (glue (xgl, ue) (1, 2) != 3) #endif
abort ();
return 0;
}

View File

@ -16,7 +16,7 @@ static const char t1[] = "1.1";
#define f h #define f h
#define h(a) a+f #define h(a) a+f
static const char s2[] = S( f(1)(2) ); static const char s2[] = S( f(1)(2) );
static const char t2[] = "1+f(2)"; static const char t2[] = "1+h(2)";
#undef I #undef I
#undef f #undef f