diff options
author | Jason Merrill <jason@redhat.com> | 2018-04-12 16:03:33 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-04-12 16:03:33 -0400 |
commit | 38f3a877505df9a6e355add3424120f39450c432 (patch) | |
tree | 3fd42df87398348c6dd035d4b1fdbb12ec2da387 | |
parent | 4930c53ee69f18a6fd689527864d419ce0333e7a (diff) | |
download | gcc-38f3a877505df9a6e355add3424120f39450c432.zip gcc-38f3a877505df9a6e355add3424120f39450c432.tar.gz gcc-38f3a877505df9a6e355add3424120f39450c432.tar.bz2 |
PR c++/85356 - ICE with pointer to member function.
* pt.c (maybe_instantiate_noexcept): Do instantiate in templates if
flag_noexcept_type. Build the new spec within the function context.
* except.c (build_noexcept_spec): Do get constant value in templates
if flag_noexcept_type.
* decl.c (check_redeclaration_exception_specification): Don't
instantiate noexcept on a dependent declaration.
From-SVN: r259356
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/decl.c | 7 | ||||
-rw-r--r-- | gcc/cp/except.c | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/mem_func_ptr2.C | 13 |
5 files changed, 35 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e3bc2d9..08021df 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2018-04-12 Jason Merrill <jason@redhat.com> + + PR c++/85356 - ICE with pointer to member function. + * pt.c (maybe_instantiate_noexcept): Do instantiate in templates if + flag_noexcept_type. Build the new spec within the function context. + * except.c (build_noexcept_spec): Do get constant value in templates + if flag_noexcept_type. + * decl.c (check_redeclaration_exception_specification): Don't + instantiate noexcept on a dependent declaration. + 2018-04-12 Marek Polacek <polacek@redhat.com> PR c++/85258 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 44a152b..9f1a171 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1232,8 +1232,11 @@ check_redeclaration_exception_specification (tree new_decl, && UNEVALUATED_NOEXCEPT_SPEC_P (old_exceptions)) return; - maybe_instantiate_noexcept (new_decl); - maybe_instantiate_noexcept (old_decl); + if (!type_dependent_expression_p (old_decl)) + { + maybe_instantiate_noexcept (new_decl); + maybe_instantiate_noexcept (old_decl); + } new_exceptions = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (new_decl)); old_exceptions = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (old_decl)); diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 0b46698..6dab6d6 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -1194,11 +1194,14 @@ build_noexcept_spec (tree expr, int complain) { /* This isn't part of the signature, so don't bother trying to evaluate it until instantiation. */ - if (!processing_template_decl && TREE_CODE (expr) != DEFERRED_NOEXCEPT) + if (TREE_CODE (expr) != DEFERRED_NOEXCEPT + && (!processing_template_decl + || (flag_noexcept_type && !value_dependent_expression_p (expr)))) { expr = perform_implicit_conversion_flags (boolean_type_node, expr, complain, LOOKUP_NORMAL); + expr = instantiate_non_dependent_expr (expr); expr = cxx_constant_value (expr); } if (TREE_CODE (expr) == INTEGER_CST) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 76e546c..da8a526 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -23234,7 +23234,8 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t complain) tree fntype, spec, noex, clone; /* Don't instantiate a noexcept-specification from template context. */ - if (processing_template_decl) + if (processing_template_decl + && (!flag_noexcept_type || type_dependent_expression_p (fn))) return true; if (DECL_CLONED_FUNCTION_P (fn)) @@ -23273,10 +23274,10 @@ maybe_instantiate_noexcept (tree fn, tsubst_flags_t complain) tf_warning_or_error, fn, /*function_p=*/false, /*integral_constant_expression_p=*/true); + spec = build_noexcept_spec (noex, tf_warning_or_error); pop_deferring_access_checks (); pop_access_scope (fn); pop_tinst_level (); - spec = build_noexcept_spec (noex, tf_warning_or_error); if (spec == error_mark_node) spec = noexcept_false_spec; } diff --git a/gcc/testsuite/g++.dg/template/mem_func_ptr2.C b/gcc/testsuite/g++.dg/template/mem_func_ptr2.C new file mode 100644 index 0000000..9ceabd3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/mem_func_ptr2.C @@ -0,0 +1,13 @@ +// PR c++/85356 + +struct A +{ + A& operator=(int); +}; + +void foo(A&(A::*)(int)); + +template<int> void bar() +{ + foo(&A::operator=); +} |