This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
New testsuite area for preprocessor tests
- To: gcc-patches at gcc dot gnu dot org
- Subject: New testsuite area for preprocessor tests
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Tue, 27 Jun 2000 15:25:33 -0700
This patch creates a subdirectory of gcc.dg for preprocessor tests,
and moves all the existing preprocessor tests I could find into the
new directory. Some of the tests have also been adjusted to be more
robust or not to run an executable.
The patch below does not include any of the "deletions".
This has been bootstrapped and tested on i386-linux and is now
committed.
zw
* gcc.dg/cpp: New directory.
* gcc.dg/cpp/cpp.exp: New driver.
* gcc.dg/cpp/20000627-1.c: New test.
* gcc.c-torture/special/special.exp: Remove entry for 921210-1.c.
* gcc.c-torture/special/921210-1.c: Move to gcc.dg/cpp/19921210-1.c
and rewrite as a compilation test.
* gcc.dg: Move many files into the cpp subdirectory, possibly
renaming or editing them as well.
Old name New name
990119-1.c cpp/19990119-1.c
990228-1.c cpp/19990228-1.c
990407-1.c cpp/19990407-1.c
990409-1.c cpp/19990409-1.c
990413-1.c cpp/19990413-1.c
990703-1.c cpp/19990703-1.c
20000127-1.c cpp/20000127-1.c
20000129-1.c cpp/20000129-1.c
20000207-1.c cpp/20000207-1.c
20000207-2.c cpp/20000207-2.c
20000209-1.c cpp/20000209-1.c
20000209-2.c cpp/20000209-2.c
20000301-1.c cpp/20000301-1.c
20000419-1.c cpp/20000419-1.c
20000510-1.S cpp/20000510-1.S
20000519-1.c cpp/20000519-1.c
20000529-1.c cpp/20000529-1.c
20000625-1.c cpp/20000625-1.c
20000625-2.c cpp/20000625-2.c
cpp-as1.c cpp/assert1.c
cpp-as2.c cpp/assert2.c
endif-label.c cpp/endif.c
cpp-hash1.c cpp/hash1.c
cpp-hash2.c cpp/hash2.c
cpp-if1.c cpp/if-1.c
cpp-if2.c cpp/if-2.c
cpp-if3.c cpp/if-3.c
cpp-if4.c cpp/if-4.c
cpp-if5.c cpp/if-5.c
cpp-cond.c cpp/if-cexp.c
cpp-missingop.c cpp/if-mop.c
cpp-opprec.c cpp/if-oppr.c
cpp-ifparen.c cpp/if-paren.c
cpp-shift.c cpp/if-shift.c
cpp-unary.c cpp/if-unary.c
cpp-li1.c cpp/line1.c
cpp-li2.c cpp/line2.c
lineno.c cpp/line3.c
lineno-2.c cpp/line4.c
cpp-mi.c cpp/mi1.c
cpp-mic.h cpp/mi1c.h
cpp-micc.h cpp/mi1cc.h
cpp-mind.h cpp/mi1nd.h
cpp-mindp.h cpp/mi1ndp.h
cpp-mix.h cpp/mi1x.h
cpp-mi2.c cpp/mi2.c
cpp-mi2a.h cpp/mi2a.h
cpp-mi2b.h cpp/mi2b.h
cpp-mi2c.h cpp/mi2c.h
cpp-mi3.c cpp/mi3.c
cpp-mi3.def cpp/mi3.def
poison-1.c cpp/poison.c
pr-impl.c cpp/prag-imp.c
cpp-redef-2.c cpp/redef1.c
cpp-redef.c cpp/redef2.c
strpaste.c cpp/strp1.c
strpaste-2.c cpp/strp2.c
cpp-tradpaste.c cpp/tr-paste.c
cpp-tradwarn1.c cpp/tr-warn1.c
cpp-tradwarn2.c cpp/tr-warn2.c
trigraphs.c cpp/trigraphs.c
cpp-unc1.c cpp/unc1.c
cpp-unc2.c cpp/unc2.c
cpp-unc3.c cpp/unc3.c
cpp-unc.c cpp/unc4.c
undef.c cpp/undef1.c
undef-2.c cpp/undef2.c
cpp-wi1.c cpp/widestr1.c
cxx-comments-1.c cpp/cxxcom1.c
cxx-comments-2.c cpp/cxxcom2.c
cpp-missingparen.c cpp/if-mpar.c
cpp-shortcircuit.c cpp/if-sc.c
cpp-tradstringify.c cpp/tr-str.c
===================================================================
Index: gcc.c-torture/special/special.exp
--- gcc.c-torture/special/special.exp 1999/09/22 10:15:28 1.7
+++ gcc.c-torture/special/special.exp 2000/06/27 22:22:05
@@ -50,17 +50,6 @@ if { [istarget rs6000-*-aix*]
dg-runtest $srcdir/$subdir/981006-1.c "-Wuninitialized -O2 $extra_flags" ""
dg-finish
-# 921210-1
-set lines [gcc_target_compile $srcdir/$subdir/921210-1.c "" preprocess ""]
-set lines [prune [split [prune_warnings [prune_gcc_output $lines]] "\n"] ""]
-set line [lindex $lines [expr [llength $lines]-1]]
-regsub -all " " $line "" clean
-if [expr [string compare $clean "(a->f+1)+1"]==0] then {
- pass "921210-1.c"
-} else {
- fail "921210-1.c"
-}
-
# 920521-1
c-torture 920521-1.c "-S"
===================================================================
Index: gcc.dg/cpp/19921210-1.c
--- gcc.dg/cpp/19921210-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/19921210-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,13 @@
+/* Test for proper disabling of macros within their own expansions. */
+/* { dg-do compile } */
+
+/* The following is a trick to evaluate a complex boolean expression
+ at compile time, inspired by autoconf 2.13's sizeof-detection. */
+
+enum { a = 4, f = 3 };
+
+#define a1(y) (y+2)
+#define a2(y) a1(y)+1
+#define f a+f
+
+char array[(a2(f)) == 10 ? 1 : -1];
===================================================================
Index: gcc.dg/cpp/19990119-1.c
--- gcc.dg/cpp/19990119-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/19990119-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,9 @@
+/* This checks for two things:
+ - an obscure corner case in the standard rules for __LINE__
+ - regression of an associated bug in cpplib where the semicolon got lost */
+/* { dg-do compile } */
+
+enum { i = __LINE__\
+};
+
+char array[i == 6 ? 1 : -1];
===================================================================
Index: gcc.dg/cpp/19990228-1.c
--- gcc.dg/cpp/19990228-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/19990228-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,29 @@
+/* Regression test for cpp. The following input may cause core dumps
+ or # line markers in the middle of the line. */
+/* { dg-do preprocess } */
+
+#define foo(string, arg) bar(2, string, arg)
+
+foo ("\
+\
+\
+\
+\
+\
+\
+\
+\
+\
+\
+",
+NULL);
+
+/*
+ { dg-final { if ![file exists 990228-1.i] { return } } }
+ { dg-final { set tmp [grep 990228-1.i ".#"] } }
+ { dg-final { if { [string length $tmp] == 0 } \{ } }
+ { dg-final { pass "990228-1.c: linemarkers in middle of line" } }
+ { dg-final { \} else \{ } }
+ { dg-final { fail "990228-1.c: linemarkers in middle of line" } }
+ { dg-final { \} } }
+ */
===================================================================
Index: gcc.dg/cpp/19990407-1.c
--- gcc.dg/cpp/19990407-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/19990407-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,19 @@
+/* Regression test for a cpplib macro-expansion bug where
+ `@' becomes `@@' when stringified. */
+
+/* { dg-do run } */
+
+#include <string.h>
+#include <stdlib.h>
+
+#define STR(x) #x
+
+char *a = STR(@foo), *b = "@foo";
+
+int
+main(void)
+{
+ if (strcmp (a, b))
+ abort ();
+ return 0;
+}
===================================================================
Index: gcc.dg/cpp/19990409-1.c
--- gcc.dg/cpp/19990409-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/19990409-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,6 @@
+/* Test that __LINE__ works when embedded in a macro. */
+/* { dg-do compile } */
+
+#define XLINE __LINE__
+
+char array[XLINE == __LINE__ ? 1 : -1];
===================================================================
Index: gcc.dg/cpp/19990413-1.c
--- gcc.dg/cpp/19990413-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/19990413-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,13 @@
+/* Verify that cpp doesn't screw up the line numbering when a macro argument
+ extends over multiple lines. */
+/* { dg-do compile } */
+
+#define FOO(x) /* nothing */
+
+void
+func(void)
+{
+ FOO(i
+ = 4)
+ else; /* { dg-error "parse error" "error on this line" { target *-*-* } { 12 } } */
+}
===================================================================
Index: gcc.dg/cpp/19990703-1.c
--- gcc.dg/cpp/19990703-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/19990703-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+
+/* Test of obscure case in token pasting in the preprocessor.
+ I can't think of any way to make this problem provoke a syntax error.
+ Based on a bug report by Manfred Hollstein. */
+
+#include <string.h>
+
+#define SP1(x, y) SP2(x, y)
+#define SP2(x, y) SP3(x##y)
+#define SP3(x) #x
+#define MZ -0
+
+int
+main(void)
+{
+ char *x = SP1(0,MZ);
+ char *y = "0-0"; /* should be the expansion of SP1(0,MZ) */
+
+ if(strcmp(x, y))
+ return 1;
+ else
+ return 0;
+}
===================================================================
Index: gcc.dg/cpp/20000127-1.c
--- gcc.dg/cpp/20000127-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000127-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,139 @@
+/* { dg-do compile } */
+
+/* Test for core dump in the preprocessor. Originally exposed by
+ XEmacs, but this has been synthesized from scratch. */
+
+#define foo(bar) bar
+
+int x =
+foo(
+ /*
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ xxxxxxxxxxxxxxxx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:32:27 1998
+++ gcc.dg/cpp/20000129-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,15 @@
+/* Regression test for trigraph warnings. Under certain conditions we
+ got the line numbers wrong.
+ Originally exposed by XEmacs and reported by Martin Buchholz
+ <martin@xemacs.org>; this test case is synthetic. */
+
+/* { dg-do preprocess } */
+/* { dg-options -Wall } */
+
+#define some_macro \
+ blah \
+ blah \
+ blah \
+ blah
+
+??> /* { dg-warning "trigraph ..." "trigraph encountered" } */
===================================================================
Index: gcc.dg/cpp/20000207-1.c
--- gcc.dg/cpp/20000207-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000207-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,16 @@
+/* { dg-do preprocess } */
+
+/* Test for proper handling of unary minus in #if. */
+
+#if !(-1)
+#error Error /* { dg-bogus "Error" "case !(-1)" } */
+#endif
+
+#if !-1
+#error Error /* { dg-bogus "Error" "case !-1" } */
+#endif
+
+#if -1
+#else
+#error Error /* { dg-bogus "Error" "case -1" } */
+#endif
===================================================================
Index: gcc.dg/cpp/20000207-2.c
--- gcc.dg/cpp/20000207-2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000207-2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,16 @@
+/* { dg-do preprocess } */
+
+/* Test for proper handling of unary plus in #if. */
+
+#if !(+1)
+#error Error /* { dg-bogus "Error" "case !(+1)" } */
+#endif
+
+#if !+1
+#error Error /* { dg-bogus "Error" "case !+1" } */
+#endif
+
+#if +1
+#else
+#error Error /* { dg-bogus "Error" "case +1" } */
+#endif
===================================================================
Index: gcc.dg/cpp/20000209-1.c
--- gcc.dg/cpp/20000209-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000209-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,34 @@
+/* { dg-do preprocess } */
+
+/* Tests for line numbering around function-like macro calls.
+ Bug found by Mark Mitchell. */
+
+#define f(x) x
+#define g f
+
+f (3);
+#error here /* { dg-error "here" "case 0" } */
+
+f
+ (3);
+#error here /* { dg-error "here" "case 1" } */
+
+(f
+ )(3);
+#error here /* { dg-error "here" "case 2" } */
+
+g
+ (3);
+#error here /* { dg-error "here" "case 3" } */
+
+(g
+ )(3);
+#error here /* { dg-error "here" "case 4" } */
+
+f /* some
+ text */ (3);
+#error here /* { dg-error "here" "case 5" } */
+
+(g /* some
+ text */ )(3);
+#error here /* { dg-error "here" "case 6" } */
===================================================================
Index: gcc.dg/cpp/20000209-2.c
--- gcc.dg/cpp/20000209-2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000209-2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+/* Distilled from glibc sources. Tests preprocessor corner cases.
+ Since it uses rest args, we must turn off -pedantic-errors. */
+
+#define NO_PAREN(rest...) rest
+#define DEFINE_CATEGORY(category, items) \
+const int _nl_value_type_##category[] = { NO_PAREN items }
+
+DEFINE_CATEGORY
+(
+ LC_COLLATE,
+ (
+ 1,
+ 2,
+ 3,
+ ));
+
+DEFINE_CATEGORY(LC_CTYPE, (1, 2, 3));
===================================================================
Index: gcc.dg/cpp/20000301-1.c
--- gcc.dg/cpp/20000301-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000301-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,3 @@
+/* { dg-do preprocess } */
+/* Test for crash with indented empty definitions. */
+ #define _LIBC_LIMITS_H_ /* nothing */
===================================================================
Index: gcc.dg/cpp/20000419-1.c
--- gcc.dg/cpp/20000419-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000419-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,15 @@
+/* Test for erroneous deletion of the entire macro expansion when pruning
+ \r escapes. Problem noted by DJ Delorie <dj@delorie.com>; test case
+ distilled from GNU libc header files. */
+/* { dg-do preprocess } */
+
+#define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
+#define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+#define __ASMNAME2(prefix, cname) __STRING (prefix) cname
+#define __STRING(x) #x
+
+__REDIRECT (a, b, c)
+__ASMNAME2 (__USER_LABEL_PREFIX__, harumph)
+
+/* { dg-bogus "used without args" "no args, 1" { target *-*-* } 11 } */
+/* { dg-bogus "used without args" "no args, 1" { target *-*-* } 12 } */
===================================================================
Index: gcc.dg/cpp/20000510-1.S
--- gcc.dg/cpp/20000510-1.S Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000510-1.S Tue Jun 27 14:53:17 2000
@@ -0,0 +1,20 @@
+/* Regression test - in assembly language, # may have some significance
+ other than 'stringize macro argument' and therefore must be preserved
+ in the output, and should not be warned about. */
+/* { dg-do preprocess } */
+
+#define foo() mov r0, #5 /* { dg-bogus "not followed" "spurious warning" } */
+
+entry:
+ foo()
+
+/*
+ { dg-final { if ![file exists 20000510-1.i] { return } } }
+ { dg-final { set tmp [grep 20000510-1.i # line] } }
+ { dg-final { if {[string length $tmp] > 0} \{ } }
+ { dg-final { pass "20000510-1.S: # preservation" } }
+ { dg-final { \} else \{ } }
+ { dg-final { fail "20000510-1.S: # preservation" } }
+ { dg-final { \} } }
+*/
+
===================================================================
Index: gcc.dg/cpp/20000519-1.c
--- gcc.dg/cpp/20000519-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000519-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,10 @@
+/* Regression test for preprocessor crash.
+ Reported by Mathias Froehlich <frohlich@na.uni-tuebingen.de>. */
+/* { dg-do preprocess } */
+#define foo
+
+#define __CAT__(a,b,c,d) a##b##c##d
+#define CAT(a,b,c,d) __CAT__(a,b,c,d)
+
+#define bar CAT(,foo,bar,)
+bar
===================================================================
Index: gcc.dg/cpp/20000529-1.c
--- gcc.dg/cpp/20000529-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000529-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,14 @@
+/* Regression test for bug with macro expansion on #if lines -
+ exposed by glibc. */
+/* { dg-do compile } */
+
+# define SHLIB_COMPAT(lib, introduced, obsoleted) \
+ (!(ABI_##lib##_##obsoleted - 0) \
+ || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0)))
+
+#if 0
+bad
+#elif SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+int
+#endif
+x;
===================================================================
Index: gcc.dg/cpp/20000625-1.c
--- gcc.dg/cpp/20000625-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000625-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,16 @@
+/* Regression test for paste corner cases. Distilled from
+ syscall stub logic in glibc. */
+
+/* { dg-do compile } */
+
+#define ENTRY(name) name##:
+#define socket bind
+
+int
+main(void)
+{
+ goto socket;
+
+ ENTRY(socket)
+ return 0;
+}
===================================================================
Index: gcc.dg/cpp/20000625-2.c
--- gcc.dg/cpp/20000625-2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000625-2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,27 @@
+/* More paste corner cases from glibc. */
+/* { dg-do run } */
+
+#define symbol_version(name, version) name##@##version
+
+#define str(x) xstr(x)
+#define xstr(x) #x
+
+const char a[] = str(symbol_version(getrlimit, GLIBC_2.0));
+const char b[] = str(getrlimit@GLIBC_2.0);
+const char c[] = "getrlimit@GLIBC_2.0";
+
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(void)
+{
+ if(strcmp(a, b))
+ abort();
+ if(strcmp(b, c))
+ abort();
+ if(strcmp(c, a))
+ abort();
+
+ return 0;
+}
===================================================================
Index: gcc.dg/cpp/20000627-1.c
--- gcc.dg/cpp/20000627-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/20000627-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,10 @@
+/* Test for spurious warnings with backslashes in perverse locations.
+ Bug exposed by Plumhall. */
+/* { dg-do compile } */
+
+extern int bar;
+
+#def\
+ine foo bar
+
+int main(void) { return foo; }
===================================================================
Index: gcc.dg/cpp/assert1.c
--- gcc.dg/cpp/assert1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/assert1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,46 @@
+/* Basic tests of the #assert preprocessor extension. */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+#define def unused expansion
+#define fail int fail
+
+#assert abc (def)
+#assert abc (ghi)
+#assert abc (jkl)
+#assert space ( s p a c e )
+
+/* Basic: */
+#if !#abc (def) || !#abc (ghi) || !#abc (jkl)
+fail
+#endif
+
+/* any answer for #abc */
+#if !#abc
+fail
+#endif
+
+/* internal whitespace is collapsed,
+ external whitespace is deleted */
+#if !#space (s p a c e) || !#space ( s p a c e ) || #space (space)
+fail
+#endif
+
+/* removing assertions */
+#unassert abc (jkl)
+#if !#abc || !#abc (def) || !#abc (ghi) || #abc (jkl)
+fail
+#endif
+
+#unassert abc
+#if #abc || #abc (def) || #abc (ghi) || #abc (jkl)
+fail
+#endif
+
+int gobble
+
+/* make sure it can succeed too.
+ also check space before open paren isn't significant */
+#if #space(s p a c e)
+;
+#endif
===================================================================
Index: gcc.dg/cpp/assert2.c
--- gcc.dg/cpp/assert2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/assert2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,24 @@
+/* Malformed assertion tests. */
+/* { dg-do preprocess } */
+/* { dg-options "-fno-show-column" } */
+
+#assert /* { dg-error "without predicate" "assert w/o predicate" } */
+#assert % /* { dg-error "an identifier" "assert punctuation" } */
+#assert 12 /* { dg-error "an identifier" "assert number" } */
+#assert abc /* { dg-error "missing" "assert w/o answer" } */
+
+#if # /* { dg-error "without predicate" "test w/o predicate" } */
+#endif
+
+#if #% /* { dg-error "an identifier" "test punctuation" } */
+#endif
+
+#if #12 /* { dg-error "an identifier" "test number" } */
+#endif
+
+#if #abc
+#error /* { dg-bogus "error" "test w/o answer" } */
+#endif
+
+#if #abc[def] /* { dg-error "invalid char" "test with malformed answer" } */
+#endif
===================================================================
Index: gcc.dg/cpp/cpp.exp
--- gcc.dg/cpp/cpp.exp Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/cpp.exp Tue Jun 27 14:53:17 2000
@@ -0,0 +1,70 @@
+# Copyright (C) 1997, 2000 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gcc@prep.ai.mit.edu
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# Utility for scanning compiler result, invoked via dg-final.
+# Call pass if pattern is present, otherwise fail.
+proc scan-assembler { testcase pattern } {
+ global subdir
+
+ set fd [open [file rootname $testcase].s r]
+ set text [read $fd]
+ close $fd
+
+ if [regexp -- $pattern $text] {
+ pass "$subdir/$testcase scan-assembler"
+ } else {
+ fail "$subdir/$testcase scan-assembler"
+ }
+}
+
+# Call pass if pattern is not present, otherwise fail.
+proc scan-assembler-not { testcase pattern } {
+ global subdir
+
+ set fd [open [file rootname $testcase].s r]
+ set text [read $fd]
+ close $fd
+
+ if ![regexp -- $pattern $text] {
+ pass "$subdir/$testcase scan-assembler-not"
+ } else {
+ fail "$subdir/$testcase scan-assembler-not"
+ }
+}
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+ "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
===================================================================
Index: gcc.dg/cpp/cxxcom1.c
--- gcc.dg/cpp/cxxcom1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/cxxcom1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,20 @@
+/* { dg-do preprocess } */
+/* { dg-options "-pedantic -std=gnu89" } */
+
+/* You can't do this in your own code... */
+// C++ comment is not in C89 { dg-warning "style comment|reported only once" "good warning" }
+
+/* ...but we don't bitch about it more than once. */
+// C++ comment is not in C89 { dg-bogus "style comment" "bad warning" }
+
+/*
+ { dg-final { if ![file exists cxx-comments-1.i] { return } } }
+ { dg-final { set tmp [grep cxx-comments-1.i "is not in C89" line] } }
+ { dg-final { # send_user "$tmp\n" } }
+ { dg-final { if [regexp "is not in C89" $tmp] \{ } }
+ { dg-final { fail "cxx-comments-1: comment strip check" } }
+ { dg-final { \} else \{ } }
+ { dg-final { pass "cxx-comments-1: comment strip check" } }
+ { dg-final { \} } }
+*/
+
===================================================================
Index: gcc.dg/cpp/cxxcom2.c
--- gcc.dg/cpp/cxxcom2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/cxxcom2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,20 @@
+/* { dg-do preprocess } */
+/* { dg-options "-pedantic -std=c89" } */
+
+/* This is an extension and therefore gets a warning. */
+#line 5 "cxx-comments-2.c" 3 /* { dg-warning "garbage at end" "#line extension" } */
+
+/* A system header may contain C++ comments irrespective of mode. */
+// C++ comment is not in C89 { dg-bogus "style comment" "bad warning" }
+
+/*
+ { dg-final { if ![file exists cxx-comments-2.i] { return } } }
+ { dg-final { set tmp [grep cxx-comments-2.i "is not in C89" line] } }
+ { dg-final { # send_user "$tmp\n" } }
+ { dg-final { if [regexp "is not in C89" $tmp] \{ } }
+ { dg-final { fail "cxx-comments-2: comment strip check" } }
+ { dg-final { \} else \{ } }
+ { dg-final { pass "cxx-comments-2: comment strip check" } }
+ { dg-final { \} } }
+*/
+
===================================================================
Index: gcc.dg/cpp/endif.c
--- gcc.dg/cpp/endif.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/endif.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,15 @@
+/* { dg-do preprocess } */
+/* { dg-options "-pedantic -Wall" } */
+
+/* You can't get away with this in your own code... */
+#ifdef KERNEL
+#define foo
+#endif KERNEL /* { dg-warning "forbids text after" "good warning" } */
+
+/* This will provoke a warning because the '3' is an extension. */
+#line 10 "endif-label.c" 3 /* { dg-warning "garbage at end" "#line extension" } */
+
+/* ... but in a system header, it's acceptable. */
+#ifdef KERNEL
+#define foo
+#endif KERNEL /* { dg-bogus "forbids text after" "bad warning" } */
===================================================================
Index: gcc.dg/cpp/hash1.c
--- gcc.dg/cpp/hash1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/hash1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,9 @@
+/* Test for proper handling of # in object-like macros.
+ From Linux kernel. */
+/* { dg-do preprocess } */
+
+#define FIXUP .section ".fixup",#alloc,#execinstr
+
+FIXUP
+
+/* { dg-bogus "not followed by" "object-like #" { target *-*-* } 3 } */
===================================================================
Index: gcc.dg/cpp/hash2.c
--- gcc.dg/cpp/hash2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/hash2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,15 @@
+/* Test for erroneously thinking comments are token-pastes.
+ From XFree86 4.0. */
+/* { dg-do preprocess } */
+/* { dg-options "-traditional" } */
+
+#ifndef foo
+#define foo /**/
+#endif
+
+#ifndef foo
+#define foo /* as nothing */
+#endif
+
+/* { dg-bogus "(start|end) of macro" "paste at end" { target *-*-* } 7 } */
+/* { dg-bogus "(start|end) of macro" "comment at end" { target *-*-* } 11 } */
===================================================================
Index: gcc.dg/cpp/if-1.c
--- gcc.dg/cpp/if-1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,34 @@
+/* { dg-do preprocess } */
+/* { dg-options "-pedantic-errors" } */
+
+#if 0xa != 10
+#error 0xa != 10 /* { dg-bogus "#error" "normal conversion" } */
+#endif
+
+#if 077 != 63
+#error 077 != 63 /* { dg-bogus "#error" "normal conversion" } */
+#endif
+
+#if 12wrt /* { dg-error "nvalid number|missing white" "invalid number" } */
+#endif
+
+#if 0abc /* { dg-error "nvalid number|missing white" "invalid number" } */
+#endif
+
+#if 42abc /* { dg-error "nvalid number|missing white" "invalid number" } */
+#endif
+
+#if 1.2 /* { dg-error "loating point numbers" "floating point in #if" } */
+#endif
+
+#if 4uu /* { dg-error "too many 'u'" "too many suffixes" } */
+#endif
+
+#if 124123231lll /* { dg-error "too many 'l'" "too many suffixes" } */
+#endif
+
+#if 099 /* { dg-error "digits beyond the radix" "decimal in octal constant" } */
+#endif
+
+#if 0xfffffffffffffffff /* { dg-error "integer constant out of range" "range error" } */
+#endif
===================================================================
Index: gcc.dg/cpp/if-2.c
--- gcc.dg/cpp/if-2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,19 @@
+/* { dg-do preprocess } */
+/* { dg-options -pedantic-errors } */
+
+#if 'a' != 'a' || '\001' != 1 || '\x12' != 0x12
+#error a,1,0x12 /* { dg-bogus "#error" "basic charconst recognition" } */
+#endif
+
+#if 'a' != L'a' || L'\xfeed' != 0xfeed
+#error L'a',0xfeed /* { dg-bogus "#error" "wide charconst recognition" } */
+#endif
+
+#if 'abcd' /* { dg-warning "multi-character character constant" "multi-character charconst" } */
+#endif
+
+#if 'abcdefghi' /* { dg-error "character constant (is )?too long" "charconst too long" } */
+#endif
+
+#if '' /* { dg-error "empty character constant" "empty charconst" } */
+#endif
===================================================================
Index: gcc.dg/cpp/if-3.c
--- gcc.dg/cpp/if-3.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-3.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,25 @@
+/* Test that the preprocessor is capable of 64-bit arithmetic.
+ (Must turn off -pedantic, since `LL' constants are only in C9x.) */
+/* { dg-do preprocess } */
+/* { dg-options "" } */
+
+#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 << 62) || !(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
===================================================================
Index: gcc.dg/cpp/if-4.c
--- gcc.dg/cpp/if-4.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-4.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,8 @@
+/* Regression test for proper error message. The token name isn't
+ NUL terminated, so we would print garbage after it. */
+/* { dg-do compile } */
+
+#if 1 += 2 /* { dg-error "'\\+=' is not allowed" "+= in if" } */
+syntax_error
+#endif
+int foo;
===================================================================
Index: gcc.dg/cpp/if-5.c
--- gcc.dg/cpp/if-5.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-5.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,12 @@
+/* Regression test: #ifdef 0 should not crash. Problem noted by
+ Jakub Jelinek <jakub@redhat.com>. */
+/* { dg-do preprocess } */
+
+#ifdef 0 /* { dg-error "with invalid argument" } */
+#error not seen
+#endif
+
+#ifndef 0 /* { dg-error "with invalid argument" } */
+#else
+#error not seen
+#endif
===================================================================
Index: gcc.dg/cpp/if-cexp.c
--- gcc.dg/cpp/if-cexp.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-cexp.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,13 @@
+/* { dg-do preprocess } */
+
+/* Test the ? : opearator, for precedence and both true and false. */
+
+#if 1 ? 1 ? 2 : 0 : 0
+#error OK /* { dg-error "OK" "nested ? :" } */
+#endif
+
+#if ((0) ? (1) ? (2) : (3) : (4) ? (5): (6)) == 5
+#error OK /* { dg-error "OK" "nested ? : with parens" } */
+#endif
+
+
===================================================================
Index: gcc.dg/cpp/if-mop.c
--- gcc.dg/cpp/if-mop.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-mop.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,23 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+
+/* Various illegal expressions with missing components. */
+
+#if /* { dg-error "no expression" "empty #if" } */
+#endif
+
+#if ~ /* { dg-error "no right op" "no unary operand" } */
+#endif
+
+#if 3 + * 6 + 4 /* { dg-error "no left op" "no left operand" } */
+#endif
+
+#if 2 ~2 /* { dg-error "missing bin" "no binary operator" } */
+#endif
+
+#if 1 + 2 (3) /* { dg-error "missing bin" "immediate then open paren" } */
+#endif
+
+#if (2) 4 * 2 /* { dg-error "missing bin" "close paren then immediate" } */
+#endif
===================================================================
Index: gcc.dg/cpp/if-mpar.c
--- gcc.dg/cpp/if-mpar.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-mpar.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,21 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* Test various combinations of missing parentheses give the correct
+ missing parenthesis message. */
+
+/* { dg-do preprocess } */
+
+#if (1 /* { dg-error "missing '\\)'" "missing ')' no. 1" } */
+#endif
+
+#if 2 * (3 + 4 /* { dg-error "missing '\\)'" "missing ')' no. 2" } */
+#endif
+
+#if (2)) /* { dg-error "missing '\\('" "missing '(' no. 1" } */
+#endif
+
+#if ) /* { dg-error "missing '\\('" "missing '(' no. 2" } */
+#endif
+
+#if 4) /* { dg-error "missing '\\('" "missing '(' no. 3" } */
+#endif
===================================================================
Index: gcc.dg/cpp/if-oppr.c
--- gcc.dg/cpp/if-oppr.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-oppr.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,97 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* Test the full range of preprocessor operator precedence. Each
+ operator is tested with one of immediately higher precedence to
+ verify it is of strictly lower precedence. To avoid complications,
+ each test uses just those two operators. Occasionally this assumes
+ correct operation of if-then-else, so the first tests verify this. */
+
+/* { dg-do preprocess } */
+
+/* Ensure correct functioning of if-then-else. */
+#if 1
+#else
+#error #else block evaluated for true conditional
+#endif
+
+#if 0
+#error #if block evaluated for false conditional
+#else
+#endif
+
+/* , not higher than ?. This is not a syntax error if it is. */
+#if 1 ? 0, 1: 1 /* { dg-error "syntax" "? higher precedence than ," } */
+#error
+#endif
+
+/* : strictly higher than ?. This would give a syntax error otherwise. */
+#if 0 ? 0 : 1 ? 1 : 1
+#endif
+
+/* || strictly higher than ?:. */
+#if 1 ? 0: 0 || 1
+#error operator ?: has higher precedence than operator ||
+#endif
+
+/* && strictly higher than ||. */
+#if 1 || 0 && 0
+#else
+#error operator || has higher precedence than operator &&
+#endif
+
+/* | strictly higher than &&. */
+#if 0 && 0 | 1
+#error operator && has higher precedence than operator |
+#endif
+
+/* ^ strictly higher than |. */
+#if 1 | 0 ^ 1
+#else
+#error operator | has higher precedence than operator ^
+#endif
+
+/* & strictly higher than ^. */
+#if 1 ^ 0 & 0
+#else
+#error operator ^ has higher precedence than operator &
+#endif
+
+/* == (!=) strictly higher than &. */
+#if 0 & 0 == 0
+#error operator & has higher precedence than operator ==
+#endif
+
+/* < (>, <=, >=) strictly higher than == (!=). */
+
+#if 0 == 0 < 0
+#else
+#error operator == has higher precedence than operator <
+#endif
+
+/* << (>>) strictly higher than < (>, <=, >=). */
+#if 1 < 1 << 1
+#else
+#error operator < has higher precedence than operator <<
+#endif
+
+/* Binary + (-) strictly higher than << (>>). */
+#if 0 << 0 + 1
+#error operator << has higher precedence than binary +
+#endif
+
+/* Binary * (/, %) strictly higher than binary + (-). */
+#if 1 + 0 * 0
+#else
+#error binary + has higher precedence than binary *
+#endif
+
+/* Unary operators (!, ~, -, +) strictly higher than binary * (/, %).
+ Equality is hard to detect because of right-associativity. */
+#if ~1 * 0
+#error binary * has higher precedence than operator ~
+#endif
+
+/* () > Unary. Unfortunately this requires an additional operator. */
+#if -(1 - 1)
+#error unary - has higher precedence than operator ()
+#endif
===================================================================
Index: gcc.dg/cpp/if-paren.c
--- gcc.dg/cpp/if-paren.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-paren.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,31 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+
+/* These now use "!=" rather than "<" to increase chance of failure. */
+#if 16 * (1) + 4 != 20
+#error /* { dg-bogus "error" "with paren" } */
+#endif
+
+#if 16 * 1 + 4 != 20
+#error /* { dg-bogus "error" "without paren" } */
+#endif
+
+#if () /* { dg-error "expression between" "empty paren" } */
+#endif
+
+#if (1) == 1
+#error /* { dg-error "error" "simple parens no. 1" } */
+#endif
+
+#if (2)
+#error /* { dg-error "error" "simple parens no. 2" } */
+#endif
+
+#if 3 == (3)
+#error /* { dg-error "error" "simple parens no. 3" } */
+#endif
+
+#if (((-1) + 8)) == ((+2) * ((3)) - -1)
+#error /* { dg-error "error" "nested parentheses" } */
+#endif
===================================================================
Index: gcc.dg/cpp/if-sc.c
--- gcc.dg/cpp/if-sc.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-sc.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,26 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+
+/* Test that all operators correctly short circuit. */
+
+#if (2 || 3 / 0) != 1
+#error /* { dg-bogus "error" "|| short circuit" } */
+#endif
+
+#if 0 && 3 / 0
+#error /* { dg-bogus "error" "&& short circuit" } */
+#endif
+
+#if 1 ? 0 : 3 / 0
+#error /* { dg-bogus "error" "? : right short circuit" } */
+#endif
+
+#if 0 ? 3 / 0 : 2
+#else
+#error /* { dg-bogus "error" "? : left short circuit" } */
+#endif
+
+#if -1 ? 0 && 3 / 0 : 3 / 0 + 5 == 5
+#error /* { dg-bogus "error" "nested short circuiting" } */
+#endif
===================================================================
Index: gcc.dg/cpp/if-shift.c
--- gcc.dg/cpp/if-shift.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-shift.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,22 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+
+/* Test shift operators. */
+
+#if 1 << 4 != 16
+#error /* { dg-bogus "error" "<< +ve shift" } */
+#endif
+
+#if 19 >> 2 != 4
+#error /* { dg-bogus "error" ">> +ve shift" } */
+#endif
+
+#if 17 << -2 != 17 >> 2
+#error /* { dg-bogus "error" "<< -ve shift" } */
+#endif
+
+#if 25 >> -2 != 25 << 2
+#error /* { dg-bogus "error" ">> -ve shift" } */
+#endif
+
===================================================================
Index: gcc.dg/cpp/if-unary.c
--- gcc.dg/cpp/if-unary.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/if-unary.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+
+/* Test the various unary operators. */
+
+#if 1 + + + 1 /* allow multiple unary sign operators :) */
+#endif
+
+#if 8 - +3 != +4 + +1
+#error /* { dg-bogus "error" "unary +" } */
+#endif
+
+#if -2 - -1 != -1
+#error /* { dg-bogus "error" "unary -" } */
+#endif
+
+#if ~0 != -1
+#error /* { dg-bogus "error" "unary ~" } */
+#endif
+
+#if !0 && (!1 == 0) && !!1 != 1
+#error /* { dg-bogus "error" "unary !" } */
+#endif
+
+#if ~~8 != 8
+#error /* { dg-bogus "error" "double unary ~" } */
+#endif
+
+#if 5 + +!-4 != 5
+#error /* { dg-bogus "error" "compound unary +, !, -" } */
+#endif
===================================================================
Index: gcc.dg/cpp/line1.c
--- gcc.dg/cpp/line1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/line1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,18 @@
+/* Copyright (C) 2000 Free Software Foundation.
+
+ by Alexandre Oliva <oliva@lsd.ic.unicamp.br> */
+
+/* { dg-do preprocess } */
+
+/* The line number below must be just a few lines greater than the
+ actual line number. */
+#line 10 "baz"
+wibble
+
+/*
+ { dg-final { if \{ [grep line1.i baz] != "" \} \{ } }
+ { dg-final { pass "line1.i: #line directive optimization" } }
+ { dg-final { \} else \{ } }
+ { dg-final { fail "line1.i: #line directive optimization" } }
+ { dg-final { \} } }
+*/
===================================================================
Index: gcc.dg/cpp/line2.c
--- gcc.dg/cpp/line2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/line2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,13 @@
+/* Copyright (C) 2000 Free Software Foundation.
+
+ by Alexandre Oliva <oliva@lsd.ic.unicamp.br> */
+
+/* { dg-do preprocess } */
+
+#line 1
+#line 0
+#line 2
+#line 32768
+
+/* { dg-error "out of range" "line # too low" { target *-*-* } 1 } */
+/* { dg-error "out of range" "line # too high" { target *-*-* } 2 } */
===================================================================
Index: gcc.dg/cpp/line3.c
--- gcc.dg/cpp/line3.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/line3.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-Wwrite-strings" } */
+/* The purpose of this test is to ensure that line numbers in diagnostics
+ are accurate after macros whose arguments contain newlines and are
+ substituted multiple times. The semicolons are on separate lines because
+ #line can only correct numbering on line boundaries. */
+#define one(x) x
+#define two(x) x x
+#define four(x) two(x) two(x)
+
+int
+main(void)
+{
+ char *A;
+
+ A = "text"; /* { dg-warning "discards qualifiers" "case zero" } */
+ A = one("text"
+ "text")
+ ; /* { dg-warning "discards qualifiers" "case one" } */
+ A = two("text"
+ "text")
+ ; /* { dg-warning "discards qualifiers" "case two" } */
+ A = four("text"
+ "text")
+ ; /* { dg-warning "discards qualifiers" "case four" } */
+
+ return 0;
+}
===================================================================
Index: gcc.dg/cpp/line4.c
--- gcc.dg/cpp/line4.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/line4.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+/* Test #line with and without macros for the line number. */
+
+extern void abort (void);
+
+#define L 90
+
+#line 44
+enum { i = __LINE__ };
+
+#line L
+enum { j = __LINE__ };
+
+#line 16 /* N.B. the _next_ line is line 16. */
+
+char array1[i == 44 ? 1 : -1];
+char array2[j == 90 ? 1 : -1];
+char array3[__LINE__ == 19 ? 1 : -1];
===================================================================
Index: gcc.dg/cpp/mi1.c
--- gcc.dg/cpp/mi1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,37 @@
+/* Test "ignore redundant include" facility.
+ We must test with C and C++ comments outside the guard conditional;
+ also, we test guarding with #ifndef and #if !defined.
+ -H is used because cpp mi1ght confuse the issue by optimizing out
+ #line markers. This test only passes if each of the headers is
+ read exactly once.
+
+ The disgusting regexp in the dg-error line, when stuck into
+ dg.exp's compiler-output regexp, matches the correct -H output and
+ only the correct -H output. It has to be all on one line because
+ otherwise it will not be interpreted all in one unit. */
+
+/* { dg-do compile }
+ { dg-options "-H" }
+ { dg-error "mi1c\.h\n\[^\n\]*mi1cc\.h\n\[^\n\]*mi1nd\.h\n\[^\n\]*mi1ndp\.h\n\[^\n\]*mi1x\.h" "redundant include check" { target *-*-* } 0 } */
+
+#include "mi1c.h"
+#include "mi1c.h"
+
+#include "mi1cc.h"
+#include "mi1cc.h"
+
+#include "mi1nd.h"
+#include "mi1nd.h"
+
+#include "mi1ndp.h"
+#include "mi1ndp.h"
+
+#define MIX_H
+#include "mi1x.h"
+#include "mi1x.h"
+
+int
+main (void)
+{
+ return a + b + c + d;
+}
===================================================================
Index: gcc.dg/cpp/mi1c.h
--- gcc.dg/cpp/mi1c.h Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi1c.h Tue Jun 27 14:53:17 2000
@@ -0,0 +1,10 @@
+/* Redundant header include test with C comments at top. */
+
+#ifndef CPP_MIC_H
+#define CPP_MIC_H
+
+int a;
+
+#endif
+
+/* And at the end too! */
===================================================================
Index: gcc.dg/cpp/mi1cc.h
--- gcc.dg/cpp/mi1cc.h Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi1cc.h Tue Jun 27 14:53:17 2000
@@ -0,0 +1,10 @@
+// Redundant header include test with C comments at top.
+
+#ifndef CPP_MICC_H
+#define CPP_MICC_H
+
+int b;
+
+#endif
+
+// And at the end too!
===================================================================
Index: gcc.dg/cpp/mi1nd.h
--- gcc.dg/cpp/mi1nd.h Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi1nd.h Tue Jun 27 14:53:17 2000
@@ -0,0 +1,8 @@
+/* Redundant include check with #if !defined. */
+
+#if !defined CPP_MIND_H
+#define CPP_MIND_H
+
+int c;
+
+#endif
===================================================================
Index: gcc.dg/cpp/mi1ndp.h
--- gcc.dg/cpp/mi1ndp.h Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi1ndp.h Tue Jun 27 14:53:17 2000
@@ -0,0 +1,7 @@
+#if !defined ( CPP_MINDP_H)
+#define CPP_MINDP_H
+
+/* Redundant include check with #if !defined and parentheses. */
+int d;
+
+#endif
===================================================================
Index: gcc.dg/cpp/mi1x.h
--- gcc.dg/cpp/mi1x.h Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi1x.h Tue Jun 27 14:53:17 2000
@@ -0,0 +1,9 @@
+/* This header is never to have its contents visible, but it should
+ still receive the optimization. */
+
+#ifndef MIX_H
+#define MIX_H
+
+#define main wibble
+
+#endif
===================================================================
Index: gcc.dg/cpp/mi2.c
--- gcc.dg/cpp/mi2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,12 @@
+/* Test for overly eager multiple include optimization.
+ Problem distilled from glibc 2.0.7's time.h, sys/time.h, timebits.h.
+ Problem noted by Tom Tromey <tromey@cygnus.com>. */
+/* { dg-do compile } */
+
+#include "mi2a.h"
+#include "mi2b.h"
+
+int main (void)
+{
+ return x;
+}
===================================================================
Index: gcc.dg/cpp/mi2a.h
--- gcc.dg/cpp/mi2a.h Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi2a.h Tue Jun 27 14:53:17 2000
@@ -0,0 +1,5 @@
+/* Test for overly eager multiple include optimization.
+ Problem distilled from glibc 2.0.7's time.h, sys/time.h, timebits.h.
+ Problem noted by Tom Tromey <tromey@cygnus.com>. */
+
+#include "mi2c.h"
===================================================================
Index: gcc.dg/cpp/mi2b.h
--- gcc.dg/cpp/mi2b.h Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi2b.h Tue Jun 27 14:53:17 2000
@@ -0,0 +1,6 @@
+/* Test for overly eager multiple include optimization.
+ Problem distilled from glibc 2.0.7's time.h, sys/time.h, timebits.h.
+ Problem noted by Tom Tromey <tromey@cygnus.com>. */
+
+#define need_x
+#include "mi2c.h"
===================================================================
Index: gcc.dg/cpp/mi2c.h
--- gcc.dg/cpp/mi2c.h Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi2c.h Tue Jun 27 14:53:17 2000
@@ -0,0 +1,15 @@
+/* Test for overly eager multiple include optimization.
+ Problem distilled from glibc 2.0.7's time.h, sys/time.h, timebits.h.
+ Problem noted by Tom Tromey <tromey@cygnus.com>. */
+#ifdef need_x
+#undef need_x
+#ifndef have_x
+#define have_x
+extern int x;
+#endif
+#endif
+
+#ifndef t_h
+#define t_h
+extern int y;
+#endif
===================================================================
Index: gcc.dg/cpp/mi3.c
--- gcc.dg/cpp/mi3.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi3.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,17 @@
+/* Another test case for over-eager multiple include optimization.
+ This one distilled from glibc's setlocale.c and categories.def. */
+/* { dg-do compile } */
+
+#define X a
+#include "mi3.def"
+#undef X
+
+#define X b
+#include "mi3.def"
+#undef X
+
+int
+main(void)
+{
+ return a + b;
+}
===================================================================
Index: gcc.dg/cpp/mi3.def
--- gcc.dg/cpp/mi3.def Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/mi3.def Tue Jun 27 14:53:17 2000
@@ -0,0 +1,10 @@
+/* Another test case for over-eager multiple include optimization.
+ This one distilled from glibc's setlocale.c and categories.def.
+ The #ifdef block doesn't cover the entire file, so it must not be
+ taken for a reinclude guard. */
+
+#ifndef NO_POSTLOAD
+#define NO_POSTLOAD NULL
+#endif
+
+int X;
===================================================================
Index: gcc.dg/cpp/poison.c
--- gcc.dg/cpp/poison.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/poison.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,25 @@
+/* { dg-do preprocess }
+ { dg-options "-fno-show-column" } */
+
+#pragma poison foo
+foo /* { dg-error "foo" "use of foo" } */
+#pragma poison foo2 foo3
+foo2 /* { dg-error "foo2" "use of foo2" } */
+foo3 /* { dg-error "foo3" "use of foo3" } */
+#pragma poison foo4 foo5
+foo4 /* { dg-error "foo4" "use of foo4" } */
+foo5 /* { dg-error "foo5" "use of foo5" } */
+#pragma poison +++ /* { dg-error "invalid" "poison non-identifier" } */
+#define foo6 123
+#pragma poison foo6 /* { dg-warning "foo6" "poison defined macro" } */
+#define foo6 345 /* { dg-error "foo6" "def of foo6" } */
+#define foo6 456 /* { dg-error "foo6" "redef of foo6" } */
+#ifdef foo6 /* { dg-error "foo6" "#ifdef foo6" } */
+#error hey! foo6 poisoned!
+#endif
+#if defined(foo6) /* { dg-error "foo6" "#if defined foo6" } */
+#error no, foo6 still poisoned!
+#else
+foo6 /* { dg-error "foo6" "use of foo6" } */
+#endif
+#pragma poison
===================================================================
Index: gcc.dg/cpp/prag-imp.c
--- gcc.dg/cpp/prag-imp.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/prag-imp.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,7 @@
+/* Test warnings generated by #pragma implementation in the wrong place. */
+/* { dg-do preprocess } */
+
+#pragma implementation "stdlib.h" /* { dg-bogus "appears after" "stdlib.h" } */
+#include <stdlib.h>
+#include <stdio.h>
+#pragma implementation "stdio.h" /* { dg-warning "appears after" "stdio.h" } */
===================================================================
Index: gcc.dg/cpp/redef1.c
--- gcc.dg/cpp/redef1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/redef1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,19 @@
+/* Test for redefining macros with insignificant (i.e. whitespace)
+ differences. */
+
+/* { dg-do preprocess } */
+
+#define foo bar
+#define /* x */ foo /* x */ bar /* x */
+
+#define quux(thud) a one and a thud and a two
+#define /**/ quux( thud ) /**/ a one and a /**/ thud /**/ and /**/ a two
+#define quux(thud) a one and a thud and a two /* bah */
+
+/* { dg-bogus "redefined" "foo redefined" { target *-*-* } 7 } */
+/* { dg-bogus "redefined" "quux redefined" { target *-*-* } 10 } */
+/* { dg-bogus "redefined" "quux redefined" { target *-*-* } 11 } */
+
+/* { dg-bogus "previous def" "foo prev def" { target *-*-* } 6 } */
+/* { dg-bogus "previous def" "quux prev def" { target *-*-* } 9 } */
+/* { dg-bogus "previous def" "quux prev def" { target *-*-* } 10 } */
===================================================================
Index: gcc.dg/cpp/redef2.c
--- gcc.dg/cpp/redef2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/redef2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,30 @@
+/* Test for redefining macros with significant differences. */
+
+/* { dg-do preprocess }
+ { dg-options "-ansi -pedantic -Wall -fno-show-column" } */
+
+#define mac(a, b) (a) + (b)
+#define mac(a, b) (a) * (b)
+#define mac(a, b) (a) * (x)
+#define mac(a, g) (a) * (x)
+
+#define ro(x) foo x bar
+#define ro(x, b) foo x bar
+
+#define va(a...) a
+#define va(...) __VA_ARGS__
+
+/* { dg-warning "redefined" "redef mac" { target *-*-* } 7 }
+ { dg-warning "redefined" "redef mac" { target *-*-* } 8 }
+ { dg-warning "redefined" "redef mac" { target *-*-* } 9 }
+ { dg-warning "redefined" "redef ro" { target *-*-* } 12 }
+ { dg-warning "redefined" "redef va" { target *-*-* } 15 }
+
+ { dg-warning "previous" "prev def mac" { target *-*-* } 6 }
+ { dg-warning "previous" "prev def mac" { target *-*-* } 7 }
+ { dg-warning "previous" "prev def mac" { target *-*-* } 8 }
+ { dg-warning "previous" "prev def ro" { target *-*-* } 11 }
+ { dg-warning "previous" "prev def va" { target *-*-* } 14 }
+
+ { dg-warning "varargs" "named varargs" { target *-*-* } 14 }
+ { dg-warning "varargs" "anon varargs" { target *-*-* } 15 } */
===================================================================
Index: gcc.dg/cpp/strp1.c
--- gcc.dg/cpp/strp1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/strp1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+
+/* Regression test for stringizing and token pasting.
+ We got internal escape markers in the strings. */
+
+#include <string.h>
+#include <stdlib.h>
+
+#define S(x) _S(x)
+#define _S(x) #x
+
+#define I 1
+static const char s1[] = S(I.1);
+static const char t1[] = "1.1";
+
+#define f h
+#define h(a) a+f
+static const char s2[] = S( f(1)(2) );
+static const char t2[] = "1+h(2)";
+
+#undef I
+#undef f
+#undef h
+
+int
+main(void)
+{
+ if (strcmp (s1, t1))
+ abort ();
+
+ if (strcmp (s2, t2))
+ abort ();
+
+ return 0;
+}
===================================================================
Index: gcc.dg/cpp/strp2.c
--- gcc.dg/cpp/strp2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/strp2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+
+/* Test for odd corner cases in stringizing/pasting.
+ Taken more or less verbatim from C99 section 6.10.3.3. */
+
+#include <stdlib.h>
+#include <string.h>
+
+#define hash_hash # ## #
+#define mkstr(a) # a
+#define in_between(a) mkstr(a)
+#define join(c, d) in_between(c hash_hash d)
+
+const char p[] = join(x, y);
+const char q[] = "x ## y";
+
+int
+main (void)
+{
+ if (strcmp (p, q))
+ abort ();
+ return 0;
+}
===================================================================
Index: gcc.dg/cpp/tr-paste.c
--- gcc.dg/cpp/tr-paste.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/tr-paste.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,17 @@
+/* Test for proper comment elimination semantics from cpplib's -traditional.
+ This should compile and link with compiled with `gcc -traditional-cpp'.
+ Test case by Jason R. Thorpe <thorpej@zembu.com>. */
+
+/* { dg-do compile } */
+/* { dg-options "-traditional" } */
+
+#define A(name) X/**/name
+
+#define B(name) \
+void A(Y/**/name)() { A(name)(); }
+
+void Xhello() { printf("hello world\n"); }
+
+B(hello)
+
+int main() { XYhello(); return (0); }
===================================================================
Index: gcc.dg/cpp/tr-str.c
--- gcc.dg/cpp/tr-str.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/tr-str.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,4 @@
+/* Test whether traditional stringify works. */
+/* { dg-do preprocess } */
+/* { dg-options "-traditional" } */
+#define foo(a, b) c="a"; d="b";
===================================================================
Index: gcc.dg/cpp/tr-warn1.c
--- gcc.dg/cpp/tr-warn1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/tr-warn1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,30 @@
+/* Test for warnings about nontraditional directives. */
+/* { dg-do preprocess } */
+/* { dg-options "-pedantic -Wtraditional -fno-show-column" } */
+
+/* Block 1: K+R directives should have the # indented. */
+
+#define foo bar /* { dg-bogus "indented" "^#kandr" } */
+# define foo bar /* { dg-bogus "indented" "^# kandr" } */
+ #define foo bar /* { dg-warning "indented" "^ #kandr" } */
+ # define foo bar /* { dg-warning "indented" "^ # kandr" } */
+
+/* Block 2: C89 directives should not have the # indented. */
+
+#pragma whatever /* { dg-warning "indented" "^#c89" } */
+# pragma whatever /* { dg-warning "indented" "^# c89" } */
+ #pragma whatever /* { dg-bogus "indented" "^ #c89" } */
+ # pragma whatever /* { dg-bogus "indented" "^ # c89" } */
+
+/* Block 3: Extensions should not have the # indented,
+ _and_ they should get a -pedantic warning. */
+
+#assert foo(bar) /* { dg-warning "indented" "^#ext" } */
+# assert bar(baz) /* { dg-warning "indented" "^# ext" } */
+ #assert baz(quux) /* { dg-bogus "indented" "^ #ext" } */
+ # assert quux(weeble) /* { dg-bogus "indented" "^ # ext" } */
+
+/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 22 } */
+/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 23 } */
+/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 24 } */
+/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 25 } */
===================================================================
Index: gcc.dg/cpp/tr-warn2.c
--- gcc.dg/cpp/tr-warn2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/tr-warn2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,14 @@
+/* K+R rejects use of function-like macros in non-function context.
+ ANSI C explicitly permits this (the macro is not expanded). */
+
+/* { dg-do compile } */
+/* { dg-options -Wtraditional } */
+
+enum { SIGN_EXTEND = 23 };
+
+#define SIGN_EXTEND(v) (((v) < 0) ? -1 : 0)
+
+int fun(void)
+{
+ return SIGN_EXTEND; /* { dg-warning "must be used with arguments" } */
+}
===================================================================
Index: gcc.dg/cpp/trigraphs.c
--- gcc.dg/cpp/trigraphs.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/trigraphs.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-options "-ansi" } */
+
+extern void abort (void);
+
+/* Basic tests for trigraph conversion.
+ All of them are here, but not in all possible contexts. *??/
+/
+
+??=include <stdio.h>
+
+??=define TWELVE 1??/
+2
+
+static const char str??(??) = "0123456789??/n";
+
+int
+main(void)
+??<
+ if (sizeof str != TWELVE)
+ abort ();
+
+ if ((5 ??' 3) != 6)
+ abort ();
+
+ if ((5 ??! 3) != 7)
+ abort ();
+
+ return 0;
+??>
===================================================================
Index: gcc.dg/cpp/unc1.c
--- gcc.dg/cpp/unc1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/unc1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,13 @@
+/* Tests for un-terminated conditionals: 1. */
+
+#if 1 /* { dg-error "unterminated" "unterminated #if" } */
+
+#ifdef notdef /* { dg-bogus "unterminated" "nested terminated #ifdef" } */
+
+blah blah blah
+
+#endif
+
+more text
+
+/* oops! */
===================================================================
Index: gcc.dg/cpp/unc2.c
--- gcc.dg/cpp/unc2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/unc2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,11 @@
+/* Tests for unterminated conditionals: 2. */
+
+#ifdef __sparc__ /* { dg-error "unterminated" "unterminated if-elif-elif..." } */
+sparc
+#elif defined __powerpc__
+ppc
+#elif defined __i386__
+i386
+#elif defined __vax__
+vax
+
===================================================================
Index: gcc.dg/cpp/unc3.c
--- gcc.dg/cpp/unc3.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/unc3.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,4 @@
+/* Tests for unterminated conditionals: 3. */
+
+#if 1 /* { dg-error "#else" "unterminated #else" } */
+#else
===================================================================
Index: gcc.dg/cpp/unc4.c
--- gcc.dg/cpp/unc4.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/unc4.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,40 @@
+/* { dg-do preprocess } */
+/* { dg-options "-fno-show-column" } */
+
+/* Tests for un-terminated conditional diagnostics.
+ Copyright (c) 1999 Free Software Foundation.
+ Contributed by Zack Weinberg, who made it up all by himself. */
+
+#endif /* { dg-error "#endif" "#endif without #if" } */
+
+#else /* { dg-error "#else" "#else without #if" } */
+#endif /* { dg-error "#endif" "#endif after #else without #if" } */
+
+#elif 0 /* { dg-error "#elif" "#elif without #if" } */
+#endif /* { dg-error "#endif" "#endif after #else without #if" } */
+
+#if 1 /* { dg-bogus "unterminated" "terminated true conditional" } */
+blah
+#endif
+
+#if 0 /* { dg-bogus "unterminated" "terminated false conditional" } */
+ignored
+#endif
+
+/* We shouldn't see unbalanced conditionals inside #if'ed out #includes. */
+#if 0
+#include "unc1.c"
+#endif
+
+/* The ifdef below should not get an error just because there's a bad if
+ inside the included file.
+ The odd dg-error tag on the include matches the "In file included from"
+ message. */
+#define FOO
+#ifdef FOO /* { dg-bogus "unterminated" "nested unterm" } */
+#include "unc1.c" /* { dg-error "" } */
+#endif
+
+/* dg.exp doesn't read the included files for tags, so we have to
+ do them explicitly here. */
+/* { dg-error "#if" "unc1.c: unterminated #if" { target *-*-* } 3 } */
===================================================================
Index: gcc.dg/cpp/undef1.c
--- gcc.dg/cpp/undef1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/undef1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,14 @@
+/* { dg-do preprocess } */
+
+/* 6.9.3.11: ...If there are sequences of preprocessing tokens within
+ the list of arguments that would otherwise act as preprocessing
+ directives, the behavior is undefined.
+
+ I choose to make this a hard error. It definitely should not cause
+ a core dump. */
+
+#define foo(bar) bar
+
+foo( blah
+#undef foo /* { dg-error "may not be used inside" "foo(#undef foo)" } */
+ blah )
===================================================================
Index: gcc.dg/cpp/undef2.c
--- gcc.dg/cpp/undef2.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/undef2.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,23 @@
+/* C99 6.10.8 para 4: None of [the predefined macro names] shall be the
+ subject of a #define or an #undef preprocessing directive. */
+
+/* { dg-do preprocess } */
+
+#undef __DATE__ /* { dg-warning "undefining" "__DATE__" } */
+#undef __TIME__ /* { dg-warning "undefining" "__TIME__" } */
+#undef __FILE__ /* { dg-warning "undefining" "__FILE__" } */
+#undef __LINE__ /* { dg-warning "undefining" "__LINE__" } */
+#undef __STDC__ /* { dg-warning "undefining" "__STDC__" } */
+
+/* These should be protected from #undef, but aren't, because they
+ are set with normal #define commands - and on top of that, some
+ of them are library properties, outside our control. To consider:
+ warn about undefining/redefining any identifier beginning with
+ __STDC_ .
+
+ __STDC_HOSTED__
+ __STDC_VERSION__
+ __STDC_IEC_559__
+ __STDC_IEC_559_COMPLEX__
+ __STDC_ISO_10646__
+ */
===================================================================
Index: gcc.dg/cpp/widestr1.c
--- gcc.dg/cpp/widestr1.c Tue May 5 13:32:27 1998
+++ gcc.dg/cpp/widestr1.c Tue Jun 27 14:53:17 2000
@@ -0,0 +1,9 @@
+/* Copyright (C) 2000 Free Software Foundation.
+
+ by Alexandre Oliva <oliva@lsd.ic.unicamp.br> */
+
+/* { dg-do preprocess } */
+
+#line 1 L"foo" /* { dg-error "not a string" "wide string in #line" } */
+#include L"stdio.h" /* { dg-error "expects" "wide string in #include" } */
+#pragma implementation L"test.h" /* { dg-error "malformed" "wide string in #pragma implementation" } */