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);


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);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to