diff mbox

[C++] PR 13981 (resend)

Message ID 536B6D92.6010206@oracle.com
State New
Headers show

Commit Message

Paolo Carlini May 8, 2014, 11:42 a.m. UTC
... Manuel suggested to also use DECL_SOURCE_LOCATION, while we are at 
it. Thus I'm retesting the below.

Thanks,
Paolo.

//////////////////

Comments

Jason Merrill May 8, 2014, 1:51 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 210205)
+++ cp/typeck.c	(working copy)
@@ -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: 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;  // { dg-message "is incomplete" }
+
+void func( A *a );
+
+int main()
+{
+  B *b = 0;
+  func(b);  // { dg-error "cannot convert" }
+}