[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2022-02-04 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

Patrick Palka  changed:

   What|Removed |Added

 CC||rs2740 at gmail dot com

--- Comment #12 from Patrick Palka  ---
*** Bug 69778 has been marked as a duplicate of this bug. ***

[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2022-01-28 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

Patrick Palka  changed:

   What|Removed |Added

   Target Milestone|--- |12.0
 Resolution|--- |FIXED
 CC||ppalka at gcc dot gnu.org
 Status|NEW |RESOLVED
   Assignee|unassigned at gcc dot gnu.org  |nickhuang99 at hotmail 
dot com

--- Comment #11 from Patrick Palka  ---
Marking as fixed for GCC 12, thanks for working on this!

[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2021-10-01 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

--- Comment #10 from CVS Commits  ---
The master branch has been updated by Jason Merrill :

https://gcc.gnu.org/g:7c99923f8c544ec07109e8333acb2c2388c38a1b

commit r12-4051-g7c99923f8c544ec07109e8333acb2c2388c38a1b
Author: qingzhe huang 
Date:   Fri Oct 1 10:46:35 2021 -0400

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  

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.

[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2021-08-23 Thread nickhuang99 at hotmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

--- Comment #9 from qingzhe huang  ---
OK, Thank you very much!



From: redi at gcc dot gnu.org 
Sent: August 23, 2021 9:37 AM
To: nickhuan...@hotmail.com 
Subject: [Bug c++/101783] unnecessary error when top level cv qualifier is
dropped

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

--- Comment #8 from Jonathan Wakely  ---
No, I cannot approve compiler patches.

--
You are receiving this mail because:
You reported the bug.
You are on the CC list for the bug.

[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2021-08-23 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

--- Comment #8 from Jonathan Wakely  ---
No, I cannot approve compiler patches.

[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2021-08-23 Thread nickhuang99 at hotmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

--- Comment #7 from qingzhe huang  ---
Jonathan,

Is it possible for you to review and commit my patch?
(https://gcc.gnu.org/pipermail/gcc-patches/2021-August/577040.html).


Thank you!

[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2021-08-09 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

--- Comment #6 from Jonathan Wakely  ---
Please send patches to the mailing list for review, they are likely to get
ignored or forgotten in bugzilla.

https://gcc.gnu.org/contribute.html#patches

[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2021-08-08 Thread nickhuang99 at hotmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

nick huang  changed:

   What|Removed |Added

 CC||nickhuang99 at hotmail dot com

--- Comment #5 from nick huang  ---
Created attachment 51274
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51274&action=edit
suggested fix for PR101783

Here is my suggested fix for this bug. The root cause of this bug is that it
considers reference with cv qualifier as an error by generating value for
variable "bad_quals". However, this is not correct for case of typedef. Here I
quote spec:
"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."

[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2021-08-06 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

--- Comment #4 from Jonathan Wakely  ---
(In reply to nick huang from comment #0)
> The signature of *f* would drop unnecessary const anyway as top-level
> cv qualifier according to spec. So, there is no need to generate error.
> 
> 2. clang gives a warning but still accept it of which I believe appropriate
> (https://www.godbolt.org/z/9qWrj5asq). MSVC accept without complaining
> (https://www.godbolt.org/z/3coqMnjjq).

EDG warns too:

"101783.C", line 8: warning: type qualifiers are meaningless here
  void f(const typename A::Type){}
^

[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2021-08-06 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

--- Comment #3 from Jonathan Wakely  ---
GCC 4.4 and earlier didn't accept it with the typename there:

101783.C:8: error: using 'typename' outside of template
101783.C:8: error: 'const' qualifiers cannot be applied to 'B&'


The typename started to be accepted with r0-94634

re PR c++/22154 ([DR 382] qualified names should allow typename keyword in
front of it (even in non-templates))

2009-07-13  Andrew Pinski

PR C++/22154
* parser.c (cp_parser_elaborated_type_specifier): Accept typename
in
front of qualified names.

2009-07-13  Andrew Pinski  

PR C++/22154
* g++.old-deja/g++.pt/typename10.C: Update for DR 382, typename in
front of qualified names are allowed.
* g++.dg/parse/crash10.C: Likewise.
* g++.dg/parse/error15.C: Likewise.
* g++.dg/parse/typename9.C: Likewise.
* g++.dg/parse/error8.C: Likewise.

From-SVN: r149590

[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2021-08-06 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords|diagnostic  |
   Last reconfirmed||2021-08-06
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW

--- Comment #2 from Jonathan Wakely  ---
Confirmed, doesn't seem to be a regression.

It compiles if you remove the typename:

template struct A{
typedef T& Type;
};
template
void f(const typename A::Type){}
struct B{};
template <>
void f(const A::Type){}

[Bug c++/101783] unnecessary error when top level cv qualifier is dropped

2021-08-05 Thread nickhuang99 at hotmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101783

--- Comment #1 from nick huang  ---
The following snippet of code and error gives more clear the issue.
Considering:

template struct A{
typedef T& Type;
};
template
void f(const typename A::Type){}
struct B{};
template <>
void f(const typename A::Type){}

generates following error:

 error: ‘const’ qualifiers cannot be applied to ‘A::Type {aka B&}’
 void f(const typename A::Type){}
^~~~

This would obviously confuses users about why *const* cannot be applied. Being
unable to apply the *const* to *B&* SHOULD NOT be an error, instead it is
merely a warning to be issued.