https://github.com/efriedma-quic updated 
https://github.com/llvm/llvm-project/pull/215423

>From 50b691251a28c5019392c40440cf2ae36131d208 Mon Sep 17 00:00:00 2001
From: Eli Friedman <[email protected]>
Date: Mon, 10 Aug 2026 15:23:03 -0700
Subject: [PATCH 1/2] [C++] Don't mark a field invalid for unparsed in-class
 member initializer.

We delay parsing of in-class member initializers until the end of the
outermost class declaration. It is an error for code to try to use that
initializer before it's parsed.  However, sometimes that error can be
suppressed by an SFINAE context.  Since we aren't sure a user-visible
error will be emitted, don't mark the field invalid.

Fixes https://github.com/llvm/llvm-project/issues/215166 .
---
 clang/lib/Sema/SemaExpr.cpp                        |  1 -
 clang/lib/Sema/SemaTemplateInstantiate.cpp         |  1 -
 .../SemaCXX/cxx11-default-member-initializers.cpp  | 14 ++++++++++++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5f4af9debe91a..90e360e2b05fc 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5903,7 +5903,6 @@ ExprResult Sema::BuildCXXDefaultInitExpr(SourceLocation 
Loc, FieldDecl *Field) {
       if (!Pattern->hasInClassInitializer() ||
           InstantiateInClassInitializer(Loc, Field, Pattern,
                                         getTemplateInstantiationArgs(Field))) {
-        Field->setInvalidDecl();
         return ExprError();
       }
     }
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 21d68f765bdaf..93824b9ef9da7 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3912,7 +3912,6 @@ bool Sema::InstantiateInClassInitializer(
         << OutermostClass << Pattern;
     Diag(Pattern->getEndLoc(),
          diag::note_default_member_initializer_not_yet_parsed);
-    Instantiation->setInvalidDecl();
     return true;
   }
 
diff --git a/clang/test/SemaCXX/cxx11-default-member-initializers.cpp 
b/clang/test/SemaCXX/cxx11-default-member-initializers.cpp
index 5e26c3a3b82cd..1aa04df395379 100644
--- a/clang/test/SemaCXX/cxx11-default-member-initializers.cpp
+++ b/clang/test/SemaCXX/cxx11-default-member-initializers.cpp
@@ -17,6 +17,20 @@ namespace PR31692 {
   static_assert(__is_constructible(A::X), "");
 }
 
+namespace PR215166 {
+  // Same as above, but with a class template.
+  struct A {
+    template<typename T> struct X { int n = 0; };
+    X<int> x;
+    // Trigger construction of X<int>() from a SFINAE context. This must not 
mark
+    // any part of X<int> as invalid.
+    static_assert(!__is_constructible(X<int>), "");
+    // Check that X<int>::n is not marked invalid.
+    double &r = x.n; // expected-error {{non-const lvalue reference to type 
'double' cannot bind to a value of unrelated type 'int'}}
+  };
+  // A::X can now be default-constructed.
+  static_assert(__is_constructible(A::X<int>), "");
+}
 
 struct S {
 } constexpr s;

>From 1c0122fbd99778d69680d13211537ea59a613744 Mon Sep 17 00:00:00 2001
From: Eli Friedman <[email protected]>
Date: Tue, 11 Aug 2026 14:51:19 -0700
Subject: [PATCH 2/2] Add release note

---
 clang/docs/ReleaseNotes.md | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 8549d03f83a4f..b5aa71119e4b7 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -467,6 +467,11 @@ features cannot lower the translation-unit ABI level;
 - Fixed friend declarations sometimes making non-visible default arguments
   incorrectly visible to default argument redefinition checks across modules.
 
+- Fixed handling of SFINAE failures for expressions which depend on in-class
+  member initializers of templates which are not yet parsed. An example is
+  using ``__is_constructible`` on a nested class template inside the definition
+  of the containing class. (#GH215166)
+
 #### Bug Fixes to AST Handling
 
 - Fixed a non-deterministic ordering of unused local typedefs that made

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

Reply via email to