diff libcpp/pch.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line diff
--- a/libcpp/pch.c	Fri Oct 27 22:46:09 2017 +0900
+++ b/libcpp/pch.c	Thu Oct 25 07:37:49 2018 +0900
@@ -1,5 +1,5 @@
 /* Part of CPP library.  (Precompiled header reading/writing.)
-   Copyright (C) 2000-2017 Free Software Foundation, Inc.
+   Copyright (C) 2000-2018 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
@@ -50,50 +50,47 @@
 write_macdef (cpp_reader *pfile, cpp_hashnode *hn, void *file_p)
 {
   FILE *f = (FILE *) file_p;
+  bool is_void = false;
   switch (hn->type)
     {
     case NT_VOID:
       if (! (hn->flags & NODE_POISONED))
 	return 1;
-      /* XXX Really fallthru?  */
-      /* FALLTHRU */
-
-    case NT_MACRO:
-      if ((hn->flags & NODE_BUILTIN)
-	  && (!pfile->cb.user_builtin_macro
-	      || !pfile->cb.user_builtin_macro (pfile, hn)))
-	return 1;
-
-      {
-	struct macrodef_struct s;
-	const unsigned char *defn;
-
-	s.name_length = NODE_LEN (hn);
-	s.flags = hn->flags & NODE_POISONED;
+      is_void = true;
+      goto poisoned;
 
-	if (hn->type == NT_MACRO)
-	  {
-	    defn = cpp_macro_definition (pfile, hn);
-	    s.definition_length = ustrlen (defn);
-	  }
-	else
-	  {
-	    defn = NODE_NAME (hn);
-	    s.definition_length = s.name_length;
-	  }
-
-	if (fwrite (&s, sizeof (s), 1, f) != 1
-	    || fwrite (defn, 1, s.definition_length, f) != s.definition_length)
-	  {
-	    cpp_errno (pfile, CPP_DL_ERROR,
-		       "while writing precompiled header");
-	    return 0;
-	  }
-      }
+    case NT_BUILTIN_MACRO:
       return 1;
 
-    case NT_ASSERTION:
-      /* Not currently implemented.  */
+    case NT_USER_MACRO:
+      if (hn->value.macro->kind != cmk_assert)
+	{
+	poisoned:
+	  struct macrodef_struct s;
+	  const unsigned char *defn;
+
+	  s.name_length = NODE_LEN (hn);
+	  s.flags = hn->flags & NODE_POISONED;
+
+	  if (is_void)
+	    {
+	      defn = NODE_NAME (hn);
+	      s.definition_length = s.name_length;
+	    }
+	  else
+	    {
+	      defn = cpp_macro_definition (pfile, hn);
+	      s.definition_length = ustrlen (defn);
+	    }
+
+	  if (fwrite (&s, sizeof (s), 1, f) != 1
+	      || fwrite (defn, 1, s.definition_length, f) != s.definition_length)
+	    {
+	      cpp_errno (pfile, CPP_DL_ERROR,
+			 "while writing precompiled header");
+	      return 0;
+	    }
+	}
       return 1;
 
     default:
@@ -228,8 +225,11 @@
 
   switch (hn->type)
     {
-    case NT_MACRO:
-      if (hn->flags & NODE_BUILTIN)
+    case NT_BUILTIN_MACRO:
+      return 1;
+
+    case NT_USER_MACRO:
+      if (hn->value.macro->kind == cmk_assert)
 	return 1;
 
       /* fall through.  */
@@ -250,10 +250,6 @@
       }
       return 1;
 
-    case NT_ASSERTION:
-      /* Not currently implemented.  */
-      return 1;
-
     default:
       abort ();
     }
@@ -267,8 +263,11 @@
 
   switch (hn->type)
     {
-    case NT_MACRO:
-      if (hn->flags & NODE_BUILTIN)
+    case NT_BUILTIN_MACRO:
+      return 1;
+
+    case NT_USER_MACRO:
+      if (hn->value.macro->kind == cmk_assert)
 	return 1;
 
       /* fall through.  */
@@ -289,10 +288,6 @@
       }
       return 1;
 
-    case NT_ASSERTION:
-      /* Not currently implemented.  */
-      return 1;
-
     default:
       abort ();
     }
@@ -623,7 +618,7 @@
 	  goto fail;
 	}
 
-      if (h->type != NT_MACRO)
+      if (h->type == NT_VOID)
 	{
 	  /* It's ok if __GCC_HAVE_DWARF2_CFI_ASM becomes undefined,
 	     as in, when the PCH file is created with -g and we're
@@ -760,13 +755,7 @@
 {
   struct save_macro_data *data = (struct save_macro_data *)data_p;
 
-  if ((h->flags & NODE_BUILTIN)
-      && h->type == NT_MACRO
-      && r->cb.user_builtin_macro)
-    r->cb.user_builtin_macro (r, h);
-
-  if (h->type != NT_VOID
-      && (h->flags & NODE_BUILTIN) == 0)
+  if (cpp_user_macro_p (h))
     {
       if (data->count == data->array_size)
 	{
@@ -774,28 +763,14 @@
 	  data->defns = XRESIZEVEC (uchar *, data->defns, (data->array_size));
 	}
 
-      switch (h->type)
-	{
-	case NT_ASSERTION:
-	  /* Not currently implemented.  */
-	  return 1;
+      const uchar * defn = cpp_macro_definition (r, h);
+      size_t defnlen = ustrlen (defn);
 
-	case NT_MACRO:
-	  {
-	    const uchar * defn = cpp_macro_definition (r, h);
-	    size_t defnlen = ustrlen (defn);
-
-	    data->defns[data->count] = (uchar *) xmemdup (defn, defnlen,
-                                                          defnlen + 2);
-	    data->defns[data->count][defnlen] = '\n';
-	  }
-	  break;
-
-	default:
-	  abort ();
-	}
+      data->defns[data->count] = (uchar *) xmemdup (defn, defnlen, defnlen + 2);
+      data->defns[data->count][defnlen] = '\n';
       data->count++;
     }
+
   return 1;
 }
 
@@ -835,6 +810,7 @@
     s->n_true		= cpp_lookup (r, DSC("true"));
     s->n_false		= cpp_lookup (r, DSC("false"));
     s->n__VA_ARGS__     = cpp_lookup (r, DSC("__VA_ARGS__"));
+    s->n__VA_OPT__      = cpp_lookup (r, DSC("__VA_OPT__"));
     s->n__has_include__ = cpp_lookup (r, DSC("__has_include__"));
     s->n__has_include_next__ = cpp_lookup (r, DSC("__has_include_next__"));
   }