Commit 7e422c4f by Paolo Carlini Committed by Paolo Carlini

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
parent add0c111
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> 2014-05-07 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/61083 PR c++/61083
......
...@@ -8094,6 +8094,14 @@ convert_for_assignment (tree type, tree rhs, ...@@ -8094,6 +8094,14 @@ convert_for_assignment (tree type, tree rhs,
default: default:
gcc_unreachable(); 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; return error_mark_node;
} }
......
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> 2014-05-08 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/59100 PR tree-optimization/59100
......
// 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" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment