diff options
author | Douglas Gregor <doug.gregor@gmail.com> | 2008-08-06 19:08:12 +0000 |
---|---|---|
committer | Doug Gregor <dgregor@gcc.gnu.org> | 2008-08-06 19:08:12 +0000 |
commit | 865a3a421ada308194ab5960e4931fa09c3c68ad (patch) | |
tree | 9c00222f32383f6e7a60ef225649e796d310d8aa /gcc/cp/parser.c | |
parent | 2696a995839501cf16495ff72f2a0bbc7cc0b72b (diff) | |
download | gcc-865a3a421ada308194ab5960e4931fa09c3c68ad.zip gcc-865a3a421ada308194ab5960e4931fa09c3c68ad.tar.gz gcc-865a3a421ada308194ab5960e4931fa09c3c68ad.tar.bz2 |
re PR c++/36460 (No space between >'s not always handled in C++0x)
2008-08-06 Douglas Gregor <doug.gregor@gmail.com>
PR c++/36460
* parser.c (cp_parser_template_argument): Don't assume that '>>'
following a type-id is an error when in C++0x mode.
2008-08-06 Douglas Gregor <doug.gregor@gmail.com>
PR c++/36460
* g++.dg/cpp0x/bracket3.C: Add another test case for the >>
warning under -Wc++0x-compat.
* g++.dg/cpp0x/bracket4.C: Add testcase for PR c++/36460.
From-SVN: r138819
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 76adb63..7c1b04d 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -10386,9 +10386,10 @@ cp_parser_template_argument (cp_parser* parser) Therefore, we try a type-id first. */ cp_parser_parse_tentatively (parser); argument = cp_parser_type_id (parser); - /* If there was no error parsing the type-id but the next token is a '>>', - we probably found a typo for '> >'. But there are type-id which are - also valid expressions. For instance: + /* If there was no error parsing the type-id but the next token is a + '>>', our behavior depends on which dialect of C++ we're + parsing. In C++98, we probably found a typo for '> >'. But there + are type-id which are also valid expressions. For instance: struct X { int operator >> (int); }; template <int V> struct Foo {}; @@ -10397,8 +10398,12 @@ cp_parser_template_argument (cp_parser* parser) Here 'X()' is a valid type-id of a function type, but the user just wanted to write the expression "X() >> 5". Thus, we remember that we found a valid type-id, but we still try to parse the argument as an - expression to see what happens. */ + expression to see what happens. + + In C++0x, the '>>' will be considered two separate '>' + tokens. */ if (!cp_parser_error_occurred (parser) + && cxx_dialect == cxx98 && cp_lexer_next_token_is (parser->lexer, CPP_RSHIFT)) { maybe_type_id = true; |