diff options
author | Jason Merrill <jason@redhat.com> | 2019-11-05 15:36:09 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2019-11-05 15:36:09 -0500 |
commit | 8aa76bb74696d0987e04a82ebcbc44f745ce788d (patch) | |
tree | 51e7fd2a980daeb3ea6a34cfb89b37137299cce2 /gcc/cp | |
parent | 0df65305ff678bd1ad5305e69e3d73e43f0f34f0 (diff) | |
download | gcc-8aa76bb74696d0987e04a82ebcbc44f745ce788d.zip gcc-8aa76bb74696d0987e04a82ebcbc44f745ce788d.tar.gz gcc-8aa76bb74696d0987e04a82ebcbc44f745ce788d.tar.bz2 |
Catch missed uses of function with unsatisfied constraints.
While looking at CA378 I noticed that we weren't properly diagnosing two of
the three erroneous lines in the example.
* decl2.c (mark_used): Diagnose use of a function with unsatisfied
constraints here.
* typeck.c (cp_build_function_call_vec): Not here.
From-SVN: r277860
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 15 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 20 |
3 files changed, 21 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4d9d567..00f5218 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-11-05 Jason Merrill <jason@redhat.com> + + * decl2.c (mark_used): Diagnose use of a function with unsatisfied + constraints here. + * typeck.c (cp_build_function_call_vec): Not here. + 2019-11-05 Nathan Sidwell <nathan@acm.org> PR c++/92370 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index b9f3b87..4dc5481 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -5524,6 +5524,21 @@ mark_used (tree decl, tsubst_flags_t complain) directly. */ maybe_instantiate_decl (decl); + if (flag_concepts && TREE_CODE (decl) == FUNCTION_DECL + && !constraints_satisfied_p (decl)) + { + if (complain & tf_error) + { + auto_diagnostic_group d; + error ("use of function %qD with unsatisfied constraints", + decl); + location_t loc = DECL_SOURCE_LOCATION (decl); + inform (loc, "declared here"); + diagnose_constraints (loc, decl, NULL_TREE); + } + return false; + } + if (processing_template_decl || in_template_function ()) return true; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 27d9785..eefb83d 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3871,26 +3871,6 @@ cp_build_function_call_vec (tree function, vec<tree, va_gc> **params, if (TREE_CODE (function) == FUNCTION_DECL) { - /* If the function is a non-template member function - or a non-template friend, then we need to check the - constraints. - - Note that if overload resolution failed with a single - candidate this function will be used to explicitly diagnose - the failure for the single call expression. The check is - technically redundant since we also would have failed in - add_function_candidate. */ - if (flag_concepts - && (complain & tf_error) - && !constraints_satisfied_p (function)) - { - auto_diagnostic_group d; - error ("cannot call function %qD", function); - location_t loc = DECL_SOURCE_LOCATION (function); - diagnose_constraints (loc, function, NULL_TREE); - return error_mark_node; - } - if (!mark_used (function, complain)) return error_mark_node; fndecl = function; |