Commit 66e61a34 by Jason Merrill

cp-tree.h (register_constexpr_fundef): Declare.

	* cp-tree.h (register_constexpr_fundef): Declare.
	* decl.c (maybe_save_function_definition): New.
	(finish_function): Use it.
	* semantics.c (constexpr_fundef): New datatype.
	(constexpr_fundef_table): New global table.
	(constexpr_fundef_equal): New.
	(constexpr_fundef_hash): Likewise.
	(retrieve_constexpr_fundef): Likewise.
	(validate_constexpr_fundecl): Store in the table.
	(build_data_member_initialization): New fn.
	(build_constexpr_constructor_member_initializers): New.
	(register_constexpr_fundef): Define.
	(is_this_parameter): New.
	(get_function_named_in_call): Likewise.
	(get_nth_callarg): Likewise.
	(check_automatic_or_tls): New.
	(morally_constexpr_builtin_function_p): New.
	(potential_constant_expression): New.

From-SVN: r166165
parent aef4a215
2010-11-01 Gabriel Dos Reis <gdr@cse.tamu.edu>
Jason Merrill <jason@redhat.com>
* cp-tree.h (register_constexpr_fundef): Declare.
* decl.c (maybe_save_function_definition): New.
(finish_function): Use it.
* semantics.c (constexpr_fundef): New datatype.
(constexpr_fundef_table): New global table.
(constexpr_fundef_equal): New.
(constexpr_fundef_hash): Likewise.
(retrieve_constexpr_fundef): Likewise.
(validate_constexpr_fundecl): Store in the table.
(build_data_member_initialization): New fn.
(build_constexpr_constructor_member_initializers): New.
(register_constexpr_fundef): Define.
(is_this_parameter): New.
(get_function_named_in_call): Likewise.
(get_nth_callarg): Likewise.
(check_automatic_or_tls): New.
(morally_constexpr_builtin_function_p): New.
(potential_constant_expression): New.
2010-11-01 Jason Merrill <jason@redhat.com> 2010-11-01 Jason Merrill <jason@redhat.com>
* decl2.c (decl_constant_var_p): New fn. * decl2.c (decl_constant_var_p): New fn.
......
...@@ -5252,6 +5252,7 @@ extern void finish_handler (tree); ...@@ -5252,6 +5252,7 @@ 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 validate_constexpr_fundecl (tree);
extern tree register_constexpr_fundef (tree, tree);
extern tree ensure_literal_type_for_constexpr_object (tree); extern tree ensure_literal_type_for_constexpr_object (tree);
enum { enum {
......
...@@ -12667,6 +12667,19 @@ record_key_method_defined (tree fndecl) ...@@ -12667,6 +12667,19 @@ record_key_method_defined (tree fndecl)
} }
} }
/* Subroutine of finish_function.
Save the body of constexpr functions for possible
future compile time evaluation. */
static void
maybe_save_function_definition (tree fun)
{
if (!processing_template_decl
&& DECL_DECLARED_CONSTEXPR_P (fun)
&& !DECL_CLONED_FUNCTION_P (fun))
register_constexpr_fundef (fun, DECL_SAVED_TREE (fun));
}
/* Finish up a function declaration and compile that function /* Finish up a function declaration and compile that function
all the way to assembler language output. The free the storage all the way to assembler language output. The free the storage
for the function definition. for the function definition.
...@@ -12778,6 +12791,10 @@ finish_function (int flags) ...@@ -12778,6 +12791,10 @@ finish_function (int flags)
of curly braces for a function. */ of curly braces for a function. */
gcc_assert (stmts_are_full_exprs_p ()); gcc_assert (stmts_are_full_exprs_p ());
/* Save constexpr function body before it gets munged by
the NRV transformation. */
maybe_save_function_definition (fndecl);
/* Set up the named return value optimization, if we can. Candidate /* Set up the named return value optimization, if we can. Candidate
variables are selected in check_return_expr. */ variables are selected in check_return_expr. */
if (current_function_return_value) if (current_function_return_value)
......
2010-11-01 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/constexpr-ctor2.C: New.
2010-11-01 Nicola Pero <nicola.pero@meta-innovation.com> 2010-11-01 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented format and noreturn attributes for Objective-C methods. Implemented format and noreturn attributes for Objective-C methods.
......
// { dg-options -std=c++0x }
struct A
{
A();
};
struct B : A
{
constexpr B(): A() { } // { dg-error "A::A" }
};
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