PR c++/85464 - missing location for -Wignored-qualifiers diagnostic

Message ID CAH6eHdRXmks=9JrLMnZZF7A6M3E+-SP=ZbmOzyGEwTr_Wn9wbA@mail.gmail.com
State New
Headers show
Series
  • PR c++/85464 - missing location for -Wignored-qualifiers diagnostic
Related show

Commit Message

Jonathan Wakely April 19, 2018, 1:29 p.m.
The fix for PR c++/69733 caused a regression for conversion operators
with redundant cv-qualifiers, changing an incorrect location to an
unknown location. This restores it to the incorrect location (as was
already done on trunk by the fix for PR c++/65775).

Tested x86_64-linux, OK for gcc-7-branch?
commit fc16f7b06d38c34be068b9ae3a4fd8d6095070e5
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Apr 19 12:01:53 2018 +0100

    PR c++/85464 - missing location for -Wignored-qualifiers diagnostic
    
    The fix for PR c++/69733 caused a regression for conversion operators
    with redundant cv-qualifiers, changing an incorrect location to an
    unknown location. This restores it to the incorrect location (as was
    already done on trunk by the fix for PR c++/65775).
    
    gcc/cp:
    
            PR c++/85464 - missing location for -Wignored-qualifiers diagnostic
            * decl.c (grokdeclarator): If declspecs->locations[ds_type_spec]
            is UNKNOWN_LOCATION fall back to input_location.
    
    gcc/testsuite:
    
            PR c++/85464 - missing location for -Wignored-qualifiers diagnostic
            * g++.dg/diagnostic/pr85464.C: New.

Comments

Jakub Jelinek April 19, 2018, 1:37 p.m. | #1
On Thu, Apr 19, 2018 at 02:29:37PM +0100, Jonathan Wakely wrote:
> The fix for PR c++/69733 caused a regression for conversion operators

> with redundant cv-qualifiers, changing an incorrect location to an

> unknown location. This restores it to the incorrect location (as was

> already done on trunk by the fix for PR c++/65775).

> 

> Tested x86_64-linux, OK for gcc-7-branch?


LGTM, though please commit the testcase also to trunk.

> commit fc16f7b06d38c34be068b9ae3a4fd8d6095070e5

> Author: Jonathan Wakely <jwakely@redhat.com>

> Date:   Thu Apr 19 12:01:53 2018 +0100

> 

>     PR c++/85464 - missing location for -Wignored-qualifiers diagnostic

>     

>     The fix for PR c++/69733 caused a regression for conversion operators

>     with redundant cv-qualifiers, changing an incorrect location to an

>     unknown location. This restores it to the incorrect location (as was

>     already done on trunk by the fix for PR c++/65775).

>     

>     gcc/cp:

>     

>             PR c++/85464 - missing location for -Wignored-qualifiers diagnostic

>             * decl.c (grokdeclarator): If declspecs->locations[ds_type_spec]

>             is UNKNOWN_LOCATION fall back to input_location.

>     

>     gcc/testsuite:

>     

>             PR c++/85464 - missing location for -Wignored-qualifiers diagnostic

>             * g++.dg/diagnostic/pr85464.C: New.


	Jakub
Jonathan Wakely April 19, 2018, 1:38 p.m. | #2
On 19 April 2018 at 14:37, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Apr 19, 2018 at 02:29:37PM +0100, Jonathan Wakely wrote:

>> The fix for PR c++/69733 caused a regression for conversion operators

>> with redundant cv-qualifiers, changing an incorrect location to an

>> unknown location. This restores it to the incorrect location (as was

>> already done on trunk by the fix for PR c++/65775).

>>

>> Tested x86_64-linux, OK for gcc-7-branch?

>

> LGTM, though please commit the testcase also to trunk.


Ah yes, I forgot to mention that I planned to do that.


>

>> commit fc16f7b06d38c34be068b9ae3a4fd8d6095070e5

>> Author: Jonathan Wakely <jwakely@redhat.com>

>> Date:   Thu Apr 19 12:01:53 2018 +0100

>>

>>     PR c++/85464 - missing location for -Wignored-qualifiers diagnostic

>>

>>     The fix for PR c++/69733 caused a regression for conversion operators

>>     with redundant cv-qualifiers, changing an incorrect location to an

>>     unknown location. This restores it to the incorrect location (as was

>>     already done on trunk by the fix for PR c++/65775).

>>

>>     gcc/cp:

>>

>>             PR c++/85464 - missing location for -Wignored-qualifiers diagnostic

>>             * decl.c (grokdeclarator): If declspecs->locations[ds_type_spec]

>>             is UNKNOWN_LOCATION fall back to input_location.

>>

>>     gcc/testsuite:

>>

>>             PR c++/85464 - missing location for -Wignored-qualifiers diagnostic

>>             * g++.dg/diagnostic/pr85464.C: New.

>

>         Jakub
Jason Merrill April 19, 2018, 1:42 p.m. | #3
Ok.

On Thu, Apr 19, 2018, 7:38 AM Jonathan Wakely <jwakely.gcc@gmail.com> wrote:

> On 19 April 2018 at 14:37, Jakub Jelinek <jakub@redhat.com> wrote:

> > On Thu, Apr 19, 2018 at 02:29:37PM +0100, Jonathan Wakely wrote:

> >> The fix for PR c++/69733 caused a regression for conversion operators

> >> with redundant cv-qualifiers, changing an incorrect location to an

> >> unknown location. This restores it to the incorrect location (as was

> >> already done on trunk by the fix for PR c++/65775).

> >>

> >> Tested x86_64-linux, OK for gcc-7-branch?

> >

> > LGTM, though please commit the testcase also to trunk.

>

> Ah yes, I forgot to mention that I planned to do that.

>

>

> >

> >> commit fc16f7b06d38c34be068b9ae3a4fd8d6095070e5

> >> Author: Jonathan Wakely <jwakely@redhat.com>

> >> Date:   Thu Apr 19 12:01:53 2018 +0100

> >>

> >>     PR c++/85464 - missing location for -Wignored-qualifiers diagnostic

> >>

> >>     The fix for PR c++/69733 caused a regression for conversion

> operators

> >>     with redundant cv-qualifiers, changing an incorrect location to an

> >>     unknown location. This restores it to the incorrect location (as was

> >>     already done on trunk by the fix for PR c++/65775).

> >>

> >>     gcc/cp:

> >>

> >>             PR c++/85464 - missing location for -Wignored-qualifiers

> diagnostic

> >>             * decl.c (grokdeclarator): If

> declspecs->locations[ds_type_spec]

> >>             is UNKNOWN_LOCATION fall back to input_location.

> >>

> >>     gcc/testsuite:

> >>

> >>             PR c++/85464 - missing location for -Wignored-qualifiers

> diagnostic

> >>             * g++.dg/diagnostic/pr85464.C: New.

> >

> >         Jakub

>

Patch

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5c519146043..9809d06eed8 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10105,6 +10105,8 @@  grokdeclarator (const cp_declarator *declarator,
 						      declspecs->locations);
   if (typespec_loc == UNKNOWN_LOCATION)
     typespec_loc = declspecs->locations[ds_type_spec];
+  if (typespec_loc == UNKNOWN_LOCATION)
+    typespec_loc = input_location;
 
   /* Look inside a declarator for the name being declared
      and get it as a string, for an error message.  */
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr85464.C b/gcc/testsuite/g++.dg/diagnostic/pr85464.C
new file mode 100644
index 00000000000..ee8b65185e5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/pr85464.C
@@ -0,0 +1,5 @@ 
+// { dg-options "-Wignored-qualifiers" }
+struct Test {
+   operator int const(); // { dg-warning "type qualifiers ignored" }
+   operator int const() const; // { dg-warning "type qualifiers ignored" }
+};