From 3f23e487f38e56a3daa66ad22dc2216fa17db885 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Mon, 20 May 2019 06:59:06 +0000 Subject: [PATCH] Fix PR 81721: ICE with PCH and Pragma warning and C++ operator libcpp/ChangeLog: 2019-05-19 Andrew Pinski PR pch/81721 * lex.c (cpp_token_val_index ): If tok->flags has NAMED_OP set, then return CPP_TOKEN_FLD_NODE. gcc/testsuite/ChangeLog: 2019-05-19 Andrew Pinski PR pch/81721 * g++.dg/pch/operator-1.C: New testcase. * g++.dg/pch/operator-1.Hs: New file. From-SVN: r271395 --- libcpp/lex.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libcpp/lex.c') diff --git a/libcpp/lex.c b/libcpp/lex.c index eedfcbb..16ded6e 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -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; -- cgit v1.1