From: Jason Merrill Date: Sat, 5 Oct 2024 16:11:24 +0000 (-0400) Subject: c++: require_deduced_type and modules X-Git-Tag: basepoints/gcc-16~5433 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53f20f992a7b0f18fec83ea696c466aa53a1293c;p=thirdparty%2Fgcc.git c++: require_deduced_type and modules With modules more variables have DECL_LANG_SPECIFIC, so we were failing to call require_deduced_type in constexpr-if30.C. gcc/cp/ChangeLog: * decl2.cc (mark_used): Always check require_deduced_type. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/auto43.C: Adjust diagnostic. * g++.dg/cpp2a/lambda-generic7.C: Likewise. --- diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index 0279372488c..a0c319086d7 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -6124,19 +6124,13 @@ mark_used (tree decl, tsubst_flags_t complain /* = tf_warning_or_error */) DECL_LANG_SPECIFIC set, and these are also the only decls that we might need special handling for. */ if (!VAR_OR_FUNCTION_DECL_P (decl) - || DECL_LANG_SPECIFIC (decl) == NULL || DECL_THUNK_P (decl)) - { - if (!decl_dependent_p (decl) - && !require_deduced_type (decl, complain)) - return false; - return true; - } + return true; /* We only want to do this processing once. We don't need to keep trying to instantiate inline templates, because unit-at-a-time will make sure we get them compiled before functions that want to inline them. */ - if (DECL_ODR_USED (decl)) + if (DECL_LANG_SPECIFIC (decl) && DECL_ODR_USED (decl)) return true; if (flag_concepts && TREE_CODE (decl) == FUNCTION_DECL @@ -6164,6 +6158,13 @@ mark_used (tree decl, tsubst_flags_t complain /* = tf_warning_or_error */) && DECL_OMP_DECLARE_REDUCTION_P (decl))) maybe_instantiate_decl (decl); + if (!decl_dependent_p (decl) + && !require_deduced_type (decl, complain)) + return false; + + if (DECL_LANG_SPECIFIC (decl) == NULL) + return true; + if (processing_template_decl || in_template_context) return true; diff --git a/gcc/testsuite/g++.dg/cpp0x/auto43.C b/gcc/testsuite/g++.dg/cpp0x/auto43.C index 45a827553d0..19b6c47cf12 100644 --- a/gcc/testsuite/g++.dg/cpp0x/auto43.C +++ b/gcc/testsuite/g++.dg/cpp0x/auto43.C @@ -8,5 +8,5 @@ template struct A void foo() { - A<0>().operator auto(); // { dg-error "invalid use of .auto" } + A<0>().operator auto(); // { dg-error "auto" } } diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-generic7.C b/gcc/testsuite/g++.dg/cpp2a/lambda-generic7.C index de457420530..b8c599c11c3 100644 --- a/gcc/testsuite/g++.dg/cpp2a/lambda-generic7.C +++ b/gcc/testsuite/g++.dg/cpp2a/lambda-generic7.C @@ -6,5 +6,5 @@ struct S { }; template auto foo(T, U) { - [] <> () { foo (S{}, S{}); }; // { dg-error "expected" } + [] <> () { foo (S{}, S{}); }; // { dg-error "" } }