From 14b1760ca7edbe72f2ed43df5fb4f1bc6ea567e5 Mon Sep 17 00:00:00 2001
From: Dodji Seketeli <dodji@gcc.gnu.org>
Date: Tue, 1 Jul 2014 16:04:37 +0200
Subject: [PATCH] Revert "PR preprocessor/60723 - missing system-ness marks for
 macro tokens"

This reverts commit 747e04f26ac3fb775bfc9af61e9170b9461b6cfc.

From-SVN: r212199
---
 gcc/c-family/ChangeLog             | 15 ------
 gcc/c-family/c-ppoutput.c          | 76 ++++++++++--------------------
 gcc/testsuite/ChangeLog            |  5 --
 gcc/testsuite/gcc.dg/cpp/syshdr4.c | 24 ----------
 gcc/testsuite/gcc.dg/cpp/syshdr4.h |  8 ----
 gcc/testsuite/gcc.dg/cpp/syshdr5.c | 14 ------
 gcc/testsuite/gcc.dg/cpp/syshdr5.h |  6 ---
 7 files changed, 24 insertions(+), 124 deletions(-)
 delete mode 100644 gcc/testsuite/gcc.dg/cpp/syshdr4.c
 delete mode 100644 gcc/testsuite/gcc.dg/cpp/syshdr4.h
 delete mode 100644 gcc/testsuite/gcc.dg/cpp/syshdr5.c
 delete mode 100644 gcc/testsuite/gcc.dg/cpp/syshdr5.h

diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index f6b83c88e476..672c4e8c80c9 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,18 +1,3 @@
-2014-07-01  Dodji Seketeli  <dodji@redhat.com>
-
-	PR preprocessor/60723
-	* c-ppoutput.c (struct print::prev_was_system_token): New data
-	member.
-	(init_pp_output): Initialize it.
-	(maybe_print_line_1, maybe_print_line, print_line_1, print_line)
-	(do_line_change): Return a flag saying if a line marker was
-	emitted or not.
-	(scan_translation_unit): Detect if the system-ness of the token we
-	are about to emit is different from the one of the previously
-	emitted token.  If so, emit a line marker.  Avoid emitting useless
-	adjacent line markers.
-	(scan_translation_unit_directives_only): Adjust.
-
 2014-07-01  Marek Polacek  <polacek@redhat.com>
 
 	* c.opt (Wint-conversion): New option.
diff --git a/gcc/c-family/c-ppoutput.c b/gcc/c-family/c-ppoutput.c
index 618e1c94b6c4..f3b5fa4487db 100644
--- a/gcc/c-family/c-ppoutput.c
+++ b/gcc/c-family/c-ppoutput.c
@@ -36,8 +36,6 @@ static struct
   unsigned char printed;	/* Nonzero if something output at line.  */
   bool first_time;		/* pp_file_change hasn't been called yet.  */
   const char *src_file;		/* Current source file.  */
-  bool prev_was_system_token;	/* True if the previous token was a
-				   system token.*/
 } print;
 
 /* Defined and undefined macros being queued for output with -dU at
@@ -60,11 +58,11 @@ static void account_for_newlines (const unsigned char *, size_t);
 static int dump_macro (cpp_reader *, cpp_hashnode *, void *);
 static void dump_queued_macros (cpp_reader *);
 
-static bool print_line_1 (source_location, const char*, FILE *);
-static bool print_line (source_location, const char *);
-static bool maybe_print_line_1 (source_location, FILE *);
-static bool maybe_print_line (source_location);
-static bool do_line_change (cpp_reader *, const cpp_token *,
+static void print_line_1 (source_location, const char*, FILE *);
+static void print_line (source_location, const char *);
+static void maybe_print_line_1 (source_location, FILE *);
+static void maybe_print_line (source_location);
+static void do_line_change (cpp_reader *, const cpp_token *,
 			    source_location, int);
 
 /* Callback routines for the parser.   Most of these are active only
@@ -158,7 +156,6 @@ init_pp_output (FILE *out_stream)
   print.outf = out_stream;
   print.first_time = 1;
   print.src_file = "";
-  print.prev_was_system_token = false;
 }
 
 /* Writes out the preprocessed file, handling spacing and paste
@@ -171,7 +168,6 @@ scan_translation_unit (cpp_reader *pfile)
     = cpp_get_options (parse_in)->lang != CLK_ASM
       && !flag_no_line_commands;
   bool in_pragma = false;
-  bool line_marker_emitted = false;
 
   print.source = NULL;
   for (;;)
@@ -204,7 +200,7 @@ scan_translation_unit (cpp_reader *pfile)
 	      && do_line_adjustments
 	      && !in_pragma)
 	    {
-	      line_marker_emitted = do_line_change (pfile, token, loc, false);
+	      do_line_change (pfile, token, loc, false);
 	      putc (' ', print.outf);
 	    }
 	  else if (print.source->flags & PREV_WHITE
@@ -220,7 +216,7 @@ scan_translation_unit (cpp_reader *pfile)
 	  if (src_line != print.src_line
 	      && do_line_adjustments
 	      && !in_pragma)
-	    line_marker_emitted = do_line_change (pfile, token, loc, false);
+	    do_line_change (pfile, token, loc, false);
 	  putc (' ', print.outf);
 	}
 
@@ -232,7 +228,7 @@ scan_translation_unit (cpp_reader *pfile)
 	  const char *space;
 	  const char *name;
 
-	  line_marker_emitted = maybe_print_line (token->src_loc);
+	  maybe_print_line (token->src_loc);
 	  fputs ("#pragma ", print.outf);
 	  c_pp_lookup_pragma (token->val.pragma, &space, &name);
 	  if (space)
@@ -252,18 +248,9 @@ scan_translation_unit (cpp_reader *pfile)
 	  if (cpp_get_options (parse_in)->debug)
 	      linemap_dump_location (line_table, token->src_loc,
 				     print.outf);
-
-	  if (!line_marker_emitted
-	      && print.prev_was_system_token != !!in_system_header_at(loc))
-	    /* The system-ness of this token is different from the one
-	       of the previous token.  Let's emit a line change to
-	       mark the new system-ness before we emit the token.  */
-	    line_marker_emitted = do_line_change (pfile, token, loc, false);
 	  cpp_output_token (token, print.outf);
-	  line_marker_emitted = false;
 	}
 
-      print.prev_was_system_token = !!in_system_header_at(loc);
       /* CPP_COMMENT tokens and raw-string literal tokens can
 	 have embedded new-line characters.  Rather than enumerating
 	 all the possible token types just check if token uses
@@ -288,7 +275,7 @@ scan_translation_unit_directives_only (cpp_reader *pfile)
   struct _cpp_dir_only_callbacks cb;
 
   cb.print_lines = print_lines_directives_only;
-  cb.maybe_print_line = (void (*) (source_location)) maybe_print_line;
+  cb.maybe_print_line = maybe_print_line;
 
   _cpp_preprocess_dir_only (pfile, &cb);
 }
@@ -319,13 +306,11 @@ scan_translation_unit_trad (cpp_reader *pfile)
 
 /* If the token read on logical line LINE needs to be output on a
    different line to the current one, output the required newlines or
-   a line marker.  If a line marker was emitted, return TRUE otherwise
-   return FALSE.  */
+   a line marker, and return 1.  Otherwise return 0.  */
 
-static bool
+static void
 maybe_print_line_1 (source_location src_loc, FILE *stream)
 {
-  bool emitted_line_marker = false;
   int src_line = LOCATION_LINE (src_loc);
   const char *src_file = LOCATION_FILE (src_loc);
 
@@ -349,34 +334,29 @@ maybe_print_line_1 (source_location src_loc, FILE *stream)
 	}
     }
   else
-    emitted_line_marker = print_line_1 (src_loc, "", stream);
+    print_line_1 (src_loc, "", stream);
 
-  return emitted_line_marker;
 }
 
 /* If the token read on logical line LINE needs to be output on a
    different line to the current one, output the required newlines or
-   a line marker.  If a line marker was emitted, return TRUE otherwise
-   return FALSE.  */
+   a line marker, and return 1.  Otherwise return 0.  */
 
-static bool
+static void
 maybe_print_line (source_location src_loc)
 {
   if (cpp_get_options (parse_in)->debug)
     linemap_dump_location (line_table, src_loc,
 			   print.outf);
-  return maybe_print_line_1 (src_loc, print.outf);
+  maybe_print_line_1 (src_loc, print.outf);
 }
 
 /* Output a line marker for logical line LINE.  Special flags are "1"
-   or "2" indicating entering or leaving a file.  If the line marker
-   was effectively emitted, return TRUE otherwise return FALSE.  */
+   or "2" indicating entering or leaving a file.  */
 
-static bool
+static void
 print_line_1 (source_location src_loc, const char *special_flags, FILE *stream)
 {
-  bool emitted_line_marker = false;
-
   /* End any previous line of text.  */
   if (print.printed)
     putc ('\n', stream);
@@ -411,39 +391,33 @@ print_line_1 (source_location src_loc, const char *special_flags, FILE *stream)
 	fputs (" 3", stream);
 
       putc ('\n', stream);
-      emitted_line_marker = true;
     }
-
-  return emitted_line_marker;
 }
 
 /* Output a line marker for logical line LINE.  Special flags are "1"
-   or "2" indicating entering or leaving a file.  Return TRUE if a
-   line marker was effectively emitted, FALSE otherwise.  */
+   or "2" indicating entering or leaving a file.  */
 
-static bool
+static void
 print_line (source_location src_loc, const char *special_flags)
 {
     if (cpp_get_options (parse_in)->debug)
       linemap_dump_location (line_table, src_loc,
 			     print.outf);
-    return print_line_1 (src_loc, special_flags, print.outf);
+    print_line_1 (src_loc, special_flags, print.outf);
 }
 
-/* Helper function for cb_line_change and scan_translation_unit.
-   Return TRUE if a line marker is emitted, FALSE otherwise.  */
-static bool
+/* Helper function for cb_line_change and scan_translation_unit.  */
+static void
 do_line_change (cpp_reader *pfile, const cpp_token *token,
 		source_location src_loc, int parsing_args)
 {
-  bool emitted_line_marker = false;
   if (define_queue || undef_queue)
     dump_queued_macros (pfile);
 
   if (token->type == CPP_EOF || parsing_args)
-    return false;
+    return;
 
-  emitted_line_marker = maybe_print_line (src_loc);
+  maybe_print_line (src_loc);
   print.prev = 0;
   print.source = 0;
 
@@ -460,8 +434,6 @@ do_line_change (cpp_reader *pfile, const cpp_token *token,
       while (-- spaces >= 0)
 	putc (' ', print.outf);
     }
-
-  return emitted_line_marker;
 }
 
 /* Called when a line of output is started.  TOKEN is the first token
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e12393c9e596..e0133116b91c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -13,11 +13,6 @@
 
 	* g++.dg/cpp1y/pr59867.C: Fix target selector.
 
-2014-07-01  Dodji Seketeli  <dodji@redhat.com>
-
-	PR preprocessor/60723
-	* gcc.dg/cpp/syshdr{4,5}.{c,h}: New test files.
-
 2014-07-01  Marek Polacek  <polacek@redhat.com>
 
 	* gcc.dg/Wint-conversion.c: New test.
diff --git a/gcc/testsuite/gcc.dg/cpp/syshdr4.c b/gcc/testsuite/gcc.dg/cpp/syshdr4.c
deleted file mode 100644
index fe001d2ed0ea..000000000000
--- a/gcc/testsuite/gcc.dg/cpp/syshdr4.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Contributed by Nicholas Ormrod */
-/* Origin: PR preprocessor/60723 */
-
-/* This tests that multi-line macro callsites, which are defined
-   in system headers and whose expansion contains a builtin followed
-   by a non-builtin token, do not generate a line directive that
-   mark the current file as being a system file, when performing
-   non-integrated preprocessing. */
-/* System files suppress div-by-zero warnings, so the presence of
-   such indicates the lack of the bug.
-
-   { dg-do compile }
-   { dg-options -no-integrated-cpp }  */
-
-#include "syshdr4.h"
-FOO(
-)
-
-int
-foo()
-{
-  return 1 / 0; /* { dg-warning "div-by-zero" } */
-  return 0;
-}
diff --git a/gcc/testsuite/gcc.dg/cpp/syshdr4.h b/gcc/testsuite/gcc.dg/cpp/syshdr4.h
deleted file mode 100644
index c464f6e702a6..000000000000
--- a/gcc/testsuite/gcc.dg/cpp/syshdr4.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Contributed by Nicholas Ormrod
-   Origin: PR preprocessor/60723.
-
-   This file is to be included by the syshdr4.c file.  */
-
-#pragma GCC system_header
-
-#define FOO() int line = __LINE__ ;
diff --git a/gcc/testsuite/gcc.dg/cpp/syshdr5.c b/gcc/testsuite/gcc.dg/cpp/syshdr5.c
deleted file mode 100644
index 42c62638d99b..000000000000
--- a/gcc/testsuite/gcc.dg/cpp/syshdr5.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Origin: PR preprocessor/60723
-
-   { dg-do compile }
-   { dg-options -no-integrated-cpp }  */
-
-#include "syshdr5.h"
-
-int
-main()
-{
-  FOO(1/0 /*  { dg-warning "division by zero" }  */
-      );
-  return 0;
-}
diff --git a/gcc/testsuite/gcc.dg/cpp/syshdr5.h b/gcc/testsuite/gcc.dg/cpp/syshdr5.h
deleted file mode 100644
index 300d6c36a039..000000000000
--- a/gcc/testsuite/gcc.dg/cpp/syshdr5.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Origin: PR preprocessor/60723
-
-   This header file is to be included by the syshdr5.c file.  */
-
-#pragma GCC system_header
-#define FOO(A)do {int line = __LINE__ ; A;} while(0)
-- 
GitLab