Tests by Zack Weinberg <zackw@stanford.edu>.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Wed, 13 Dec 2000 19:47:04 +0000 (19:47 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Wed, 13 Dec 2000 19:47:04 +0000 (19:47 +0000)
* gcc.dg/cpp/defined.c: Update.
* gcc.dg/cpp/defined_trad.c: New tests.

From-SVN: r38229

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/defined.c
gcc/testsuite/gcc.dg/cpp/defined_trad.c

index 627b22f3e965023cc7a1a16e4652242707f7b4da..d903cc938fdd19140bd63dcbccf68de8de03e20f 100644 (file)
@@ -1,3 +1,10 @@
+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.
index 0e82f7e1f50789a76b93f263b25e5e6adb91add0..de1ef2993bc52eb5b8d27e6af517e2eeb911e886 100644 (file)
@@ -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" } */
 #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
index 1902b061b844ba443e7f0798a4b8cd6117e03000..666fd712f5adf71c4a1a1936e57cfb54fc6f8184 100644 (file)
@@ -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
 #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