Commit 04fd40b9 by Neil Booth Committed by Neil Booth

Tests by Zack Weinberg <zackw@stanford.edu>.

	* gcc.dg/cpp/defined.c: Update.
	* gcc.dg/cpp/defined_trad.c: New tests.

From-SVN: r38229
parent a65fd88a
2000-12-13 Neil Booth <neil@daikokuya.demon.co.uk> 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. * gcc.dg/cpp/trad-direct.c: Update.
2000-12-11 Neil Booth <neilb@earthling.net> 2000-12-11 Neil Booth <neilb@earthling.net>
......
...@@ -4,17 +4,53 @@ ...@@ -4,17 +4,53 @@
/* Tests behaviour of the defined operator. */ /* 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. */ /* No diagnostics, though you could argue there should be. */
#if defined defined #if defined defined
#error defined is defined! #error defined is defined!
#endif #endif
#define defined /* { dg-error "defined" } */
#define is_Z_defined defined Z #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 /* The behaviour of "defined" when it comes from a macro expansion is
now documented. */ now documented. */
#if is_Z_defined /* { dg-warning "macro expansion" } */ #if is_Z_defined /* { dg-warning "macro expansion" } */
...@@ -22,6 +58,11 @@ ...@@ -22,6 +58,11 @@
#endif #endif
#define Z #define Z
#if !defined(Z)
#error Z is defined
#endif
#if !is_Z_defined /* { dg-warning "macro expansion" } */ #if !is_Z_defined /* { dg-warning "macro expansion" } */
#error Macro expanding into defined operator test 2 #error Macro expanding into defined operator test 2
#endif #endif
...@@ -3,9 +3,10 @@ ...@@ -3,9 +3,10 @@
/* { dg-do preprocess } */ /* { dg-do preprocess } */
/* { dg-options "-traditional" } */ /* { 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 #if defined REGPARMS
#error REGPARMS should not be defined #error REGPARMS should not be defined
...@@ -15,3 +16,64 @@ ...@@ -15,3 +16,64 @@
#if !defined REGPARMS #if !defined REGPARMS
#error REGPARMS should be defined #error REGPARMS should be defined
#endif #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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment