]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c/67730
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Oct 2015 18:01:50 +0000 (18:01 +0000)
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Oct 2015 18:01:50 +0000 (18:01 +0000)
* c-typeck.c (convert_for_assignment): Use the expansion point
location throughout.

* gcc.dg/pr67730-1.c: New test.
* gcc.dg/pr67730-2.c: New test.
* gcc.dg/pr67730.h: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228408 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr67730-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr67730-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr67730.h [new file with mode: 0644]

index 7c0051f20f63294e40392c455e15120ed4e10ba6..c6eab4ed0fc84030506aced1d05c352e7b0fc8c9 100644 (file)
@@ -1,3 +1,9 @@
+2015-10-02  Marek Polacek  <polacek@redhat.com>
+
+       PR c/67730
+       * c-typeck.c (convert_for_assignment): Use the expansion point
+       location throughout.
+
 2015-10-02  Marek Polacek  <polacek@redhat.com>
 
        PR c/64249
index 11e487c414b530b96d8b6df246a875e6457e2542..ad02d6cfda1a3e0eab7f60e89c76e87a912fa3e3 100644 (file)
@@ -5718,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;
index 8211e03f9437ebef75d4e1c59ed02a77a5512eb8..e671952cdbddae0c0eb7b0ca2f1606370be65e0b 100644 (file)
@@ -1,3 +1,10 @@
+2015-10-02  Marek Polacek  <polacek@redhat.com>
+
+       PR c/67730
+       * gcc.dg/pr67730-1.c: New test.
+       * gcc.dg/pr67730-2.c: New test.
+       * gcc.dg/pr67730.h: New test.
+
 2015-10-02  Marek Polacek  <polacek@redhat.com>
 
        * c-c++-common/Wduplicated-cond-2.c: Skip until PR67819 is resolved.
diff --git a/gcc/testsuite/gcc.dg/pr67730-1.c b/gcc/testsuite/gcc.dg/pr67730-1.c
new file mode 100644 (file)
index 0000000..bb82f6d
--- /dev/null
@@ -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" } */
+}
diff --git a/gcc/testsuite/gcc.dg/pr67730-2.c b/gcc/testsuite/gcc.dg/pr67730-2.c
new file mode 100644 (file)
index 0000000..29d7267
--- /dev/null
@@ -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" } */
+}
diff --git a/gcc/testsuite/gcc.dg/pr67730.h b/gcc/testsuite/gcc.dg/pr67730.h
new file mode 100644 (file)
index 0000000..9a9afc9
--- /dev/null
@@ -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;
+}