diff options
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r-- | gcc/cpplib.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 25b57c6..efd87e1 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -2029,7 +2029,10 @@ cpp_get_token (pfile) handle_eof: if (CPP_BUFFER (pfile)->seen_eof) { - if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) == CPP_NULL_BUFFER (pfile)) + if (CPP_PREV_BUFFER (CPP_BUFFER (pfile)) == CPP_NULL_BUFFER (pfile) + /* If we've been reading from redirected input, the + frontend will pop the buffer. */ + || CPP_BUFFER (pfile)->manual_pop) return CPP_EOF; cpp_pop_buffer (pfile); @@ -2172,8 +2175,25 @@ cpp_get_token (pfile) c2 = PEEKC (); if (c2 == '-' && opts->chill) goto comment; /* Chill style comment */ - if (c2 == '-' || c2 == '=' || c2 == '>') + if (c2 == '-' || c2 == '=') goto op2; + if (c2 == '>') + { + if (opts->cplusplus && PEEKN (1) == '*') + { + /* In C++, there's a ->* operator. */ + op3: + token = CPP_OTHER; + pfile->only_seen_white = 0; + CPP_RESERVE (pfile, 4); + CPP_PUTC_Q (pfile, c); + CPP_PUTC_Q (pfile, GETC ()); + CPP_PUTC_Q (pfile, GETC ()); + CPP_NUL_TERMINATE_Q (pfile); + return token; + } + goto op2; + } goto randomchar; case '<': @@ -2219,7 +2239,8 @@ cpp_get_token (pfile) c2 = PEEKC (); if (c2 == '=') goto op2; - if (c2 != c) + /* GNU C++ supports MIN and MAX operators <? and >?. */ + if (c2 != c && (!opts->cplusplus || c2 != '?')) goto randomchar; FORWARD(1); CPP_RESERVE (pfile, 4); @@ -2241,6 +2262,11 @@ cpp_get_token (pfile) c = GETC (); goto number; } + + /* In C++ there's a .* operator. */ + if (opts->cplusplus && c2 == '*') + goto op2; + if (c2 == '.' && PEEKN(1) == '.') { CPP_RESERVE(pfile, 4); @@ -2549,7 +2575,7 @@ parse_name (pfile, c) /* Parse a string starting with C. A single quoted string is treated like a double -- some programs (e.g., troff) are perverse this way. (However, a single quoted string is not allowed to extend over - multiple lines. */ + multiple lines.) */ static void parse_string (pfile, c) cpp_reader *pfile; |