Hi,

in this very old issue submitter requested some sort of hint in the diagnostic that the specific problem with the testcase has to do with class type B being incomplete. I think an inform can do.

I feared that we would provide too many "false positives", in the sense that the inform would often not be that useful, depending on the target type, but in fact I tried and it *never* (X) triggers in our whole testsuite, thus I'm not that worried anymore ;)

Tested x86_64-linux.

Thanks,
Paolo.

(X) Without the class type check it would trigger 2 times in g++.old-deja for arrays of unknown bound. I think we don't want those.

////////////////////////
/cp
2013-08-27  Paolo Carlini  <paolo.carl...@oracle.com>

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

/testsuite
2013-08-27  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/13981
        * g++.dg/diagnostic/pr13981.C: New.
Index: cp/typeck.c
===================================================================
--- cp/typeck.c (revision 202020)
+++ cp/typeck.c (working copy)
@@ -7983,6 +7983,11 @@ convert_for_assignment (tree type, tree rhs,
                    default:
                      gcc_unreachable();
                  }
+             if (TYPE_PTR_P (rhstype)
+                 && CLASS_TYPE_P (TREE_TYPE (rhstype))
+                 && !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