https://gcc.gnu.org/g:fb4f6d2cc4a1fbdf631815e31174ce771475500a

commit r16-6276-gfb4f6d2cc4a1fbdf631815e31174ce771475500a
Author: Egas Ribeiro <[email protected]>
Date:   Sun Dec 7 23:36:09 2025 +0000

    c++: Handle error_mark_node in mark_used and mark_single_function
    
    These functions should return false for error_mark_node to properly
    propagate errors from callers.
    
    gcc/cp/ChangeLog:
    
            * decl2.cc (mark_single_function): Return false for error_mark_node.
            (mark_used): Likewise.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/DRs/dr3061.C: Remove cascading error expectation.
            * g++.dg/cpp0x/initlist31.C: Likewise.
    
    Signed-off-by: Egas Ribeiro <[email protected]>
    Reviewed-by: Jason Merrill <[email protected]>

Diff:
---
 gcc/cp/decl2.cc                         | 6 ++++++
 gcc/testsuite/g++.dg/DRs/dr3061.C       | 2 +-
 gcc/testsuite/g++.dg/cpp0x/initlist31.C | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index 8ec9740c8a9e..93415203d394 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -6301,6 +6301,9 @@ mark_single_function (tree expr, tsubst_flags_t complain)
   expr = maybe_undo_parenthesized_ref (expr);
   expr = tree_strip_any_location_wrapper (expr);
 
+  if (expr == error_mark_node)
+    return false;
+
   if (is_overloaded_fn (expr) == 1
       && !mark_used (expr, complain)
       && !(complain & tf_error))
@@ -6343,6 +6346,9 @@ fn_template_being_defined (tree decl)
 bool
 mark_used (tree decl, tsubst_flags_t complain /* = tf_warning_or_error */)
 {
+  if (decl == error_mark_node)
+    return false;
+
   /* If we're just testing conversions or resolving overloads, we
      don't want any permanent effects like forcing functions to be
      output or instantiating templates.  */
diff --git a/gcc/testsuite/g++.dg/DRs/dr3061.C 
b/gcc/testsuite/g++.dg/DRs/dr3061.C
index 728829848f54..bd8b74cdafb0 100644
--- a/gcc/testsuite/g++.dg/DRs/dr3061.C
+++ b/gcc/testsuite/g++.dg/DRs/dr3061.C
@@ -12,7 +12,7 @@ foo ()
   template for (int x : { 1, })                // { dg-warning "'template for' 
only available with" "" { target c++23_down } }
     ;
   for (int x : { , })                  // { dg-error "expected 
primary-expression before ',' token" }
-    ;                                  // { dg-error "unable to deduce" "" { 
target *-*-* } .-1 }
+    ;
   template for (int x : { , })         // { dg-warning "'template for' only 
available with" "" { target c++23_down } }
     ;                                  // { dg-error "expected 
primary-expression before ',' token" "" { target *-*-* } .-1 }
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist31.C 
b/gcc/testsuite/g++.dg/cpp0x/initlist31.C
index a8a29f9c853d..6d88edb397ff 100644
--- a/gcc/testsuite/g++.dg/cpp0x/initlist31.C
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist31.C
@@ -9,5 +9,5 @@ void f() {
   auto y =
   {
     string(Equation()) // { dg-error "12:'Equation' was not declared" }
-  }; // { dg-error "unable to deduce" }
+  };
 }

Reply via email to