aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-10-28 11:47:26 -0400
committerPatrick Palka <ppalka@redhat.com>2020-10-28 11:47:26 -0400
commit9ccc3495766116ea4ae8e4cd8129beca60e30445 (patch)
tree622bad79f4db558f58a19afcb464d5fa90c51590 /gcc/cp/decl2.c
parent7d5f38e49e59a09140473aa592133360428a1d83 (diff)
downloadgcc-9ccc3495766116ea4ae8e4cd8129beca60e30445.zip
gcc-9ccc3495766116ea4ae8e4cd8129beca60e30445.tar.gz
gcc-9ccc3495766116ea4ae8e4cd8129beca60e30445.tar.bz2
c++: Check constraints before instantiation from mark_used [PR95132]
This makes mark_used check constraints of a function _before_ calling maybe_instantiate_decl, so that we don't try instantiating a function (as part of return type deduction) with unsatisfied constraints. gcc/cp/ChangeLog: PR c++/95132 * decl2.c (mark_used): Move up the constraints_satisfied_p check so that we check constraints before calling maybe_instantiate_decl. gcc/testsuite/ChangeLog: PR c++/95132 * g++.dg/cpp2a/concepts-fn7.C: New test.
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 6fd0814..71107e0 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -5588,16 +5588,6 @@ mark_used (tree decl, tsubst_flags_t complain)
if (DECL_ODR_USED (decl))
return true;
- /* Normally, we can wait until instantiation-time to synthesize DECL.
- However, if DECL is a static data member initialized with a constant
- or a constexpr function, we need it right now because a reference to
- such a data member or a call to such function is not value-dependent.
- For a function that uses auto in the return type, we need to instantiate
- it to find out its type. For OpenMP user defined reductions, we need
- them instantiated for reduction clauses which inline them by hand
- directly. */
- maybe_instantiate_decl (decl);
-
if (flag_concepts && TREE_CODE (decl) == FUNCTION_DECL
&& !constraints_satisfied_p (decl))
{
@@ -5613,6 +5603,16 @@ mark_used (tree decl, tsubst_flags_t complain)
return false;
}
+ /* Normally, we can wait until instantiation-time to synthesize DECL.
+ However, if DECL is a static data member initialized with a constant
+ or a constexpr function, we need it right now because a reference to
+ such a data member or a call to such function is not value-dependent.
+ For a function that uses auto in the return type, we need to instantiate
+ it to find out its type. For OpenMP user defined reductions, we need
+ them instantiated for reduction clauses which inline them by hand
+ directly. */
+ maybe_instantiate_decl (decl);
+
if (processing_template_decl || in_template_function ())
return true;