aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog5
-rw-r--r--libcpp/include/cpplib.h1
-rw-r--r--libcpp/lex.c9
3 files changed, 14 insertions, 1 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index a13f750..8be8438 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-05 Tim van Deurzen <tim@kompiler.org>
+
+ * cpplib.h: Add spaceship operator for C++.
+ * lex.c: Implement conditional lexing of spaceship operator for C++20.
+
2019-10-31 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/92296
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index c655d3f..ed108f1 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -78,6 +78,7 @@ struct _cpp_file;
OP(NOT_EQ, "!=") \
OP(GREATER_EQ, ">=") \
OP(LESS_EQ, "<=") \
+ OP(SPACESHIP, "<=>") \
\
/* These two are unary + / - in preprocessor expressions. */ \
OP(PLUS_EQ, "+=") /* math */ \
diff --git a/libcpp/lex.c b/libcpp/lex.c
index 3e7d1c3..e95eda3f 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -2980,7 +2980,13 @@ _cpp_lex_direct (cpp_reader *pfile)
result->type = CPP_LESS;
if (*buffer->cur == '=')
- buffer->cur++, result->type = CPP_LESS_EQ;
+ {
+ buffer->cur++, result->type = CPP_LESS_EQ;
+ if (*buffer->cur == '>'
+ && CPP_OPTION (pfile, cplusplus)
+ && CPP_OPTION (pfile, lang) >= CLK_GNUCXX2A)
+ buffer->cur++, result->type = CPP_SPACESHIP;
+ }
else if (*buffer->cur == '<')
{
buffer->cur++;
@@ -3491,6 +3497,7 @@ cpp_avoid_paste (cpp_reader *pfile, const cpp_token *token1,
|| (CPP_OPTION (pfile, objc)
&& token1->val.str.text[0] == '@'
&& (b == CPP_NAME || b == CPP_STRING)));
+ case CPP_LESS_EQ: return c == '>';
case CPP_STRING:
case CPP_WSTRING:
case CPP_UTF8STRING: