diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/defined.c | 47 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/defined_trad.c | 66 |
3 files changed, 115 insertions, 5 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 627b22f..d903cc9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,12 @@ 2000-12-13 Neil Booth <neil@daikokuya.demon.co.uk> + Tests by Zack Weinberg <zackw@stanford.edu>. + + * gcc.dg/cpp/defined.c: Update. + * gcc.dg/cpp/defined_trad.c: New tests. + +2000-12-13 Neil Booth <neil@daikokuya.demon.co.uk> + * gcc.dg/cpp/trad-direct.c: Update. 2000-12-11 Neil Booth <neilb@earthling.net> diff --git a/gcc/testsuite/gcc.dg/cpp/defined.c b/gcc/testsuite/gcc.dg/cpp/defined.c index 0e82f7e..de1ef29 100644 --- a/gcc/testsuite/gcc.dg/cpp/defined.c +++ b/gcc/testsuite/gcc.dg/cpp/defined.c @@ -4,17 +4,53 @@ /* Tests behaviour of the defined operator. */ -/* Source: Neil Booth, 29 Oct 2000. */ +/* Source: Neil Booth, 29 Oct 2000, Zack Weinberg 11 Dec 2000. */ + +#define defined /* { dg-error "defined" } */ /* No diagnostics, though you could argue there should be. */ #if defined defined #error defined is defined! #endif -#define defined /* { dg-error "defined" } */ - #define is_Z_defined defined Z +#if defined Z +#error Z is not defined +#endif + +/* The behaviour of "defined" when it comes from a macro expansion is + now documented. */ +#if is_Z_defined /* { dg-warning "macro expansion" } */ +#error Macro expanding into defined operator test 1 +#endif + +#define Z + +#if !defined Z +#error Z is defined +#endif + +#if !is_Z_defined /* { dg-warning "macro expansion" } */ +#error Macro expanding into defined operator test 2 +#endif + +#undef is_Z_defined +#undef Z + +/* Do all the tests over again with the () form of defined. */ + +/* No diagnostics, though you could argue there should be. */ +#if defined(defined) +#error defined is defined! +#endif + +#define is_Z_defined defined ( Z ) + +#if defined(Z) +#error Z is not defined +#endif + /* The behaviour of "defined" when it comes from a macro expansion is now documented. */ #if is_Z_defined /* { dg-warning "macro expansion" } */ @@ -22,6 +58,11 @@ #endif #define Z + +#if !defined(Z) +#error Z is defined +#endif + #if !is_Z_defined /* { dg-warning "macro expansion" } */ #error Macro expanding into defined operator test 2 #endif diff --git a/gcc/testsuite/gcc.dg/cpp/defined_trad.c b/gcc/testsuite/gcc.dg/cpp/defined_trad.c index 1902b06..666fd71 100644 --- a/gcc/testsuite/gcc.dg/cpp/defined_trad.c +++ b/gcc/testsuite/gcc.dg/cpp/defined_trad.c @@ -3,9 +3,10 @@ /* { dg-do preprocess } */ /* { dg-options "-traditional" } */ -/* Tests tradcpp0 with defined. */ +/* Tests tradcpp0 with defined. The defined operator in traditional C + works just the same as the defined operator in Standard C. */ -/* Source: Glibc, 11 Dec 2000. */ +/* Source: Zack Weinberg, glibc, Neil Booth 11 Dec 2000. */ #if defined REGPARMS #error REGPARMS should not be defined @@ -15,3 +16,64 @@ #if !defined REGPARMS #error REGPARMS should be defined #endif + +#define defined /* { dg-error "defined" } */ + +/* No diagnostics, though you could argue there should be. */ +#if defined defined +#error defined is defined! +#endif + +#define is_Z_defined defined Z + +#if defined Z +#error Z is not defined +#endif + +/* The behaviour of "defined" when it comes from a macro expansion is + now documented. */ +#if is_Z_defined +#error Macro expanding into defined operator test 1 +#endif + +#define Z + +#if !defined Z +#error Z is defined +#endif + +#if !is_Z_defined +#error Macro expanding into defined operator test 2 +#endif + +#undef is_Z_defined +#undef Z + +/* Do all the tests over again with the () form of defined. */ + +/* No diagnostics, though you could argue there should be. */ +#if defined(defined) +#error defined is defined! +#endif + +#define is_Z_defined defined ( Z ) + +#if defined(Z) +#error Z is not defined +#endif + +/* The behaviour of "defined" when it comes from a macro expansion is + now documented. */ +#if is_Z_defined +#error Macro expanding into defined operator test 1 +#endif + +#define Z + +#if !defined(Z) +#error Z is defined +#endif + +#if !is_Z_defined +#error Macro expanding into defined operator test 2 +#endif |