From 5a9abe846617efea4a128134db0915a044d7dd73 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Sun, 30 Apr 2023 19:43:38 +0000 Subject: [PATCH] [clang-repl] Correctly disambiguate dtor declarations from statements. Differential revision: https://reviews.llvm.org/D148425 --- clang/lib/Parse/ParseTentative.cpp | 6 ++---- clang/test/Interpreter/disambiguate-decl-stmt.cpp | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp index b26faaf..934087e 100644 --- a/clang/lib/Parse/ParseTentative.cpp +++ b/clang/lib/Parse/ParseTentative.cpp @@ -88,10 +88,8 @@ bool Parser::isCXXDeclarationStatement( } case tok::kw_operator: return true; - case tok::annot_cxxscope: // Check if this is a dtor. - if (NextToken().is(tok::tilde)) - return true; - break; + case tok::tilde: + return true; default: break; } diff --git a/clang/test/Interpreter/disambiguate-decl-stmt.cpp b/clang/test/Interpreter/disambiguate-decl-stmt.cpp index 0022ad7..8f8a2a9 100644 --- a/clang/test/Interpreter/disambiguate-decl-stmt.cpp +++ b/clang/test/Interpreter/disambiguate-decl-stmt.cpp @@ -26,6 +26,10 @@ I x = 10; x.I::~I(); x = 20; +struct Dtor1 {~Dtor1();}; +Dtor1::~Dtor1() { printf("Dtor1\n"); } +Dtor1 d1; + // Ctors // Deduction guide -- 2.7.4