]> gcc.gnu.org Git - gcc.git/commit
c++: Add -fimplicit-constexpr
authorJason Merrill <jason@redhat.com>
Wed, 13 Oct 2021 15:47:25 +0000 (11:47 -0400)
committerJason Merrill <jason@redhat.com>
Mon, 15 Nov 2021 23:50:07 +0000 (18:50 -0500)
commit87c2080b056ea2b7f145cba927f36e4f40900205
treef088b9fa589fd828ad401f6555416bc0a343cb9f
parent29e4163a092ce08ba3a88a05ac2fa3f23b1cec28
c++: Add -fimplicit-constexpr

With each successive C++ standard the restrictions on the use of the
constexpr keyword for functions get weaker and weaker; it recently occurred
to me that it is heading toward the same fate as the C register keyword,
which was once useful for optimization but became obsolete.  Similarly, it
seems to me that we should be able to just treat inlines as constexpr
functions and not make people add the extra keyword everywhere.

There were a lot of testcase changes needed; many disabling errors about
non-constexpr functions that are now constexpr, and many disabling implicit
constexpr so that the tests can check the same thing as before, whether
that's mangling or whatever.

gcc/c-family/ChangeLog:

* c.opt: Add -fimplicit-constexpr.
* c-cppbuiltin.c: Define __cpp_implicit_constexpr.
* c-opts.c (c_common_post_options): Disable below C++14.

gcc/cp/ChangeLog:

* cp-tree.h (struct lang_decl_fn): Add implicit_constexpr.
(decl_implicit_constexpr_p): New.
* class.c (type_maybe_constexpr_destructor): Use
TYPE_HAS_TRIVIAL_DESTRUCTOR and maybe_constexpr_fn.
(finalize_literal_type_property): Simplify.
* constexpr.c (is_valid_constexpr_fn): Check for dtor.
(maybe_save_constexpr_fundef): Try to set DECL_DECLARED_CONSTEXPR_P
on inlines.
(cxx_eval_call_expression): Use maybe_constexpr_fn.
(maybe_constexpr_fn): Handle flag_implicit_constexpr.
(var_in_maybe_constexpr_fn): Use maybe_constexpr_fn.
(potential_constant_expression_1): Likewise.
(decl_implicit_constexpr_p): New.
* decl.c (validate_constexpr_redeclaration): Allow change with
-fimplicit-constexpr.
(grok_special_member_properties): Use maybe_constexpr_fn.
* error.c (dump_function_decl): Don't print 'constexpr'
if it's implicit.
* Make-lang.in (check-c++-all): Update.

libstdc++-v3/ChangeLog:

* testsuite/20_util/to_address/1_neg.cc: Adjust error.
* testsuite/26_numerics/random/concept.cc: Adjust asserts.

gcc/testsuite/ChangeLog:

* lib/g++-dg.exp: Handle "impcx".
* lib/target-supports.exp
(check_effective_target_implicit_constexpr): New.
* g++.dg/abi/abi-tag16.C:
* g++.dg/abi/abi-tag18a.C:
* g++.dg/abi/guard4.C:
* g++.dg/abi/lambda-defarg1.C:
* g++.dg/abi/mangle26.C:
* g++.dg/cpp0x/constexpr-diag3.C:
* g++.dg/cpp0x/constexpr-ex1.C:
* g++.dg/cpp0x/constexpr-ice5.C:
* g++.dg/cpp0x/constexpr-incomplete2.C:
* g++.dg/cpp0x/constexpr-memfn1.C:
* g++.dg/cpp0x/constexpr-neg3.C:
* g++.dg/cpp0x/constexpr-specialization.C:
* g++.dg/cpp0x/inh-ctor19.C:
* g++.dg/cpp0x/inh-ctor30.C:
* g++.dg/cpp0x/lambda/lambda-mangle3.C:
* g++.dg/cpp0x/lambda/lambda-mangle5.C:
* g++.dg/cpp1y/auto-fn12.C:
* g++.dg/cpp1y/constexpr-loop5.C:
* g++.dg/cpp1z/constexpr-lambda7.C:
* g++.dg/cpp2a/constexpr-dtor3.C:
* g++.dg/cpp2a/constexpr-new13.C:
* g++.dg/cpp2a/constinit11.C:
* g++.dg/cpp2a/constinit12.C:
* g++.dg/cpp2a/constinit14.C:
* g++.dg/cpp2a/constinit15.C:
* g++.dg/cpp2a/spaceship-constexpr1.C:
* g++.dg/cpp2a/spaceship-eq3.C:
* g++.dg/cpp2a/udlit-class-nttp-neg2.C:
* g++.dg/debug/dwarf2/auto1.C:
* g++.dg/debug/dwarf2/cdtor-1.C:
* g++.dg/debug/dwarf2/lambda1.C:
* g++.dg/debug/dwarf2/pr54508.C:
* g++.dg/debug/dwarf2/pubnames-2.C:
* g++.dg/debug/dwarf2/pubnames-3.C:
* g++.dg/ext/is_literal_type3.C:
* g++.dg/ext/visibility/template7.C:
* g++.dg/gcov/gcov-12.C:
* g++.dg/gcov/gcov-2.C:
* g++.dg/ipa/devirt-35.C:
* g++.dg/ipa/devirt-36.C:
* g++.dg/ipa/devirt-37.C:
* g++.dg/ipa/devirt-44.C:
* g++.dg/ipa/imm-devirt-1.C:
* g++.dg/lookup/builtin5.C:
* g++.dg/lto/inline-crossmodule-1_0.C:
* g++.dg/modules/enum-1_a.C:
* g++.dg/modules/fn-inline-1_c.C:
* g++.dg/modules/pmf-1_b.C:
* g++.dg/modules/used-1_c.C:
* g++.dg/tls/thread_local11.C:
* g++.dg/tls/thread_local11a.C:
* g++.dg/tm/pr46653.C:
* g++.dg/ubsan/pr70035.C:
* g++.old-deja/g++.other/delete6.C:
* g++.dg/modules/pmf-1_a.H:
Adjust for implicit constexpr.
68 files changed:
gcc/c-family/c-cppbuiltin.c
gcc/c-family/c-opts.c
gcc/c-family/c.opt
gcc/cp/Make-lang.in
gcc/cp/class.c
gcc/cp/constexpr.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/error.c
gcc/testsuite/g++.dg/abi/abi-tag16.C
gcc/testsuite/g++.dg/abi/abi-tag18a.C
gcc/testsuite/g++.dg/abi/guard4.C
gcc/testsuite/g++.dg/abi/lambda-defarg1.C
gcc/testsuite/g++.dg/abi/mangle26.C
gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C
gcc/testsuite/g++.dg/cpp0x/constexpr-ex1.C
gcc/testsuite/g++.dg/cpp0x/constexpr-ice5.C
gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete2.C
gcc/testsuite/g++.dg/cpp0x/constexpr-memfn1.C
gcc/testsuite/g++.dg/cpp0x/constexpr-neg3.C
gcc/testsuite/g++.dg/cpp0x/constexpr-specialization.C
gcc/testsuite/g++.dg/cpp0x/inh-ctor19.C
gcc/testsuite/g++.dg/cpp0x/inh-ctor30.C
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle3.C
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle5.C
gcc/testsuite/g++.dg/cpp1y/auto-fn12.C
gcc/testsuite/g++.dg/cpp1y/constexpr-loop5.C
gcc/testsuite/g++.dg/cpp1z/constexpr-lambda7.C
gcc/testsuite/g++.dg/cpp2a/constexpr-dtor3.C
gcc/testsuite/g++.dg/cpp2a/constexpr-new13.C
gcc/testsuite/g++.dg/cpp2a/constinit11.C
gcc/testsuite/g++.dg/cpp2a/constinit12.C
gcc/testsuite/g++.dg/cpp2a/constinit14.C
gcc/testsuite/g++.dg/cpp2a/constinit15.C
gcc/testsuite/g++.dg/cpp2a/spaceship-constexpr1.C
gcc/testsuite/g++.dg/cpp2a/spaceship-eq3.C
gcc/testsuite/g++.dg/cpp2a/udlit-class-nttp-neg2.C
gcc/testsuite/g++.dg/debug/dwarf2/auto1.C
gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
gcc/testsuite/g++.dg/debug/dwarf2/lambda1.C
gcc/testsuite/g++.dg/debug/dwarf2/pr54508.C
gcc/testsuite/g++.dg/debug/dwarf2/pubnames-2.C
gcc/testsuite/g++.dg/debug/dwarf2/pubnames-3.C
gcc/testsuite/g++.dg/ext/is_literal_type3.C
gcc/testsuite/g++.dg/ext/visibility/template7.C
gcc/testsuite/g++.dg/gcov/gcov-12.C
gcc/testsuite/g++.dg/gcov/gcov-2.C
gcc/testsuite/g++.dg/ipa/devirt-35.C
gcc/testsuite/g++.dg/ipa/devirt-36.C
gcc/testsuite/g++.dg/ipa/devirt-37.C
gcc/testsuite/g++.dg/ipa/devirt-44.C
gcc/testsuite/g++.dg/ipa/imm-devirt-1.C
gcc/testsuite/g++.dg/lookup/builtin5.C
gcc/testsuite/g++.dg/lto/inline-crossmodule-1_0.C
gcc/testsuite/g++.dg/modules/enum-1_a.C
gcc/testsuite/g++.dg/modules/fn-inline-1_c.C
gcc/testsuite/g++.dg/modules/pmf-1_a.H
gcc/testsuite/g++.dg/modules/pmf-1_b.C
gcc/testsuite/g++.dg/modules/used-1_c.C
gcc/testsuite/g++.dg/tls/thread_local11.C
gcc/testsuite/g++.dg/tls/thread_local11a.C
gcc/testsuite/g++.dg/tm/pr46653.C
gcc/testsuite/g++.dg/ubsan/pr70035.C
gcc/testsuite/g++.old-deja/g++.other/delete6.C
gcc/testsuite/lib/g++-dg.exp
gcc/testsuite/lib/target-supports.exp
libstdc++-v3/testsuite/20_util/to_address/1_neg.cc
libstdc++-v3/testsuite/26_numerics/random/concept.cc
This page took 0.08864 seconds and 6 git commands to generate.