diff --git a/src/Changes b/src/Changes index 3b683cef04..79bcd59a6c 100644 --- a/src/Changes +++ b/src/Changes @@ -1,3 +1,13 @@ +10/1/26 [GH #197] +Deducing noexcept-specifiers + +Previously, the front end emulated Clang and GCC's ability to deduce simple +dependent noexcept-specifiers (see the entry for EDGcpfe/18317 of 9/6/17). +Meanwhile, the standard has been changed through Core issue 2355 to make that +behavior standard-mandated. It is now the default behavior, except in +Microsoft mode with microsoft_version < 1951. + + Version 7.0, September 28, 2026 9/15/26 [EDGcpfe/28958] diff --git a/src/cmd_line.c b/src/cmd_line.c index cf2b819cd1..a1fc4154cb 100644 --- a/src/cmd_line.c +++ b/src/cmd_line.c @@ -3237,7 +3237,7 @@ option values if they were not already set by a command line option. exc_spec_in_func_type = TRUE; } /* if */ #endif /* EXC_SPEC_IN_FUNC_TYPE_ENABLING_POSSIBLE */ - deduction_from_exc_spec_allowed = FALSE; + deduction_from_exc_spec_allowed = microsoft_version >= 1951; if (!option_kind_used[(int)optk_aligned_new]) { overaligned_allocation_enabled = TRUE; } /* if */ @@ -5928,13 +5928,7 @@ before this routine is called. warn_on_deduced_return_types = TRUE; } /* if */ } /* if */ - if (cpp17_mode) { - /* g++ and clang allow deduction from the noexcept flag of a function - parameter. */ - if (exc_spec_in_func_type) { - deduction_from_exc_spec_allowed = TRUE; - } /* if */ - } else { + if (!cpp17_mode) { /* g++ and clang do not implement this as a DR in C++14 mode. Note that clang has this disabled by default even in C++17 mode (as of 6.0.1). But we don't have a separate option to enable this, so we still @@ -13281,7 +13275,7 @@ variables declared in cmd_line.h. implicit_noexcept_enabled = FALSE; core_constant_expr_is_noexcept = FALSE; exc_spec_in_func_type = FALSE; - deduction_from_exc_spec_allowed = FALSE; + deduction_from_exc_spec_allowed = TRUE; delegating_constructors_enabled = FALSE; inheriting_constructors_enabled = FALSE; constexpr_enabled = FALSE; diff --git a/src/templates.c b/src/templates.c index 1545357144..41a501ed64 100644 --- a/src/templates.c +++ b/src/templates.c @@ -13889,9 +13889,6 @@ A nontype template parameter is potentially being deduced from a noexcept specifier. For example: template void f(int (*)() noexcept(B)); - -This is currently nonstandard, but accepted by GCC and Clang, and the omission -in the standard is perhaps accidental. */ { a_boolean match = FALSE; @@ -13910,8 +13907,7 @@ in the standard is perhaps accidental. if (deduction_from_exc_spec_allowed && (flags & MTT_ALLOW_STRICTER_NOEXCEPT) == 0 && !constant_bool_value_known_at_compile_time(t_cp)) { - /* Some compilers allow deduction from the noexcept flag of a function - type. Do this deduction, if needed. */ + /* Perform deduction from the noexcept flag of a function type. */ a_constant_ptr cp; a_boolean cp_is_local = FALSE; if (esp != NULL && esp->variant.noexcept_arg != NULL) { diff --git a/tests/expectations/edg_x86_32/cwg.log b/tests/expectations/edg_x86_32/cwg.log index 4a252b98ce..73bb0931f6 100644 --- a/tests/expectations/edg_x86_32/cwg.log +++ b/tests/expectations/edg_x86_32/cwg.log @@ -1,6 +1,3 @@ -2355a.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355c.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355d.sft.cpp:fn:-DTEST_NUMBER=1:FAIL: P2615R1a.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: P2647R1b.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: cwg1028c.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: diff --git a/tests/expectations/edg_x86_32_cp/cwg.log b/tests/expectations/edg_x86_32_cp/cwg.log index 6d9dcaf602..55af429f01 100644 --- a/tests/expectations/edg_x86_32_cp/cwg.log +++ b/tests/expectations/edg_x86_32_cp/cwg.log @@ -1,6 +1,3 @@ -2355a.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355c.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355d.sft.cpp:fn:-DTEST_NUMBER=1:FAIL: P2615R1a.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: P2647R1b.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: cwg1028c.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: diff --git a/tests/expectations/edg_x86_64/cwg.log b/tests/expectations/edg_x86_64/cwg.log index 4a252b98ce..73bb0931f6 100644 --- a/tests/expectations/edg_x86_64/cwg.log +++ b/tests/expectations/edg_x86_64/cwg.log @@ -1,6 +1,3 @@ -2355a.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355c.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355d.sft.cpp:fn:-DTEST_NUMBER=1:FAIL: P2615R1a.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: P2647R1b.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: cwg1028c.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: diff --git a/tests/expectations/edg_x86_64_cp/cwg.log b/tests/expectations/edg_x86_64_cp/cwg.log index 6d9dcaf602..55af429f01 100644 --- a/tests/expectations/edg_x86_64_cp/cwg.log +++ b/tests/expectations/edg_x86_64_cp/cwg.log @@ -1,6 +1,3 @@ -2355a.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355c.sft.cpp:cp:-DTEST_NUMBER=1:FAIL: -2355d.sft.cpp:fn:-DTEST_NUMBER=1:FAIL: P2615R1a.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: P2647R1b.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: cwg1028c.sft.cpp:fp:-DTEST_NUMBER=1:FAIL: diff --git a/tests/tests/cwg/2355a.sft.cpp b/tests/tests/cwg/2355a.sft.cpp index 300a2f376b..0d618bc057 100644 --- a/tests/tests/cwg/2355a.sft.cpp +++ b/tests/tests/cwg/2355a.sft.cpp @@ -1,4 +1,5 @@ -//options_all:--c++20 -tused -A +//options:--c++17 -A:--c++17 --gn 160200:--c++17 --clang_version 230100:--ms_c++17 --microsoft_version 1950;fn:--ms_c++17 --microsoft_version 1951:--c++14 -A;fn:--c++14 --gn 160200;fn:--c++14 --clang_version 230100;fn:--ms_c++14 --microsoft_version 1950;fn:--ms_c++14 --microsoft_version 1951;fn +//options_all:-tused template void f1(void (*)() noexcept(E)); void g1();