summaryrefslogtreecommitdiff
path: root/gcc/testsuite/lib
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-10-13 11:47:25 -0400
committerJason Merrill <jason@redhat.com>2021-11-15 18:50:07 -0500
commit87c2080b056ea2b7f145cba927f36e4f40900205 (patch)
treef088b9fa589fd828ad401f6555416bc0a343cb9f /gcc/testsuite/lib
parent29e4163a092ce08ba3a88a05ac2fa3f23b1cec28 (diff)
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.
Diffstat (limited to 'gcc/testsuite/lib')
-rw-r--r--gcc/testsuite/lib/g++-dg.exp3
-rw-r--r--gcc/testsuite/lib/target-supports.exp4
2 files changed, 6 insertions, 1 deletions
diff --git a/gcc/testsuite/lib/g++-dg.exp b/gcc/testsuite/lib/g++-dg.exp
index c360770a7a2..fd06d278faa 100644
--- a/gcc/testsuite/lib/g++-dg.exp
+++ b/gcc/testsuite/lib/g++-dg.exp
@@ -57,7 +57,8 @@ proc g++-dg-runtest { testcases flags default-extra-flags } {
set option_list { }
foreach x $std_list {
# Handle "concepts" as C++17 plus Concepts TS.
- if { $x eq "concepts" } then { set x "17 -fconcepts" }
+ if { $x eq "concepts" } then { set x "17 -fconcepts"
+ } elseif { $x eq "impcx" } then { set x "23 -fimplicit-constexpr" }
lappend option_list "${std_prefix}$x"
}
} else {
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 8cbda192fe0..c928d99a14b 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -10232,6 +10232,10 @@ proc check_effective_target_concepts { } {
return [check-flags { "" { } { -fconcepts } }]
}
+proc check_effective_target_implicit_constexpr { } {
+ return [check-flags { "" { } { -fimplicit-constexpr } }]
+}
+
# Return 1 if expensive testcases should be run.
proc check_effective_target_run_expensive_tests { } {