s390: -Wpsabi diagnostics for C++14 vs. C++17 ABI incompatibility on s390{,x} [PR94704]
authorJakub Jelinek <jakub@redhat.com>
Tue, 28 Apr 2020 08:26:24 +0000 (10:26 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 28 Apr 2020 08:26:24 +0000 (10:26 +0200)
> We probably have to look into providing a -Wpsabi warning as well.

So like this?

2020-04-28  Jakub Jelinek  <jakub@redhat.com>

PR target/94704
* config/s390/s390.c (s390_function_arg_vector,
s390_function_arg_float): Emit -Wpsabi diagnostics if the ABI changed.

gcc/ChangeLog
gcc/config/s390/s390.c

index fe1ddac16eb35efca1a52cacb71610212af453f5..bb017f2de2b6c713d7e29f914c145905b8e37157 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/94704
+       * config/s390/s390.c (s390_function_arg_vector,
+       s390_function_arg_float): Emit -Wpsabi diagnostics if the ABI changed.
+
 2020-04-28  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR tree-optimization/94727
index e282bb8c666a4c680f15c4a0f298924f6a6475f3..50994bc413ddb12fd2bd42d7d81dad3c73f43911 100644 (file)
@@ -11911,16 +11911,22 @@ s390_function_arg_vector (machine_mode mode, const_tree type)
 
   /* The ABI says that record types with a single member are treated
      just like that member would be.  */
+  bool cxx17_empty_base_seen = false;
   while (TREE_CODE (type) == RECORD_TYPE)
     {
       tree field, single = NULL_TREE;
 
       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
        {
-         if (TREE_CODE (field) != FIELD_DECL
-             || cxx17_empty_base_field_p (field))
+         if (TREE_CODE (field) != FIELD_DECL)
            continue;
 
+         if (cxx17_empty_base_field_p (field))
+           {
+             cxx17_empty_base_seen = true;
+             continue;
+           }
+
          if (single == NULL_TREE)
            single = TREE_TYPE (field);
          else
@@ -11940,7 +11946,22 @@ s390_function_arg_vector (machine_mode mode, const_tree type)
        }
     }
 
-  return VECTOR_TYPE_P (type);
+  if (!VECTOR_TYPE_P (type))
+    return false;
+
+  if (warn_psabi && cxx17_empty_base_seen)
+    {
+      static unsigned last_reported_type_uid;
+      unsigned uid = TYPE_UID (TYPE_MAIN_VARIANT (type));
+      if (uid != last_reported_type_uid)
+       {
+         last_reported_type_uid = uid;
+         inform (input_location, "parameter passing for argument of type "
+                                 "%qT when C++17 is enabled changed to match "
+                                 "C++14 in GCC 10.1", type);
+       }
+    }
+  return true;
 }
 
 /* Return true if a function argument of type TYPE and mode MODE
@@ -11962,15 +11983,20 @@ s390_function_arg_float (machine_mode mode, const_tree type)
 
   /* The ABI says that record types with a single member are treated
      just like that member would be.  */
+  bool cxx17_empty_base_seen = false;
   while (TREE_CODE (type) == RECORD_TYPE)
     {
       tree field, single = NULL_TREE;
 
       for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
        {
-         if (TREE_CODE (field) != FIELD_DECL
-             || cxx17_empty_base_field_p (field))
+         if (TREE_CODE (field) != FIELD_DECL)
            continue;
+         if (cxx17_empty_base_field_p (field))
+           {
+             cxx17_empty_base_seen = true;
+             continue;
+           }
 
          if (single == NULL_TREE)
            single = TREE_TYPE (field);
@@ -11984,7 +12010,23 @@ s390_function_arg_float (machine_mode mode, const_tree type)
        type = single;
     }
 
-  return TREE_CODE (type) == REAL_TYPE;
+  if (TREE_CODE (type) != REAL_TYPE)
+    return false;
+
+  if (warn_psabi && cxx17_empty_base_seen)
+    {
+      static unsigned last_reported_type_uid;
+      unsigned uid = TYPE_UID (TYPE_MAIN_VARIANT (type));
+      if (uid != last_reported_type_uid)
+       {
+         last_reported_type_uid = uid;
+         inform (input_location, "parameter passing for argument of type "
+                                 "%qT when C++17 is enabled changed to match "
+                                 "C++14 in GCC 10.1", type);
+       }
+    }
+
+  return true;
 }
 
 /* Return true if a function argument of type TYPE and mode MODE