c++: cv-qualified ref introduced by typedef [PR101783]
authorqingzhe huang <nickhuang99@hotmail.com>
Fri, 1 Oct 2021 14:46:35 +0000 (10:46 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 1 Oct 2021 15:44:47 +0000 (11:44 -0400)
commit7c99923f8c544ec07109e8333acb2c2388c38a1b
tree419bf8cdb8be6ccc0bcdca6911e692c2e23c0a7f
parent17374dab3eefd282977ad90743c9aff97f2e41ce
c++: cv-qualified ref introduced by typedef [PR101783]

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  <nickhuang99@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
gcc/testsuite/g++.dg/parse/pr101783.C [new file with mode: 0644]