[PATCH] Fix PR 81721: ICE with PCH and Pragma warning and C++ operator
authorAndrew Pinski <apinski@marvell.com>
Mon, 20 May 2019 06:59:06 +0000 (06:59 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Mon, 20 May 2019 06:59:06 +0000 (23:59 -0700)
libcpp/ChangeLog:
2019-05-19  Andrew Pinski  <apinski@marvell.com>

        PR pch/81721
        * lex.c (cpp_token_val_index <case SPELL_OPERATOR>): If tok->flags
        has NAMED_OP set, then return CPP_TOKEN_FLD_NODE.

gcc/testsuite/ChangeLog:
2019-05-19  Andrew Pinski  <apinski@marvell.com>

        PR pch/81721
        * g++.dg/pch/operator-1.C: New testcase.
        * g++.dg/pch/operator-1.Hs: New file.

From-SVN: r271395

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pch/operator-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/pch/operator-1.Hs [new file with mode: 0644]
libcpp/ChangeLog
libcpp/lex.c

index fe971aa85d313386e63972446f53b0a4b251d1b7..bb03a9b84420861abb5919ab7068694d293f7369 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-19  Andrew Pinski  <apinski@marvell.com>
+
+       PR pch/81721
+       * g++.dg/pch/operator-1.C: New testcase.
+       * g++.dg/pch/operator-1.Hs: New file.
+
 2019-05-19  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/90498
diff --git a/gcc/testsuite/g++.dg/pch/operator-1.C b/gcc/testsuite/g++.dg/pch/operator-1.C
new file mode 100644 (file)
index 0000000..290b5f7
--- /dev/null
@@ -0,0 +1,2 @@
+#include "operator-1.H"
+int main(void){ major(0);} /* { dg-warning "Did not Work" } */
diff --git a/gcc/testsuite/g++.dg/pch/operator-1.Hs b/gcc/testsuite/g++.dg/pch/operator-1.Hs
new file mode 100644 (file)
index 0000000..657dae1
--- /dev/null
@@ -0,0 +1,9 @@
+# define __glibc_macro_warning1(message) _Pragma (#message)
+# define __glibc_macro_warning(message) \
+  __glibc_macro_warning1 (GCC warning message)
+#define __SYSMACROS_DM1(...) __glibc_macro_warning (#__VA_ARGS__)
+
+#define __SYSMACROS_DM(symbol) __SYSMACROS_DM1 \
+ (Did not Work)
+
+# define major(dev) __SYSMACROS_DM (major) (dev+0)
index 317d1bdd208594ce36f41c2704993eb81d2e1277..71a09495440e6574b35e0a5ca88d46fcdf75d11b 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-19  Andrew Pinski  <apinski@marvell.com>
+
+       PR pch/81721
+       * lex.c (cpp_token_val_index <case SPELL_OPERATOR>): If tok->flags
+       has NAMED_OP set, then return CPP_TOKEN_FLD_NODE.
+
 2019-05-14  Martin Liska  <mliska@suse.cz>
 
        PR preprocessor/90382
index eedfcbb31466440a915de3da24b67d5c3bf25a59..16ded6e9b0589c365febba41cf04a090a11d9cca 100644 (file)
@@ -3756,7 +3756,11 @@ cpp_token_val_index (const cpp_token *tok)
     case SPELL_LITERAL:
       return CPP_TOKEN_FLD_STR;
     case SPELL_OPERATOR:
-      if (tok->type == CPP_PASTE)
+      /* Operands which were originally spelled as ident keep around
+         the node for the exact spelling.  */
+      if (tok->flags & NAMED_OP)
+       return CPP_TOKEN_FLD_NODE;
+      else if (tok->type == CPP_PASTE)
        return CPP_TOKEN_FLD_TOKEN_NO;
       else
        return CPP_TOKEN_FLD_NONE;