[clang] ba475a4 - [clang-repl] Disambiguate global namespace identifiers
Jonas Hahnfeld via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 14 01:11:43 PDT 2023
Author: Jonas Hahnfeld
Date: 2023-08-14T10:11:27+02:00
New Revision: ba475a4a3440a21e5de6a39a16215836f2614f04
URL: https://github.com/llvm/llvm-project/commit/ba475a4a3440a21e5de6a39a16215836f2614f04
DIFF: https://github.com/llvm/llvm-project/commit/ba475a4a3440a21e5de6a39a16215836f2614f04.diff
LOG: [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
Added:
Modified:
clang/lib/Parse/ParseTentative.cpp
clang/test/Interpreter/disambiguate-decl-stmt.cpp
Removed:
################################################################################
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index b7c83bbeb82ee7..66433705250010 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -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);
diff --git a/clang/test/Interpreter/disambiguate-decl-stmt.cpp b/clang/test/Interpreter/disambiguate-decl-stmt.cpp
index 4553a560ee5324..cbc456da6eb512 100644
--- a/clang/test/Interpreter/disambiguate-decl-stmt.cpp
+++ b/clang/test/Interpreter/disambiguate-decl-stmt.cpp
@@ -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"); }
More information about the cfe-commits
mailing list