re PR c++/13981 (Give message about incomplete class that might be implicitly upcasted.)

/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
This commit is contained in:
Paolo Carlini 2014-05-08 14:30:56 +00:00 committed by Paolo Carlini
parent add0c11114
commit 7e422c4f04
4 changed files with 31 additions and 0 deletions

View 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

View 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;
}

View 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

View File

@ -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" }
}