summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-10 00:07:23 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-10 00:07:23 +0000
commit946ce1b70473e06c40af6817c28521213af2fb8d (patch)
treedbbe9eb784b1862db1081f71d85145cf0a696198
parente67abcc992189883a074e23f227f5b20ea5de814 (diff)
downloadgcc-946ce1b70473e06c40af6817c28521213af2fb8d.tar.gz
* cppinit.c (cpp_post_options): Shut off macro expansion if
-fpreprocessed. * cpplib.c (_cpp_handle_directive): If -fpreprocessed, accept IN_I directives only if the # is in column 1 and the directive name begins in column 2. * cppmain.c (scan_buffer): Insert a space between # and an identifier, when that identifier is a directive name. * tradcpp.c (struct file_buf): Add a pointer to the next entry in the header search path. (enum node_type): Add T_INCLUDE_NEXT. (directive_table): Add entry for include_next. (do_include_next): New function. (process_include): New routine, broken out of do_include. (finclude): Insert 'nhd' argument, to be copied into next_header_dir of the new buffer. (main): Adjust to match. * gsyslimits.h, limity.h: Un-indent #include_next. testsuite: * gcc.dg/cpp/direct2.c: New test. * gcc.dg/cpp/direct2s.c: New test. * gcc.c-torture/execute/920730-1t.c: #undef __GNUC__ at head. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@41932 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog23
-rw-r--r--gcc/cppinit.c5
-rw-r--r--gcc/cpplib.c27
-rw-r--r--gcc/cppmain.c7
-rw-r--r--gcc/gsyslimits.h2
-rw-r--r--gcc/limity.h2
-rw-r--r--gcc/testsuite/ChangeLog137
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/920730-1t.c5
-rw-r--r--gcc/testsuite/gcc.dg/cpp/direct2.c37
-rw-r--r--gcc/testsuite/gcc.dg/cpp/direct2s.c39
-rw-r--r--gcc/tradcpp.c108
11 files changed, 314 insertions, 78 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fa02fad4b24..a081dfe90a6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,24 @@
+2001-05-09 Zack Weinberg <zackw@stanford.edu>
+
+ * cppinit.c (cpp_post_options): Shut off macro expansion if
+ -fpreprocessed.
+ * cpplib.c (_cpp_handle_directive): If -fpreprocessed, accept
+ IN_I directives only if the # is in column 1 and the directive
+ name begins in column 2.
+ * cppmain.c (scan_buffer): Insert a space between # and an
+ identifier, when that identifier is a directive name.
+
+ * tradcpp.c (struct file_buf): Add a pointer to the next entry
+ in the header search path.
+ (enum node_type): Add T_INCLUDE_NEXT.
+ (directive_table): Add entry for include_next.
+ (do_include_next): New function.
+ (process_include): New routine, broken out of do_include.
+ (finclude): Insert 'nhd' argument, to be copied into
+ next_header_dir of the new buffer.
+ (main): Adjust to match.
+ * gsyslimits.h, limity.h: Un-indent #include_next.
+
2001-05-09 Joseph S. Myers <jsm28@cam.ac.uk>
* objc.texi: Move from ../libobjc/objc-features.texi. Adjust for
@@ -466,7 +487,7 @@ Fri May 4 13:10:03 CEST 2001 Jan Hubicka <jh@suse.cz>
(REG_OK_FOR_INDEX_P): Use INT_REG_OK_FOR_INDEX_P.
(REG_OK_FOR_BASE_P): Use INT_REG_OK_FOR_BASE_P.
(LEGITIMATE_OFFSET_ADDRESS_P): Use INT_REG_OK_FOR_INDEX_P and
- INT_REG_OK_FOR_BASE_P instead of REG_OK_FOR_INDEX_P and
+ INT_REG_OK_FOR_BASE_P instead of REG_OK_FOR_INDEX_P and
REG_OK_FOR_BASE_P. Take an additional parameter.
(LEGITIMATE_INDEXED_ADDRESS_P): Likeewise.
(LEGITIMATE_INDIRECT_ADDRESS_P): Likewise.
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index 980cdb1df42..fc15db4451a 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -1716,6 +1716,11 @@ cpp_post_options (pfile)
if (CPP_OPTION (pfile, user_label_prefix) == NULL)
CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX;
+ /* Permanently disable macro expansion if we are rescanning
+ preprocessed text. */
+ if (CPP_OPTION (pfile, preprocessed))
+ pfile->state.prevent_expansion = 1;
+
/* We need to do this after option processing and before
cpp_start_read, as cppmain.c relies on the options->no_output to
set its callbacks correctly before calling cpp_start_read. */
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 057bdf4ccae..97e0cf21fdd 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -311,7 +311,32 @@ _cpp_handle_directive (pfile, indented)
/* If we are rescanning preprocessed input, only directives tagged
with IN_I are honored, and the warnings below are suppressed. */
- if (! CPP_OPTION (pfile, preprocessed) || dir->flags & IN_I)
+ if (CPP_OPTION (pfile, preprocessed))
+ {
+ /* Kluge alert. In order to be sure that code like this
+ #define HASH #
+ HASH define foo bar
+ does not cause '#define foo bar' to get executed when
+ compiled with -save-temps, we recognize directives in
+ -fpreprocessed mode only if the # is in column 1 and the
+ directive name starts in column 2. This output can only
+ be generated by the directive callbacks in cppmain.c (see
+ also the special case in scan_buffer). */
+ if (dir->flags & IN_I && !indented && !(dname.flags & PREV_WHITE))
+ (*dir->handler) (pfile);
+ /* That check misses '# 123' linemarkers. Let them through too. */
+ else if (dname.type == CPP_NUMBER)
+ (*dir->handler) (pfile);
+ else
+ {
+ /* We don't want to process this directive. Put back the
+ tokens so caller will see them (and issue an error,
+ probably). */
+ _cpp_push_token (pfile, &dname, &pfile->directive_pos);
+ skip = 0;
+ }
+ }
+ else
{
/* Traditionally, a directive is ignored unless its # is in
column 1. Therefore in code intended to work with K+R
diff --git a/gcc/cppmain.c b/gcc/cppmain.c
index ceab9c992e7..db7f0736fea 100644
--- a/gcc/cppmain.c
+++ b/gcc/cppmain.c
@@ -238,6 +238,13 @@ scan_buffer (pfile)
== AVOID_LPASTE
&& cpp_avoid_paste (pfile, &tokens[1 - index], token))
token->flags |= PREV_WHITE;
+ /* Special case '# <directive name>': insert a space between
+ the # and the token. This will prevent it from being
+ treated as a directive when this code is re-preprocessed.
+ XXX Should do this only at the beginning of a line, but how? */
+ else if (token->type == CPP_NAME && token->val.node->directive_index
+ && tokens[1 - index].type == CPP_HASH)
+ token->flags |= PREV_WHITE;
cpp_output_token (token, print.outf);
print.printed = 1;
diff --git a/gcc/gsyslimits.h b/gcc/gsyslimits.h
index cc7b3fb877a..a3628025e8a 100644
--- a/gcc/gsyslimits.h
+++ b/gcc/gsyslimits.h
@@ -4,5 +4,5 @@
instead of this text. */
#define _GCC_NEXT_LIMITS_H /* tell gcc's limits.h to recurse */
- #include_next <limits.h>
+#include_next <limits.h>
#undef _GCC_NEXT_LIMITS_H
diff --git a/gcc/limity.h b/gcc/limity.h
index b2831fc459b..8bb398f6786 100644
--- a/gcc/limity.h
+++ b/gcc/limity.h
@@ -4,7 +4,7 @@
#else /* not _GCC_LIMITS_H_ */
#ifdef _GCC_NEXT_LIMITS_H
- #include_next <limits.h> /* recurse down to the real one */
+#include_next <limits.h> /* recurse down to the real one */
#endif
#endif /* not _GCC_LIMITS_H_ */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f4a0c70f5e4..a540321eefc 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2001-05-09 Zack Weinberg <zackw@stanford.edu>
+
+ * gcc.dg/cpp/direct2.c: New test.
+ * gcc.dg/cpp/direct2s.c: New test.
+
+ * gcc.c-torture/execute/920730-1t.c: #undef __GNUC__ at head.
+
2001-05-07 Mark Mitchell <mark@codesourcery.com>
* g++.old-deja/g++.other/op2.C: Don't use `glob' as a variable.
@@ -26,7 +33,7 @@
* lib/g++.exp (g++_include_flags): Don't use any special flags
if TESTING_IN_BUILD_TREE is not defined.
- (g++_init): Use a plain 'c++' as the compiler if
+ (g++_init): Use a plain 'c++' as the compiler if
TESTING_IN_BUILD_TREEE is not defined.
2001-05-02 Jakub Jelinek <jakub@redhat.com>
@@ -187,7 +194,7 @@ Thu Apr 26 11:15:12 2001 Jeffrey A Law (law@cygnus.com)
* gcc.dg/wtr-conversion-1.c: Don't test for width changes.
2001-04-12 Nathan Sidwell <nathan@codesourcery.com>
-
+
* g++.old-deja/g++.abi/primary3.C (main): Correct expected layout.
* g++.old-deja/g++.abi/crash1.C: New test.
@@ -205,7 +212,7 @@ Thu Apr 26 11:15:12 2001 Jeffrey A Law (law@cygnus.com)
22001-04-11 Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de>
- * g++.old-deja/g++.robertl/eb42.C: Same.
+ * g++.old-deja/g++.robertl/eb42.C: Same.
001-04-10 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
@@ -470,9 +477,9 @@ Fri Apr 6 15:36:15 2001 J"orn Rennecke <amylaar@redhat.com>
2001-03-06 Zack Weinberg <zackw@stanford.edu>
- * objc/execute/string1.m, objc/execute/string2.m: Compare the
- result of -cString against what we expect it to be; don't just
- print it out for no one to read.
+ * objc/execute/string1.m, objc/execute/string2.m: Compare the
+ result of -cString against what we expect it to be; don't just
+ print it out for no one to read.
* objc/execute/string3.m, objc/execute/string4.m: New tests.
Based on testcases provided by Nicola Pero.
@@ -546,8 +553,8 @@ Wed Feb 21 12:38:22 2001 Ovidiu Predescu <ovidiu@cup.hp.com>
2001-02-21 Gabriel Dos Reis <gdr@merlin.codesourcery.com>
- * g++.old-deja/g++.other/lookup22.C: New test.
-
+ * g++.old-deja/g++.other/lookup22.C: New test.
+
2001-02-19 Zack Weinberg <zackw@stanford.edu>
* g77.dg: New directory.
@@ -562,7 +569,7 @@ Wed Feb 21 12:38:22 2001 Ovidiu Predescu <ovidiu@cup.hp.com>
2001-02-16 Gabriel Dos Reis <gdr@codesourcery.com>
* g++.old-deja/g++.other/decl9.C: New test.
-
+
2001-02-16 Jakub Jelinek <jakub@redhat.com>
* g++.old-deja/g++.other/init16.C: Update the test so that it does
@@ -676,7 +683,7 @@ Wed Feb 7 09:54:47 2001 Ovidiu Predescu <ovidiu@cup.hp.com>
2001-02-06 Neil Booth <neil@daikokuya.demon.co.uk>
- * gcc.dg/cpp/avoidpaste1.c: Update.
+ * gcc.dg/cpp/avoidpaste1.c: Update.
Tue Feb 5 8:53:33 2001 Ovidiu Predescu <ovidiu@cup.hp.com>
@@ -718,7 +725,7 @@ Tue Feb 5 8:53:33 2001 Ovidiu Predescu <ovidiu@cup.hp.com>
2001-02-01 Neil Booth <neil@daikokuya.demon.co.uk>
- * gcc.dg/cpp/avoidpaste2.c: New tests.
+ * gcc.dg/cpp/avoidpaste2.c: New tests.
2001-01-31 Jakub Jelinek <jakub@redhat.com>
@@ -739,12 +746,12 @@ Wed Jan 31 12:23:32 2001 J"orn Rennecke <amylaar@redhat.com>
2001-01-31 Neil Booth <neil@daikokuya.demon.co.uk>
- * gcc.dg/cpp/tr-warn1.c: Add tests.
+ * gcc.dg/cpp/tr-warn1.c: Add tests.
2001-01-31 Neil Booth <neil@daikokuya.demon.co.uk>
- * gcc.dg/cpp/avoidpaste1.c: Update.
- * gcc.dg/cpp/paste4.c: Update.
+ * gcc.dg/cpp/avoidpaste1.c: Update.
+ * gcc.dg/cpp/paste4.c: Update.
2001-01-30 Jeffrey Oldham <oldham@codesourcery.com>
@@ -770,7 +777,7 @@ Wed Jan 31 12:23:32 2001 J"orn Rennecke <amylaar@redhat.com>
2001-01-28 Neil Booth <neil@daikokuya.demon.co.uk>
- * gcc.dg/cpp/avoidpaste1.c: Test case.
+ * gcc.dg/cpp/avoidpaste1.c: Test case.
2001-01-28 Jakub Jelinek <jakub@redhat.com>
@@ -886,7 +893,7 @@ Wed Jan 31 12:23:32 2001 J"orn Rennecke <amylaar@redhat.com>
2001-01-18 Neil Booth <neil@daikokuya.demon.co.uk>
- * gcc.dg/cpp/assembl2.S: New test case.
+ * gcc.dg/cpp/assembl2.S: New test case.
2001-01-17 Jeffrey Oldham <oldham@codesourcery.com>
@@ -926,9 +933,9 @@ Wed Jan 31 12:23:32 2001 J"orn Rennecke <amylaar@redhat.com>
2001-01-15 Neil Booth <neil@daikokuya.demon.co.uk>
- * gcc.dg/cpp/if-2.c: Comment out occasionally bogus test; we
- have an equivalent working one below it.
-
+ * gcc.dg/cpp/if-2.c: Comment out occasionally bogus test; we
+ have an equivalent working one below it.
+
2001-01-14 Jeffrey Oldham <oldham@codesourcery.com>
* g++.old-deja/g++.ext/instantiate2.C: Add explanatory comment.
@@ -970,8 +977,8 @@ Wed Jan 31 12:23:32 2001 J"orn Rennecke <amylaar@redhat.com>
2001-01-13 Neil Booth <neil@daikokuya.demon.co.uk>
- * gcc.dg/cpp/widestr1.c: Update.
- * gcc.dg/cpp/prag-imp.c: Remove.
+ * gcc.dg/cpp/widestr1.c: Update.
+ * gcc.dg/cpp/prag-imp.c: Remove.
2001-01-12 Jakub Jelinek <jakub@redhat.com>
@@ -1018,7 +1025,7 @@ Wed Jan 31 12:23:32 2001 J"orn Rennecke <amylaar@redhat.com>
2001-01-10 Alan Lehotsky <lehotsky@tiac.net>
* gcc.dg/20000926-1.c: Parameterize for machines with 16-bit ints.
-
+
2001-01-10 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.pt/error3.C: New test.
@@ -1034,17 +1041,17 @@ Wed Jan 31 12:23:32 2001 J"orn Rennecke <amylaar@redhat.com>
2001-01-08 Jonathan Larmour <jlarmour@redhat.com>
* gcc.dg/20000419-2.c: Move to "special" subdirectory.
- * gcc.dg/special/20000419-2.c: New file. Identical to above.
- * gcc.dg/special/special.exp: New test driver which will check
- for alias support for the above test.
+ * gcc.dg/special/20000419-2.c: New file. Identical to above.
+ * gcc.dg/special/special.exp: New test driver which will check
+ for alias support for the above test.
2001-01-09 Alan Lehotsky <lehotsky@tiac.net>
* gcc.c-torture/execute/921202-1.c: Use STACK_SIZE to avoid
problems on small machines.
* gcc.c-torture/execute/920730-1.c: Use values from <limits.h> to
- parameterize.
-
+ parameterize.
+
2001-01-09 Jeffrey Oldham <oldham@codesourcery.com>
* g++.old-deja/g++.ext/instantiate2.C: ERROR line should fail for
@@ -1229,7 +1236,7 @@ Thu Jan 4 13:54:11 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
2001-01-03 Jeffrey Oldham <oldham@codesourcery.com>
* lib/target-supports.exp (check_alias_available): Modified to
- indicate aliases not supported if only weak aliases are supported.
+ indicate aliases not supported if only weak aliases are supported.
2001-01-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
@@ -1362,12 +1369,12 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-12-17 Neil Booth <neil@daikokuya.demon.co.uk>
- * gcc.dg/cpp/multiline.c: New test.
+ * gcc.dg/cpp/multiline.c: New test.
2000-12-17 Neil Booth <neil@daikokuya.demon.co.uk>
- * g++.old-deja/g++.other/syshdr1.C: Update.
- * gcc.dg/cpp/lineflags.c: Remove temporarily.
+ * g++.old-deja/g++.other/syshdr1.C: Update.
+ * gcc.dg/cpp/lineflags.c: Remove temporarily.
2000-12-15 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
@@ -1415,7 +1422,7 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-12-11 Neil Booth <neilb@earthling.net>
- * gcc.dg/cpp/if-2.c: Separate tests so that which failed is obvious.
+ * gcc.dg/cpp/if-2.c: Separate tests so that which failed is obvious.
2000-12-09 Joseph S. Myers <jsm28@cam.ac.uk>
@@ -1423,10 +1430,10 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-12-09 Neil Booth <neilb@earthling.net>
- * gcc.dg/cpp/lineflags.c: New tests.
- * gcc.dg/cpp/poison.c: Update.
- * gcc.dg/cpp/redef2.c: Update.
- * gcc.dg/cpp/skipping.c: New test.
+ * gcc.dg/cpp/lineflags.c: New tests.
+ * gcc.dg/cpp/poison.c: Update.
+ * gcc.dg/cpp/redef2.c: Update.
+ * gcc.dg/cpp/skipping.c: New test.
2000-12-07 Geoffrey Keating <geoffk@redhat.com>
@@ -1434,12 +1441,12 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-12-07 Neil Booth <neilb@earthling.net>
- * gcc.dg/wtr-aggr-init-1.c, wtr-escape-1.c, wtr-int-type-1.c,
- wtr-label-1.c, wtr-static-1.c, wtr-strcat-1.c, wtr-suffix-1.c,
- wtr-switch-1.c, wtr-unary-plus-1.c, wtr-union-init-1.c
- wtr-union-init-2.c, wtr-union-init-3.c: Update.
- * gcc.dg/cpp/extratokens.c, tr-warn4.c, tr-warn5.c, tr-warn6.c:
- Update.
+ * gcc.dg/wtr-aggr-init-1.c, wtr-escape-1.c, wtr-int-type-1.c,
+ wtr-label-1.c, wtr-static-1.c, wtr-strcat-1.c, wtr-suffix-1.c,
+ wtr-switch-1.c, wtr-unary-plus-1.c, wtr-union-init-1.c
+ wtr-union-init-2.c, wtr-union-init-3.c: Update.
+ * gcc.dg/cpp/extratokens.c, tr-warn4.c, tr-warn5.c, tr-warn6.c:
+ Update.
2000-12-07 Joseph S. Myers <jsm28@cam.ac.uk>
@@ -1514,8 +1521,8 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-12-04 Neil Booth <neilb@earthling.net>
- * gcc.dg/cpp/assert_trad1.c, assert_trad2.c, assert_trad3.c:
- New tests.
+ * gcc.dg/cpp/assert_trad1.c, assert_trad2.c, assert_trad3.c:
+ New tests.
2000-12-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
@@ -1528,7 +1535,7 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-12-03 Neil Booth <neilb@earthling.net>
- * gcc.dg/cpp/macro6.c: New test cases.
+ * gcc.dg/cpp/macro6.c: New test cases.
2000-12-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
@@ -1548,19 +1555,19 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-12-02 Neil Booth <neilb@earthling.net>
- * g++.old-deja/g++.other/externC4.C,
- g++.old-deja/g++.other/friend10.C: New tests.
+ * g++.old-deja/g++.other/externC4.C,
+ g++.old-deja/g++.other/friend10.C: New tests.
2000-12-02 Neil Booth <neilb@earthling.net>
- * g++.old-deja/g++.other/instan2.C
- * g++.old-deja/g++.other/instan3.C: New test.
+ * g++.old-deja/g++.other/instan2.C
+ * g++.old-deja/g++.other/instan3.C: New test.
2000-12-02 Neil Booth <neilb@earthling.net>
- * gcc.dg/cpp/c++98.c,c++98-pedantic.c,c89.c,c89-pedantic.c,
- c94.c,c94-pedantic.c,c99.c,c99-pedantic.c,gnuc89.c,gnuc89-pedantic.c,
- gnuc99.c,gnuc99-pedantic.c: New tests.
+ * gcc.dg/cpp/c++98.c,c++98-pedantic.c,c89.c,c89-pedantic.c,
+ c94.c,c94-pedantic.c,c99.c,c99-pedantic.c,gnuc89.c,gnuc89-pedantic.c,
+ gnuc99.c,gnuc99-pedantic.c: New tests.
2000-12-01 Joseph S. Myers <jsm28@cam.ac.uk>
@@ -1569,9 +1576,9 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-12-01 Neil Booth <neilb@earthling.net>
- * gcc.dg/cpp/20000720-1.S: Remove duplicate testcase.
- * gcc.dg/cpp/poison.c: Update.
- * gcc.dg/cpp/spacing1.c: New testcase for all spacing issues.
+ * gcc.dg/cpp/20000720-1.S: Remove duplicate testcase.
+ * gcc.dg/cpp/poison.c: Update.
+ * gcc.dg/cpp/spacing1.c: New testcase for all spacing issues.
2000-12-01 Toon Moene <toon@moene.indiv.nluug.nl>
@@ -1727,7 +1734,7 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-11-22 Loren J. Rittle <ljrittle@acm.org>
- * g++.old-deja/g++.robertl/eb39.C: Don't include libio.h.
+ * g++.old-deja/g++.robertl/eb39.C: Don't include libio.h.
2000-11-22 Jakub Jelinek <jakub@redhat.com>
@@ -1747,7 +1754,7 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-11-21 Neil Booth <neilb@earthling.net>
- * gcc.dg/cpp/integrated1.c: Remove.
+ * gcc.dg/cpp/integrated1.c: Remove.
2000-11-21 Jakub Jelinek <jakub@redhat.com>
@@ -1773,8 +1780,8 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-11-20 Neil Booth <neilb@earthling.net>
- * gcc.dg/cpp/paste2.c: Update test.
- * objc/execute/paste.m: New test.
+ * gcc.dg/cpp/paste2.c: Update test.
+ * objc/execute/paste.m: New test.
2000-11-20 Joseph S. Myers <jsm28@cam.ac.uk>
@@ -1853,8 +1860,8 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-11-15 Neil Booth <neilb@earthling.net>
- gcc.dg/cpp/_Pragma1.c: Update.
- gcc.dg/cpp/_Pragma2.c: New test.
+ gcc.dg/cpp/_Pragma1.c: Update.
+ gcc.dg/cpp/_Pragma2.c: New test.
2000-11-15 Nathan Sidwell <nathan@codesourcery.com>
@@ -2038,7 +2045,7 @@ Thu Dec 21 22:43:03 2000 J"orn Rennecke <amylaar@redhat.com>
2000-11-04 Neil Booth <neilb@earthling.net>
- * gcc.dg/cpp/include2.c: New tests.
+ * gcc.dg/cpp/include2.c: New tests.
Fri Nov 3 13:32:14 2000 Mark P Mitchell <mark@codesourcery.com>
@@ -2092,7 +2099,7 @@ Fri Nov 3 13:32:14 2000 Mark P Mitchell <mark@codesourcery.com>
2000-10-29 Neil Booth <neilb@earthling.net>
- * gcc.dg/cpp/macro4.c, macro5.c: New tests.
+ * gcc.dg/cpp/macro4.c, macro5.c: New tests.
* mi1.c, mi1c.h: Add null directives to multiple-include test.
* mi5.c: Test multiple includes work with -C.
* trigraphs.c: Test ^= version.
@@ -2341,7 +2348,7 @@ Mon Oct 9 23:32:06 MET DST 2000 Jan Hubicka <jh@suse.cz>
2000-09-26 Jakub Jelinek <jakub@redhat.com>
- * gcc.c-torture/compile/20000923-1.c: New test.
+ * gcc.c-torture/compile/20000923-1.c: New test.
2000-09-25 Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr>
@@ -2473,7 +2480,7 @@ Tue Sep 12 18:32:07 2000 J"orn Rennecke <amylaar@redhat.co.uk>
2000-09-07 Catherine Moore <clm@redhat.com>
- * gcc.c-torture/execute/unroll-1.c: New test.
+ * gcc.c-torture/execute/unroll-1.c: New test.
2000-09-06 Zack Weinberg <zack@wolery.cumb.org>
diff --git a/gcc/testsuite/gcc.c-torture/execute/920730-1t.c b/gcc/testsuite/gcc.c-torture/execute/920730-1t.c
index bc5e4131983..7467f35753c 100644
--- a/gcc/testsuite/gcc.c-torture/execute/920730-1t.c
+++ b/gcc/testsuite/gcc.c-torture/execute/920730-1t.c
@@ -1,3 +1,8 @@
/* This is just 920730-1.c compiled with -traditional.
See 920730-1t.x. */
+
+/* It is necessary to undefine __GNUC__ in order to prevent glibc 2.2's
+ sys/cdefs.h from issuing an #error. Do Not Ask. */
+#undef __GNUC__
+
#include "920730-1.c"
diff --git a/gcc/testsuite/gcc.dg/cpp/direct2.c b/gcc/testsuite/gcc.dg/cpp/direct2.c
new file mode 100644
index 00000000000..d6dc1088c37
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/direct2.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ Contributed by Nathan Sidwell 8 May 2001 <nathan@codesourcery.com> */
+
+/* Test of prohibition on directives which result from macro expansion.
+ See also direct2s.c */
+
+/* { dg-do compile } */
+
+#define HASH #
+#define HASHDEFINE #define
+#define HASHINCLUDE #include
+
+HASH include "somerandomfile" /*{ dg-error "syntax|parse" "non-include" }*/
+/*{ dg-bogus "No such" "don't execute non-include" { target *-*-* } 13 }*/
+HASHINCLUDE <somerandomfile> /*{ dg-error "syntax|parse" "non-include 2" }*/
+/*{ dg-bogus "No such" "don't execute non-include 2" { target *-*-* } 15 }*/
+
+void g ()
+{
+HASH define X 1 /* { dg-error "syntax error" "# from macro" } */
+HASHDEFINE Y 1 /* { dg-error "syntax error" "#define from macro" } */
+}
+
+#pragma GCC dependency "direct2.c"
+#
+
+void f ()
+{
+ int i = X; /* { dg-error "undeclared|for each" "no macro X" } */
+ int j = Y; /* { dg-error "undeclared|for each" "no macro Y" } */
+}
+
+#define slashstar /##*
+#define starslash *##/
+
+slashstar starslash /* { dg-error "parse error" "not a comment" } */
+/* { dg-warning "does not give" "paste warning(s)" { target *-*-* } 36 } */
diff --git a/gcc/testsuite/gcc.dg/cpp/direct2s.c b/gcc/testsuite/gcc.dg/cpp/direct2s.c
new file mode 100644
index 00000000000..6c98ecc9a12
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/direct2s.c
@@ -0,0 +1,39 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ Contributed by Nathan Sidwell 8 May 2001 <nathan@codesourcery.com> */
+
+/* Test of prohibition on directives which result from macro
+ expansion. Same as direct2.c, with -save-temps applied; results
+ should be identical. */
+
+/* { dg-do compile } */
+/* { dg-options "-save-temps -ansi -pedantic-errors" } */
+
+#define HASH #
+#define HASHDEFINE #define
+#define HASHINCLUDE #include
+
+HASH include "somerandomfile" /*{ dg-error "syntax|parse" "non-include" }*/
+/*{ dg-bogus "No such" "don't execute non-include" { target *-*-* } 15 }*/
+HASHINCLUDE <somerandomfile> /*{ dg-error "syntax|parse" "non-include 2" }*/
+/*{ dg-bogus "No such" "don't execute non-include 2" { target *-*-* } 17 }*/
+
+void g ()
+{
+HASH define X 1 /* { dg-error "syntax error" "# from macro" } */
+HASHDEFINE Y 1 /* { dg-error "syntax error" "#define from macro" } */
+}
+
+#pragma GCC dependency "direct2s.c"
+#
+
+void f ()
+{
+ int i = X; /* { dg-error "undeclared|for each" "no macro X" } */
+ int j = Y; /* { dg-error "undeclared|for each" "no macro Y" } */
+}
+
+#define slashstar /##*
+#define starslash *##/
+
+slashstar starslash /* { dg-error "parse error" "not a comment" } */
+/* { dg-warning "does not give" "paste warning(s)" { target *-*-* } 38 } */
diff --git a/gcc/tradcpp.c b/gcc/tradcpp.c
index bfb12027b83..46b7e994a0c 100644
--- a/gcc/tradcpp.c
+++ b/gcc/tradcpp.c
@@ -105,6 +105,7 @@ static const char *user_label_prefix;
It is zero for rescanning results of macro expansion
and for expanding macro arguments. */
#define INPUT_STACK_MAX 200
+struct file_name_list;
struct file_buf {
const char *fname;
int lineno;
@@ -120,6 +121,8 @@ struct file_buf {
struct if_stack *if_stack;
/* Object to be freed at end of input at this level. */
U_CHAR *free_ptr;
+ /* Position to start scanning for #include_next in this file. */
+ struct file_name_list *next_header_dir;
} instack[INPUT_STACK_MAX];
typedef struct file_buf FILE_BUF;
@@ -240,6 +243,7 @@ union hashval {
enum node_type {
T_DEFINE = 1, /* `#define' */
T_INCLUDE, /* `#include' */
+ T_INCLUDE_NEXT,/* `#include_next' */
T_IFDEF, /* `#ifdef' */
T_IFNDEF, /* `#ifndef' */
T_IF, /* `#if' */
@@ -358,6 +362,7 @@ static void do_error PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *));
static void do_warning PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *));
static void do_line PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *));
static void do_include PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *));
+static void do_include_next PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *));
static void do_undef PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *));
static void do_if PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *));
static void do_ifdef PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *));
@@ -415,7 +420,10 @@ static void make_assertion PARAMS ((const char *));
static void grow_outbuf PARAMS ((FILE_BUF *, int));
static int handle_directive PARAMS ((FILE_BUF *, FILE_BUF *));
-static void finclude PARAMS ((int, const char *, FILE_BUF *));
+static void process_include PARAMS ((struct file_name_list *,
+ const U_CHAR *, int, int, FILE_BUF *));
+static void finclude PARAMS ((int, const char *,
+ struct file_name_list *, FILE_BUF *));
static void init_dependency_output PARAMS ((void));
static void rescan PARAMS ((FILE_BUF *, int));
static void newline_fix PARAMS ((U_CHAR *));
@@ -450,6 +458,7 @@ struct directive directive_table[] = {
{ 4, do_elif, "elif", T_ELIF },
{ 5, do_error, "error", T_ERROR },
{ 7, do_warning, "warning", T_WARNING },
+ { 12, do_include_next, "include_next", T_INCLUDE_NEXT },
{ 6, do_assert, "assert", T_ASSERT },
{ 8, do_unassert,"unassert",T_UNASSERT},
{ -1, 0, "", T_UNUSED},
@@ -853,7 +862,7 @@ main (argc, argv)
if (print_deps)
deps_add_dep (deps, pend[i].arg);
- finclude (fd, pend[i].arg, &outbuf);
+ finclude (fd, pend[i].arg, 0, &outbuf);
}
indepth--;
no_output--;
@@ -2278,22 +2287,17 @@ do_include (buf, limit, op)
U_CHAR *buf, *limit;
FILE_BUF *op;
{
- char *fname; /* Dynamically allocated fname buffer */
U_CHAR *fbeg, *fend; /* Beginning and end of fname */
struct file_name_list *stackp = include; /* Chain of dirs to search */
struct file_name_list dsp[1]; /* First in chain, if #include "..." */
int flen;
- int f; /* file number */
-
int retried = 0; /* Have already tried macro
expanding the include line*/
FILE_BUF trybuf; /* It got expanded into here */
int system_header_p = 0; /* 0 for "...", 1 for <...> */
- f= -1; /* JF we iz paranoid! */
-
get_filename:
fbeg = buf;
@@ -2374,6 +2378,90 @@ get_filename:
}
flen = fend - fbeg;
+ process_include (stackp, fbeg, flen, system_header_p, op);
+}
+
+static void
+do_include_next (buf, limit, op)
+ U_CHAR *buf, *limit;
+ FILE_BUF *op;
+{
+ U_CHAR *fbeg, *fend; /* Beginning and end of fname */
+
+ struct file_name_list *stackp; /* Chain of dirs to search */
+ int flen;
+
+ int retried = 0; /* Have already tried macro
+ expanding the include line*/
+ FILE_BUF trybuf; /* It got expanded into here */
+ int system_header_p = 0; /* 0 for "...", 1 for <...> */
+
+ /* Treat as plain #include if we don't know where to start
+ looking. */
+ stackp = instack[indepth].next_header_dir;
+ if (stackp == 0)
+ {
+ do_include (buf, limit, op);
+ return;
+ }
+
+get_filename:
+
+ fbeg = buf;
+ SKIP_WHITE_SPACE (fbeg);
+ /* Discard trailing whitespace so we can easily see
+ if we have parsed all the significant chars we were given. */
+ while (limit != fbeg && is_nvspace (limit[-1])) limit--;
+
+ switch (*fbeg++) {
+ case '\"':
+ fend = fbeg;
+ while (fend != limit && *fend != '\"')
+ fend++;
+ if (*fend == '\"' && fend + 1 == limit)
+ break;
+ goto fail;
+
+ case '<':
+ fend = fbeg;
+ while (fend != limit && *fend != '>') fend++;
+ if (*fend == '>' && fend + 1 == limit) {
+ system_header_p = 1;
+ break;
+ }
+ goto fail;
+
+ default:
+ fail:
+ if (retried) {
+ error ("#include expects \"fname\" or <fname>");
+ return;
+ } else {
+ trybuf = expand_to_temp_buffer (buf, limit, 0);
+ buf = (U_CHAR *) alloca (trybuf.bufp - trybuf.buf + 1);
+ memcpy (buf, trybuf.buf, trybuf.bufp - trybuf.buf);
+ limit = buf + (trybuf.bufp - trybuf.buf);
+ free (trybuf.buf);
+ retried++;
+ goto get_filename;
+ }
+ }
+
+ flen = fend - fbeg;
+ process_include (stackp, fbeg, flen, system_header_p, op);
+}
+
+static void
+process_include (stackp, fbeg, flen, system_header_p, op)
+ struct file_name_list *stackp;
+ const U_CHAR *fbeg;
+ int flen;
+ int system_header_p;
+ FILE_BUF *op;
+{
+ char *fname;
+ int f = -1; /* file number */
+
fname = (char *) alloca (max_include_len + flen + 2);
/* + 2 above for slash and terminating null. */
@@ -2472,7 +2560,7 @@ get_filename:
system_include_depth++;
/* Actually process the file. */
- finclude (f, fname, op);
+ finclude (f, fname, stackp->next, op);
if (system_header_p)
system_include_depth--;
@@ -2485,9 +2573,10 @@ get_filename:
with output to OP. */
static void
-finclude (f, fname, op)
+finclude (f, fname, nhd, op)
int f;
const char *fname;
+ struct file_name_list *nhd;
FILE_BUF *op;
{
int st_mode;
@@ -2506,6 +2595,7 @@ finclude (f, fname, op)
fp->length = 0;
fp->lineno = 1;
fp->if_stack = if_stack;
+ fp->next_header_dir = nhd;
if (S_ISREG (st_mode)) {
fp->buf = (U_CHAR *) xmalloc (st_size + 2);