[Parser] Fix assertion-on-invalid for unexpected typename.
authorVolodymyr Sapsai <vsapsai@apple.com>
Tue, 10 Apr 2018 18:29:47 +0000 (18:29 +0000)
committerVolodymyr Sapsai <vsapsai@apple.com>
Tue, 10 Apr 2018 18:29:47 +0000 (18:29 +0000)
commit344b6ca4d1b264b8bc2abf5eb91b52713d663a9d
tree4c42b4cbee24397d7adedb72f4ebdca452e8b1c0
parent28e0b48b2a8575bbef060815a907d64890b3f789
[Parser] Fix assertion-on-invalid for unexpected typename.

In `ParseDeclarationSpecifiers` for the code

    class A typename A;

we were able to annotate token `kw_typename` because it refers to
existing type. But later during processing token `annot_typename` we
failed to `SetTypeSpecType` and exited switch statement leaving
annotation token unconsumed. The code after the switch statement failed
because it didn't expect a special token.

The fix is not to assume that switch statement consumes all special
tokens and consume any token, not just non-special.

rdar://problem/37099386

Reviewers: rsmith, arphaman

Reviewed By: rsmith

Subscribers: jkorous-apple, cfe-commits

Differential Revision: https://reviews.llvm.org/D44449

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329735 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Parse/ParseDecl.cpp
test/Parser/cxx-decl.cpp