diff options
author | Jason Merrill <jason@redhat.com> | 2011-09-06 14:09:01 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-09-06 14:09:01 -0400 |
commit | e2605091be4ae6b26d8df1d6b6842ff02a73a675 (patch) | |
tree | e20937f632c58c1a01487434d4d86c8b697ce0c8 | |
parent | df7b0cc4aae0620d830b8e9f8ed8a586e68f470b (diff) | |
download | gcc-e2605091be4ae6b26d8df1d6b6842ff02a73a675.zip gcc-e2605091be4ae6b26d8df1d6b6842ff02a73a675.tar.gz gcc-e2605091be4ae6b26d8df1d6b6842ff02a73a675.tar.bz2 |
re PR c++/50296 (New C++ test failures)
PR c++/50296
* semantics.c (register_constexpr_fundef): Call is_valid_constexpr_fn.
(cx_check_missing_mem_inits): Handle bases and empty trivial members.
(validate_constexpr_fundecl): Remove.
* decl.c (start_preparsed_function): Don't call it.
* cp-tree.h: Don't declare it.
From-SVN: r178604
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/decl.c | 4 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 41 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C | 4 |
6 files changed, 27 insertions, 34 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b676dd1..2fe60fe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2011-09-06 Jason Merrill <jason@redhat.com> + + PR c++/50296 + * semantics.c (register_constexpr_fundef): Call is_valid_constexpr_fn. + (cx_check_missing_mem_inits): Handle bases and empty trivial members. + (validate_constexpr_fundecl): Remove. + * decl.c (start_preparsed_function): Don't call it. + * cp-tree.h: Don't declare it. + 2011-09-04 Jason Merrill <jason@redhat.com> PR c++/49267 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index cf6c056..ae4cd07 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5367,7 +5367,6 @@ extern void finish_handler_parms (tree, tree); extern void finish_handler (tree); extern void finish_cleanup (tree, tree); extern bool literal_type_p (tree); -extern tree validate_constexpr_fundecl (tree); extern tree register_constexpr_fundef (tree, tree); extern bool check_constexpr_ctor_body (tree, tree); extern tree ensure_literal_type_for_constexpr_object (tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 39a0b0e..eed4535 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12659,10 +12659,6 @@ start_preparsed_function (tree decl1, tree attrs, int flags) maybe_apply_pragma_weak (decl1); } - /* constexpr functions must have literal argument types and - literal return type. */ - validate_constexpr_fundecl (decl1); - /* Reset this in case the call to pushdecl changed it. */ current_function_decl = decl1; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index bdc4cf2..f782df9 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5485,7 +5485,6 @@ is_valid_constexpr_fn (tree fun, bool complain) } } - /* Check this again here for cxx_eval_call_expression. */ if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fun) && !CLASSTYPE_LITERAL_P (DECL_CONTEXT (fun))) { @@ -5502,29 +5501,6 @@ is_valid_constexpr_fn (tree fun, bool complain) return ret; } -/* Return non-null if FUN certainly designates a valid constexpr function - declaration. Otherwise return NULL. Issue appropriate diagnostics - if necessary. Note that we only check the declaration, not the body - of the function. */ - -tree -validate_constexpr_fundecl (tree fun) -{ - if (processing_template_decl || !DECL_DECLARED_CONSTEXPR_P (fun)) - return NULL; - else if (DECL_CLONED_FUNCTION_P (fun)) - /* We already checked the original function. */ - return fun; - - if (!is_valid_constexpr_fn (fun, !DECL_TEMPLATE_INFO (fun))) - { - DECL_DECLARED_CONSTEXPR_P (fun) = false; - return NULL; - } - - return fun; -} - /* Subroutine of build_constexpr_constructor_member_initializers. The expression tree T represents a data member initialization in a (constexpr) constructor definition. Build a pairing of @@ -5799,17 +5775,27 @@ cx_check_missing_mem_inits (tree fun, tree body, bool complain) else { index = CONSTRUCTOR_ELT (body, i)->index; - /* Skip base vtable inits. */ - if (TREE_CODE (index) == COMPONENT_REF) + /* Skip base and vtable inits. */ + if (TREE_CODE (index) != FIELD_DECL) continue; } for (; field != index; field = DECL_CHAIN (field)) { + tree ftype; if (TREE_CODE (field) != FIELD_DECL || (DECL_C_BIT_FIELD (field) && !DECL_NAME (field))) continue; if (!complain) return true; + ftype = strip_array_types (TREE_TYPE (field)); + if (type_has_constexpr_default_constructor (ftype)) + { + /* It's OK to skip a member with a trivial constexpr ctor. + A constexpr ctor that isn't trivial should have been + added in by now. */ + gcc_checking_assert (!TYPE_HAS_COMPLEX_DFLT (ftype)); + continue; + } error ("uninitialized member %qD in %<constexpr%> constructor", field); bad = true; @@ -5834,6 +5820,9 @@ register_constexpr_fundef (tree fun, tree body) constexpr_fundef entry; constexpr_fundef **slot; + if (!is_valid_constexpr_fn (fun, !DECL_TEMPLATE_INFO (fun))) + return NULL; + body = massage_constexpr_body (fun, body); if (body == NULL_TREE || body == error_mark_node) { diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C index 44e6bc7..cbd4983 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C @@ -17,4 +17,4 @@ constexpr int b = A<B>().f(); // { dg-error "non-constexpr function" } template <class T> constexpr int f (T t) { return 42; } // { dg-error "parameter" } -constexpr int x = f(B()); // { dg-error "constexpr function" } +constexpr int x = f(B()); // { dg-error "constexpr" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C index 1831a2b0..57782cf 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C @@ -19,5 +19,5 @@ struct C constexpr int i = f(C<int>()); constexpr int j = C<int>().m(C<int>()); -constexpr int k = C<double>().m(A()); // { dg-error "non-constexpr function" } -constexpr int l = g(C<double>(),A()); // { dg-error "non-constexpr function" } +constexpr int k = C<double>().m(A()); // { dg-error "constexpr" } +constexpr int l = g(C<double>(),A()); // { dg-error "constexpr" } |