public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nickhuang99 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/51851] [core/1001] Overriding a function with a parameter of dependent type fails to override.
Date: Mon, 23 Aug 2021 14:10:37 +0000	[thread overview]
Message-ID: <bug-51851-4-0CU7eDTDPi@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-51851-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51851

--- Comment #7 from qingzhe huang <nickhuang99 at hotmail dot com> ---
Thank you for clarifications!

I just found a solution for this 10-year-old issue and preparing a patch.
However, the solution is not able to solve more complicated cases which
requires more work.
This issue is so complicated and I am hesitating to file more complicated bugs
which this patch won't work because it requires improvement work of function
*resolve_typename_type* to handle recursive case correctly.



diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 3414cbdc876..db0d43b2b08 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -14493,7 +14493,16 @@ grokparms (tree parmlist, tree *parms)

          /* Top-level qualifiers on the parameters are
             ignored for function types.  */
-         type = cp_build_qualified_type (type, 0);
+         int type_quals = 0;
+         /* Top-level qualifiers are reserved for array type. PR101783 */
+         if (TREE_CODE (type) == TYPENAME_TYPE)
+         {
+            tree resolved_type = resolve_typename_type(type, false);
+            if (resolved_type && TREE_CODE(resolved_type) == ARRAY_TYPE)
+               type_quals = CP_TYPE_CONST_P(type);
+         }
+         type = cp_build_qualified_type (type, type_quals);
+
          if (TREE_CODE (type) == METHOD_TYPE)
            {
              error ("parameter %qD invalidly declared method type", decl);

  parent reply	other threads:[~2021-08-23 14:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-13 19:13 [Bug c++/51851] New: " ville.voutilainen at gmail dot com
2012-01-13 20:07 ` [Bug c++/51851] " ville.voutilainen at gmail dot com
2012-01-13 21:12 ` jason at gcc dot gnu.org
2021-07-12 16:57 ` [Bug c++/51851] [core/1001] " mpolacek at gcc dot gnu.org
2021-08-23 12:31 ` nickhuang99 at hotmail dot com
2021-08-23 13:41 ` redi at gcc dot gnu.org
2021-08-23 13:43 ` redi at gcc dot gnu.org
2021-08-23 14:10 ` nickhuang99 at hotmail dot com [this message]
2021-10-15 21:00 ` cvs-commit at gcc dot gnu.org

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=bug-51851-4-0CU7eDTDPi@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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: link
Be 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).