Skip to content

Commit

Permalink
[clang-repl] Disambiguate global namespace identifiers
Browse files Browse the repository at this point in the history
A double colon starts an identifier name in the global namespace and
must be tentatively parsed as such.

Differential Revision: https://reviews.llvm.org/D157480
  • Loading branch information
hahnjo committed Aug 14, 2023
1 parent 06dfc84 commit ba475a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/lib/Parse/ParseTentative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ bool Parser::isCXXDeclarationStatement(
case tok::kw_static_assert:
case tok::kw__Static_assert:
return true;
case tok::coloncolon:
case tok::identifier: {
if (DisambiguatingWithExpression) {
RevertingTentativeParsingAction TPA(*this);
Expand Down
4 changes: 4 additions & 0 deletions clang/test/Interpreter/disambiguate-decl-stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ struct Dtor1 {~Dtor1();};
Dtor1::~Dtor1() { printf("Dtor1\n"); }
Dtor1 d1;

struct Dtor2 { ~Dtor2(); };
::Dtor2::~Dtor2() { printf("Dtor2\n"); }
Dtor2 d2;

struct ANestedDtor { struct A1 { struct A2 { ~A2(); }; }; };
ANestedDtor::A1::A2::~A2() { printf("Dtor A::A1::A2::~A2\n"); }

Expand Down

0 comments on commit ba475a4

Please sign in to comment.