public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-contracts] c++: move more contracts code to contracts.cc
@ 2021-07-06 20:43 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-07-06 20:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d1ee78da0042e558e3de22b2fe535410b871ac00

commit d1ee78da0042e558e3de22b2fe535410b871ac00
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 30 17:31:21 2021 -0400

    c++: move more contracts code to contracts.cc
    
    gcc/cp/ChangeLog:
    
            * cp-tree.h (rebuild_postconditions): Adjust prototype.
            (build_arg_list): Remove prototype.
            (maybe_update_postconditions, start_function_contracts)
            (finish_function_contracts)
            (apply_postcondition_to_return): Declare.
            * contracts.cc: Move lots from other files.
            (rebuild_postconditions): Remove type parm.
            (start_function_contracts): Factor from start_preparsed_function.
            (maybe_update_postconditions): Factor from
            apply_deduced_return_type.
            * decl.c: Move lots to contracts.cc.
            * pt.c (tsubst_copy_and_build): Remove FLOAT_EXPR handling.
            * semantics.c: Move lots to contracts.cc.
            * typeck.c (apply_postcondition_to_return): Move to contracts.cc.
            * config-lang.in: Add contracts.cc to gtfiles.
    
    gcc/testsuite/ChangeLog:
    
            * contracts/backtrace_handler/assert_fail.cpp: Moved to...
            * g++.dg/contracts/backtrace_handler/assert_fail.cpp: ...here.
            * contracts/backtrace_handler/handle_contract_violation.cpp: Moved to...
            * g++.dg/contracts/backtrace_handler/handle_contract_violation.cpp: ...here.
            * g++.dg/cpp2a/contracts-access1.C: Moved to...
            * g++.dg/contracts/contracts-access1.C: ...here.
            * g++.dg/cpp2a/contracts-assume1.C: Moved to...
            * g++.dg/contracts/contracts-assume1.C: ...here.
            * g++.dg/cpp2a/contracts-assume2.C: Moved to...
            * g++.dg/contracts/contracts-assume2.C: ...here.
            * g++.dg/cpp2a/contracts-assume3.C: Moved to...
            * g++.dg/contracts/contracts-assume3.C: ...here.
            * g++.dg/cpp2a/contracts-assume4.C: Moved to...
            * g++.dg/contracts/contracts-assume4.C: ...here.
            * g++.dg/cpp2a/contracts-assume5.C: Moved to...
            * g++.dg/contracts/contracts-assume5.C: ...here.
            * g++.dg/cpp2a/contracts-assume6.C: Moved to...
            * g++.dg/contracts/contracts-assume6.C: ...here.
            * g++.dg/cpp2a/contracts-config1.C: Moved to...
            * g++.dg/contracts/contracts-config1.C: ...here.
            * g++.dg/cpp2a/contracts-constexpr1.C: Moved to...
            * g++.dg/contracts/contracts-constexpr1.C: ...here.
            * g++.dg/cpp2a/contracts-constexpr2.C: Moved to...
            * g++.dg/contracts/contracts-constexpr2.C: ...here.
            * g++.dg/cpp2a/contracts-conversion1.C: Moved to...
            * g++.dg/contracts/contracts-conversion1.C: ...here.
            * g++.dg/cpp2a/contracts-ctor-dtor1.C: Moved to...
            * g++.dg/contracts/contracts-ctor-dtor1.C: ...here.
            * g++.dg/cpp2a/contracts-ctor-dtor2.C: Moved to...
            * g++.dg/contracts/contracts-ctor-dtor2.C: ...here.
            * g++.dg/cpp2a/contracts-cv1.C: Moved to...
            * g++.dg/contracts/contracts-cv1.C: ...here.
            * g++.dg/cpp2a/contracts-deduced1.C: Moved to...
            * g++.dg/contracts/contracts-deduced1.C: ...here.
            * g++.dg/cpp2a/contracts-deduced2.C: Moved to...
            * g++.dg/contracts/contracts-deduced2.C: ...here.
            * g++.dg/cpp2a/contracts-friend1.C: Moved to...
            * g++.dg/contracts/contracts-friend1.C: ...here.
            * g++.dg/cpp2a/contracts-ft1.C: Moved to...
            * g++.dg/contracts/contracts-ft1.C: ...here.
            * g++.dg/cpp2a/contracts-ignore1.C: Moved to...
            * g++.dg/contracts/contracts-ignore1.C: ...here.
            * g++.dg/cpp2a/contracts-ignore2.C: Moved to...
            * g++.dg/contracts/contracts-ignore2.C: ...here.
            * g++.dg/cpp2a/contracts-large-return.C: Moved to...
            * g++.dg/contracts/contracts-large-return.C: ...here.
            * g++.dg/cpp2a/contracts-multiline1.C: Moved to...
            * g++.dg/contracts/contracts-multiline1.C: ...here.
            * g++.dg/cpp2a/contracts-multiple-inheritance1.C: Moved to...
            * g++.dg/contracts/contracts-multiple-inheritance1.C: ...here.
            * g++.dg/cpp2a/contracts-multiple-inheritance2.C: Moved to...
            * g++.dg/contracts/contracts-multiple-inheritance2.C: ...here.
            * g++.dg/cpp2a/contracts-nested-class1.C: Moved to...
            * g++.dg/contracts/contracts-nested-class1.C: ...here.
            * g++.dg/cpp2a/contracts-nested-class2.C: Moved to...
            * g++.dg/contracts/contracts-nested-class2.C: ...here.
            * g++.dg/cpp2a/contracts-override.C: Moved to...
            * g++.dg/contracts/contracts-override.C: ...here.
            * g++.dg/cpp2a/contracts-post1.C: Moved to...
            * g++.dg/contracts/contracts-post1.C: ...here.
            * g++.dg/cpp2a/contracts-post2.C: Moved to...
            * g++.dg/contracts/contracts-post2.C: ...here.
            * g++.dg/cpp2a/contracts-post3.C: Moved to...
            * g++.dg/contracts/contracts-post3.C: ...here.
            * g++.dg/cpp2a/contracts-post4.C: Moved to...
            * g++.dg/contracts/contracts-post4.C: ...here.
            * g++.dg/cpp2a/contracts-post5.C: Moved to...
            * g++.dg/contracts/contracts-post5.C: ...here.
            * g++.dg/cpp2a/contracts-post6.C: Moved to...
            * g++.dg/contracts/contracts-post6.C: ...here.
            * g++.dg/cpp2a/contracts-pre1.C: Moved to...
            * g++.dg/contracts/contracts-pre1.C: ...here.
            * g++.dg/cpp2a/contracts-pre10.C: Moved to...
            * g++.dg/contracts/contracts-pre10.C: ...here.
            * g++.dg/cpp2a/contracts-pre2.C: Moved to...
            * g++.dg/contracts/contracts-pre2.C: ...here.
            * g++.dg/cpp2a/contracts-pre2a1.C: Moved to...
            * g++.dg/contracts/contracts-pre2a1.C: ...here.
            * g++.dg/cpp2a/contracts-pre2a2.C: Moved to...
            * g++.dg/contracts/contracts-pre2a2.C: ...here.
            * g++.dg/cpp2a/contracts-pre3.C: Moved to...
            * g++.dg/contracts/contracts-pre3.C: ...here.
            * g++.dg/cpp2a/contracts-pre4.C: Moved to...
            * g++.dg/contracts/contracts-pre4.C: ...here.
            * g++.dg/cpp2a/contracts-pre5.C: Moved to...
            * g++.dg/contracts/contracts-pre5.C: ...here.
            * g++.dg/cpp2a/contracts-pre6.C: Moved to...
            * g++.dg/contracts/contracts-pre6.C: ...here.
            * g++.dg/cpp2a/contracts-pre7.C: Moved to...
            * g++.dg/contracts/contracts-pre7.C: ...here.
            * g++.dg/cpp2a/contracts-pre9.C: Moved to...
            * g++.dg/contracts/contracts-pre9.C: ...here.
            * g++.dg/cpp2a/contracts-redecl1.C: Moved to...
            * g++.dg/contracts/contracts-redecl1.C: ...here.
            * g++.dg/cpp2a/contracts-redecl2.C: Moved to...
            * g++.dg/contracts/contracts-redecl2.C: ...here.
            * g++.dg/cpp2a/contracts-redecl3.C: Moved to...
            * g++.dg/contracts/contracts-redecl3.C: ...here.
            * g++.dg/cpp2a/contracts-redecl4.C: Moved to...
            * g++.dg/contracts/contracts-redecl4.C: ...here.
            * g++.dg/cpp2a/contracts-redecl5.C: Moved to...
            * g++.dg/contracts/contracts-redecl5.C: ...here.
            * g++.dg/cpp2a/contracts-redecl6.C: Moved to...
            * g++.dg/contracts/contracts-redecl6.C: ...here.
            * g++.dg/cpp2a/contracts-redecl7.C: Moved to...
            * g++.dg/contracts/contracts-redecl7.C: ...here.
            * g++.dg/cpp2a/contracts-redecl8.C: Moved to...
            * g++.dg/contracts/contracts-redecl8.C: ...here.
            * g++.dg/cpp2a/contracts-tmpl-attr1.C: Moved to...
            * g++.dg/contracts/contracts-tmpl-attr1.C: ...here.
            * g++.dg/cpp2a/contracts-tmpl-spec1.C: Moved to...
            * g++.dg/contracts/contracts-tmpl-spec1.C: ...here.
            * g++.dg/cpp2a/contracts-tmpl-spec2.C: Moved to...
            * g++.dg/contracts/contracts-tmpl-spec2.C: ...here.
            * g++.dg/cpp2a/contracts-tmpl-spec3.C: Moved to...
            * g++.dg/contracts/contracts-tmpl-spec3.C: ...here.
            * g++.dg/cpp2a/contracts1.C: Moved to...
            * g++.dg/contracts/contracts1.C: ...here.
            * g++.dg/cpp2a/contracts10.C: Moved to...
            * g++.dg/contracts/contracts10.C: ...here.
            * g++.dg/cpp2a/contracts11.C: Moved to...
            * g++.dg/contracts/contracts11.C: ...here.
            * g++.dg/cpp2a/contracts12.C: Moved to...
            * g++.dg/contracts/contracts12.C: ...here.
            * g++.dg/cpp2a/contracts13.C: Moved to...
            * g++.dg/contracts/contracts13.C: ...here.
            * g++.dg/cpp2a/contracts14.C: Moved to...
            * g++.dg/contracts/contracts14.C: ...here.
            * g++.dg/cpp2a/contracts15.C: Moved to...
            * g++.dg/contracts/contracts15.C: ...here.
            * g++.dg/cpp2a/contracts16.C: Moved to...
            * g++.dg/contracts/contracts16.C: ...here.
            * g++.dg/cpp2a/contracts17.C: Moved to...
            * g++.dg/contracts/contracts17.C: ...here.
            * g++.dg/cpp2a/contracts18.C: Moved to...
            * g++.dg/contracts/contracts18.C: ...here.
            * g++.dg/cpp2a/contracts19.C: Moved to...
            * g++.dg/contracts/contracts19.C: ...here.
            * g++.dg/cpp2a/contracts2.C: Moved to...
            * g++.dg/contracts/contracts2.C: ...here.
            * g++.dg/cpp2a/contracts20.C: Moved to...
            * g++.dg/contracts/contracts20.C: ...here.
            * g++.dg/cpp2a/contracts22.C: Moved to...
            * g++.dg/contracts/contracts22.C: ...here.
            * g++.dg/cpp2a/contracts24.C: Moved to...
            * g++.dg/contracts/contracts24.C: ...here.
            * g++.dg/cpp2a/contracts25.C: Moved to...
            * g++.dg/contracts/contracts25.C: ...here.
            * g++.dg/cpp2a/contracts3.C: Moved to...
            * g++.dg/contracts/contracts3.C: ...here.
            * g++.dg/cpp2a/contracts35.C: Moved to...
            * g++.dg/contracts/contracts35.C: ...here.
            * g++.dg/cpp2a/contracts4.C: Moved to...
            * g++.dg/contracts/contracts4.C: ...here.
            * g++.dg/cpp2a/contracts5.C: Moved to...
            * g++.dg/contracts/contracts5.C: ...here.
            * g++.dg/cpp2a/contracts6.C: Moved to...
            * g++.dg/contracts/contracts6.C: ...here.
            * g++.dg/cpp2a/contracts7.C: Moved to...
            * g++.dg/contracts/contracts7.C: ...here.
            * g++.dg/cpp2a/contracts8.C: Moved to...
            * g++.dg/contracts/contracts8.C: ...here.
            * g++.dg/cpp2a/contracts9.C: Moved to...
            * g++.dg/contracts/contracts9.C: ...here.
            * contracts/except_preload_handler/assert_fail.cpp: Moved to...
            * g++.dg/contracts/except_preload_handler/assert_fail.cpp: ...here.
            * contracts/except_preload_handler/handle_contract_violation.cpp: Moved to...
            * g++.dg/contracts/except_preload_handler/handle_contract_violation.cpp: ...here.
            * contracts/noexcept_preload_handler/assert_fail.cpp: Moved to...
            * g++.dg/contracts/noexcept_preload_handler/assert_fail.cpp: ...here.
            * contracts/noexcept_preload_handler/handle_contract_violation.cpp: Moved to...
            * g++.dg/contracts/noexcept_preload_handler/handle_contract_violation.cpp: ...here.
            * contracts/preload_handler/assert_fail.cpp: Moved to...
            * g++.dg/contracts/preload_handler/assert_fail.cpp: ...here.
            * contracts/preload_handler/handle_contract_violation.cpp: Moved to...
            * g++.dg/contracts/preload_handler/handle_contract_violation.cpp: ...here.
            * contracts/preload_nocontinue_handler/assert_fail.cpp: Moved to...
            * g++.dg/contracts/preload_nocontinue_handler/assert_fail.cpp: ...here.
            * contracts/preload_nocontinue_handler/handle_contract_violation.cpp: Moved to...
            * g++.dg/contracts/preload_nocontinue_handler/handle_contract_violation.cpp: ...here.
            * contracts/preload_nocontinue_handler/nocontinue.cpp: Moved to...
            * g++.dg/contracts/preload_nocontinue_handler/nocontinue.cpp: ...here.
            * contracts/backtrace_handler/Makefile: Moved to...
            * g++.dg/contracts/backtrace_handler/Makefile: ...here.
            * contracts/backtrace_handler/README: Moved to...
            * g++.dg/contracts/backtrace_handler/README: ...here.
            * contracts/backtrace_handler/example_out.txt: Moved to...
            * g++.dg/contracts/backtrace_handler/example_out.txt: ...here.
            * contracts/backtrace_handler/example_pretty.txt: Moved to...
            * g++.dg/contracts/backtrace_handler/example_pretty.txt: ...here.
            * contracts/backtrace_handler/prettytrace.sh: Moved to...
            * g++.dg/contracts/backtrace_handler/prettytrace.sh: ...here.
            * contracts/except_preload_handler/Makefile: Moved to...
            * g++.dg/contracts/except_preload_handler/Makefile: ...here.
            * contracts/except_preload_handler/README: Moved to...
            * g++.dg/contracts/except_preload_handler/README: ...here.
            * contracts/noexcept_preload_handler/Makefile: Moved to...
            * g++.dg/contracts/noexcept_preload_handler/Makefile: ...here.
            * contracts/noexcept_preload_handler/README: Moved to...
            * g++.dg/contracts/noexcept_preload_handler/README: ...here.
            * contracts/preload_handler/Makefile: Moved to...
            * g++.dg/contracts/preload_handler/Makefile: ...here.
            * contracts/preload_handler/README: Moved to...
            * g++.dg/contracts/preload_handler/README: ...here.
            * contracts/preload_nocontinue_handler/Makefile: Moved to...
            * g++.dg/contracts/preload_nocontinue_handler/Makefile: ...here.
            * contracts/preload_nocontinue_handler/README: Moved to...
            * g++.dg/contracts/preload_nocontinue_handler/README: ...here.

Diff:
---
 gcc/cp/cp-tree.h                                   |   7 +-
 gcc/cp/contracts.cc                                | 708 ++++++++++++++++++++-
 gcc/cp/decl.c                                      | 126 +---
 gcc/cp/pt.c                                        |   8 -
 gcc/cp/semantics.c                                 | 537 +---------------
 gcc/cp/typeck.c                                    |  33 -
 .../contracts/backtrace_handler/assert_fail.cpp    |   0
 .../handle_contract_violation.cpp                  |   0
 .../{cpp2a => contracts}/contracts-access1.C       |   0
 .../{cpp2a => contracts}/contracts-assume1.C       |   0
 .../{cpp2a => contracts}/contracts-assume2.C       |   0
 .../{cpp2a => contracts}/contracts-assume3.C       |   0
 .../{cpp2a => contracts}/contracts-assume4.C       |   0
 .../{cpp2a => contracts}/contracts-assume5.C       |   0
 .../{cpp2a => contracts}/contracts-assume6.C       |   0
 .../{cpp2a => contracts}/contracts-config1.C       |   0
 .../{cpp2a => contracts}/contracts-constexpr1.C    |   0
 .../{cpp2a => contracts}/contracts-constexpr2.C    |   0
 .../{cpp2a => contracts}/contracts-conversion1.C   |   0
 .../{cpp2a => contracts}/contracts-ctor-dtor1.C    |   0
 .../{cpp2a => contracts}/contracts-ctor-dtor2.C    |   0
 .../g++.dg/{cpp2a => contracts}/contracts-cv1.C    |   0
 .../{cpp2a => contracts}/contracts-deduced1.C      |   0
 .../{cpp2a => contracts}/contracts-deduced2.C      |   0
 .../{cpp2a => contracts}/contracts-friend1.C       |   0
 .../g++.dg/{cpp2a => contracts}/contracts-ft1.C    |   0
 .../{cpp2a => contracts}/contracts-ignore1.C       |   0
 .../{cpp2a => contracts}/contracts-ignore2.C       |   0
 .../{cpp2a => contracts}/contracts-large-return.C  |   0
 .../{cpp2a => contracts}/contracts-multiline1.C    |   0
 .../contracts-multiple-inheritance1.C              |   0
 .../contracts-multiple-inheritance2.C              |   0
 .../{cpp2a => contracts}/contracts-nested-class1.C |   0
 .../{cpp2a => contracts}/contracts-nested-class2.C |   0
 .../{cpp2a => contracts}/contracts-override.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts-post1.C  |   0
 .../g++.dg/{cpp2a => contracts}/contracts-post2.C  |   0
 .../g++.dg/{cpp2a => contracts}/contracts-post3.C  |   0
 .../g++.dg/{cpp2a => contracts}/contracts-post4.C  |   0
 .../g++.dg/{cpp2a => contracts}/contracts-post5.C  |   0
 .../g++.dg/{cpp2a => contracts}/contracts-post6.C  |   0
 .../g++.dg/{cpp2a => contracts}/contracts-pre1.C   |   0
 .../g++.dg/{cpp2a => contracts}/contracts-pre10.C  |   0
 .../g++.dg/{cpp2a => contracts}/contracts-pre2.C   |   0
 .../g++.dg/{cpp2a => contracts}/contracts-pre2a1.C |   0
 .../g++.dg/{cpp2a => contracts}/contracts-pre2a2.C |   0
 .../g++.dg/{cpp2a => contracts}/contracts-pre3.C   |   0
 .../g++.dg/{cpp2a => contracts}/contracts-pre4.C   |   0
 .../g++.dg/{cpp2a => contracts}/contracts-pre5.C   |   0
 .../g++.dg/{cpp2a => contracts}/contracts-pre6.C   |   0
 .../g++.dg/{cpp2a => contracts}/contracts-pre7.C   |   0
 .../g++.dg/{cpp2a => contracts}/contracts-pre9.C   |   0
 .../{cpp2a => contracts}/contracts-redecl1.C       |   0
 .../{cpp2a => contracts}/contracts-redecl2.C       |   0
 .../{cpp2a => contracts}/contracts-redecl3.C       |   0
 .../{cpp2a => contracts}/contracts-redecl4.C       |   0
 .../{cpp2a => contracts}/contracts-redecl5.C       |   0
 .../{cpp2a => contracts}/contracts-redecl6.C       |   0
 .../{cpp2a => contracts}/contracts-redecl7.C       |   0
 .../{cpp2a => contracts}/contracts-redecl8.C       |   0
 .../{cpp2a => contracts}/contracts-tmpl-attr1.C    |   0
 .../{cpp2a => contracts}/contracts-tmpl-spec1.C    |   0
 .../{cpp2a => contracts}/contracts-tmpl-spec2.C    |   0
 .../{cpp2a => contracts}/contracts-tmpl-spec3.C    |   0
 .../g++.dg/{cpp2a => contracts}/contracts1.C       |   0
 .../g++.dg/{cpp2a => contracts}/contracts10.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts11.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts12.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts13.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts14.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts15.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts16.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts17.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts18.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts19.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts2.C       |   0
 .../g++.dg/{cpp2a => contracts}/contracts20.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts22.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts24.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts25.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts3.C       |   0
 .../g++.dg/{cpp2a => contracts}/contracts35.C      |   0
 .../g++.dg/{cpp2a => contracts}/contracts4.C       |   0
 .../g++.dg/{cpp2a => contracts}/contracts5.C       |   0
 .../g++.dg/{cpp2a => contracts}/contracts6.C       |   0
 .../g++.dg/{cpp2a => contracts}/contracts7.C       |   0
 .../g++.dg/{cpp2a => contracts}/contracts8.C       |   0
 .../g++.dg/{cpp2a => contracts}/contracts9.C       |   0
 .../except_preload_handler/assert_fail.cpp         |   0
 .../handle_contract_violation.cpp                  |   0
 .../noexcept_preload_handler/assert_fail.cpp       |   0
 .../handle_contract_violation.cpp                  |   0
 .../contracts/preload_handler/assert_fail.cpp      |   0
 .../preload_handler/handle_contract_violation.cpp  |   0
 .../preload_nocontinue_handler/assert_fail.cpp     |   0
 .../handle_contract_violation.cpp                  |   0
 .../preload_nocontinue_handler/nocontinue.cpp      |   0
 gcc/cp/config-lang.in                              |   1 +
 .../contracts/backtrace_handler/Makefile           |   0
 .../contracts/backtrace_handler/README             |   0
 .../contracts/backtrace_handler/example_out.txt    |   0
 .../contracts/backtrace_handler/example_pretty.txt |   0
 .../contracts/backtrace_handler/prettytrace.sh     |   0
 .../contracts/except_preload_handler/Makefile      |   0
 .../contracts/except_preload_handler/README        |   0
 .../contracts/noexcept_preload_handler/Makefile    |   0
 .../contracts/noexcept_preload_handler/README      |   0
 .../contracts/preload_handler/Makefile             |   0
 .../{ => g++.dg}/contracts/preload_handler/README  |   0
 .../contracts/preload_nocontinue_handler/Makefile  |   0
 .../contracts/preload_nocontinue_handler/README    |   0
 111 files changed, 717 insertions(+), 703 deletions(-)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 4a1ac2769c7..81009f65cc1 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -7561,7 +7561,7 @@ extern tree invalidate_contract			(tree);
 extern tree make_postcondition_variable		(cp_expr);
 extern tree make_postcondition_variable		(cp_expr, tree);
 extern bool check_postcondition_result		(tree, tree, location_t);
-extern void rebuild_postconditions		(tree, tree);
+extern void rebuild_postconditions		(tree);
 extern tree grok_contract			(tree, tree, tree, cp_expr, location_t);
 extern tree finish_contract_attribute		(tree, tree);
 extern void update_late_contract		(tree, tree, tree);
@@ -7585,7 +7585,6 @@ extern void set_contracts_original_fn		(tree, tree);
 extern tree start_postcondition_statement	();
 extern void finish_postcondition_statement	(tree);
 extern tree build_contract_check		(tree);
-extern vec<tree, va_gc> *build_arg_list		(tree);
 extern tree get_postcondition_result_parameter	(tree);
 extern tree get_precondition_function		(tree);
 extern tree get_postcondition_function		(tree);
@@ -7594,6 +7593,10 @@ extern tree get_contracts_original_fn		(tree);
 extern void emit_assertion			(tree);
 extern void emit_preconditions			(tree);
 extern void emit_postconditions			(tree);
+extern void maybe_update_postconditions		(tree);
+extern void start_function_contracts		(tree);
+extern void finish_function_contracts		(tree);
+extern tree apply_postcondition_to_return	(tree, tree);
 
 inline void
 set_decl_contracts (tree decl, tree contract_attrs)
diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index 2d005d5ab9b..0e64dc08e99 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -639,8 +639,9 @@ check_postcondition_result (tree decl, tree type, location_t loc)
    attribute.  */
 
 void
-rebuild_postconditions (tree decl, tree type)
+rebuild_postconditions (tree decl)
 {
+  tree type = TREE_TYPE (TREE_TYPE (decl));
   tree attributes = DECL_CONTRACTS (decl);
 
   for (; attributes ; attributes = TREE_CHAIN (attributes))
@@ -1261,3 +1262,708 @@ match_deferred_contracts (tree decl)
   /* Clear out deferred match list so we don't check it twice.  */
   pending_guarded_decls.remove (decl);
 }
+
+/* Map from FUNCTION_DECL to a FUNCTION_DECL for either the PRE_FN or POST_FN.
+   These are used to parse contract conditions and are called inside the body
+   of the guarded function.  */
+static GTY(()) hash_map<tree, tree> *decl_pre_fn;
+static GTY(()) hash_map<tree, tree> *decl_post_fn;
+static GTY(()) hash_map<tree, tree> *decl_original_fn;
+
+/* Returns the precondition funtion for D, or null if not set.  */
+
+tree
+get_precondition_function (tree d)
+{
+  hash_map_maybe_create<hm_ggc> (decl_pre_fn);
+  tree *result = decl_pre_fn->get (d);
+  return result ? *result : NULL_TREE;
+}
+
+/* Returns the postcondition funtion for D, or null if not set.  */
+
+tree
+get_postcondition_function (tree d)
+{
+  hash_map_maybe_create<hm_ggc> (decl_post_fn);
+  tree *result = decl_post_fn->get (d);
+  return result ? *result : NULL_TREE;
+}
+
+/* Makes PRE the precondition function for D.  */
+
+void
+set_precondition_function (tree d, tree pre)
+{
+  gcc_assert (pre);
+  hash_map_maybe_create<hm_ggc> (decl_pre_fn);
+  gcc_assert (!decl_pre_fn->get (d));
+  decl_pre_fn->put (d, pre);
+}
+
+/* Makes POST the postcondition function for D.  */
+
+void
+set_postcondition_function (tree d, tree post)
+{
+  gcc_assert (post);
+  hash_map_maybe_create<hm_ggc> (decl_post_fn);
+  gcc_assert (!decl_post_fn->get (d));
+  decl_post_fn->put (d, post);
+}
+
+/* Set the PRE and POST functions for D.  Note that PRE and POST can be
+   null in this case. If so the functions are not recorded.  */
+
+void
+set_contract_functions (tree d, tree pre, tree post)
+{
+  if (pre)
+    set_precondition_function (d, pre);
+  if (post)
+    set_postcondition_function (d, post);
+}
+
+/* Returns the original guarded function of a precondition or postcondition
+   function D, or null if it does not exist.  */
+
+tree
+get_contracts_original_fn (tree d)
+{
+  hash_map_maybe_create<hm_ggc> (decl_original_fn);
+  tree *result = decl_original_fn->get (d);
+  return result ? *result : NULL_TREE;
+}
+
+
+/* Set the original fn for a contract function D.  */
+
+void
+set_contracts_original_fn (tree d, tree orig)
+{
+  gcc_assert (orig);
+  hash_map_maybe_create<hm_ggc> (decl_original_fn);
+
+  /* FIXME: Why are we resetting the contract function? This is called
+     from finish_function, but seems to just re-assert that the original
+     function is the same.  */
+  if (tree p = get_contracts_original_fn (d))
+    gcc_assert (p == orig);
+
+  decl_original_fn->put (d, orig);
+}
+
+/* Return a copy of the FUNCTION_DECL IDECL with its own unshared
+   PARM_DECL and DECL_ATTRIBUTEs.  */
+
+static tree
+copy_fn_decl (tree idecl)
+{
+  tree decl = copy_decl (idecl);
+  DECL_ATTRIBUTES (decl) = copy_list (DECL_ATTRIBUTES (idecl));
+
+  if (DECL_RESULT (idecl))
+    {
+      DECL_RESULT (decl) = copy_decl (DECL_RESULT (idecl));
+      DECL_CONTEXT (DECL_RESULT (decl)) = decl;
+    }
+  if (!DECL_ARGUMENTS (idecl) || VOID_TYPE_P (DECL_ARGUMENTS (idecl)))
+    return decl;
+
+  tree last = DECL_ARGUMENTS (decl) = copy_decl (DECL_ARGUMENTS (decl));
+  DECL_CONTEXT (last) = decl;
+  for (tree p = TREE_CHAIN (DECL_ARGUMENTS (idecl)); p; p = TREE_CHAIN (p))
+    {
+      if (VOID_TYPE_P (p))
+	{
+	  TREE_CHAIN (last) = void_list_node;
+	  break;
+	}
+      last = TREE_CHAIN (last) = copy_decl (p);
+      DECL_CONTEXT (last) = decl;
+    }
+  return decl;
+}
+
+/* Build a declaration for the pre- or postcondition of a guarded FNDECL.  */
+
+static tree
+build_contract_condition_function (tree fndecl, bool pre)
+{
+  if (TREE_TYPE (fndecl) == error_mark_node)
+    return error_mark_node;
+  if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fndecl)
+      && !TYPE_METHOD_BASETYPE (TREE_TYPE (fndecl)))
+    return error_mark_node;
+
+  /* Create and rename the unchecked function and give an internal name.  */
+  tree fn = copy_fn_decl (fndecl);
+  DECL_RESULT (fn) = NULL_TREE;
+  tree value_type = pre ? void_type_node : TREE_TYPE (TREE_TYPE (fn));
+
+  /* Don't propagate declaration attributes to the checking function,
+     including the original contracts.  */
+  DECL_ATTRIBUTES (fn) = NULL_TREE;
+
+  tree arg_types = NULL_TREE;
+  tree *last = &arg_types;
+
+  /* FIXME will later optimizations delete unused args to prevent extra arg
+   * passing? do we care? */
+  tree class_type = NULL_TREE;
+  for (tree arg_type = TYPE_ARG_TYPES (TREE_TYPE (fn));
+      arg_type && arg_type != void_list_node;
+      arg_type = TREE_CHAIN (arg_type))
+    {
+      if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fndecl)
+	  && TYPE_ARG_TYPES (TREE_TYPE (fn)) == arg_type)
+      {
+	class_type = TREE_TYPE (TREE_VALUE (arg_type));
+	continue;
+      }
+      *last = build_tree_list (TREE_PURPOSE (arg_type), TREE_VALUE (arg_type));
+      last = &TREE_CHAIN (*last);
+    }
+
+  if (pre || VOID_TYPE_P (value_type))
+    *last = void_list_node;
+  else
+    {
+      /* FIXME do we need magic to perfectly forward this so we don't clobber
+	 RVO/NRVO etc?  */
+      tree name = get_identifier ("__r");
+      tree parm = build_lang_decl (PARM_DECL, name, value_type);
+      DECL_CONTEXT (parm) = fn;
+      DECL_ARGUMENTS (fn) = chainon (DECL_ARGUMENTS (fn), parm);
+
+      *last = build_tree_list (NULL_TREE, value_type);
+      TREE_CHAIN (*last) = void_list_node;
+    }
+
+  TREE_TYPE (fn) = build_function_type (value_type, arg_types);
+  if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fndecl))
+    TREE_TYPE (fn) = build_method_type (class_type, TREE_TYPE (fn));
+
+  DECL_NAME (fn) = copy_node (DECL_NAME (fn));
+  DECL_INITIAL (fn) = error_mark_node;
+  set_contracts_original_fn (fn, fndecl);
+
+  IDENTIFIER_VIRTUAL_P (DECL_NAME (fn)) = false;
+  DECL_VIRTUAL_P (fn) = false;
+
+  /* Update various inline related declaration properties.  */
+  //DECL_DECLARED_INLINE_P (fn) = true;
+  DECL_DISREGARD_INLINE_LIMITS (fn) = true;
+  TREE_NO_WARNING (fn) = 1;
+
+  return fn;
+}
+
+static bool
+has_active_contract_condition (tree d, tree_code c)
+{
+  for (tree as = DECL_CONTRACTS (d) ; as != NULL_TREE; as = TREE_CHAIN (as))
+    {
+      tree contract = TREE_VALUE (TREE_VALUE (as));
+      if (TREE_CODE (contract) == c && contract_active_p (contract))
+	return true;
+    }
+  return false;
+}
+
+/* True if D has any checked or assumed preconditions.  */
+
+static bool
+has_active_preconditions (tree d)
+{
+  return has_active_contract_condition (d, PRECONDITION_STMT);
+}
+
+/* True if D has any checked or assumed postconditions.  */
+
+static bool
+has_active_postconditions (tree d)
+{
+  return has_active_contract_condition (d, POSTCONDITION_STMT);
+}
+
+/* Build the precondition checking function for D.  */
+
+static tree
+build_precondition_function (tree d)
+{
+  if (!has_active_preconditions (d))
+    return NULL_TREE;
+
+  return build_contract_condition_function (d, /*pre=*/true);
+}
+
+/* Build the postcondition checking function for D. If the return
+   type is undeduced, don't build the function yet. We do that in
+   apply_deduced_return_type.  */
+
+static tree
+build_postcondition_function (tree d)
+{
+  if (!has_active_postconditions (d))
+    return NULL_TREE;
+
+  tree type = TREE_TYPE (TREE_TYPE (d));
+  if (is_auto (type))
+    return NULL_TREE;
+
+  return build_contract_condition_function (d, /*pre=*/false);
+}
+
+void
+build_contract_function_decls (tree d)
+{
+  /* Constructors and destructors have their contracts inserted inline.  */
+  if (DECL_CONSTRUCTOR_P (d) || DECL_DESTRUCTOR_P (d))
+    return;
+
+  /* Build the pre/post functions (or not).  */
+  tree pre = build_precondition_function (d);
+  tree post = build_postcondition_function (d);
+  set_contract_functions (d, pre, post);
+}
+
+/* Begin a new scope for the postcondition.  */
+
+tree
+start_postcondition_statement ()
+{
+  tree list = push_stmt_list ();
+  tree stmt = begin_compound_stmt (BCS_NORMAL);
+  return build_tree_list (list, stmt);
+}
+
+/* Finish the block containing the postcondition check.  */
+
+void
+finish_postcondition_statement (tree stmt)
+{
+  finish_compound_stmt (TREE_VALUE (stmt));
+  pop_stmt_list (TREE_PURPOSE (stmt));
+}
+
+static const char *
+get_contract_level_name (tree contract)
+{
+  if (CONTRACT_LITERAL_MODE_P (contract))
+    return "";
+  if (tree mode = CONTRACT_MODE (contract))
+    if (tree level = TREE_VALUE (mode))
+      return IDENTIFIER_POINTER (level);
+  return "default";
+}
+
+static const char *
+get_contract_role_name (tree contract)
+{
+  if (CONTRACT_LITERAL_MODE_P (contract))
+    return "";
+  if (tree mode = CONTRACT_MODE (contract))
+    if (tree role = TREE_PURPOSE (mode))
+      return IDENTIFIER_POINTER (role);
+  return "default";
+}
+
+static void
+build_contract_handler_fn (tree contract,
+			   contract_continuation cmode)
+{
+  const char *level = get_contract_level_name (contract);
+  const char *role = get_contract_role_name (contract);
+  tree comment = CONTRACT_COMMENT (contract);
+
+  expanded_location loc = expand_location (EXPR_LOCATION (contract));
+
+  tree continue_mode = build_int_cst (boolean_type_node, cmode != NEVER_CONTINUE);
+  tree line_number = build_int_cst (integer_type_node, loc.line);
+  tree file_name = build_string_literal (strlen (loc.file) + 1, loc.file);
+  const char *function_name_str =
+    TREE_CODE (contract) == ASSERTION_STMT
+      || DECL_CONSTRUCTOR_P (current_function_decl)
+      || DECL_DESTRUCTOR_P (current_function_decl)
+    ? current_function_name ()
+    : fndecl_name (DECL_ORIGINAL_FN (current_function_decl));
+  tree function_name = build_string_literal (strlen (function_name_str) + 1,
+					     function_name_str);
+  tree level_str = build_string_literal (strlen (level) + 1, level);
+  tree role_str = build_string_literal (strlen (role) + 1, role);
+
+  /* FIXME: Do we want a string for this?.  */
+  tree continuation = build_int_cst (integer_type_node, cmode);
+
+  tree violation_fn;
+  if (cmode == MAYBE_CONTINUE)
+    violation_fn = on_contract_violation_fn;
+  else
+    violation_fn = on_contract_violation_never_fn;
+  tree call = build_call_expr (violation_fn, 8, continue_mode, line_number,
+			       file_name, function_name, comment,
+			       level_str, role_str,
+			       continuation);
+
+  finish_expr_stmt (call);
+}
+
+/* Return true if CONTRACT is checked or assumed under the current build
+   configuration. */
+
+bool
+contract_active_p (tree contract)
+{
+  return get_contract_semantic (contract) != CCS_IGNORE;
+}
+
+/* Return true if any contract in the CONTRACT list is checked or assumed
+   under the current build configuration. */
+
+bool
+contract_any_active_p (tree contract)
+{
+  for (; contract != NULL_TREE; contract = CONTRACT_CHAIN (contract))
+    if (contract_active_p (TREE_VALUE (TREE_VALUE (contract))))
+      return true;
+  return false;
+}
+
+/* Generate the code that checks or assumes a contract, but do not attach
+   it to the current context.  This is called during genericization.  */
+
+tree
+build_contract_check (tree contract)
+{
+  contract_semantic semantic = get_contract_semantic (contract);
+  if (semantic == CCS_INVALID)
+    return NULL_TREE;
+
+  /* Ignored contracts are never checked or assumed.  */
+  if (semantic == CCS_IGNORE)
+    return build1 (NOP_EXPR, void_type_node, integer_zero_node);
+
+  remap_dummy_this (current_function_decl, &CONTRACT_CONDITION (contract));
+  tree condition = CONTRACT_CONDITION (contract);
+  if (condition == error_mark_node)
+    return NULL_TREE;
+
+  /* If an assumed contract condition is not fully defined, the current method
+     of turning it into a compile time assumption fails and emits run time
+     code.  We don't want that, so just turn these into NOP.  */
+  if (semantic == CCS_ASSUME && !cp_tree_defined_p (condition))
+    return build1 (NOP_EXPR, void_type_node, integer_zero_node);
+
+  tree if_stmt = begin_if_stmt ();
+  tree cond = build_x_unary_op (EXPR_LOCATION (contract),
+				TRUTH_NOT_EXPR,
+				condition,
+				tf_warning_or_error);
+  finish_if_stmt_cond (cond, if_stmt);
+
+  if (semantic == CCS_ASSUME)
+    {
+      tree unreachable_fn = builtin_decl_implicit (BUILT_IN_UNREACHABLE);
+      tree call = build_call_expr (unreachable_fn, 0);
+      finish_expr_stmt (call);
+    }
+  else
+    {
+      /* Get the continuation mode.  */
+      contract_continuation cmode;
+      switch (semantic)
+	{
+	  case CCS_NEVER: cmode = NEVER_CONTINUE; break;
+	  case CCS_MAYBE: cmode = MAYBE_CONTINUE; break;
+	  default: gcc_unreachable ();
+	}
+
+      build_contract_handler_fn (contract, cmode);
+    }
+
+  finish_then_clause (if_stmt);
+  tree scope = IF_SCOPE (if_stmt);
+  IF_SCOPE (if_stmt) = NULL;
+  return do_poplevel (scope);
+}
+
+/* Generate the statement for the given contract attribute by adding the
+   statement to the current block. Returns the next contract in the chain.  */
+
+static tree
+emit_contract_statement (tree attr)
+{
+  gcc_assert (TREE_CODE (attr) == TREE_LIST);
+  tree contract = CONTRACT_STATEMENT (attr);
+
+  /* Only add valid contracts.  */
+  if (get_contract_semantic (contract) != CCS_INVALID
+      && CONTRACT_CONDITION (contract) != error_mark_node)
+    add_stmt (contract);
+
+  return CONTRACT_CHAIN (attr);
+}
+
+/* Add the statements of contract attributes ATTRS to the current block.  */
+
+static void
+emit_contract_conditions (tree attrs, tree_code code)
+{
+  if (!attrs) return;
+  gcc_assert (TREE_CODE (attrs) == TREE_LIST);
+  gcc_assert (code == PRECONDITION_STMT || code == POSTCONDITION_STMT);
+  while (attrs)
+    {
+      tree contract = CONTRACT_STATEMENT (attrs);
+      if (TREE_CODE (contract) == code)
+	attrs = emit_contract_statement (attrs);
+      else
+	attrs = CONTRACT_CHAIN (attrs);
+    }
+}
+
+/* Emit the statement for an assertion attribute.  */
+
+void
+emit_assertion (tree attr)
+{
+  emit_contract_statement (attr);
+}
+
+/* Emit statements for precondition attributes.  */
+
+void
+emit_preconditions (tree attr)
+{
+  return emit_contract_conditions (attr, PRECONDITION_STMT);
+}
+
+/* Emit statements for postcondition attributes.  */
+
+void
+emit_postconditions (tree contracts)
+{
+  return emit_contract_conditions (contracts, POSTCONDITION_STMT);
+}
+
+/* Converts a contract condition to bool and ensures it has a locaiton.  */
+
+tree
+finish_contract_condition (cp_expr condition)
+{
+  /* Ensure we have the condition location saved in case we later need to
+     emit a conversion error during template instantiation and wouldn't
+     otherwise have it.  */
+  if (!CAN_HAVE_LOCATION_P (condition) || EXCEPTIONAL_CLASS_P (condition))
+    {
+      condition = build1_loc (condition.get_location (), VIEW_CONVERT_EXPR,
+			      TREE_TYPE (condition), condition);
+      EXPR_LOCATION_WRAPPER_P (condition) = 1;
+    }
+
+  if (condition == error_mark_node || type_dependent_expression_p (condition))
+    return condition;
+
+  return condition_conversion (condition);
+}
+
+void
+maybe_update_postconditions (tree fco)
+{
+  /* Update any postconditions and the postcondition checking function
+     as needed.  If there are postconditions, we'll use those to rewrite
+     return statements to check postconditions.  */
+  if (has_active_postconditions (fco))
+    {
+      rebuild_postconditions (fco);
+      tree post = build_postcondition_function (fco);
+      set_postcondition_function (fco, post);
+    }
+}
+
+/* Called on attribute lists that must not contain contracts.  If any
+   contracts are present, issue an error diagnostic and return true.  */
+
+bool
+diagnose_misapplied_contracts (tree attributes)
+{
+  if (attributes == NULL_TREE)
+    return false;
+
+  tree contract_attr = find_contract (attributes);
+  if (!contract_attr)
+    return false;
+
+  error_at (EXPR_LOCATION (CONTRACT_STATEMENT (contract_attr)),
+	    "contracts must appertain to a function type");
+
+  /* Invalidate the contract so we don't treat it as valid later on.  */
+  invalidate_contract (TREE_VALUE (TREE_VALUE (contract_attr)));
+
+  return true;
+}
+
+/* Build and return an argument list using all the arguments passed to the
+   (presumably guarded) FUNCTION_DECL FN.  This can be used to forward all of
+   FN's arguments to a function taking the same list of arguments -- namely
+   the unchecked form of FN. */
+
+static vec<tree, va_gc> *
+build_arg_list (tree fn)
+{
+  gcc_assert (TREE_CODE (fn) == FUNCTION_DECL);
+
+  vec<tree, va_gc> *args = make_tree_vector ();
+  for (tree t = DECL_ARGUMENTS (fn); t != NULL_TREE; t = TREE_CHAIN (t))
+    {
+      if (is_this_parameter (t))
+	continue; // skip already inserted `this` args
+
+      vec_safe_push (args, forward_parm (t));
+    }
+  return args;
+}
+
+void
+start_function_contracts (tree decl1)
+{
+  bool starting_guarded_p = !processing_template_decl
+    && DECL_ORIGINAL_FN (decl1) == NULL_TREE
+    && contract_any_active_p (DECL_CONTRACTS (decl1))
+    && !DECL_CONSTRUCTOR_P (decl1)
+    && !DECL_DESTRUCTOR_P (decl1);
+
+  if (!starting_guarded_p)
+    return;
+
+  /* Contracts may have just been added without a chance to parse them, though
+     we still need the PRE_FN available to generate a call to it.  */
+  if (!DECL_PRE_FN (decl1))
+    build_contract_function_decls (decl1);
+
+  /* If we're starting a guarded function with valid contracts, we need to
+     insert a call to the pre function.  */
+  if (DECL_PRE_FN (decl1)
+      && DECL_PRE_FN (decl1) != error_mark_node)
+    {
+      vec<tree, va_gc> *args = build_arg_list (decl1);
+
+      push_deferring_access_checks (dk_no_check);
+      tree call = finish_call_expr (DECL_PRE_FN (decl1), &args,
+				    /*disallow_virtual=*/true,
+				    /*koenig_p=*/false,
+				    /*complain=*/tf_warning_or_error);
+      gcc_assert (call != error_mark_node);
+      pop_deferring_access_checks ();
+
+      /* Just add the call expression.  */
+      finish_expr_stmt (call);
+    }
+}
+
+/* Finish up the pre & post function definitions for a guarded FNDECL,
+   and compile those functions all the way to assembler language output.  */
+
+void
+finish_function_contracts (tree fndecl)
+{
+  bool finishing_guarded_p = !processing_template_decl
+    && DECL_ORIGINAL_FN (fndecl) == NULL_TREE
+    && contract_any_active_p (DECL_CONTRACTS (fndecl))
+    && !DECL_CONSTRUCTOR_P (fndecl)
+    && !DECL_DESTRUCTOR_P (fndecl);
+
+  if (!finishing_guarded_p)
+    return;
+
+  for (tree ca = DECL_CONTRACTS (fndecl); ca; ca = CONTRACT_CHAIN (ca))
+    {
+      tree contract = CONTRACT_STATEMENT (ca);
+      if (!CONTRACT_CONDITION (contract)
+	  || CONTRACT_CONDITION_DEFERRED_P (contract)
+	  || CONTRACT_CONDITION (contract) == error_mark_node)
+	return;
+    }
+
+  int flags = SF_DEFAULT | SF_PRE_PARSED;
+  tree finished_pre = NULL_TREE, finished_post = NULL_TREE;
+
+  /* If either the pre or post functions are bad, don't bother emitting
+     any contracts.  The program is already ill-formed.  */
+  tree pre = DECL_PRE_FN (fndecl);
+  tree post = DECL_POST_FN (fndecl);
+  if (pre == error_mark_node || post == error_mark_node)
+    return;
+
+  /* Create a copy of the contracts with references to fndecl's args replaced
+     with references to either the args of pre or post function.  */
+  tree contracts = copy_list (DECL_CONTRACTS (fndecl));
+  for (tree attr = contracts; attr; attr = CONTRACT_CHAIN (attr))
+    {
+      tree contract = copy_node (CONTRACT_STATEMENT (attr));
+      if (TREE_CODE (contract) == PRECONDITION_STMT)
+	remap_contract (fndecl, pre, contract, /*duplicate_p=*/false);
+      else if (TREE_CODE (contract) == POSTCONDITION_STMT)
+	remap_contract (fndecl, post, contract, /*duplicate_p=*/false);
+      TREE_VALUE (attr) = build_tree_list (NULL_TREE, contract);
+    }
+
+  if (pre && DECL_INITIAL (fndecl) != error_mark_node)
+    {
+      DECL_PENDING_INLINE_P (pre) = false;
+      start_preparsed_function (pre, DECL_ATTRIBUTES (pre), flags);
+      emit_preconditions (contracts);
+      finished_pre = finish_function (false);
+      expand_or_defer_fn (finished_pre);
+    }
+  if (post && DECL_INITIAL (fndecl) != error_mark_node)
+    {
+      DECL_PENDING_INLINE_P (post) = false;
+      start_preparsed_function (post,
+				DECL_ATTRIBUTES (post),
+				flags);
+      emit_postconditions (contracts);
+
+      tree res = get_postcondition_result_parameter (fndecl);
+      if (res)
+	finish_return_stmt (res);
+      finished_post = finish_function (false);
+      expand_or_defer_fn (finished_post);
+    }
+}
+
+/* Rewrite the expression of a returned expression so that it invokes the
+   postcondition function as needed.  */
+
+tree
+apply_postcondition_to_return (tree post, tree expr)
+{
+  if (!expr || expr == error_mark_node)
+    return expr;
+
+  vec<tree, va_gc> *args = build_arg_list (current_function_decl);
+
+  // FIXME: do we need forward_parm or similar?
+  if (get_postcondition_result_parameter (current_function_decl))
+    vec_safe_push (args, expr);
+
+  push_deferring_access_checks (dk_no_check);
+  tree call = finish_call_expr (post,
+				&args,
+				/*disallow_virtual=*/true,
+				/*koenig_p=*/false,
+				/*complain=*/tf_warning_or_error);
+  gcc_assert (call != error_mark_node);
+
+  /* We may not have actually built a CALL_EXPR; for instance if the
+     return type is large (contracts-large-return.C).  */
+  if (TREE_CODE (call) == CALL_EXPR)
+    CALL_FROM_THUNK_P (call) = 1;
+
+  pop_deferring_access_checks ();
+
+  return call;
+}
+
+#include "gt-cp-contracts.h"
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 1b17dfc2419..a622b13692c 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -103,7 +103,6 @@ static void store_parm_decls (tree);
 static void initialize_local_var (tree, tree);
 static void expand_static_init (tree, tree);
 static location_t smallest_type_location (const cp_decl_specifier_seq*);
-static void finish_function_contracts (tree fndecl);
 
 /* The following symbols are subsumed in the cp_global_trees array, and
    listed here individually for documentation purposes.
@@ -947,28 +946,6 @@ determine_local_discriminator (tree decl)
   timevar_cond_stop (TV_NAME_LOOKUP, subtime);
 }
 
-/* Called on attribute lists that must not contain contracts.  If any
-   contracts are present, issue an error diagnostic and return true.  */
-
-bool
-diagnose_misapplied_contracts (tree attributes)
-{
-  if (attributes == NULL_TREE)
-    return false;
-
-  tree contract_attr = find_contract (attributes);
-  if (!contract_attr)
-    return false;
-
-  error_at (EXPR_LOCATION (CONTRACT_STATEMENT (contract_attr)),
-	    "contracts must appertain to a function type");
-
-  /* Invalidate the contract so we don't treat it as valid later on.  */
-  invalidate_contract (TREE_VALUE (TREE_VALUE (contract_attr)));
-
-  return true;
-}
-
 \f
 
 /* Returns true if functions FN1 and FN2 have equivalent trailing
@@ -10408,7 +10385,7 @@ grokfndecl (tree ctype,
     }
 
   if (DECL_HAS_CONTRACTS_P (decl))
-    rebuild_postconditions (decl, TREE_TYPE (type));
+    rebuild_postconditions (decl);
 
   /* Check main's type after attributes have been applied.  */
   if (ctype == NULL_TREE && DECL_MAIN_P (decl))
@@ -17153,34 +17130,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
 
   push_operator_bindings ();
 
-  bool starting_guarded_p = !processing_template_decl
-      && DECL_ORIGINAL_FN (decl1) == NULL_TREE
-      && contract_any_active_p (DECL_CONTRACTS (decl1))
-      && !DECL_CONSTRUCTOR_P (decl1)
-      && !DECL_DESTRUCTOR_P (decl1);
-  /* Contracts may have just been added without a chance to parse them, though
-     we still need the PRE_FN available to generate a call to it.  */
-  if (starting_guarded_p && !DECL_PRE_FN (decl1))
-    build_contract_function_decls (decl1);
-
-  /* If we're starting a guarded function with valid contracts, we need to
-     insert a call to the pre function.  */
-  if (starting_guarded_p && DECL_PRE_FN (decl1)
-      && DECL_PRE_FN (decl1) != error_mark_node)
-    {
-      vec<tree, va_gc> *args = build_arg_list (decl1);
-
-      push_deferring_access_checks (dk_no_check);
-      tree call = finish_call_expr (DECL_PRE_FN (decl1), &args,
-				    /*disallow_virtual=*/true,
-				    /*koenig_p=*/false,
-				    /*complain=*/tf_warning_or_error);
-      gcc_assert (call != error_mark_node);
-      pop_deferring_access_checks ();
-
-      /* Just add the call expression.  */
-      finish_expr_stmt (call);
-    }
+  start_function_contracts (decl1);
 
   if (!processing_template_decl
       && (flag_lifetime_dse > 1)
@@ -17670,13 +17620,6 @@ finish_function (bool inline_p)
 			      current_eh_spec_block);
     }
 
-  /* True if this is a guarded function.  */
-  bool finishing_guarded_p = !processing_template_decl
-    && DECL_ORIGINAL_FN (fndecl) == NULL_TREE
-    && contract_any_active_p (DECL_CONTRACTS (fndecl))
-    && !DECL_CONSTRUCTOR_P (fndecl)
-    && !DECL_DESTRUCTOR_P (fndecl);
-
   /* If we're saving up tree structure, tie off the function now.  */
   DECL_SAVED_TREE (fndecl) = pop_stmt_list (DECL_SAVED_TREE (fndecl));
 
@@ -17945,74 +17888,11 @@ finish_function (bool inline_p)
 
   invoke_plugin_callbacks (PLUGIN_FINISH_PARSE_FUNCTION, fndecl);
 
-  if (finishing_guarded_p)
-    finish_function_contracts (fndecl);
+  finish_function_contracts (fndecl);
 
   return fndecl;
 }
 
-/* Finish up the pre & post function definitions for a guarded FNDECL,
-   and compile those functions all the way to assembler language output.  */
-
-static void
-finish_function_contracts (tree fndecl)
-{
-  for (tree ca = DECL_CONTRACTS (fndecl); ca; ca = CONTRACT_CHAIN (ca))
-    {
-      tree contract = CONTRACT_STATEMENT (ca);
-      if (!CONTRACT_CONDITION (contract)
-	  || CONTRACT_CONDITION_DEFERRED_P (contract)
-	  || CONTRACT_CONDITION (contract) == error_mark_node)
-	return;
-    }
-
-  int flags = SF_DEFAULT | SF_PRE_PARSED;
-  tree finished_pre = NULL_TREE, finished_post = NULL_TREE;
-
-  /* If either the pre or post functions are bad, don't bother emitting
-     any contracts.  The program is already ill-formed.  */
-  tree pre = DECL_PRE_FN (fndecl);
-  tree post = DECL_POST_FN (fndecl);
-  if (pre == error_mark_node || post == error_mark_node)
-    return;
-
-  /* Create a copy of the contracts with references to fndecl's args replaced
-     with references to either the args of pre or post function.  */
-  tree contracts = copy_list (DECL_CONTRACTS (fndecl));
-  for (tree attr = contracts; attr; attr = CONTRACT_CHAIN (attr))
-    {
-      tree contract = copy_node (CONTRACT_STATEMENT (attr));
-      if (TREE_CODE (contract) == PRECONDITION_STMT)
-	remap_contract (fndecl, pre, contract, /*duplicate_p=*/false);
-      else if (TREE_CODE (contract) == POSTCONDITION_STMT)
-	remap_contract (fndecl, post, contract, /*duplicate_p=*/false);
-      TREE_VALUE (attr) = build_tree_list (NULL_TREE, contract);
-    }
-
-  if (pre && DECL_INITIAL (fndecl) != error_mark_node)
-    {
-      DECL_PENDING_INLINE_P (pre) = false;
-      start_preparsed_function (pre, DECL_ATTRIBUTES (pre), flags);
-      emit_preconditions (contracts);
-      finished_pre = finish_function (false);
-      expand_or_defer_fn (finished_pre);
-    }
-  if (post && DECL_INITIAL (fndecl) != error_mark_node)
-    {
-      DECL_PENDING_INLINE_P (post) = false;
-      start_preparsed_function (post,
-				DECL_ATTRIBUTES (post),
-				flags);
-      emit_postconditions (contracts);
-
-      tree res = get_postcondition_result_parameter (fndecl);
-      if (res)
-	finish_return_stmt (res);
-      finished_post = finish_function (false);
-      expand_or_defer_fn (finished_post);
-    }
-}
-
 \f
 /* Create the FUNCTION_DECL for a function definition.
    DECLSPECS and DECLARATOR are the parts of the declaration;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ba5afde309d..b2fbfe0e3f9 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19935,14 +19935,6 @@ tsubst_copy_and_build (tree t,
 				RECUR (TREE_OPERAND (t, 0)),
 				complain|decltype_flag));
 
-    case FLOAT_EXPR:
-      /* FIXME: This case was taken out, presumably because everything is
-	 moving to use IMPLICIT_CONV_EXPR. However, cvt.c is still producing
-	 FLOAT_EXPRs in some cases.  */
-      if (!type_dependent_expression_p (TREE_OPERAND (t, 0)))
-	return t;
-      /* Fall through. */
-
     case FIX_TRUNC_EXPR:
       /* convert_like should have created an IMPLICIT_CONV_EXPR.  */
       gcc_unreachable ();
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index f05614b6cf1..3e9550f9753 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -45,7 +45,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "gomp-constants.h"
 #include "predict.h"
 #include "memmodel.h"
-#include "contracts.h"
 
 /* There routines provide a modular interface to perform many parsing
    operations.  They may therefore be used during actual parsing, or
@@ -719,532 +718,6 @@ end_maybe_infinite_loop (tree cond)
     }
 }
 
-/* Build and return an argument list using all the arguments passed to the
-   (presumably guarded) FUNCTION_DECL FN.  This can be used to forward all of
-   FN's arguments to a function taking the same list of arguments -- namely
-   the unchecked form of FN. */
-
-vec<tree, va_gc> *
-build_arg_list (tree fn)
-{
-  gcc_assert (TREE_CODE (fn) == FUNCTION_DECL);
-
-  vec<tree, va_gc> *args = make_tree_vector ();
-  for (tree t = DECL_ARGUMENTS (fn); t != NULL_TREE; t = TREE_CHAIN (t))
-    {
-      if (is_this_parameter (t))
-	continue; // skip already inserted `this` args
-
-      vec_safe_push (args, forward_parm (t));
-    }
-  return args;
-}
-
-/* Map from FUNCTION_DECL to a FUNCTION_DECL for either the PRE_FN or POST_FN.
-   These are used to parse contract conditions and are called inside the body
-   of the guarded function.  */
-static GTY(()) hash_map<tree, tree> *decl_pre_fn;
-static GTY(()) hash_map<tree, tree> *decl_post_fn;
-static GTY(()) hash_map<tree, tree> *decl_original_fn;
-
-/* Returns the precondition funtion for D, or null if not set.  */
-
-tree
-get_precondition_function (tree d)
-{
-  hash_map_maybe_create<hm_ggc> (decl_pre_fn);
-  tree *result = decl_pre_fn->get (d);
-  return result ? *result : NULL_TREE;
-}
-
-/* Returns the postcondition funtion for D, or null if not set.  */
-
-tree
-get_postcondition_function (tree d)
-{
-  hash_map_maybe_create<hm_ggc> (decl_post_fn);
-  tree *result = decl_post_fn->get (d);
-  return result ? *result : NULL_TREE;
-}
-
-/* Makes PRE the precondition function for D.  */
-
-void
-set_precondition_function (tree d, tree pre)
-{
-  gcc_assert (pre);
-  hash_map_maybe_create<hm_ggc> (decl_pre_fn);
-  gcc_assert (!decl_pre_fn->get (d));
-  decl_pre_fn->put (d, pre);
-}
-
-/* Makes POST the postcondition function for D.  */
-
-void
-set_postcondition_function (tree d, tree post)
-{
-  gcc_assert (post);
-  hash_map_maybe_create<hm_ggc> (decl_post_fn);
-  gcc_assert (!decl_post_fn->get (d));
-  decl_post_fn->put (d, post);
-}
-
-/* Set the PRE and POST functions for D.  Note that PRE and POST can be
-   null in this case. If so the functions are not recorded.  */
-
-void
-set_contract_functions (tree d, tree pre, tree post)
-{
-  if (pre)
-    set_precondition_function (d, pre);
-  if (post)
-    set_postcondition_function (d, post);
-}
-
-/* Returns the original guarded function of a precondition or postcondition
-   function D, or null if it does not exist.  */
-
-tree
-get_contracts_original_fn (tree d)
-{
-  hash_map_maybe_create<hm_ggc> (decl_original_fn);
-  tree *result = decl_original_fn->get (d);
-  return result ? *result : NULL_TREE;
-}
-
-
-/* Set the original fn for a contract function D.  */
-
-void
-set_contracts_original_fn (tree d, tree orig)
-{
-  gcc_assert (orig);
-  hash_map_maybe_create<hm_ggc> (decl_original_fn);
-
-  /* FIXME: Why are we resetting the contract function? This is called
-     from finish_function, but seems to just re-assert that the original
-     function is the same.  */
-  if (tree p = get_contracts_original_fn (d))
-    gcc_assert (p == orig);
-
-  decl_original_fn->put (d, orig);
-}
-
-/* Return a copy of the FUNCTION_DECL IDECL with its own unshared
-   PARM_DECL and DECL_ATTRIBUTEs.  */
-
-static tree
-copy_fn_decl (tree idecl)
-{
-  tree decl = copy_decl (idecl);
-  DECL_ATTRIBUTES (decl) = copy_list (DECL_ATTRIBUTES (idecl));
-
-  if (DECL_RESULT (idecl))
-    {
-      DECL_RESULT (decl) = copy_decl (DECL_RESULT (idecl));
-      DECL_CONTEXT (DECL_RESULT (decl)) = decl;
-    }
-  if (!DECL_ARGUMENTS (idecl) || VOID_TYPE_P (DECL_ARGUMENTS (idecl)))
-    return decl;
-
-  tree last = DECL_ARGUMENTS (decl) = copy_decl (DECL_ARGUMENTS (decl));
-  DECL_CONTEXT (last) = decl;
-  for (tree p = TREE_CHAIN (DECL_ARGUMENTS (idecl)); p; p = TREE_CHAIN (p))
-    {
-      if (VOID_TYPE_P (p))
-	{
-	  TREE_CHAIN (last) = void_list_node;
-	  break;
-	}
-      last = TREE_CHAIN (last) = copy_decl (p);
-      DECL_CONTEXT (last) = decl;
-    }
-  return decl;
-}
-
-/* Build a declaration for the pre- or postcondition of a guarded FNDECL.  */
-
-static tree
-build_contract_condition_function (tree fndecl, bool pre)
-{
-  if (TREE_TYPE (fndecl) == error_mark_node)
-    return error_mark_node;
-  if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fndecl)
-      && !TYPE_METHOD_BASETYPE (TREE_TYPE (fndecl)))
-    return error_mark_node;
-
-  /* Create and rename the unchecked function and give an internal name.  */
-  tree fn = copy_fn_decl (fndecl);
-  DECL_RESULT (fn) = NULL_TREE;
-  tree value_type = pre ? void_type_node : TREE_TYPE (TREE_TYPE (fn));
-
-  /* Don't propagate declaration attributes to the checking function,
-     including the original contracts.  */
-  DECL_ATTRIBUTES (fn) = NULL_TREE;
-
-  tree arg_types = NULL_TREE;
-  tree *last = &arg_types;
-
-  /* FIXME will later optimizations delete unused args to prevent extra arg
-   * passing? do we care? */
-  tree class_type = NULL_TREE;
-  for (tree arg_type = TYPE_ARG_TYPES (TREE_TYPE (fn));
-      arg_type && arg_type != void_list_node;
-      arg_type = TREE_CHAIN (arg_type))
-    {
-      if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fndecl)
-	  && TYPE_ARG_TYPES (TREE_TYPE (fn)) == arg_type)
-      {
-	class_type = TREE_TYPE (TREE_VALUE (arg_type));
-	continue;
-      }
-      *last = build_tree_list (TREE_PURPOSE (arg_type), TREE_VALUE (arg_type));
-      last = &TREE_CHAIN (*last);
-    }
-
-  if (pre || VOID_TYPE_P (value_type))
-    *last = void_list_node;
-  else
-    {
-      /* FIXME do we need magic to perfectly forward this so we don't clobber
-	 RVO/NRVO etc?  */
-      tree name = get_identifier ("__r");
-      tree parm = build_lang_decl (PARM_DECL, name, value_type);
-      DECL_CONTEXT (parm) = fn;
-      DECL_ARGUMENTS (fn) = chainon (DECL_ARGUMENTS (fn), parm);
-
-      *last = build_tree_list (NULL_TREE, value_type);
-      TREE_CHAIN (*last) = void_list_node;
-    }
-
-  TREE_TYPE (fn) = build_function_type (value_type, arg_types);
-  if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fndecl))
-    TREE_TYPE (fn) = build_method_type (class_type, TREE_TYPE (fn));
-
-  DECL_NAME (fn) = copy_node (DECL_NAME (fn));
-  DECL_INITIAL (fn) = error_mark_node;
-  set_contracts_original_fn (fn, fndecl);
-
-  IDENTIFIER_VIRTUAL_P (DECL_NAME (fn)) = false;
-  DECL_VIRTUAL_P (fn) = false;
-
-  /* Update various inline related declaration properties.  */
-  //DECL_DECLARED_INLINE_P (fn) = true;
-  DECL_DISREGARD_INLINE_LIMITS (fn) = true;
-  TREE_NO_WARNING (fn) = 1;
-
-  return fn;
-}
-
-static bool
-has_active_contract_condition (tree d, tree_code c)
-{
-  for (tree as = DECL_CONTRACTS (d) ; as != NULL_TREE; as = TREE_CHAIN (as))
-    {
-      tree contract = TREE_VALUE (TREE_VALUE (as));
-      if (TREE_CODE (contract) == c && contract_active_p (contract))
-	return true;
-    }
-  return false;
-}
-
-/* True if D has any checked or assumed preconditions.  */
-
-static bool
-has_active_preconditions (tree d)
-{
-  return has_active_contract_condition (d, PRECONDITION_STMT);
-}
-
-/* True if D has any checked or assumed postconditions.  */
-
-static bool
-has_active_postconditions (tree d)
-{
-  return has_active_contract_condition (d, POSTCONDITION_STMT);
-}
-
-/* Build the precondition checking function for D.  */
-
-static tree
-build_precondition_function (tree d)
-{
-  if (!has_active_preconditions (d))
-    return NULL_TREE;
-
-  return build_contract_condition_function (d, /*pre=*/true);
-}
-
-/* Build the postcondition checking function for D. If the return
-   type is undeduced, don't build the function yet. We do that in
-   apply_deduced_return_type.  */
-
-static tree
-build_postcondition_function (tree d)
-{
-  if (!has_active_postconditions (d))
-    return NULL_TREE;
-
-  tree type = TREE_TYPE (TREE_TYPE (d));
-  if (is_auto (type))
-    return NULL_TREE;
-
-  return build_contract_condition_function (d, /*pre=*/false);
-}
-
-void
-build_contract_function_decls (tree d)
-{
-  /* Constructors and destructors have their contracts inserted inline.  */
-  if (DECL_CONSTRUCTOR_P (d) || DECL_DESTRUCTOR_P (d))
-    return;
-
-  /* Build the pre/post functions (or not).  */
-  tree pre = build_precondition_function (d);
-  tree post = build_postcondition_function (d);
-  set_contract_functions (d, pre, post);
-}
-
-/* Begin a new scope for the postcondition.  */
-
-tree
-start_postcondition_statement ()
-{
-  tree list = push_stmt_list ();
-  tree stmt = begin_compound_stmt (BCS_NORMAL);
-  return build_tree_list (list, stmt);
-}
-
-/* Finish the block containing the postcondition check.  */
-
-void
-finish_postcondition_statement (tree stmt)
-{
-  finish_compound_stmt (TREE_VALUE (stmt));
-  pop_stmt_list (TREE_PURPOSE (stmt));
-}
-
-static const char *
-get_contract_level_name (tree contract)
-{
-  if (CONTRACT_LITERAL_MODE_P (contract))
-    return "";
-  if (tree mode = CONTRACT_MODE (contract))
-    if (tree level = TREE_VALUE (mode))
-      return IDENTIFIER_POINTER (level);
-  return "default";
-}
-
-static const char *
-get_contract_role_name (tree contract)
-{
-  if (CONTRACT_LITERAL_MODE_P (contract))
-    return "";
-  if (tree mode = CONTRACT_MODE (contract))
-    if (tree role = TREE_PURPOSE (mode))
-      return IDENTIFIER_POINTER (role);
-  return "default";
-}
-
-static void
-build_contract_handler_fn (tree contract,
-			   contract_continuation cmode)
-{
-  const char *level = get_contract_level_name (contract);
-  const char *role = get_contract_role_name (contract);
-  tree comment = CONTRACT_COMMENT (contract);
-
-  expanded_location loc = expand_location (EXPR_LOCATION (contract));
-
-  tree continue_mode = build_int_cst (boolean_type_node, cmode != NEVER_CONTINUE);
-  tree line_number = build_int_cst (integer_type_node, loc.line);
-  tree file_name = build_string_literal (strlen (loc.file) + 1, loc.file);
-  const char *function_name_str =
-    TREE_CODE (contract) == ASSERTION_STMT
-      || DECL_CONSTRUCTOR_P (current_function_decl)
-      || DECL_DESTRUCTOR_P (current_function_decl)
-    ? current_function_name ()
-    : fndecl_name (DECL_ORIGINAL_FN (current_function_decl));
-  tree function_name = build_string_literal (strlen (function_name_str) + 1,
-					     function_name_str);
-  tree level_str = build_string_literal (strlen (level) + 1, level);
-  tree role_str = build_string_literal (strlen (role) + 1, role);
-
-  /* FIXME: Do we want a string for this?.  */
-  tree continuation = build_int_cst (integer_type_node, cmode);
-
-  tree violation_fn;
-  if (cmode == MAYBE_CONTINUE)
-    violation_fn = on_contract_violation_fn;
-  else
-    violation_fn = on_contract_violation_never_fn;
-  tree call = build_call_expr (violation_fn, 8, continue_mode, line_number,
-			       file_name, function_name, comment,
-			       level_str, role_str,
-			       continuation);
-
-  finish_expr_stmt (call);
-}
-
-/* Return true if CONTRACT is checked or assumed under the current build
-   configuration. */
-
-bool
-contract_active_p (tree contract)
-{
-  return get_contract_semantic (contract) != CCS_IGNORE;
-}
-
-/* Return true if any contract in the CONTRACT list is checked or assumed
-   under the current build configuration. */
-
-bool
-contract_any_active_p (tree contract)
-{
-  for (; contract != NULL_TREE; contract = CONTRACT_CHAIN (contract))
-    if (contract_active_p (TREE_VALUE (TREE_VALUE (contract))))
-      return true;
-  return false;
-}
-
-/* Generate the code that checks or assumes a contract, but do not attach
-   it to the current context.  This is called during genericization.  */
-
-tree
-build_contract_check (tree contract)
-{
-  contract_semantic semantic = get_contract_semantic (contract);
-  if (semantic == CCS_INVALID)
-    return NULL_TREE;
-
-  /* Ignored contracts are never checked or assumed.  */
-  if (semantic == CCS_IGNORE)
-    return build1 (NOP_EXPR, void_type_node, integer_zero_node);
-
-  remap_dummy_this (current_function_decl, &CONTRACT_CONDITION (contract));
-  tree condition = CONTRACT_CONDITION (contract);
-  if (condition == error_mark_node)
-    return NULL_TREE;
-
-  /* If an assumed contract condition is not fully defined, the current method
-     of turning it into a compile time assumption fails and emits run time
-     code.  We don't want that, so just turn these into NOP.  */
-  if (semantic == CCS_ASSUME && !cp_tree_defined_p (condition))
-    return build1 (NOP_EXPR, void_type_node, integer_zero_node);
-
-  tree if_stmt = begin_if_stmt ();
-  tree cond = build_x_unary_op (EXPR_LOCATION (contract),
-				TRUTH_NOT_EXPR,
-				condition,
-				tf_warning_or_error);
-  finish_if_stmt_cond (cond, if_stmt);
-
-  if (semantic == CCS_ASSUME)
-    {
-      tree unreachable_fn = builtin_decl_implicit (BUILT_IN_UNREACHABLE);
-      tree call = build_call_expr (unreachable_fn, 0);
-      finish_expr_stmt (call);
-    }
-  else
-    {
-      /* Get the continuation mode.  */
-      contract_continuation cmode;
-      switch (semantic)
-	{
-	  case CCS_NEVER: cmode = NEVER_CONTINUE; break;
-	  case CCS_MAYBE: cmode = MAYBE_CONTINUE; break;
-	  default: gcc_unreachable ();
-	}
-
-      build_contract_handler_fn (contract, cmode);
-    }
-
-  finish_then_clause (if_stmt);
-  tree scope = IF_SCOPE (if_stmt);
-  IF_SCOPE (if_stmt) = NULL;
-  return do_poplevel (scope);
-}
-
-/* Generate the statement for the given contract attribute by adding the
-   statement to the current block. Returns the next contract in the chain.  */
-
-static tree
-emit_contract_statement (tree attr)
-{
-  gcc_assert (TREE_CODE (attr) == TREE_LIST);
-  tree contract = CONTRACT_STATEMENT (attr);
-
-  /* Only add valid contracts.  */
-  if (get_contract_semantic (contract) != CCS_INVALID
-      && CONTRACT_CONDITION (contract) != error_mark_node)
-    add_stmt (contract);
-
-  return CONTRACT_CHAIN (attr);
-}
-
-/* Add the statements of contract attributes ATTRS to the current block.  */
-
-static void
-emit_contract_conditions (tree attrs, tree_code code)
-{
-  if (!attrs) return;
-  gcc_assert (TREE_CODE (attrs) == TREE_LIST);
-  gcc_assert (code == PRECONDITION_STMT || code == POSTCONDITION_STMT);
-  while (attrs)
-    {
-      tree contract = CONTRACT_STATEMENT (attrs);
-      if (TREE_CODE (contract) == code)
-	attrs = emit_contract_statement (attrs);
-      else
-	attrs = CONTRACT_CHAIN (attrs);
-    }
-}
-
-/* Emit the statement for an assertion attribute.  */
-
-void
-emit_assertion (tree attr)
-{
-  emit_contract_statement (attr);
-}
-
-/* Emit statements for precondition attributes.  */
-
-void
-emit_preconditions (tree attr)
-{
-  return emit_contract_conditions (attr, PRECONDITION_STMT);
-}
-
-/* Emit statements for postcondition attributes.  */
-
-void
-emit_postconditions (tree contracts)
-{
-  return emit_contract_conditions (contracts, POSTCONDITION_STMT);
-}
-
-/* Converts a contract condition to bool and ensures it has a locaiton.  */
-
-tree
-finish_contract_condition (cp_expr condition)
-{
-  /* Ensure we have the condition location saved in case we later need to
-     emit a conversion error during template instantiation and wouldn't
-     otherwise have it.  */
-  if (!CAN_HAVE_LOCATION_P (condition) || EXCEPTIONAL_CLASS_P (condition))
-    {
-      condition = build1_loc (condition.get_location (), VIEW_CONVERT_EXPR,
-			      TREE_TYPE (condition), condition);
-      EXPR_LOCATION_WRAPPER_P (condition) = 1;
-    }
-
-  if (condition == error_mark_node || type_dependent_expression_p (condition))
-    return condition;
-
-  return maybe_convert_cond (condition);
-}
-
 /* Begin a conditional that might contain a declaration.  When generating
    normal code, we want the declaration to appear before the statement
    containing the conditional.  When generating template code, we want the
@@ -11398,15 +10871,7 @@ apply_deduced_return_type (tree fco, tree return_type)
 
   TREE_TYPE (fco) = change_return_type (return_type, TREE_TYPE (fco));
 
-  /* Update any postconditions and the postcondition checking function
-     as needed.  If there are postconditions, we'll use those to rewrite
-     return statements to check postconditions.  */
-  if (has_active_postconditions (fco))
-    {
-      rebuild_postconditions (fco, return_type);
-      tree post = build_postcondition_function (fco);
-      set_postcondition_function (fco, post);
-    }
+  maybe_update_postconditions (fco);
 
   /* Apply the type to the result object.  */
 
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index ac91024121e..e969c56d8c1 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -10075,39 +10075,6 @@ maybe_warn_pessimizing_move (tree retval, tree functype)
     }
 }
 
-/* Rewrite the expression of a returned expression so that it invokes the
-   postcondition function as needed.  */
-
-static tree
-apply_postcondition_to_return (tree post, tree expr)
-{
-  if (!expr || expr == error_mark_node)
-    return expr;
-
-  vec<tree, va_gc> *args = build_arg_list (current_function_decl);
-
-  // FIXME: do we need forward_parm or similar?
-  if (get_postcondition_result_parameter (current_function_decl))
-    vec_safe_push (args, expr);
-
-  push_deferring_access_checks (dk_no_check);
-  tree call = finish_call_expr (post,
-				&args,
-				/*disallow_virtual=*/true,
-				/*koenig_p=*/false,
-				/*complain=*/tf_warning_or_error);
-  gcc_assert (call != error_mark_node);
-
-  /* We may not have actually built a CALL_EXPR; for instance if the
-     return type is large (contracts-large-return.C).  */
-  if (TREE_CODE (call) == CALL_EXPR)
-    CALL_FROM_THUNK_P (call) = 1;
-
-  pop_deferring_access_checks ();
-
-  return call;
-}
-
 /* Check that returning RETVAL from the current function is valid.
    Return an expression explicitly showing all conversions required to
    change RETVAL into the function return type, and to assign it to
diff --git a/gcc/testsuite/contracts/backtrace_handler/assert_fail.cpp b/gcc/testsuite/g++.dg/contracts/backtrace_handler/assert_fail.cpp
similarity index 100%
rename from gcc/testsuite/contracts/backtrace_handler/assert_fail.cpp
rename to gcc/testsuite/g++.dg/contracts/backtrace_handler/assert_fail.cpp
diff --git a/gcc/testsuite/contracts/backtrace_handler/handle_contract_violation.cpp b/gcc/testsuite/g++.dg/contracts/backtrace_handler/handle_contract_violation.cpp
similarity index 100%
rename from gcc/testsuite/contracts/backtrace_handler/handle_contract_violation.cpp
rename to gcc/testsuite/g++.dg/contracts/backtrace_handler/handle_contract_violation.cpp
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-access1.C b/gcc/testsuite/g++.dg/contracts/contracts-access1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-access1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-access1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-assume1.C b/gcc/testsuite/g++.dg/contracts/contracts-assume1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-assume1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-assume1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-assume2.C b/gcc/testsuite/g++.dg/contracts/contracts-assume2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-assume2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-assume2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-assume3.C b/gcc/testsuite/g++.dg/contracts/contracts-assume3.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-assume3.C
rename to gcc/testsuite/g++.dg/contracts/contracts-assume3.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-assume4.C b/gcc/testsuite/g++.dg/contracts/contracts-assume4.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-assume4.C
rename to gcc/testsuite/g++.dg/contracts/contracts-assume4.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-assume5.C b/gcc/testsuite/g++.dg/contracts/contracts-assume5.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-assume5.C
rename to gcc/testsuite/g++.dg/contracts/contracts-assume5.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-assume6.C b/gcc/testsuite/g++.dg/contracts/contracts-assume6.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-assume6.C
rename to gcc/testsuite/g++.dg/contracts/contracts-assume6.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-config1.C b/gcc/testsuite/g++.dg/contracts/contracts-config1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-config1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-config1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-constexpr1.C b/gcc/testsuite/g++.dg/contracts/contracts-constexpr1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-constexpr1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-constexpr1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-constexpr2.C b/gcc/testsuite/g++.dg/contracts/contracts-constexpr2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-constexpr2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-constexpr2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-conversion1.C b/gcc/testsuite/g++.dg/contracts/contracts-conversion1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-conversion1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-conversion1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-ctor-dtor1.C b/gcc/testsuite/g++.dg/contracts/contracts-ctor-dtor1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-ctor-dtor1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-ctor-dtor1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-ctor-dtor2.C b/gcc/testsuite/g++.dg/contracts/contracts-ctor-dtor2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-ctor-dtor2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-ctor-dtor2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-cv1.C b/gcc/testsuite/g++.dg/contracts/contracts-cv1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-cv1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-cv1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-deduced1.C b/gcc/testsuite/g++.dg/contracts/contracts-deduced1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-deduced1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-deduced1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-deduced2.C b/gcc/testsuite/g++.dg/contracts/contracts-deduced2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-deduced2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-deduced2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-friend1.C b/gcc/testsuite/g++.dg/contracts/contracts-friend1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-friend1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-friend1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-ft1.C b/gcc/testsuite/g++.dg/contracts/contracts-ft1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-ft1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-ft1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-ignore1.C b/gcc/testsuite/g++.dg/contracts/contracts-ignore1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-ignore1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-ignore1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-ignore2.C b/gcc/testsuite/g++.dg/contracts/contracts-ignore2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-ignore2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-ignore2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-large-return.C b/gcc/testsuite/g++.dg/contracts/contracts-large-return.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-large-return.C
rename to gcc/testsuite/g++.dg/contracts/contracts-large-return.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-multiline1.C b/gcc/testsuite/g++.dg/contracts/contracts-multiline1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-multiline1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-multiline1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-multiple-inheritance1.C b/gcc/testsuite/g++.dg/contracts/contracts-multiple-inheritance1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-multiple-inheritance1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-multiple-inheritance1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-multiple-inheritance2.C b/gcc/testsuite/g++.dg/contracts/contracts-multiple-inheritance2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-multiple-inheritance2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-multiple-inheritance2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-nested-class1.C b/gcc/testsuite/g++.dg/contracts/contracts-nested-class1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-nested-class1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-nested-class1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-nested-class2.C b/gcc/testsuite/g++.dg/contracts/contracts-nested-class2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-nested-class2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-nested-class2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-override.C b/gcc/testsuite/g++.dg/contracts/contracts-override.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-override.C
rename to gcc/testsuite/g++.dg/contracts/contracts-override.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-post1.C b/gcc/testsuite/g++.dg/contracts/contracts-post1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-post1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-post1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-post2.C b/gcc/testsuite/g++.dg/contracts/contracts-post2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-post2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-post2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-post3.C b/gcc/testsuite/g++.dg/contracts/contracts-post3.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-post3.C
rename to gcc/testsuite/g++.dg/contracts/contracts-post3.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-post4.C b/gcc/testsuite/g++.dg/contracts/contracts-post4.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-post4.C
rename to gcc/testsuite/g++.dg/contracts/contracts-post4.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-post5.C b/gcc/testsuite/g++.dg/contracts/contracts-post5.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-post5.C
rename to gcc/testsuite/g++.dg/contracts/contracts-post5.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-post6.C b/gcc/testsuite/g++.dg/contracts/contracts-post6.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-post6.C
rename to gcc/testsuite/g++.dg/contracts/contracts-post6.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-pre1.C b/gcc/testsuite/g++.dg/contracts/contracts-pre1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-pre1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-pre1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-pre10.C b/gcc/testsuite/g++.dg/contracts/contracts-pre10.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-pre10.C
rename to gcc/testsuite/g++.dg/contracts/contracts-pre10.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-pre2.C b/gcc/testsuite/g++.dg/contracts/contracts-pre2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-pre2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-pre2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-pre2a1.C b/gcc/testsuite/g++.dg/contracts/contracts-pre2a1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-pre2a1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-pre2a1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-pre2a2.C b/gcc/testsuite/g++.dg/contracts/contracts-pre2a2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-pre2a2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-pre2a2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-pre3.C b/gcc/testsuite/g++.dg/contracts/contracts-pre3.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-pre3.C
rename to gcc/testsuite/g++.dg/contracts/contracts-pre3.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-pre4.C b/gcc/testsuite/g++.dg/contracts/contracts-pre4.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-pre4.C
rename to gcc/testsuite/g++.dg/contracts/contracts-pre4.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-pre5.C b/gcc/testsuite/g++.dg/contracts/contracts-pre5.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-pre5.C
rename to gcc/testsuite/g++.dg/contracts/contracts-pre5.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-pre6.C b/gcc/testsuite/g++.dg/contracts/contracts-pre6.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-pre6.C
rename to gcc/testsuite/g++.dg/contracts/contracts-pre6.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-pre7.C b/gcc/testsuite/g++.dg/contracts/contracts-pre7.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-pre7.C
rename to gcc/testsuite/g++.dg/contracts/contracts-pre7.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-pre9.C b/gcc/testsuite/g++.dg/contracts/contracts-pre9.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-pre9.C
rename to gcc/testsuite/g++.dg/contracts/contracts-pre9.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-redecl1.C b/gcc/testsuite/g++.dg/contracts/contracts-redecl1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-redecl1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-redecl1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-redecl2.C b/gcc/testsuite/g++.dg/contracts/contracts-redecl2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-redecl2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-redecl2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-redecl3.C b/gcc/testsuite/g++.dg/contracts/contracts-redecl3.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-redecl3.C
rename to gcc/testsuite/g++.dg/contracts/contracts-redecl3.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-redecl4.C b/gcc/testsuite/g++.dg/contracts/contracts-redecl4.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-redecl4.C
rename to gcc/testsuite/g++.dg/contracts/contracts-redecl4.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-redecl5.C b/gcc/testsuite/g++.dg/contracts/contracts-redecl5.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-redecl5.C
rename to gcc/testsuite/g++.dg/contracts/contracts-redecl5.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-redecl6.C b/gcc/testsuite/g++.dg/contracts/contracts-redecl6.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-redecl6.C
rename to gcc/testsuite/g++.dg/contracts/contracts-redecl6.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-redecl7.C b/gcc/testsuite/g++.dg/contracts/contracts-redecl7.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-redecl7.C
rename to gcc/testsuite/g++.dg/contracts/contracts-redecl7.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-redecl8.C b/gcc/testsuite/g++.dg/contracts/contracts-redecl8.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-redecl8.C
rename to gcc/testsuite/g++.dg/contracts/contracts-redecl8.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-tmpl-attr1.C b/gcc/testsuite/g++.dg/contracts/contracts-tmpl-attr1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-tmpl-attr1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-tmpl-attr1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-tmpl-spec1.C b/gcc/testsuite/g++.dg/contracts/contracts-tmpl-spec1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-tmpl-spec1.C
rename to gcc/testsuite/g++.dg/contracts/contracts-tmpl-spec1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-tmpl-spec2.C b/gcc/testsuite/g++.dg/contracts/contracts-tmpl-spec2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-tmpl-spec2.C
rename to gcc/testsuite/g++.dg/contracts/contracts-tmpl-spec2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts-tmpl-spec3.C b/gcc/testsuite/g++.dg/contracts/contracts-tmpl-spec3.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts-tmpl-spec3.C
rename to gcc/testsuite/g++.dg/contracts/contracts-tmpl-spec3.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts1.C b/gcc/testsuite/g++.dg/contracts/contracts1.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts1.C
rename to gcc/testsuite/g++.dg/contracts/contracts1.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts10.C b/gcc/testsuite/g++.dg/contracts/contracts10.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts10.C
rename to gcc/testsuite/g++.dg/contracts/contracts10.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts11.C b/gcc/testsuite/g++.dg/contracts/contracts11.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts11.C
rename to gcc/testsuite/g++.dg/contracts/contracts11.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts12.C b/gcc/testsuite/g++.dg/contracts/contracts12.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts12.C
rename to gcc/testsuite/g++.dg/contracts/contracts12.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts13.C b/gcc/testsuite/g++.dg/contracts/contracts13.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts13.C
rename to gcc/testsuite/g++.dg/contracts/contracts13.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts14.C b/gcc/testsuite/g++.dg/contracts/contracts14.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts14.C
rename to gcc/testsuite/g++.dg/contracts/contracts14.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts15.C b/gcc/testsuite/g++.dg/contracts/contracts15.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts15.C
rename to gcc/testsuite/g++.dg/contracts/contracts15.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts16.C b/gcc/testsuite/g++.dg/contracts/contracts16.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts16.C
rename to gcc/testsuite/g++.dg/contracts/contracts16.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts17.C b/gcc/testsuite/g++.dg/contracts/contracts17.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts17.C
rename to gcc/testsuite/g++.dg/contracts/contracts17.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts18.C b/gcc/testsuite/g++.dg/contracts/contracts18.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts18.C
rename to gcc/testsuite/g++.dg/contracts/contracts18.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts19.C b/gcc/testsuite/g++.dg/contracts/contracts19.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts19.C
rename to gcc/testsuite/g++.dg/contracts/contracts19.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts2.C b/gcc/testsuite/g++.dg/contracts/contracts2.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts2.C
rename to gcc/testsuite/g++.dg/contracts/contracts2.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts20.C b/gcc/testsuite/g++.dg/contracts/contracts20.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts20.C
rename to gcc/testsuite/g++.dg/contracts/contracts20.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts22.C b/gcc/testsuite/g++.dg/contracts/contracts22.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts22.C
rename to gcc/testsuite/g++.dg/contracts/contracts22.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts24.C b/gcc/testsuite/g++.dg/contracts/contracts24.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts24.C
rename to gcc/testsuite/g++.dg/contracts/contracts24.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts25.C b/gcc/testsuite/g++.dg/contracts/contracts25.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts25.C
rename to gcc/testsuite/g++.dg/contracts/contracts25.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts3.C b/gcc/testsuite/g++.dg/contracts/contracts3.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts3.C
rename to gcc/testsuite/g++.dg/contracts/contracts3.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts35.C b/gcc/testsuite/g++.dg/contracts/contracts35.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts35.C
rename to gcc/testsuite/g++.dg/contracts/contracts35.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts4.C b/gcc/testsuite/g++.dg/contracts/contracts4.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts4.C
rename to gcc/testsuite/g++.dg/contracts/contracts4.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts5.C b/gcc/testsuite/g++.dg/contracts/contracts5.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts5.C
rename to gcc/testsuite/g++.dg/contracts/contracts5.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts6.C b/gcc/testsuite/g++.dg/contracts/contracts6.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts6.C
rename to gcc/testsuite/g++.dg/contracts/contracts6.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts7.C b/gcc/testsuite/g++.dg/contracts/contracts7.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts7.C
rename to gcc/testsuite/g++.dg/contracts/contracts7.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts8.C b/gcc/testsuite/g++.dg/contracts/contracts8.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts8.C
rename to gcc/testsuite/g++.dg/contracts/contracts8.C
diff --git a/gcc/testsuite/g++.dg/cpp2a/contracts9.C b/gcc/testsuite/g++.dg/contracts/contracts9.C
similarity index 100%
rename from gcc/testsuite/g++.dg/cpp2a/contracts9.C
rename to gcc/testsuite/g++.dg/contracts/contracts9.C
diff --git a/gcc/testsuite/contracts/except_preload_handler/assert_fail.cpp b/gcc/testsuite/g++.dg/contracts/except_preload_handler/assert_fail.cpp
similarity index 100%
rename from gcc/testsuite/contracts/except_preload_handler/assert_fail.cpp
rename to gcc/testsuite/g++.dg/contracts/except_preload_handler/assert_fail.cpp
diff --git a/gcc/testsuite/contracts/except_preload_handler/handle_contract_violation.cpp b/gcc/testsuite/g++.dg/contracts/except_preload_handler/handle_contract_violation.cpp
similarity index 100%
rename from gcc/testsuite/contracts/except_preload_handler/handle_contract_violation.cpp
rename to gcc/testsuite/g++.dg/contracts/except_preload_handler/handle_contract_violation.cpp
diff --git a/gcc/testsuite/contracts/noexcept_preload_handler/assert_fail.cpp b/gcc/testsuite/g++.dg/contracts/noexcept_preload_handler/assert_fail.cpp
similarity index 100%
rename from gcc/testsuite/contracts/noexcept_preload_handler/assert_fail.cpp
rename to gcc/testsuite/g++.dg/contracts/noexcept_preload_handler/assert_fail.cpp
diff --git a/gcc/testsuite/contracts/noexcept_preload_handler/handle_contract_violation.cpp b/gcc/testsuite/g++.dg/contracts/noexcept_preload_handler/handle_contract_violation.cpp
similarity index 100%
rename from gcc/testsuite/contracts/noexcept_preload_handler/handle_contract_violation.cpp
rename to gcc/testsuite/g++.dg/contracts/noexcept_preload_handler/handle_contract_violation.cpp
diff --git a/gcc/testsuite/contracts/preload_handler/assert_fail.cpp b/gcc/testsuite/g++.dg/contracts/preload_handler/assert_fail.cpp
similarity index 100%
rename from gcc/testsuite/contracts/preload_handler/assert_fail.cpp
rename to gcc/testsuite/g++.dg/contracts/preload_handler/assert_fail.cpp
diff --git a/gcc/testsuite/contracts/preload_handler/handle_contract_violation.cpp b/gcc/testsuite/g++.dg/contracts/preload_handler/handle_contract_violation.cpp
similarity index 100%
rename from gcc/testsuite/contracts/preload_handler/handle_contract_violation.cpp
rename to gcc/testsuite/g++.dg/contracts/preload_handler/handle_contract_violation.cpp
diff --git a/gcc/testsuite/contracts/preload_nocontinue_handler/assert_fail.cpp b/gcc/testsuite/g++.dg/contracts/preload_nocontinue_handler/assert_fail.cpp
similarity index 100%
rename from gcc/testsuite/contracts/preload_nocontinue_handler/assert_fail.cpp
rename to gcc/testsuite/g++.dg/contracts/preload_nocontinue_handler/assert_fail.cpp
diff --git a/gcc/testsuite/contracts/preload_nocontinue_handler/handle_contract_violation.cpp b/gcc/testsuite/g++.dg/contracts/preload_nocontinue_handler/handle_contract_violation.cpp
similarity index 100%
rename from gcc/testsuite/contracts/preload_nocontinue_handler/handle_contract_violation.cpp
rename to gcc/testsuite/g++.dg/contracts/preload_nocontinue_handler/handle_contract_violation.cpp
diff --git a/gcc/testsuite/contracts/preload_nocontinue_handler/nocontinue.cpp b/gcc/testsuite/g++.dg/contracts/preload_nocontinue_handler/nocontinue.cpp
similarity index 100%
rename from gcc/testsuite/contracts/preload_nocontinue_handler/nocontinue.cpp
rename to gcc/testsuite/g++.dg/contracts/preload_nocontinue_handler/nocontinue.cpp
diff --git a/gcc/cp/config-lang.in b/gcc/cp/config-lang.in
index b5b2f280af4..b197e02f8f9 100644
--- a/gcc/cp/config-lang.in
+++ b/gcc/cp/config-lang.in
@@ -39,6 +39,7 @@ gtfiles="\
 \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-format.c \
 \$(srcdir)/c-family/c-cppbuiltin.c \$(srcdir)/c-family/c-pragma.c \
 \$(srcdir)/cp/call.c \$(srcdir)/cp/class.c \$(srcdir)/cp/constexpr.c \
+\$(srcdir)/cp/contracts.cc \
 \$(srcdir)/cp/constraint.cc \$(srcdir)/cp/coroutines.cc \
 \$(srcdir)/cp/cp-gimplify.c \
 \$(srcdir)/cp/cp-lang.c \$(srcdir)/cp/cp-objcp-common.c \
diff --git a/gcc/testsuite/contracts/backtrace_handler/Makefile b/gcc/testsuite/g++.dg/contracts/backtrace_handler/Makefile
similarity index 100%
rename from gcc/testsuite/contracts/backtrace_handler/Makefile
rename to gcc/testsuite/g++.dg/contracts/backtrace_handler/Makefile
diff --git a/gcc/testsuite/contracts/backtrace_handler/README b/gcc/testsuite/g++.dg/contracts/backtrace_handler/README
similarity index 100%
rename from gcc/testsuite/contracts/backtrace_handler/README
rename to gcc/testsuite/g++.dg/contracts/backtrace_handler/README
diff --git a/gcc/testsuite/contracts/backtrace_handler/example_out.txt b/gcc/testsuite/g++.dg/contracts/backtrace_handler/example_out.txt
similarity index 100%
rename from gcc/testsuite/contracts/backtrace_handler/example_out.txt
rename to gcc/testsuite/g++.dg/contracts/backtrace_handler/example_out.txt
diff --git a/gcc/testsuite/contracts/backtrace_handler/example_pretty.txt b/gcc/testsuite/g++.dg/contracts/backtrace_handler/example_pretty.txt
similarity index 100%
rename from gcc/testsuite/contracts/backtrace_handler/example_pretty.txt
rename to gcc/testsuite/g++.dg/contracts/backtrace_handler/example_pretty.txt
diff --git a/gcc/testsuite/contracts/backtrace_handler/prettytrace.sh b/gcc/testsuite/g++.dg/contracts/backtrace_handler/prettytrace.sh
similarity index 100%
rename from gcc/testsuite/contracts/backtrace_handler/prettytrace.sh
rename to gcc/testsuite/g++.dg/contracts/backtrace_handler/prettytrace.sh
diff --git a/gcc/testsuite/contracts/except_preload_handler/Makefile b/gcc/testsuite/g++.dg/contracts/except_preload_handler/Makefile
similarity index 100%
rename from gcc/testsuite/contracts/except_preload_handler/Makefile
rename to gcc/testsuite/g++.dg/contracts/except_preload_handler/Makefile
diff --git a/gcc/testsuite/contracts/except_preload_handler/README b/gcc/testsuite/g++.dg/contracts/except_preload_handler/README
similarity index 100%
rename from gcc/testsuite/contracts/except_preload_handler/README
rename to gcc/testsuite/g++.dg/contracts/except_preload_handler/README
diff --git a/gcc/testsuite/contracts/noexcept_preload_handler/Makefile b/gcc/testsuite/g++.dg/contracts/noexcept_preload_handler/Makefile
similarity index 100%
rename from gcc/testsuite/contracts/noexcept_preload_handler/Makefile
rename to gcc/testsuite/g++.dg/contracts/noexcept_preload_handler/Makefile
diff --git a/gcc/testsuite/contracts/noexcept_preload_handler/README b/gcc/testsuite/g++.dg/contracts/noexcept_preload_handler/README
similarity index 100%
rename from gcc/testsuite/contracts/noexcept_preload_handler/README
rename to gcc/testsuite/g++.dg/contracts/noexcept_preload_handler/README
diff --git a/gcc/testsuite/contracts/preload_handler/Makefile b/gcc/testsuite/g++.dg/contracts/preload_handler/Makefile
similarity index 100%
rename from gcc/testsuite/contracts/preload_handler/Makefile
rename to gcc/testsuite/g++.dg/contracts/preload_handler/Makefile
diff --git a/gcc/testsuite/contracts/preload_handler/README b/gcc/testsuite/g++.dg/contracts/preload_handler/README
similarity index 100%
rename from gcc/testsuite/contracts/preload_handler/README
rename to gcc/testsuite/g++.dg/contracts/preload_handler/README
diff --git a/gcc/testsuite/contracts/preload_nocontinue_handler/Makefile b/gcc/testsuite/g++.dg/contracts/preload_nocontinue_handler/Makefile
similarity index 100%
rename from gcc/testsuite/contracts/preload_nocontinue_handler/Makefile
rename to gcc/testsuite/g++.dg/contracts/preload_nocontinue_handler/Makefile
diff --git a/gcc/testsuite/contracts/preload_nocontinue_handler/README b/gcc/testsuite/g++.dg/contracts/preload_nocontinue_handler/README
similarity index 100%
rename from gcc/testsuite/contracts/preload_nocontinue_handler/README
rename to gcc/testsuite/g++.dg/contracts/preload_nocontinue_handler/README


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-06 20:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 20:43 [gcc/devel/c++-contracts] c++: move more contracts code to contracts.cc Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).