[Bug c++/104319] better error message for parsing error when >= or >> ends a template variable.

nickhuang99 at hotmail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 3 01:45:09 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104319

--- Comment #6 from qingzhe huang <nickhuang99 at hotmail dot com> ---
But clang can give similar clear message by pointing out the space.
Just like ">>" instead "> >" after c++98, I think GCC can do better to
recognize ">>=" is possible of "> >=". Just considering even though ">>" is one
token, still parser now consider the case of ">" and ">" as to two closing
brackets for two nested templates. 
My point is that even though ">>=" is one token, it doesn't prevent parser from
splitting the token into possible two tokens. Not always the longest match
algorithms in tokenization.

My suggestion is that how about we calculate all possible superset of all other
operators. For example, ">>=" is equivalent to ">" and ">=". Or ">>" and "=".
there are tokens who is using longest match to return only the longest ones. It
is just my naive thought.


More information about the Gcc-bugs mailing list