> gcc-verify still fails with this version:
>
> > ERR: line should start with a tab: "    PR c++/101783"
> > ERR: line should start with a tab: "    * tree.c 
> > (cp_build_qualified_type_real): Excluding typedef from error"
> > ERR: line should start with a tab: "    PR c++/101783"
> > ERR: line should start with a tab: "    * g++.dg/parse/pr101783.C: New 
> > test."

> It might work better to attach the output of git format-patch.
Sorry for my clumsy copy/paste from git commit message. I now attach
git format-patch output
file as attachment. Also maybe for a little convenience of your work,
I also attach the original
commit message file when I do git commit -F.

> Also, your commit subject line is too long, at 83 characters: It must be
> under 75 characters, and preferably closer to 50.  I might shorten it to

Please go ahead. I will pay attention to this next time. Thank you!

> A change description in the ChangeLog should use present tense
> ("Exclude"), have a period at the end, and line wrap at 75 characters
> like the rest of the commit message.  So,
>
>         * tree.c (cp_build_qualified_type_real): Exclude typedef from
>         error.
>

Modified as suggested.

> > +     ([dcl.type.decltype]),in which case the cv-qualifiers are ignored.
> > +  */
>
> We usually don't put */ on its own line.

Adjusted.

Once again I thank you for your patience and really appreciate it.

On Fri, Oct 1, 2021 at 9:29 AM Jason Merrill via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On 9/30/21 14:24, nick huang wrote:
> >>> You may need to run contrib/gcc-git-customization.sh to get the git
> >>> gcc-verify command.
> > I re-setup and can use git gcc-verify. Now I can see it rejects because I 
> > forgot to add a
> > description of modified file. Now that it passes gcc-verify and I attach 
> > the changelog
> > as attachment.
> >
> > Thank you again for your patient explanation and help!
>
> You're welcome, thanks for your patience as well!  Unfortunately, git
> gcc-verify still fails with this version:
>
> > ERR: line should start with a tab: "    PR c++/101783"
> > ERR: line should start with a tab: "    * tree.c 
> > (cp_build_qualified_type_real): Excluding typedef from error"
> > ERR: line should start with a tab: "    PR c++/101783"
> > ERR: line should start with a tab: "    * g++.dg/parse/pr101783.C: New 
> > test."
>
> It might work better to attach the output of git format-patch.
>
> Also, your commit subject line is too long, at 83 characters: It must be
> under 75 characters, and preferably closer to 50.  I might shorten it to
>
> c++: cv-qualified ref introduced by typedef [PR101783]
>
> >     * tree.c (cp_build_qualified_type_real): Excluding typedef from error
>
> A change description in the ChangeLog should use present tense
> ("Exclude"), have a period at the end, and line wrap at 75 characters
> like the rest of the commit message.  So,
>
>         * tree.c (cp_build_qualified_type_real): Exclude typedef from
>         error.
>
> > +     ([dcl.type.decltype]),in which case the cv-qualifiers are ignored.
> > +  */
>
> We usually don't put */ on its own line.
>
> Jason
>


-- 
nick huang/qingzhe huang
http://www.staroceans.com
http://www.staroceans.com/english.htm
The root cause of this bug is that it considers reference with
cv-qualifiers as an error by generating value for variable "bad_quals".
However, this is not correct for case of typedef. Here I quote spec
[dcl.ref]/1 :
"Cv-qualified references are ill-formed except when the cv-qualifiers
are introduced through the use of a typedef-name ([dcl.typedef],
[temp.param]) or decltype-specifier ([dcl.type.decltype]),
in which case the cv-qualifiers are ignored."

2021-09-30  qingzhe huang  <nickhuan...@hotmail.com>

gcc/cp/ChangeLog:
        PR c++/101783
        * tree.c (cp_build_qualified_type_real): Exclude typedef from 
        error.

gcc/testsuite/ChangeLog:
        PR c++/101783
        * g++.dg/parse/pr101783.C: New test.

From e592a475030d99647de736d294cb3c6a7588af49 Mon Sep 17 00:00:00 2001
From: qingzhe huang <nickhuan...@hotmail.com>
Date: Fri, 1 Oct 2021 10:46:35 -0400
Subject: [PATCH] The root cause of this bug is that it considers reference
 with cv-qualifiers as an error by generating value for variable "bad_quals".
 However, this is not correct for case of typedef. Here I quote spec
 [dcl.ref]/1 : "Cv-qualified references are ill-formed except when the
 cv-qualifiers are introduced through the use of a typedef-name
 ([dcl.typedef], [temp.param]) or decltype-specifier ([dcl.type.decltype]), in
 which case the cv-qualifiers are ignored."

2021-09-30  qingzhe huang  <nickhuan...@hotmail.com>

gcc/cp/ChangeLog:
	PR c++/101783
	* tree.c (cp_build_qualified_type_real): Exclude typedef from
	error.

gcc/testsuite/ChangeLog:
	PR c++/101783
	* g++.dg/parse/pr101783.C: New test.
---
 gcc/cp/tree.c                         | 9 ++++++++-
 gcc/testsuite/g++.dg/parse/pr101783.C | 5 +++++
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/parse/pr101783.C

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 8840932dba2..6a6f8a642cb 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1356,11 +1356,18 @@ cp_build_qualified_type_real (tree type,
   /* A reference or method type shall not be cv-qualified.
      [dcl.ref], [dcl.fct].  This used to be an error, but as of DR 295
      (in CD1) we always ignore extra cv-quals on functions.  */
+
+  /* [dcl.ref/1] Cv-qualified references are ill-formed except when
+     the cv-qualifiers are introduced through the use of a typedef-name
+     ([dcl.typedef], [temp.param]) or decltype-specifier
+     ([dcl.type.decltype]),in which case the cv-qualifiers are
+     ignored.  */
   if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)
       && (TYPE_REF_P (type)
 	  || FUNC_OR_METHOD_TYPE_P (type)))
     {
-      if (TYPE_REF_P (type))
+      if (TYPE_REF_P (type)
+	  && (!typedef_variant_p (type) || FUNC_OR_METHOD_TYPE_P (type)))
 	bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
       type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
     }
diff --git a/gcc/testsuite/g++.dg/parse/pr101783.C b/gcc/testsuite/g++.dg/parse/pr101783.C
new file mode 100644
index 00000000000..4e0a435dd0b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/pr101783.C
@@ -0,0 +1,5 @@
+template<class T> struct A{
+        typedef T& Type;
+};
+template<class T> void f(const typename A<T>::Type){}
+template <> void f<int>(const typename A<int>::Type){}
-- 
2.17.1

Reply via email to