Hi,

some time ago I worked a bit on this very old diagnostic enhancement issue:

    http://gcc.gnu.org/ml/gcc-patches/2013-08/msg01588.html

and yesterday we got a duplicate. Adding an inform to convert_for_assignment still makes sense to me, thus I resurrected the patch, tightened a bit the check and retested it. What do you think? Should we maybe cover more cases, which?, in the inform?

Thanks,
Paolo.

////////////////////////
/cp
2014-05-08  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/13981
        * typeck.c (convert_for_assignment): Provide an inform for pointers
        to incomplete class types.

/testsuite
2014-05-08  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/13981
        * g++.dg/diagnostic/pr13981.C: New.
Index: cp/typeck.c
===================================================================
--- cp/typeck.c (revision 210205)
+++ cp/typeck.c (working copy)
@@ -8094,6 +8094,13 @@ convert_for_assignment (tree type, tree rhs,
                    default:
                      gcc_unreachable();
                  }
+             if (TYPE_PTR_P (rhstype)
+                 && TYPE_PTR_P (type)
+                 && CLASS_TYPE_P (TREE_TYPE (rhstype))
+                 && CLASS_TYPE_P (TREE_TYPE (type))
+                 && !COMPLETE_TYPE_P (TREE_TYPE (rhstype)))
+               inform (input_location, "class type %qT is incomplete",
+                       TREE_TYPE (rhstype));
            }
          return error_mark_node;
        }
Index: testsuite/g++.dg/diagnostic/pr13981.C
===================================================================
--- testsuite/g++.dg/diagnostic/pr13981.C       (revision 0)
+++ testsuite/g++.dg/diagnostic/pr13981.C       (working copy)
@@ -0,0 +1,12 @@
+// PR c++/13981
+
+struct A {};
+struct B;
+
+void func( A *a );
+
+int main()
+{
+  B *b = 0;
+  func(b);  // { dg-error "cannot convert" }
+}  // { dg-message "is incomplete" "is incomplete" { target *-*-* } 11 }

Reply via email to