Skip to content

Commit 731c93f

Browse files
hahnjotru
authored andcommitted
[clang-repl] Disambiguate global namespace identifiers
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 (cherry picked from commit ba475a4)
1 parent d6cd057 commit 731c93f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

clang/lib/Parse/ParseTentative.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ bool Parser::isCXXDeclarationStatement(
6262
case tok::kw_static_assert:
6363
case tok::kw__Static_assert:
6464
return true;
65+
case tok::coloncolon:
6566
case tok::identifier: {
6667
if (DisambiguatingWithExpression) {
6768
RevertingTentativeParsingAction TPA(*this);

clang/test/Interpreter/disambiguate-decl-stmt.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ struct Dtor1 {~Dtor1();};
3434
Dtor1::~Dtor1() { printf("Dtor1\n"); }
3535
Dtor1 d1;
3636

37+
struct Dtor2 { ~Dtor2(); };
38+
::Dtor2::~Dtor2() { printf("Dtor2\n"); }
39+
Dtor2 d2;
40+
3741
struct ANestedDtor { struct A1 { struct A2 { ~A2(); }; }; };
3842
ANestedDtor::A1::A2::~A2() { printf("Dtor A::A1::A2::~A2\n"); }
3943

0 commit comments

Comments
 (0)