Fixes #167905 --- This patch addresses an issue where invalid nested name specifier sequences containing a single colon (`a:c::`) could be treated during recovery as valid scope specifiers, which in turn led to a crashc543615744/clang/lib/Parse/ParseExprCXX.cpp (L404-L418)For malformed inputs like `a:c::`, the single colon recovery incorrectly triggers and produces an `annot_cxxscope`. When tentative parsing later runs996213c6ea/clang/lib/Parse/ParseTentative.cpp (L1739-L1740)the classifier returns `Ambiguous`, which doesn't stop parsing. The parser then enters the996213c6ea/clang/lib/Parse/ParseTentative.cpp (L1750-L1752)and consumes the invalid scope annotation, eventually reaching `EOF` and crashing.
11 lines
461 B
C++
11 lines
461 B
C++
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
|
|
namespace a { b c ( a:c::
|
|
// expected-error@-1 {{unknown type name 'b'}}
|
|
// expected-error@-2 {{unexpected ':' in nested name specifier; did you mean '::'?}}
|
|
// expected-error@-3 {{no member named 'c' in namespace 'a'}}
|
|
// expected-error@-4 {{expected ';' after top level declarator}}
|
|
// expected-note@-5 {{to match this '{'}}
|
|
// expected-error@+1 {{expected unqualified-id}} \
|
|
// expected-error@+1 {{expected '}'}}
|