Commit e2605091 by Jason Merrill Committed by Jason Merrill

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
parent df7b0cc4
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> 2011-09-04 Jason Merrill <jason@redhat.com>
PR c++/49267 PR c++/49267
......
...@@ -5367,7 +5367,6 @@ extern void finish_handler_parms (tree, tree); ...@@ -5367,7 +5367,6 @@ extern void finish_handler_parms (tree, tree);
extern void finish_handler (tree); extern void finish_handler (tree);
extern void finish_cleanup (tree, tree); extern void finish_cleanup (tree, tree);
extern bool literal_type_p (tree); extern bool literal_type_p (tree);
extern tree validate_constexpr_fundecl (tree);
extern tree register_constexpr_fundef (tree, tree); extern tree register_constexpr_fundef (tree, tree);
extern bool check_constexpr_ctor_body (tree, tree); extern bool check_constexpr_ctor_body (tree, tree);
extern tree ensure_literal_type_for_constexpr_object (tree); extern tree ensure_literal_type_for_constexpr_object (tree);
......
...@@ -12659,10 +12659,6 @@ start_preparsed_function (tree decl1, tree attrs, int flags) ...@@ -12659,10 +12659,6 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
maybe_apply_pragma_weak (decl1); 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. */ /* Reset this in case the call to pushdecl changed it. */
current_function_decl = decl1; current_function_decl = decl1;
......
...@@ -5485,7 +5485,6 @@ is_valid_constexpr_fn (tree fun, bool complain) ...@@ -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) if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fun)
&& !CLASSTYPE_LITERAL_P (DECL_CONTEXT (fun))) && !CLASSTYPE_LITERAL_P (DECL_CONTEXT (fun)))
{ {
...@@ -5502,29 +5501,6 @@ is_valid_constexpr_fn (tree fun, bool complain) ...@@ -5502,29 +5501,6 @@ is_valid_constexpr_fn (tree fun, bool complain)
return ret; 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. /* Subroutine of build_constexpr_constructor_member_initializers.
The expression tree T represents a data member initialization The expression tree T represents a data member initialization
in a (constexpr) constructor definition. Build a pairing of in a (constexpr) constructor definition. Build a pairing of
...@@ -5799,17 +5775,27 @@ cx_check_missing_mem_inits (tree fun, tree body, bool complain) ...@@ -5799,17 +5775,27 @@ cx_check_missing_mem_inits (tree fun, tree body, bool complain)
else else
{ {
index = CONSTRUCTOR_ELT (body, i)->index; index = CONSTRUCTOR_ELT (body, i)->index;
/* Skip base vtable inits. */ /* Skip base and vtable inits. */
if (TREE_CODE (index) == COMPONENT_REF) if (TREE_CODE (index) != FIELD_DECL)
continue; continue;
} }
for (; field != index; field = DECL_CHAIN (field)) for (; field != index; field = DECL_CHAIN (field))
{ {
tree ftype;
if (TREE_CODE (field) != FIELD_DECL if (TREE_CODE (field) != FIELD_DECL
|| (DECL_C_BIT_FIELD (field) && !DECL_NAME (field))) || (DECL_C_BIT_FIELD (field) && !DECL_NAME (field)))
continue; continue;
if (!complain) if (!complain)
return true; 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", error ("uninitialized member %qD in %<constexpr%> constructor",
field); field);
bad = true; bad = true;
...@@ -5834,6 +5820,9 @@ register_constexpr_fundef (tree fun, tree body) ...@@ -5834,6 +5820,9 @@ register_constexpr_fundef (tree fun, tree body)
constexpr_fundef entry; constexpr_fundef entry;
constexpr_fundef **slot; constexpr_fundef **slot;
if (!is_valid_constexpr_fn (fun, !DECL_TEMPLATE_INFO (fun)))
return NULL;
body = massage_constexpr_body (fun, body); body = massage_constexpr_body (fun, body);
if (body == NULL_TREE || body == error_mark_node) if (body == NULL_TREE || body == error_mark_node)
{ {
......
...@@ -17,4 +17,4 @@ constexpr int b = A<B>().f(); // { dg-error "non-constexpr function" } ...@@ -17,4 +17,4 @@ constexpr int b = A<B>().f(); // { dg-error "non-constexpr function" }
template <class T> template <class T>
constexpr int f (T t) { return 42; } // { dg-error "parameter" } 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" }
...@@ -19,5 +19,5 @@ struct C ...@@ -19,5 +19,5 @@ struct C
constexpr int i = f(C<int>()); constexpr int i = f(C<int>());
constexpr int j = C<int>().m(C<int>()); constexpr int j = C<int>().m(C<int>());
constexpr int k = C<double>().m(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 "non-constexpr function" } constexpr int l = g(C<double>(),A()); // { dg-error "constexpr" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment