https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/183937

Fixes #175783

>From 7aaa2eca0d7601f9a12be656bed39b3756947e0a Mon Sep 17 00:00:00 2001
From: Matheus Izvekov <[email protected]>
Date: Sat, 28 Feb 2026 16:31:27 -0300
Subject: [PATCH] [clang] use typo-corrected name qualifier for expressions

Fixes #175783
---
 clang/lib/Sema/SemaExpr.cpp                   |  7 +++++++
 clang/test/ParserOpenACC/parse-constructs.cpp |  4 ++--
 clang/test/SemaCXX/GH175783.cpp               | 12 ++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/SemaCXX/GH175783.cpp

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 9cf7f36e12aa6..9c28c4a799d98 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2738,6 +2738,13 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec 
&SS, LookupResult &R,
                          << DroppedSpecifier << NameRange,
                      PDiag(NoteID), AcceptableWithRecovery);
 
+      if (Corrected.WillReplaceSpecifier()) {
+        NestedNameSpecifier NNS = Corrected.getCorrectionSpecifier();
+        // In order to be valid, a non-empty CXXScopeSpec needs a source range.
+        SS.MakeTrivial(Context, NNS,
+                       NNS ? NameRange.getBegin() : SourceRange());
+      }
+
       // Tell the callee whether to try to recover.
       return !AcceptableWithRecovery;
     }
diff --git a/clang/test/ParserOpenACC/parse-constructs.cpp 
b/clang/test/ParserOpenACC/parse-constructs.cpp
index 69b04bcbad9e3..6d6285ce63bd2 100644
--- a/clang/test/ParserOpenACC/parse-constructs.cpp
+++ b/clang/test/ParserOpenACC/parse-constructs.cpp
@@ -18,13 +18,13 @@ namespace NS {
 #pragma acc routine(NS::foo) seq
 
 // expected-error@+2{{use of undeclared identifier 'templ'; did you mean 
'NS::templ'?}}
-// expected-error@+1{{OpenACC routine name 'templ' names a set of overloads}}
+// expected-error@+1{{OpenACC routine name 'NS::templ' names a set of 
overloads}}
 #pragma acc routine(templ) seq
 // expected-error@+1{{OpenACC routine name 'NS::templ' names a set of 
overloads}}
 #pragma acc routine(NS::templ) seq
 
 // expected-error@+2{{use of undeclared identifier 'templ'; did you mean 
'NS::templ'?}}
-// expected-error@+1{{OpenACC routine name 'templ<int>' names a set of 
overloads}}
+// expected-error@+1{{OpenACC routine name 'NS::templ<int>' names a set of 
overloads}}
 #pragma acc routine(templ<int>) seq
 // expected-error@+1{{OpenACC routine name 'NS::templ<int>' names a set of 
overloads}}
 #pragma acc routine(NS::templ<int>) seq
diff --git a/clang/test/SemaCXX/GH175783.cpp b/clang/test/SemaCXX/GH175783.cpp
new file mode 100644
index 0000000000000..6bb2acffdeae2
--- /dev/null
+++ b/clang/test/SemaCXX/GH175783.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fspell-checking-limit=0 -verify %s
+
+namespace GH175783 {
+  class B {
+  public:
+    virtual void foo(); // #foo
+  };
+  void (*p)() = &GH175783::foo;
+  // expected-error@-1 {{no member named 'foo' in namespace 'GH175783'; did 
you mean 'B::foo'?}}
+  // expected-error@-2 {{cannot initialize a variable of type 'void (*)()' 
with an rvalue of type 'void (B::*)()'}}
+  // expected-note@#foo {{'B::foo' declared here}}
+} // namespace GH175783

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to