[PATCH] D157480: [clang-repl] Disambiguate global namespace identifiers

Jonas Hahnfeld via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 9 01:43:35 PDT 2023


Hahnfeld created this revision.
Hahnfeld added reviewers: v.g.vassilev, aaron.ballman.
Herald added a project: All.
Hahnfeld requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A double colon starts an identifier name in the global namespace and must be tentatively parsed as such.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157480

Files:
  clang/lib/Parse/ParseTentative.cpp
  clang/test/Interpreter/global-namespace-disambiguate.cpp


Index: clang/test/Interpreter/global-namespace-disambiguate.cpp
===================================================================
--- /dev/null
+++ clang/test/Interpreter/global-namespace-disambiguate.cpp
@@ -0,0 +1,8 @@
+// UNSUPPORTED: system-aix
+
+// RUN: cat %s | clang-repl 2>&1 | FileCheck %s
+
+struct A { ~A(); };
+::A::~A() {}
+
+// CHECK-NOT: error
Index: clang/lib/Parse/ParseTentative.cpp
===================================================================
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -62,6 +62,7 @@
   case tok::kw_static_assert:
   case tok::kw__Static_assert:
     return true;
+  case tok::coloncolon:
   case tok::identifier: {
     if (DisambiguatingWithExpression) {
       RevertingTentativeParsingAction TPA(*this);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157480.548514.patch
Type: text/x-patch
Size: 793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230809/e091e8b6/attachment.bin>


More information about the cfe-commits mailing list