public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101106] New: [11 regression] =delete on second declaration of the same function produces a note with no error
@ 2021-06-17 11:27 jlegg at feralinteractive dot com
  2021-06-17 11:58 ` [Bug c++/101106] [11/12 " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jlegg at feralinteractive dot com @ 2021-06-17 11:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101106
           Summary: [11 regression] =delete on second declaration of the
                    same function produces a note with no error
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlegg at feralinteractive dot com
  Target Milestone: ---

GCC 10.3 correctly ([dcl.fct.def.delete] paragraph 4) diagnosed a "deleted
definition of 'int f()'" error for:
    int f();
    int f() = delete;

However, GCC 11.1 doesn't emit the error part of the diagnostic, which pointed
at the location of the deleted definition. It still emits a note pointing at
the previous declaration, with no associated error or warning.

This is possibly related to bug 90703. Unlike the example in that bug, this
previously was correctly rejected however.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/101106] [11/12 regression] =delete on second declaration of the same function produces a note with no error
  2021-06-17 11:27 [Bug c++/101106] New: [11 regression] =delete on second declaration of the same function produces a note with no error jlegg at feralinteractive dot com
@ 2021-06-17 11:58 ` rguenth at gcc dot gnu.org
  2021-06-17 12:22 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-17 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.2
            Summary|[11 regression] =delete on  |[11/12 regression] =delete
                   |second declaration of the   |on second declaration of
                   |same function produces a    |the same function produces
                   |note with no error          |a note with no error
           Keywords|                            |diagnostic

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/101106] [11/12 regression] =delete on second declaration of the same function produces a note with no error
  2021-06-17 11:27 [Bug c++/101106] New: [11 regression] =delete on second declaration of the same function produces a note with no error jlegg at feralinteractive dot com
  2021-06-17 11:58 ` [Bug c++/101106] [11/12 " rguenth at gcc dot gnu.org
@ 2021-06-17 12:22 ` redi at gcc dot gnu.org
  2021-06-17 12:25 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-17 12:22 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-06-17
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The note is attached to a pedantic warning, which is not emitted by default.

With -Wpedantic you get:

del.C:2:9: warning: deleted definition of ‘int f()’ is not first declaration
[-Wpedantic]
    2 |     int f() = delete;
      |         ^
del.C:1:9: note: previous declaration of ‘int f()’
    1 |     int f();
      |         ^

The note should only be printed when the pedwarn was printed.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/101106] [11/12 regression] =delete on second declaration of the same function produces a note with no error
  2021-06-17 11:27 [Bug c++/101106] New: [11 regression] =delete on second declaration of the same function produces a note with no error jlegg at feralinteractive dot com
  2021-06-17 11:58 ` [Bug c++/101106] [11/12 " rguenth at gcc dot gnu.org
  2021-06-17 12:22 ` redi at gcc dot gnu.org
@ 2021-06-17 12:25 ` redi at gcc dot gnu.org
  2021-06-17 15:59 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-06-17 12:25 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This was intentionally changed from an error to a pedwarn by r11-1454


    c++: Treat in-class default/delete as definitions.

    We were complaining about a constrained defaulted non-template friend in a
    template class because funcdef_flag wasn't set.  grokdeclarator would set
it
    for default/delete, but grokfield wasn't passing the 'initialized' values
    needed.  Fixing that revealed some errors in existing tests that we weren't
    diagnosing.  Since we accepted them for so long, I'm reducing the error to
a
    pedwarn to ease compiler upgrade.

    gcc/cp/ChangeLog:

            * decl2.c (grokfield): Pass SD_DEFAULTED and SD_DELETED.
            * decl.c (duplicate_decls): Reduce error for delete
            after earlier declaration to pedwarn.

The fix would be:

--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2170,11 +2170,13 @@ duplicate_decls (tree newdecl, tree olddecl, bool
hiding, bool was_hidden)
          if (DECL_DELETED_FN (newdecl))
            {
              auto_diagnostic_group d;
-             pedwarn (newdecl_loc, OPT_Wpedantic,
-                      "deleted definition of %qD is not first declaration",
-                      newdecl);
-             inform (olddecl_loc,
-                     "previous declaration of %qD", olddecl);
+             if (pedwarn (newdecl_loc, OPT_Wpedantic,
+                          "deleted definition of %qD is not first
declaration",
+                          newdecl);
+               {
+                 inform (olddecl_loc,
+                         "previous declaration of %qD", olddecl);
+               }
            }
          DECL_DELETED_FN (newdecl) |= DECL_DELETED_FN (olddecl);
        }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/101106] [11/12 regression] =delete on second declaration of the same function produces a note with no error
  2021-06-17 11:27 [Bug c++/101106] New: [11 regression] =delete on second declaration of the same function produces a note with no error jlegg at feralinteractive dot com
                   ` (2 preceding siblings ...)
  2021-06-17 12:25 ` redi at gcc dot gnu.org
@ 2021-06-17 15:59 ` jakub at gcc dot gnu.org
  2021-06-17 20:40 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-06-17 15:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #2)
> This was intentionally changed from an error to a pedwarn by r11-1454
> 
> 
>     c++: Treat in-class default/delete as definitions.
>     
>     We were complaining about a constrained defaulted non-template friend in
> a
>     template class because funcdef_flag wasn't set.  grokdeclarator would
> set it
>     for default/delete, but grokfield wasn't passing the 'initialized' values
>     needed.  Fixing that revealed some errors in existing tests that we
> weren't
>     diagnosing.  Since we accepted them for so long, I'm reducing the error
> to a
>     pedwarn to ease compiler upgrade.
>     
>     gcc/cp/ChangeLog:
>     
>             * decl2.c (grokfield): Pass SD_DEFAULTED and SD_DELETED.
>             * decl.c (duplicate_decls): Reduce error for delete
>             after earlier declaration to pedwarn.
> 
> The fix would be:
> 
> --- a/gcc/cp/decl.c
> +++ b/gcc/cp/decl.c
> @@ -2170,11 +2170,13 @@ duplicate_decls (tree newdecl, tree olddecl, bool
> hiding, bool was_hidden)
>           if (DECL_DELETED_FN (newdecl))
>             {
>               auto_diagnostic_group d;
> -             pedwarn (newdecl_loc, OPT_Wpedantic,
> -                      "deleted definition of %qD is not first declaration",
> -                      newdecl);
> -             inform (olddecl_loc,
> -                     "previous declaration of %qD", olddecl);
> +             if (pedwarn (newdecl_loc, OPT_Wpedantic,
> +                          "deleted definition of %qD is not first
> declaration",
> +                          newdecl);
> +               {
> +                 inform (olddecl_loc,
> +                         "previous declaration of %qD", olddecl);
> +               }

Except for the {}s around inform, those aren't needed.
Otherwise LGTM (even obvious).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/101106] [11/12 regression] =delete on second declaration of the same function produces a note with no error
  2021-06-17 11:27 [Bug c++/101106] New: [11 regression] =delete on second declaration of the same function produces a note with no error jlegg at feralinteractive dot com
                   ` (3 preceding siblings ...)
  2021-06-17 15:59 ` jakub at gcc dot gnu.org
@ 2021-06-17 20:40 ` cvs-commit at gcc dot gnu.org
  2021-06-21 20:42 ` cvs-commit at gcc dot gnu.org
  2021-06-22  2:16 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-17 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:331e20a69be0d9e7d448580945945d4c7a1e3c0a

commit r12-1602-g331e20a69be0d9e7d448580945945d4c7a1e3c0a
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 17 15:31:15 2021 -0400

    c++: deleted after first declaration [PR101106]

    An explicitly deleted function must be deleted on its first declaration. 
We
    were diagnosing this error only with -Wpedantic, but always giving the
    "previous declaration" note.  This patch removes the -Wpedantic dependency
    and also makes the note depend on the previous diagnostic.

            PR c++/101106

    gcc/cp/ChangeLog:

            * decl.c (duplicate_decls): Make 'deleted after first declaration'
            pedwarn on by default.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/deleted15.C: New test.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/101106] [11/12 regression] =delete on second declaration of the same function produces a note with no error
  2021-06-17 11:27 [Bug c++/101106] New: [11 regression] =delete on second declaration of the same function produces a note with no error jlegg at feralinteractive dot com
                   ` (4 preceding siblings ...)
  2021-06-17 20:40 ` cvs-commit at gcc dot gnu.org
@ 2021-06-21 20:42 ` cvs-commit at gcc dot gnu.org
  2021-06-22  2:16 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-21 20:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:2348a458e156641c5d4b0e998ae0d175196cfd51

commit r11-8629-g2348a458e156641c5d4b0e998ae0d175196cfd51
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 17 15:31:15 2021 -0400

    c++: deleted after first declaration [PR101106]

    An explicitly deleted function must be deleted on its first declaration. 
We
    were diagnosing this error only with -Wpedantic, but always giving the
    "previous declaration" note.  For GCC 11, keep the -Wpedantic dependency,
    just make the note depend on the previous diagnostic.

            PR c++/101106

    gcc/cp/ChangeLog:

            * decl.c (duplicate_decls): Condition note on return value of
pedwarn.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/deleted15.C: New test.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/101106] [11/12 regression] =delete on second declaration of the same function produces a note with no error
  2021-06-17 11:27 [Bug c++/101106] New: [11 regression] =delete on second declaration of the same function produces a note with no error jlegg at feralinteractive dot com
                   ` (5 preceding siblings ...)
  2021-06-21 20:42 ` cvs-commit at gcc dot gnu.org
@ 2021-06-22  2:16 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2021-06-22  2:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11.2/12.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-06-22  2:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 11:27 [Bug c++/101106] New: [11 regression] =delete on second declaration of the same function produces a note with no error jlegg at feralinteractive dot com
2021-06-17 11:58 ` [Bug c++/101106] [11/12 " rguenth at gcc dot gnu.org
2021-06-17 12:22 ` redi at gcc dot gnu.org
2021-06-17 12:25 ` redi at gcc dot gnu.org
2021-06-17 15:59 ` jakub at gcc dot gnu.org
2021-06-17 20:40 ` cvs-commit at gcc dot gnu.org
2021-06-21 20:42 ` cvs-commit at gcc dot gnu.org
2021-06-22  2:16 ` jason at gcc dot gnu.org

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).