]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/13981 (Give message about incomplete class that might be implicitly upcasted.)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 8 May 2014 14:30:56 +0000 (14:30 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 8 May 2014 14:30:56 +0000 (14:30 +0000)
/cp
2014-05-08  Paolo Carlini  <paolo.carlini@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.carlini@oracle.com>

PR c++/13981
* g++.dg/diagnostic/pr13981.C: New.

From-SVN: r210217

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/diagnostic/pr13981.C [new file with mode: 0644]

index 8a7f18c1169eba73f3c6f2270577b96c54e44e3e..3d400bbb7540717a95da4c8ccabba770112d7341 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/13981
+       * typeck.c (convert_for_assignment): Provide an inform for pointers
+       to incomplete class types.
+
 2014-05-07  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/61083
index 7b28a9a58695b919c89e1cee9a388337ef8c4812..b933b96fc3e53ef93c706cc579cbb45bc45a28dd 100644 (file)
@@ -8094,6 +8094,14 @@ 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 (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL
+                                             (TREE_TYPE (rhstype))),
+                       "class type %qT is incomplete", TREE_TYPE (rhstype));
            }
          return error_mark_node;
        }
index ad7a652e3f9d226a42b7b761bbc2d34d204fac70..ffbec5d2abfacec4e2ca06b37f246cb8e4456223 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/13981
+       * g++.dg/diagnostic/pr13981.C: New.
+
 2014-05-08  Marc Glisse  <marc.glisse@inria.fr>
 
        PR tree-optimization/59100
diff --git a/gcc/testsuite/g++.dg/diagnostic/pr13981.C b/gcc/testsuite/g++.dg/diagnostic/pr13981.C
new file mode 100644 (file)
index 0000000..1b8a028
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/13981
+
+struct A {};
+struct B;  // { dg-message "is incomplete" }
+
+void func( A *a );
+
+int main()
+{
+  B *b = 0;
+  func(b);  // { dg-error "cannot convert" }
+}