@@ -5708,6 +5718,10 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type,
tree rname = NULL_TREE;
bool objc_ok = false;
+ /* Use the expansion point location to handle cases such as user's
+ function returning a wrong-type macro defined in a system header. */
+ location = expansion_point_location_if_in_system_header (location);
+
if (errtype == ic_argpass)
{
tree selector;
@@ -0,0 +1,16 @@
+/* PR c/67730 */
+/* { dg-do compile } */
+/* { dg-options "-Wc++-compat" } */
+
+#include "pr67730.h"
+
+extern void bar (unsigned char *);
+
+unsigned char *
+f (void *p)
+{
+ unsigned char *uc = ONEP; /* { dg-warning "request for implicit conversion" } */
+ uc = ONEP; /* { dg-warning "request for implicit conversion" } */
+ bar (ONEP); /* { dg-warning "request for implicit conversion" } */
+ return ONEP; /* { dg-warning "request for implicit conversion" } */
+}
@@ -0,0 +1,22 @@
+/* PR c/67730 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+#include "pr67730.h"
+
+extern void bar (int);
+
+int
+fn1 (void)
+{
+ int a = NULL; /* { dg-warning "initialization makes integer from pointer" } */
+ a = NULL; /* { dg-warning "assignment makes integer from pointer" } */
+ bar (NULL); /* { dg-warning "passing argument 1" } */
+ return NULL; /* { dg-warning "return makes integer from pointer" } */
+}
+
+int
+fn2 (void)
+{
+ RETURN; /* { dg-warning "return makes integer from pointer" } */
+}
@@ -0,0 +1,32 @@
+#pragma GCC system_header
+#define NULL (void *) 0
+#define ONEP (void *) 1
+#define RETURN return NULL
+
+extern void sysbar (unsigned char *);
+
+unsigned char *
+sysfn1 (void *p)
+{
+ unsigned char *uc = ONEP;
+ uc = ONEP;
+ sysbar (ONEP);
+ return ONEP;
+}
+
+extern void sysbar2 (int);
+
+int
+sysfn2 (void)
+{
+ int a = NULL;
+ a = NULL;
+ sysbar2 (NULL);
+ return NULL;
+}
+
+int
+sysfn3 (void)
+{
+ RETURN;
+}