* [PATCH] c++: wrong looser excep spec for dep noexcept [PR113158] @ 2024-02-15 22:17 Marek Polacek 2024-02-16 20:58 ` Jason Merrill 0 siblings, 1 reply; 6+ messages in thread From: Marek Polacek @ 2024-02-15 22:17 UTC (permalink / raw) To: Jason Merrill, GCC Patches Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? By the ??? below I mean that maybe_instantiate_noexcept could return a tristate, and then maybe_check_overriding_exception_spec could check if (maybe_instantiate_noexcept ().is_unknown ()) return true; and we don't have to add any new checks to maybe_check_o_e_spec. -- >8 -- Here we find ourselves in maybe_check_overriding_exception_spec in a template context where we can't instantiate a dependent noexcept. That's OK, but we have to defer the checking otherwise we give wrong errors. PR c++/113158 gcc/cp/ChangeLog: * search.cc (maybe_check_overriding_exception_spec): Defer checking when a noexcept couldn't be instantiated. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/noexcept83.C: New test. --- gcc/cp/search.cc | 7 +++++ gcc/testsuite/g++.dg/cpp0x/noexcept83.C | 37 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept83.C diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc index c948839dc53..73d254d6b84 100644 --- a/gcc/cp/search.cc +++ b/gcc/cp/search.cc @@ -1975,6 +1975,13 @@ maybe_check_overriding_exception_spec (tree overrider, tree basefn) || UNPARSED_NOEXCEPT_SPEC_P (over_throw)) return true; + /* We also have to defer checking when we're in a template and couldn't + instantiate the noexcept yet. + ??? maybe_instantiate_noexcept already checked these. Use tristate? */ + if (type_dependent_expression_p (base_throw) + || type_dependent_expression_p (over_throw)) + return true; + if (!comp_except_specs (base_throw, over_throw, ce_derived)) { auto_diagnostic_group d; diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept83.C b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C new file mode 100644 index 00000000000..47832bbb44d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C @@ -0,0 +1,37 @@ +// PR c++/113158 +// { dg-do compile { target c++11 } } + +template<typename T> +struct V { + static constexpr bool t = false; +}; +struct base { + virtual int f() = 0; +}; + +template<typename T> +struct derived : base { + int f() noexcept(V<T>::t) override; +}; + +struct base2 { + virtual int f() noexcept = 0; +}; + +template<bool B> +struct W { + static constexpr bool t = B; +}; + +template<bool B> +struct derived2 : base2 { + int f() noexcept(W<B>::t) override; // { dg-error "looser exception specification" } +}; + +void +g () +{ + derived<int> d1; + derived2<false> d2; // { dg-message "required from here" } + derived2<true> d3; +} base-commit: b3b3bd250f0a7c22b7d46d3522c8b94c6a35d22a prerequisite-patch-id: 3beddc8cae6ef7f28cd7eac7240d5f4dad08e5f7 -- 2.43.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] c++: wrong looser excep spec for dep noexcept [PR113158] 2024-02-15 22:17 [PATCH] c++: wrong looser excep spec for dep noexcept [PR113158] Marek Polacek @ 2024-02-16 20:58 ` Jason Merrill 2024-02-16 21:33 ` [PATCH v2] " Marek Polacek 0 siblings, 1 reply; 6+ messages in thread From: Jason Merrill @ 2024-02-16 20:58 UTC (permalink / raw) To: Marek Polacek, GCC Patches On 2/15/24 17:17, Marek Polacek wrote: > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > By the ??? below I mean that maybe_instantiate_noexcept could return > a tristate, and then maybe_check_overriding_exception_spec could check > > if (maybe_instantiate_noexcept ().is_unknown ()) > return true; > > and we don't have to add any new checks to maybe_check_o_e_spec. > > -- >8 -- > Here we find ourselves in maybe_check_overriding_exception_spec in > a template context where we can't instantiate a dependent noexcept. > That's OK, but we have to defer the checking otherwise we give wrong > errors. > > PR c++/113158 > > gcc/cp/ChangeLog: > > * search.cc (maybe_check_overriding_exception_spec): Defer checking > when a noexcept couldn't be instantiated. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp0x/noexcept83.C: New test. > --- > gcc/cp/search.cc | 7 +++++ > gcc/testsuite/g++.dg/cpp0x/noexcept83.C | 37 +++++++++++++++++++++++++ > 2 files changed, 44 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept83.C > > diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc > index c948839dc53..73d254d6b84 100644 > --- a/gcc/cp/search.cc > +++ b/gcc/cp/search.cc > @@ -1975,6 +1975,13 @@ maybe_check_overriding_exception_spec (tree overrider, tree basefn) > || UNPARSED_NOEXCEPT_SPEC_P (over_throw)) > return true; > > + /* We also have to defer checking when we're in a template and couldn't > + instantiate the noexcept yet. > + ??? maybe_instantiate_noexcept already checked these. Use tristate? */ > + if (type_dependent_expression_p (base_throw) > + || type_dependent_expression_p (over_throw)) I think we also want to avoid comparing value-dependent expressions, but actually checking either one seems like more work than needed here; I'd think we want to defer in a template if the specifiers aren't both exactly true or false. > + return true; > + > if (!comp_except_specs (base_throw, over_throw, ce_derived)) > { > auto_diagnostic_group d; > diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept83.C b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C > new file mode 100644 > index 00000000000..47832bbb44d > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C > @@ -0,0 +1,37 @@ > +// PR c++/113158 > +// { dg-do compile { target c++11 } } > + > +template<typename T> > +struct V { > + static constexpr bool t = false; > +}; > +struct base { > + virtual int f() = 0; > +}; > + > +template<typename T> > +struct derived : base { > + int f() noexcept(V<T>::t) override; > +}; > + > +struct base2 { > + virtual int f() noexcept = 0; > +}; > + > +template<bool B> > +struct W { > + static constexpr bool t = B; > +}; > + > +template<bool B> > +struct derived2 : base2 { > + int f() noexcept(W<B>::t) override; // { dg-error "looser exception specification" } > +}; > + > +void > +g () > +{ > + derived<int> d1; > + derived2<false> d2; // { dg-message "required from here" } > + derived2<true> d3; > +} > > base-commit: b3b3bd250f0a7c22b7d46d3522c8b94c6a35d22a > prerequisite-patch-id: 3beddc8cae6ef7f28cd7eac7240d5f4dad08e5f7 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] c++: wrong looser excep spec for dep noexcept [PR113158] 2024-02-16 20:58 ` Jason Merrill @ 2024-02-16 21:33 ` Marek Polacek 2024-02-16 21:39 ` Patrick Palka 0 siblings, 1 reply; 6+ messages in thread From: Marek Polacek @ 2024-02-16 21:33 UTC (permalink / raw) To: Jason Merrill; +Cc: GCC Patches On Fri, Feb 16, 2024 at 03:58:02PM -0500, Jason Merrill wrote: > On 2/15/24 17:17, Marek Polacek wrote: > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > > > By the ??? below I mean that maybe_instantiate_noexcept could return > > a tristate, and then maybe_check_overriding_exception_spec could check > > > > if (maybe_instantiate_noexcept ().is_unknown ()) > > return true; > > > > and we don't have to add any new checks to maybe_check_o_e_spec. > > > > -- >8 -- > > Here we find ourselves in maybe_check_overriding_exception_spec in > > a template context where we can't instantiate a dependent noexcept. > > That's OK, but we have to defer the checking otherwise we give wrong > > errors. > > > > PR c++/113158 > > > > gcc/cp/ChangeLog: > > > > * search.cc (maybe_check_overriding_exception_spec): Defer checking > > when a noexcept couldn't be instantiated. > > > > gcc/testsuite/ChangeLog: > > > > * g++.dg/cpp0x/noexcept83.C: New test. > > --- > > gcc/cp/search.cc | 7 +++++ > > gcc/testsuite/g++.dg/cpp0x/noexcept83.C | 37 +++++++++++++++++++++++++ > > 2 files changed, 44 insertions(+) > > create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept83.C > > > > diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc > > index c948839dc53..73d254d6b84 100644 > > --- a/gcc/cp/search.cc > > +++ b/gcc/cp/search.cc > > @@ -1975,6 +1975,13 @@ maybe_check_overriding_exception_spec (tree overrider, tree basefn) > > || UNPARSED_NOEXCEPT_SPEC_P (over_throw)) > > return true; > > + /* We also have to defer checking when we're in a template and couldn't > > + instantiate the noexcept yet. > > + ??? maybe_instantiate_noexcept already checked these. Use tristate? */ > > + if (type_dependent_expression_p (base_throw) > > + || type_dependent_expression_p (over_throw)) > > I think we also want to avoid comparing value-dependent expressions, but > actually checking either one seems like more work than needed here; I'd > think we want to defer in a template if the specifiers aren't both exactly > true or false. Yeah, that'll work too. So like this? Bootstrap/regtest running; dg.exp passed. FWIW, the new check only triggered on the new test. Thanks, -- >8 -- Here we find ourselves in maybe_check_overriding_exception_spec in a template context where we can't instantiate a dependent noexcept. That's OK, but we have to defer the checking otherwise we give wrong errors. PR c++/113158 gcc/cp/ChangeLog: * search.cc (maybe_check_overriding_exception_spec): Defer checking when a noexcept couldn't be instantiated & evaluated to false/true. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/noexcept83.C: New test. --- gcc/cp/search.cc | 11 ++++++++ gcc/testsuite/g++.dg/cpp0x/noexcept83.C | 37 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept83.C diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc index c948839dc53..554ba71f4a7 100644 --- a/gcc/cp/search.cc +++ b/gcc/cp/search.cc @@ -1975,6 +1975,17 @@ maybe_check_overriding_exception_spec (tree overrider, tree basefn) || UNPARSED_NOEXCEPT_SPEC_P (over_throw)) return true; + /* We also have to defer checking when we're in a template and couldn't + instantiate & evaluate the noexcept to true/false. */ + if (processing_template_decl) + if ((base_throw + && (base_throw != noexcept_true_spec + || base_throw != noexcept_false_spec)) + || (over_throw + && (over_throw != noexcept_true_spec + || over_throw != noexcept_false_spec))) + return true; + if (!comp_except_specs (base_throw, over_throw, ce_derived)) { auto_diagnostic_group d; diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept83.C b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C new file mode 100644 index 00000000000..47832bbb44d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C @@ -0,0 +1,37 @@ +// PR c++/113158 +// { dg-do compile { target c++11 } } + +template<typename T> +struct V { + static constexpr bool t = false; +}; +struct base { + virtual int f() = 0; +}; + +template<typename T> +struct derived : base { + int f() noexcept(V<T>::t) override; +}; + +struct base2 { + virtual int f() noexcept = 0; +}; + +template<bool B> +struct W { + static constexpr bool t = B; +}; + +template<bool B> +struct derived2 : base2 { + int f() noexcept(W<B>::t) override; // { dg-error "looser exception specification" } +}; + +void +g () +{ + derived<int> d1; + derived2<false> d2; // { dg-message "required from here" } + derived2<true> d3; +} base-commit: 40b8d7b73ad2ce498758c1d9bd38ebdbc26b918b -- 2.43.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] c++: wrong looser excep spec for dep noexcept [PR113158] 2024-02-16 21:33 ` [PATCH v2] " Marek Polacek @ 2024-02-16 21:39 ` Patrick Palka 2024-02-16 22:06 ` [PATCH v3] " Marek Polacek 0 siblings, 1 reply; 6+ messages in thread From: Patrick Palka @ 2024-02-16 21:39 UTC (permalink / raw) To: Marek Polacek; +Cc: Jason Merrill, GCC Patches On Fri, 16 Feb 2024, Marek Polacek wrote: > On Fri, Feb 16, 2024 at 03:58:02PM -0500, Jason Merrill wrote: > > On 2/15/24 17:17, Marek Polacek wrote: > > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > > > > > By the ??? below I mean that maybe_instantiate_noexcept could return > > > a tristate, and then maybe_check_overriding_exception_spec could check > > > > > > if (maybe_instantiate_noexcept ().is_unknown ()) > > > return true; > > > > > > and we don't have to add any new checks to maybe_check_o_e_spec. > > > > > > -- >8 -- > > > Here we find ourselves in maybe_check_overriding_exception_spec in > > > a template context where we can't instantiate a dependent noexcept. > > > That's OK, but we have to defer the checking otherwise we give wrong > > > errors. > > > > > > PR c++/113158 > > > > > > gcc/cp/ChangeLog: > > > > > > * search.cc (maybe_check_overriding_exception_spec): Defer checking > > > when a noexcept couldn't be instantiated. > > > > > > gcc/testsuite/ChangeLog: > > > > > > * g++.dg/cpp0x/noexcept83.C: New test. > > > --- > > > gcc/cp/search.cc | 7 +++++ > > > gcc/testsuite/g++.dg/cpp0x/noexcept83.C | 37 +++++++++++++++++++++++++ > > > 2 files changed, 44 insertions(+) > > > create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept83.C > > > > > > diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc > > > index c948839dc53..73d254d6b84 100644 > > > --- a/gcc/cp/search.cc > > > +++ b/gcc/cp/search.cc > > > @@ -1975,6 +1975,13 @@ maybe_check_overriding_exception_spec (tree overrider, tree basefn) > > > || UNPARSED_NOEXCEPT_SPEC_P (over_throw)) > > > return true; > > > + /* We also have to defer checking when we're in a template and couldn't > > > + instantiate the noexcept yet. > > > + ??? maybe_instantiate_noexcept already checked these. Use tristate? */ > > > + if (type_dependent_expression_p (base_throw) > > > + || type_dependent_expression_p (over_throw)) > > > > I think we also want to avoid comparing value-dependent expressions, but > > actually checking either one seems like more work than needed here; I'd > > think we want to defer in a template if the specifiers aren't both exactly > > true or false. > > Yeah, that'll work too. So like this? > > Bootstrap/regtest running; dg.exp passed. FWIW, the new check only > triggered on the new test. > > Thanks, > > -- >8 -- > Here we find ourselves in maybe_check_overriding_exception_spec in > a template context where we can't instantiate a dependent noexcept. > That's OK, but we have to defer the checking otherwise we give wrong > errors. > > PR c++/113158 > > gcc/cp/ChangeLog: > > * search.cc (maybe_check_overriding_exception_spec): Defer checking > when a noexcept couldn't be instantiated & evaluated to false/true. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp0x/noexcept83.C: New test. > --- > gcc/cp/search.cc | 11 ++++++++ > gcc/testsuite/g++.dg/cpp0x/noexcept83.C | 37 +++++++++++++++++++++++++ > 2 files changed, 48 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept83.C > > diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc > index c948839dc53..554ba71f4a7 100644 > --- a/gcc/cp/search.cc > +++ b/gcc/cp/search.cc > @@ -1975,6 +1975,17 @@ maybe_check_overriding_exception_spec (tree overrider, tree basefn) > || UNPARSED_NOEXCEPT_SPEC_P (over_throw)) > return true; > > + /* We also have to defer checking when we're in a template and couldn't > + instantiate & evaluate the noexcept to true/false. */ > + if (processing_template_decl) > + if ((base_throw > + && (base_throw != noexcept_true_spec > + || base_throw != noexcept_false_spec)) Shouldn't these innermost || be &&? > + || (over_throw > + && (over_throw != noexcept_true_spec > + || over_throw != noexcept_false_spec))) > + return true; > + > if (!comp_except_specs (base_throw, over_throw, ce_derived)) > { > auto_diagnostic_group d; > diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept83.C b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C > new file mode 100644 > index 00000000000..47832bbb44d > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C > @@ -0,0 +1,37 @@ > +// PR c++/113158 > +// { dg-do compile { target c++11 } } > + > +template<typename T> > +struct V { > + static constexpr bool t = false; > +}; > +struct base { > + virtual int f() = 0; > +}; > + > +template<typename T> > +struct derived : base { > + int f() noexcept(V<T>::t) override; > +}; > + > +struct base2 { > + virtual int f() noexcept = 0; > +}; > + > +template<bool B> > +struct W { > + static constexpr bool t = B; > +}; > + > +template<bool B> > +struct derived2 : base2 { > + int f() noexcept(W<B>::t) override; // { dg-error "looser exception specification" } > +}; > + > +void > +g () > +{ > + derived<int> d1; > + derived2<false> d2; // { dg-message "required from here" } > + derived2<true> d3; > +} > > base-commit: 40b8d7b73ad2ce498758c1d9bd38ebdbc26b918b > -- > 2.43.2 > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] c++: wrong looser excep spec for dep noexcept [PR113158] 2024-02-16 21:39 ` Patrick Palka @ 2024-02-16 22:06 ` Marek Polacek 2024-02-17 10:07 ` Jason Merrill 0 siblings, 1 reply; 6+ messages in thread From: Marek Polacek @ 2024-02-16 22:06 UTC (permalink / raw) To: Patrick Palka; +Cc: Jason Merrill, GCC Patches On Fri, Feb 16, 2024 at 04:39:47PM -0500, Patrick Palka wrote: > On Fri, 16 Feb 2024, Marek Polacek wrote: > > + /* We also have to defer checking when we're in a template and couldn't > > + instantiate & evaluate the noexcept to true/false. */ > > + if (processing_template_decl) > > + if ((base_throw > > + && (base_throw != noexcept_true_spec > > + || base_throw != noexcept_false_spec)) > > Shouldn't these innermost || be &&? D'oh, yes, what a dumb mistake. But that shows that we could also just always return true in a template ;). Fixed. dg.exp passed so far. -- >8 -- Here we find ourselves in maybe_check_overriding_exception_spec in a template context where we can't instantiate a dependent noexcept. That's OK, but we have to defer the checking otherwise we give wrong errors. PR c++/113158 gcc/cp/ChangeLog: * search.cc (maybe_check_overriding_exception_spec): Defer checking when a noexcept couldn't be instantiated & evaluated to false/true. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/noexcept83.C: New test. --- gcc/cp/search.cc | 11 ++++++++ gcc/testsuite/g++.dg/cpp0x/noexcept83.C | 37 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept83.C diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc index c948839dc53..827f48e8604 100644 --- a/gcc/cp/search.cc +++ b/gcc/cp/search.cc @@ -1975,6 +1975,17 @@ maybe_check_overriding_exception_spec (tree overrider, tree basefn) || UNPARSED_NOEXCEPT_SPEC_P (over_throw)) return true; + /* We also have to defer checking when we're in a template and couldn't + instantiate & evaluate the noexcept to true/false. */ + if (processing_template_decl) + if ((base_throw + && base_throw != noexcept_true_spec + && base_throw != noexcept_false_spec) + || (over_throw + && over_throw != noexcept_true_spec + && over_throw != noexcept_false_spec)) + return true; + if (!comp_except_specs (base_throw, over_throw, ce_derived)) { auto_diagnostic_group d; diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept83.C b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C new file mode 100644 index 00000000000..47832bbb44d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C @@ -0,0 +1,37 @@ +// PR c++/113158 +// { dg-do compile { target c++11 } } + +template<typename T> +struct V { + static constexpr bool t = false; +}; +struct base { + virtual int f() = 0; +}; + +template<typename T> +struct derived : base { + int f() noexcept(V<T>::t) override; +}; + +struct base2 { + virtual int f() noexcept = 0; +}; + +template<bool B> +struct W { + static constexpr bool t = B; +}; + +template<bool B> +struct derived2 : base2 { + int f() noexcept(W<B>::t) override; // { dg-error "looser exception specification" } +}; + +void +g () +{ + derived<int> d1; + derived2<false> d2; // { dg-message "required from here" } + derived2<true> d3; +} base-commit: cd503b0616462445381a8232fb753239d319af76 -- 2.43.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] c++: wrong looser excep spec for dep noexcept [PR113158] 2024-02-16 22:06 ` [PATCH v3] " Marek Polacek @ 2024-02-17 10:07 ` Jason Merrill 0 siblings, 0 replies; 6+ messages in thread From: Jason Merrill @ 2024-02-17 10:07 UTC (permalink / raw) To: Marek Polacek, Patrick Palka; +Cc: GCC Patches On 2/16/24 17:06, Marek Polacek wrote: > On Fri, Feb 16, 2024 at 04:39:47PM -0500, Patrick Palka wrote: >> On Fri, 16 Feb 2024, Marek Polacek wrote: >>> + /* We also have to defer checking when we're in a template and couldn't >>> + instantiate & evaluate the noexcept to true/false. */ >>> + if (processing_template_decl) >>> + if ((base_throw >>> + && (base_throw != noexcept_true_spec >>> + || base_throw != noexcept_false_spec)) >> >> Shouldn't these innermost || be &&? > > D'oh, yes, what a dumb mistake. But that shows that we could also just > always return true in a template ;). > > Fixed. dg.exp passed so far. OK. > -- >8 -- > Here we find ourselves in maybe_check_overriding_exception_spec in > a template context where we can't instantiate a dependent noexcept. > That's OK, but we have to defer the checking otherwise we give wrong > errors. > > PR c++/113158 > > gcc/cp/ChangeLog: > > * search.cc (maybe_check_overriding_exception_spec): Defer checking > when a noexcept couldn't be instantiated & evaluated to false/true. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp0x/noexcept83.C: New test. > --- > gcc/cp/search.cc | 11 ++++++++ > gcc/testsuite/g++.dg/cpp0x/noexcept83.C | 37 +++++++++++++++++++++++++ > 2 files changed, 48 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept83.C > > diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc > index c948839dc53..827f48e8604 100644 > --- a/gcc/cp/search.cc > +++ b/gcc/cp/search.cc > @@ -1975,6 +1975,17 @@ maybe_check_overriding_exception_spec (tree overrider, tree basefn) > || UNPARSED_NOEXCEPT_SPEC_P (over_throw)) > return true; > > + /* We also have to defer checking when we're in a template and couldn't > + instantiate & evaluate the noexcept to true/false. */ > + if (processing_template_decl) > + if ((base_throw > + && base_throw != noexcept_true_spec > + && base_throw != noexcept_false_spec) > + || (over_throw > + && over_throw != noexcept_true_spec > + && over_throw != noexcept_false_spec)) > + return true; > + > if (!comp_except_specs (base_throw, over_throw, ce_derived)) > { > auto_diagnostic_group d; > diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept83.C b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C > new file mode 100644 > index 00000000000..47832bbb44d > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C > @@ -0,0 +1,37 @@ > +// PR c++/113158 > +// { dg-do compile { target c++11 } } > + > +template<typename T> > +struct V { > + static constexpr bool t = false; > +}; > +struct base { > + virtual int f() = 0; > +}; > + > +template<typename T> > +struct derived : base { > + int f() noexcept(V<T>::t) override; > +}; > + > +struct base2 { > + virtual int f() noexcept = 0; > +}; > + > +template<bool B> > +struct W { > + static constexpr bool t = B; > +}; > + > +template<bool B> > +struct derived2 : base2 { > + int f() noexcept(W<B>::t) override; // { dg-error "looser exception specification" } > +}; > + > +void > +g () > +{ > + derived<int> d1; > + derived2<false> d2; // { dg-message "required from here" } > + derived2<true> d3; > +} > > base-commit: cd503b0616462445381a8232fb753239d319af76 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-17 10:07 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-02-15 22:17 [PATCH] c++: wrong looser excep spec for dep noexcept [PR113158] Marek Polacek 2024-02-16 20:58 ` Jason Merrill 2024-02-16 21:33 ` [PATCH v2] " Marek Polacek 2024-02-16 21:39 ` Patrick Palka 2024-02-16 22:06 ` [PATCH v3] " Marek Polacek 2024-02-17 10:07 ` 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).