[clang] [Clang] prevent recovery call expression from proceeding with explicit attributes and undeclared templates (PR #107786)

Oleksandr T. via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 24 08:27:08 PDT 2024


================
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
+
+namespace GH49093 {
+  class B {
+  public:
+    static int a() { return 0; } // expected-note {{member is declared here}}
+    decltype(a< 0 >(0)) test;    // expected-error {{member 'a' used before its declaration}}
----------------
a-tarasyuk wrote:

I also thought skipping `DiagnoseDependentMemberLookup` and proceeding with the correction, as this seems to avoid those candidates and focus on the appropriate templated candidates

https://github.com/llvm/llvm-project/blob/3138eb500c9462bcb6899088d49644adb4d90f62/clang/lib/Sema/SemaExpr.cpp#L2500-L2612

since `DiagnoseDependentMemberLookup` treats these candidates as valid, it continues with recovery and constructs the call expression as entirely valid 

https://github.com/llvm/llvm-project/blob/9ac00b85e05d21be658d6aa0c91cbe05bb5dbde2/clang/lib/Sema/SemaOverload.cpp#L13899-L13901

https://github.com/llvm/llvm-project/blob/3138eb500c9462bcb6899088d49644adb4d90f62/clang/lib/Sema/SemaExpr.cpp#L6528-L6530

https://github.com/llvm/llvm-project/blob/9ac00b85e05d21be658d6aa0c91cbe05bb5dbde2/clang/lib/Sema/SemaOverload.cpp#L14145

https://github.com/llvm/llvm-project/blob/9ac00b85e05d21be658d6aa0c91cbe05bb5dbde2/clang/lib/Sema/SemaOverload.cpp#L13937

https://github.com/llvm/llvm-project/pull/107786


More information about the cfe-commits mailing list