]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: require_deduced_type and modules
authorJason Merrill <jason@redhat.com>
Sat, 5 Oct 2024 16:11:24 +0000 (12:11 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 7 Oct 2024 15:55:18 +0000 (11:55 -0400)
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.

gcc/cp/decl2.cc
gcc/testsuite/g++.dg/cpp0x/auto43.C
gcc/testsuite/g++.dg/cpp2a/lambda-generic7.C

index 0279372488c2940363095d31e78205766d402c68..a0c319086d715a9bb5f80eba8fdcc0d92617e4f8 100644 (file)
@@ -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;
 
index 45a827553d067238cacca9e705f0cb48fc26bb44..19b6c47cf1230e385452a50f6d488a0a07fc8e05 100644 (file)
@@ -8,5 +8,5 @@ template<int> struct A
 
 void foo()
 {
-  A<0>().operator auto();  // { dg-error "invalid use of .auto" }
+  A<0>().operator auto();  // { dg-error "auto" }
 }
index de45742053012df723727af94910556300e4ec71..b8c599c11c3aea9b3ca27eaf2499f3f2b7327a31 100644 (file)
@@ -6,5 +6,5 @@ struct S { };
 template<typename T, typename U>
 auto foo(T, U)
 {
-  [] <> () { foo (S{}, S{}); }; // { dg-error "expected" }
+  [] <> () { foo (S{}, S{}); }; // { dg-error "" }
 }