OSDN Git Service

* cpphash.h (struct lexer_state): Add directive_wants_padding.
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Feb 2003 18:06:30 +0000 (18:06 +0000)
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Feb 2003 18:06:30 +0000 (18:06 +0000)
* cpplib.c (_cpp_handle_directive): Set directive_wants_padding
for directives of type INCL.
(glue_header_name, parse_include): Use get_token_no_padding.
* cppmacro.c (replace_args): If directive_wants_padding,
provide padding tokens.

* testsuite/gcc.dg/cpp/include3.c: New test.
* testsuite/gcc.dg/cpp/inc/foo.h: New file.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63231 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cpphash.h
gcc/cpplib.c
gcc/cppmacro.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/inc/foo.h [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/include3.c [new file with mode: 0644]

index 4643a79..602905a 100644 (file)
@@ -1,3 +1,12 @@
+2003-02-21  Zack Weinberg  <zack@codesourcery.com>
+
+       * cpphash.h (struct lexer_state): Add directive_wants_padding.
+       * cpplib.c (_cpp_handle_directive): Set directive_wants_padding
+       for directives of type INCL.
+       (glue_header_name, parse_include): Use get_token_no_padding.
+       * cppmacro.c (replace_args): If directive_wants_padding,
+       provide padding tokens.
+
 2003-02-21  Kazu Hirata  <kazu@cs.umass.edu>
 
        * config/h8300/h8300.md (a peephole2): New.
@@ -227,8 +236,8 @@ Thu Feb 20 21:41:19 CET 2003  Jan Hubicka  <jh@suse.cz>
 
 2003-02-20  David Edelsohn  <edelsohn@gnu.org>
 
-        * config/rs6000/sysv4.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Define.
-        * config/rs6000/power4.md (power4-store,power4-vecstore): New
+       * config/rs6000/sysv4.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Define.
+       * config/rs6000/power4.md (power4-store,power4-vecstore): New
        insn reservations.
        (power4-fpstore): Compact.
 
@@ -309,7 +318,7 @@ Wed Feb 19 19:00:24 CET 2003  Jan Hubicka  <jh@suse.cz>
 
        * fixinc/inclhack.def (irix_wcsftime): Use XPG5 variant for C99.
        * fixinc/tests/base/internal/wchar_core.h: New file.
-       
+
        * fixinc/inclhack.def (irix_socklen_t): Fix broken IRIX 6.5.1[78]
        socklen_t definition.
        * fixinc/fixincl.x: Regenerate.
@@ -366,7 +375,7 @@ Tue Feb 18 23:50:59 CET 2003  Jan Hubicka  <jh@suse.cz>
 2003-02-18  Matt Austern <austern@apple.com>
 
        * toplev.c, langhooks.c, langhooks-def.h: Move
-       write_global_declarations from toplev.c to langhooks.c. 
+       write_global_declarations from toplev.c to langhooks.c.
 
 2003-02-18  Kazu Hirata  <kazu@cs.umass.edu>
 
@@ -381,34 +390,34 @@ Tue Feb 18 23:50:59 CET 2003  Jan Hubicka  <jh@suse.cz>
 
 2003-02-18  Kaz Kojima  <kkojima@gcc.gnu.org>
 
-        * config/sh/sh.c (unspec_caller_rtx_p): New.
+       * config/sh/sh.c (unspec_caller_rtx_p): New.
        (sh_cannot_copy_insn_p): New.
-        (TARGET_CANNOT_COPY_INSN_P): New.
+       (TARGET_CANNOT_COPY_INSN_P): New.
 
 2003-02-18  Richard Henderson  <rth@redhat.com>
 
        * c-common.c (handle_used_attribute): Accept static data too.
 
 2003-02-18  Nick Clifton  <nickc@redhat.com>
-            Aldy Hernandez  <aldyh@redhat.com>
+           Aldy Hernandez  <aldyh@redhat.com>
 
-        * testsuite/gcc.dg/20030218-1.c: New.
+       * testsuite/gcc.dg/20030218-1.c: New.
 
-        * doc/tm.texi: Document TARGET_VECTOR_TYPES_COMPATIBLE.
+       * doc/tm.texi: Document TARGET_VECTOR_TYPES_COMPATIBLE.
 
-        * target-def.h (TARGET_INITIALIZER): Add
-        TARGET_VECTOR_TYPES_COMPATIBLE.
-        (TARGET_VECTOR_TYPES_COMPATIBLE): New macro.
+       * target-def.h (TARGET_INITIALIZER): Add
+       TARGET_VECTOR_TYPES_COMPATIBLE.
+       (TARGET_VECTOR_TYPES_COMPATIBLE): New macro.
 
-        * target.h (struct gcc_target): Add field vector_types_compatible.
+       * target.h (struct gcc_target): Add field vector_types_compatible.
 
-        * c-typeck.c (comptypes): Take into account
-        TARGET_VECTOR_TYPES_COMPATIBLE.
-        (convert_for_assignment): Same.
+       * c-typeck.c (comptypes): Take into account
+       TARGET_VECTOR_TYPES_COMPATIBLE.
+       (convert_for_assignment): Same.
 
-        * config/rs6000/rs6000.c (is_ev64_opaque_type): New.
-        (rs6000_spe_vector_types_compatible): New.
-        (TARGET_VECTOR_TYPES_COMPATIBLE): Define.
+       * config/rs6000/rs6000.c (is_ev64_opaque_type): New.
+       (rs6000_spe_vector_types_compatible): New.
+       (TARGET_VECTOR_TYPES_COMPATIBLE): Define.
 
 2003-02-19  Andreas Schwab  <schwab@suse.de>
 
@@ -462,15 +471,15 @@ Tue Feb 18 20:15:54 2003  J"orn Rennecke <joern.rennecke@superh.com>
        (*extendhisi2_h8300): Likewise.
 
 2003-02-18  Matt Austern <austern@apple.com>
-       
+
        * langhooks.h, langhooks-def.h: introduce new langhook,
        final_write_globals, with write_global_declarations as default.
        * toplev.c: Move invocation of wrapup_global_declarations from
        compile_file to new function, write_global_declarations.  Change
        compile_file to use final_write_globals hook.  Change
        wrapup_global_declarations so writing to DECL_DEFER_OUTPUT is
-       conditional. 
-       
+       conditional.
+
 2003-02-18  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * pa.md: Correct and enhance comment.
@@ -488,9 +497,9 @@ Tue Feb 18 20:15:54 2003  J"orn Rennecke <joern.rennecke@superh.com>
 
 2003-02-17  Aldy Hernandez  <aldyh@redhat.com>
 
-        * config/rs6000/spe.h (__ev_stdd): Cast 2nd arg.
-        (__ev_stdw): Same.
-        (__ev_stdh): Same.
+       * config/rs6000/spe.h (__ev_stdd): Cast 2nd arg.
+       (__ev_stdw): Same.
+       (__ev_stdh): Same.
 
 Mon Feb 17 16:16:54 CET 2003  Jan Hubicka  <jh@suse.cz>
 
@@ -626,7 +635,7 @@ Sun Feb 16 23:07:52 CET 2003  Jan Hubicka  <jh@suse.cz>
        * function.h (struct function): Add computed_goto_common_label,
        computed_goto_common_reg.
        * function.c (free_after_compilation): Zap them.
-       * stmt.c (expand_computed_goto): Use them to produce one 
+       * stmt.c (expand_computed_goto): Use them to produce one
        indirect branch per function.
 
 2003-02-15  Richard Henderson  <rth@redhat.com>
@@ -640,8 +649,8 @@ Sun Feb 16 23:07:52 CET 2003  Jan Hubicka  <jh@suse.cz>
 
 2003-02-15  Richard Henderson  <rth@redhat.com>
 
-        * recog.c (split_all_insns): Include new blocks in life update;
-        do a global life update.
+       * recog.c (split_all_insns): Include new blocks in life update;
+       do a global life update.
 
 2003-02-15  Danny Smith  <dannysmith@users.sourceforge.net>
 
@@ -680,7 +689,7 @@ Sun Feb 16 23:07:52 CET 2003  Jan Hubicka  <jh@suse.cz>
 
 2003-02-13  Adam Nemet  <anemet@lnxw.com>
 
-       PR opt/2391 
+       PR opt/2391
        * combine.c: Fix spelling in comment.
        (cached_nonzero_bits): New function.
        (cached_num_sign_bit_copies): New function.
index 07880bd..9aff511 100644 (file)
@@ -214,6 +214,11 @@ struct lexer_state
   /* Nonzero if first token on line is CPP_HASH.  */
   unsigned char in_directive;
 
+  /* Nonzero if in a directive that will handle padding tokens itself.
+     #include needs this to avoid problems with computed include and
+     spacing between tokens.  */
+  unsigned char directive_wants_padding;
+
   /* True if we are skipping a failed conditional group.  */
   unsigned char skipping;
 
index b63fd26..ed2bc95 100644 (file)
@@ -414,6 +414,7 @@ _cpp_handle_directive (pfile, indented)
             skipping or not, we should lex angle-bracketed headers
             correctly, and maybe output some diagnostics.  */
          pfile->state.angled_headers = dir->flags & INCL;
+         pfile->state.directive_wants_padding = dir->flags & INCL;
          if (! CPP_OPTION (pfile, preprocessed))
            directive_diagnostics (pfile, dir, indented);
          if (pfile->state.skipping && !(dir->flags & COND))
@@ -582,7 +583,7 @@ glue_header_name (pfile)
   buffer = (unsigned char *) xmalloc (capacity);
   for (;;)
     {
-      token = cpp_get_token (pfile);
+      token = get_token_no_padding (pfile);
 
       if (token->type == CPP_GREATER || token->type == CPP_EOF)
        break;
@@ -634,7 +635,7 @@ parse_include (pfile)
     dir = pfile->directive->name;
 
   /* Allow macro expansion.  */
-  header = cpp_get_token (pfile);
+  header = get_token_no_padding (pfile);
   if (header->type != CPP_STRING && header->type != CPP_HEADER_NAME)
     {
       if (header->type != CPP_LESS)
index a00b835..99043ff 100644 (file)
@@ -899,7 +899,7 @@ replace_args (pfile, node, macro, args)
        count = arg->expanded_count, from = arg->expanded;
 
       /* Padding on the left of an argument (unless RHS of ##).  */
-      if (!pfile->state.in_directive
+      if ((!pfile->state.in_directive || pfile->state.directive_wants_padding)
          && src != macro->exp.tokens && !(src[-1].flags & PASTE_LEFT))
        *dest++ = padding_token (pfile, src);
 
index 08d3785..2b3fb96 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-21  Zack Weinberg  <zack@codesourcery.com>
+
+       * gcc.dg/cpp/include3.c: New test.
+       * gcc.dg/cpp/inc/foo.h: New file.
+
 2003-02-21  Glen Nakamura  <glen@imodulo.com>
 
        * gcc.c-torture/execute/20030221-1.c: New test.
@@ -25,7 +30,7 @@ Tue Feb 18 23:28:53 CET 2003  Jan Hubicka  <jh@suse.cz>
 
 2003-02-18  Aldy Hernandez  <aldyh@redhat.com>
 
-        * gcc.dg/20030218-1.c: New.
+       * gcc.dg/20030218-1.c: New.
 
 2003-02-18  Richard Henderson  <rth@redhat.com>
 
@@ -36,7 +41,7 @@ Tue Feb 18 23:28:53 CET 2003  Jan Hubicka  <jh@suse.cz>
 
        PR c++/9704
        * g++.dg/init/copy5.C: New test.
-       
+
 2003-02-18  Geoffrey Keating  <geoffk@apple.com>
 
        * gcc.dg/pch/pch.exp: Delete $bname.h before copying into it.
@@ -84,10 +89,10 @@ Sun Feb 16 23:08:19 CET 2003  Jan HUbicka  <jh@suse.cz>
 
 2003-02-12  Aldy Hernandez  <aldyh@redhat.com>
 
-        * gcc.dg/ppc-spe.c: Fix formatting.
-        Enable tests that were previously unsupported by gas.
-        Delete tests for instructions that no longer exist.
-        Switch arguments on evsubifw builtin.
+       * gcc.dg/ppc-spe.c: Fix formatting.
+       Enable tests that were previously unsupported by gas.
+       Delete tests for instructions that no longer exist.
+       Switch arguments on evsubifw builtin.
 
 2003-02-12  Kazu Hirata  <kazu@cs.umass.edu>
 
@@ -95,7 +100,7 @@ Sun Feb 16 23:08:19 CET 2003  Jan HUbicka  <jh@suse.cz>
        STACK_SIZE is too small.
 
 2003-02-10  Eric Botcazou  <ebotcazou@libertysurf.fr>
-            Christian Ehrhardt  <ehrhardt@mathematik.uni-ulm.de>
+           Christian Ehrhardt  <ehrhardt@mathematik.uni-ulm.de>
 
        * gcc.dg/decl-2.c: New test.
 
@@ -263,8 +268,8 @@ Tue Jan 28 12:19:35 CET 2003  Jan Hubicka  <jh@suse.cz>
 
 2003-01-28  D.Venkatasubramanian   <dvenkat@noida.hcltech.com>
 
-        * gcc.c-torture/execute/20010925-1.c: Changed the
-        memcpy declaration.
+       * gcc.c-torture/execute/20010925-1.c: Changed the
+       memcpy declaration.
 
 2003-01-28  Nathan Sidwell  <nathan@codesourcery.com>
 
@@ -318,13 +323,13 @@ Sat Jan 25 21:06:49 CET 2003  Jan Hubicka  <jh@suse.cz>
        PR c++/9403
        * g++.dg/parse/template3.C: New test.
        * g++.old-deja/g++.pt/memclass5.C: Add needed template keyword.
-       
+
        PR c++/795
        * g++.dg/parse/template4.C: New test.
-       
+
        PR c++/9415
        * g++.dg/template/qual2.C: New test.
-       
+
        PR c++/8545
        * g++.old-deja/g++.brendan/parse3.C: Remove XFAIL.
 
@@ -461,7 +466,7 @@ Tue Jan 21 18:01:35 CET 2003  Jan Hubicka  <jh@suse.cz>
 
        PR c++/9294:
        * g++.dg/parse/qualified1.C: New test.
-       
+
        * g++.dg/parse/typename3.C: New test.
 
 2003-01-16  Richard Henderson  <rth@redhat.com>
@@ -511,7 +516,7 @@ Tue Jan 21 18:01:35 CET 2003  Jan Hubicka  <jh@suse.cz>
        * gcc/testsuite/g++.old-deja/g++.pt/typename19.C: Remove warning.
        * gcc/testsuite/g++.old-deja/g++.robertl/eb112.C: Fix typo.
        * gcc/testsuite/g++.old-deja/g++.robertl/eb24.C: Use this->.
-       
+
 2003-01-16  Nathan Sidwell  <nathan@codesourcery.com>
 
        * g++.dg/parse/ambig2.C: New test.
@@ -618,7 +623,7 @@ Tue Jan 14 00:45:03 CET 2003  Jan Hubicka  <jh@suse.cz>
        * gcc.dg/pch/pch.exp: Compare .s files with/without PCH,
        rather than trying to build and run a program using PCH.
        * gcc.dg/pch: Remove dg-do commands from test files.
-       
+
        2002-11-08  Geoffrey Keating  <geoffk@apple.com>
 
        * gcc.dg/pch/macro-3.c: New.
@@ -740,7 +745,7 @@ Tue Jan 14 00:45:03 CET 2003  Jan Hubicka  <jh@suse.cz>
        * g++.old-deja/g++.mike/p9706.C: Likewise
        * g++.old-deja/g++.mike/p10416.C: Likewise
        * g++.old-deja/g++.mike/p11667.C: Likewise
-       * g77.f-torture/compile/20010519-1.f: Remove reference to Convex. 
+       * g77.f-torture/compile/20010519-1.f: Remove reference to Convex.
        Remove redundant reference to Iris.
        * gcc.dg/20020312-2.c: Remove references to AMD A29K, Clipper, Convex,
        Elxsi, i860, Pico Java, and WE32K.
@@ -868,7 +873,7 @@ Wed Jan  8 11:41:47 CET 2003  Jan Hubicka  <jh@suse.cz>
 2002-12-31  Mark Mitchell  <mark@codesourcery.com>
 
        * g++.dg/parse/namespace1.C: New test.
-       
+
 2003-01-01  Neil Booth  <neil@daikokuya.co.uk>
 
        * g++.dg/parse/parse4.C: New test.
@@ -1142,7 +1147,7 @@ Wed Jan  8 11:41:47 CET 2003  Jan Hubicka  <jh@suse.cz>
        * g++.old-deja/g++.pt/memtemp87.C: Add missing access specifier.
        * g++.old-deja/g++.pt/overload13.C: Correct error messages.
        * g++.old-deja/g++.pt/parms2.C: Add missing typename keyword.
-       * g++.old-deja/g++.pt/ptrmem1.C: Remove invalid use of template 
+       * g++.old-deja/g++.pt/ptrmem1.C: Remove invalid use of template
        keyword.
        * g++.old-deja/g++.pt/spec10.C: Likewise.
        * g++.old-deja/g++.pt/spec28.C: Reorder declarations.
@@ -1166,7 +1171,7 @@ Wed Jan  8 11:41:47 CET 2003  Jan Hubicka  <jh@suse.cz>
        * g++.old-deja/g++.robertl/eb79.C: Correct for new name lookup rules.
        * g++.old-deja/g++.robertl/eb82.C: Remove stray semicolons.
        * g++.old-deja/g++.robertl/eb86.C: Add missing forward declaration.
-       
+
 2002-12-26  Nathan Sidwell  <nathan@codesourcery.com>
 
        * g++.dg/warn/inline1.C: New test.
@@ -1179,9 +1184,9 @@ Wed Jan  8 11:41:47 CET 2003  Jan Hubicka  <jh@suse.cz>
        * g++.dg/template/conv5.C: New test.
 
 2002-12-24  Nathan Sidwell  <nathan@codesourcery.com>
-       
+
        * g++.dg/lookup/scoped3.C: New test.
-       
+
        * g++.dg/lookup/decl1.C: New test.
        * g++.dg/lookup/decl2.C: New test.
 
@@ -1200,9 +1205,9 @@ Wed Jan  8 11:41:47 CET 2003  Jan Hubicka  <jh@suse.cz>
 2002-12-23  Mark Mitchell  <mark@codesourcery.com>
 
        * gcc.dg/i386-bitfield3.c: New test.
-       
+
        * gcc.dg/i386-bitfield2.c: New test.
-       
+
 2002-12-22  Nathan Sidwell  <nathan@codesourcery.com>
 
        * g++.dg/parse/conv_op1.C: New test.
diff --git a/gcc/testsuite/gcc.dg/cpp/inc/foo.h b/gcc/testsuite/gcc.dg/cpp/inc/foo.h
new file mode 100644 (file)
index 0000000..ec77047
--- /dev/null
@@ -0,0 +1 @@
+extern int a;
diff --git a/gcc/testsuite/gcc.dg/cpp/include3.c b/gcc/testsuite/gcc.dg/cpp/include3.c
new file mode 100644 (file)
index 0000000..8bea2b7
--- /dev/null
@@ -0,0 +1,7 @@
+/* Unpatched, this file would include "inc/ foo.h" (note the space)  */
+
+#define PREINC_XSTR(str)             #str
+#define PREINC_STR(str)              PREINC_XSTR(str)
+#define COMP_INC(comp,file)          PREINC_STR(comp/file)
+
+#include COMP_INC(inc, foo.h)