public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9704] c++: member alias declaration [PR103968] Date: Mon, 28 Mar 2022 19:12:57 +0000 (GMT) [thread overview] Message-ID: <20220328191257.71AB63858407@sourceware.org> (raw) https://gcc.gnu.org/g:97390a9914672f5ce73c169b3ae7fd4bba25c2fe commit r11-9704-g97390a9914672f5ce73c169b3ae7fd4bba25c2fe Author: Jason Merrill <jason@redhat.com> Date: Sun Mar 27 00:28:30 2022 -0400 c++: member alias declaration [PR103968] Here, we were wrongly thinking that (const Options&)Widget<T>::c_options is not value-dependent because neither the type nor the (value of) c_options are dependent, but since we're binding it to a reference we also need to consider that it has a value-dependent address. PR c++/103968 gcc/cp/ChangeLog: * pt.c (value_dependent_expression_p): Check has_value_dependent_address for conversion to reference. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/alias-decl-mem1.C: New test. Diff: --- gcc/cp/pt.c | 4 ++++ gcc/testsuite/g++.dg/cpp0x/alias-decl-mem1.C | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1493019bd27..b80d3d13600 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -26987,6 +26987,10 @@ value_dependent_expression_p (tree expression) if (TREE_CODE (expression) == TREE_LIST) return any_value_dependent_elements_p (expression); + if (TREE_CODE (type) == REFERENCE_TYPE + && has_value_dependent_address (expression)) + return true; + return value_dependent_expression_p (expression); } diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-mem1.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-mem1.C new file mode 100644 index 00000000000..3e422de4054 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-mem1.C @@ -0,0 +1,20 @@ +// PR c++/103968 +// { dg-do compile { target c++11 } } + +template <typename Opt, Opt const& options> +struct trait +{ + template <typename T> + struct NonInstantiated{}; +}; + +struct Options {}; + +template <typename T> +struct Widget +{ + static constexpr auto c_options = Options{}; + using Trait = trait<decltype(c_options), c_options>; +}; + +Widget<int>::Trait b{}; // Crashes GCC > 10.3
reply other threads:[~2022-03-28 19:12 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220328191257.71AB63858407@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).