This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH for c++/86094, wrong calling convention for move-only class


On Wed, Jun 13, 2018 at 5:05 PM, Jason Merrill <jason@redhat.com> wrote:
> On Wed, Jun 13, 2018 at 4:12 PM, Jason Merrill <jason@redhat.com> wrote:
>> On Mon, Jun 11, 2018 at 2:38 PM, Jason Merrill <jason@redhat.com> wrote:
>>> The fix for 80178 was broken, because I forgot that copy_fn_p is false
>>> for move constructors.  As a result, the calling convention for a
>>> class with a trivial move constructor and deleted copy constructor
>>> changed inappropriately.
>>
>> This patch restores the broken behavior to -fabi-version=12 and adds
>> -fabi-version=13 for the fix; people can use -Wabi=12 with GCC 8.2 to
>> check for compatibility issues against 8.1, or -Wabi=11 to check
>> compatibility with GCC 7.
>>
>> Tested x86_64-pc-linux-gnu, applying to trunk and 8.  Do we want to
>> accelerate 8.2 because of this issue?
>
> And one more patch, to suggest -Wabi=11 rather than useless plain -Wabi.

...and another improvement to the warning.

Tested x86_64-pc-linux-gnu, applying to trunk and 8.
commit 3825732dc47c121f0c2d08dfa1993d0cf008ce89
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 14 14:36:20 2018 -0400

            * tree.c (maybe_warn_parm_abi): Inform the location of the class.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 48a0ff37372..a88481db1e0 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -4074,25 +4074,23 @@ maybe_warn_parm_abi (tree t, location_t loc)
   if ((flag_abi_version == 12 || warn_abi_version == 12)
       && classtype_has_non_deleted_move_ctor (t))
     {
+      bool w;
       if (flag_abi_version > 12)
-	warning_at (loc, OPT_Wabi, "-fabi-version=13 (GCC 8.2) fixes the "
-		    "calling convention for %qT, which was accidentally "
-		    "changed in 8.1", t);
+	w = warning_at (loc, OPT_Wabi, "-fabi-version=13 (GCC 8.2) fixes the "
+			"calling convention for %qT, which was accidentally "
+			"changed in 8.1", t);
       else
-	warning_at (loc, OPT_Wabi, "-fabi-version=12 (GCC 8.1) accidentally "
-		    "changes the calling convention for %qT", t);
+	w = warning_at (loc, OPT_Wabi, "-fabi-version=12 (GCC 8.1) accident"
+			"ally changes the calling convention for %qT", t);
+      if (w)
+	inform (location_of (t), " declared here");
       return;
     }
 
-  warning_at (loc, OPT_Wabi, "the calling convention for %qT changes in "
-	      "-fabi-version=13 (GCC 8.2)", t);
-  static bool explained = false;
-  if (!explained)
-    {
-      inform (loc, " because all of its copy and move constructors "
-	      "are deleted");
-      explained = true;
-    }
+  if (warning_at (loc, OPT_Wabi, "the calling convention for %qT changes in "
+		  "-fabi-version=13 (GCC 8.2)", t))
+    inform (location_of (t), " because all of its copy and move "
+	    "constructors are deleted");
 }
 
 /* Returns true iff copying an object of type T (including via move
diff --git a/gcc/testsuite/g++.dg/abi/invisiref2a.C b/gcc/testsuite/g++.dg/abi/invisiref2a.C
index 05330553287..127ee0ae763 100644
--- a/gcc/testsuite/g++.dg/abi/invisiref2a.C
+++ b/gcc/testsuite/g++.dg/abi/invisiref2a.C
@@ -3,7 +3,7 @@
 // { dg-additional-options "-fabi-version=12 -Wabi -fdump-tree-gimple" }
 // { dg-final { scan-tree-dump "struct S &" "gimple" } }
 
-struct S {
+struct S {			// { dg-message "" }
   S(S&&) = default;
   int i;
 };

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]