diff gcc/testsuite/gcc.dg/param-type-mismatch.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line diff
--- a/gcc/testsuite/gcc.dg/param-type-mismatch.c	Fri Oct 27 22:46:09 2017 +0900
+++ b/gcc/testsuite/gcc.dg/param-type-mismatch.c	Thu Oct 25 07:37:49 2018 +0900
@@ -1,4 +1,4 @@
-/* { dg-options "-fdiagnostics-show-caret" }  */
+/* { dg-options "-fdiagnostics-show-caret -Wpointer-sign" }  */
 
 /* A collection of calls where argument 2 is of the wrong type.  */
 
@@ -12,6 +12,8 @@
   /* { dg-begin-multiline-output "" }
    return callee_1 (first, second, third);
                            ^~~~~~
+                           |
+                           int
      { dg-end-multiline-output "" } */
   /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_1 } */
   /* { dg-begin-multiline-output "" }
@@ -30,6 +32,8 @@
   /* { dg-begin-multiline-output "" }
    return callee_2 (first, second, third);
                            ^~~~~~
+                           |
+                           int
      { dg-end-multiline-output "" } */
   /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_2 } */
   /* { dg-begin-multiline-output "" }
@@ -51,6 +55,8 @@
   /* { dg-begin-multiline-output "" }
    return callee_3 (first, second, third);
                            ^~~~~~
+                           |
+                           int
      { dg-end-multiline-output "" } */
   /* { dg-message "expected 'const char \\*' but argument is of type 'int'" "" { target *-*-* } callee_3 } */
   /* { dg-begin-multiline-output "" }
@@ -69,6 +75,8 @@
   /* { dg-begin-multiline-output "" }
    return callee_4 (first, second, third);
                            ^~~~~~
+                           |
+                           const char *
      { dg-end-multiline-output "" } */
   /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_4 } */
   /* { dg-begin-multiline-output "" }
@@ -87,6 +95,8 @@
   /* { dg-begin-multiline-output "" }
    return callee_5 (first, second, third);
                            ^~~~~~
+                           |
+                           const char *
      { dg-end-multiline-output "" } */
   /* { dg-message "expected 'float' but argument is of type 'const char \\*'" "" { target *-*-* } callee_5 } */
   /* { dg-begin-multiline-output "" }
@@ -105,6 +115,8 @@
   /* { dg-begin-multiline-output "" }
    return callee_6 (first, second, third);
                            ^~~~~~
+                           |
+                           int
      { dg-end-multiline-output "" } */
   /* { dg-message " expected 'int \\(\\*\\)\\(int,  int\\)' but argument is of type 'int'" "" { target *-*-* } callee_6 } */
   /* { dg-begin-multiline-output "" }
@@ -123,6 +135,8 @@
   /* { dg-begin-multiline-output "" }
    return callee_7 (first, second, third);
                            ^~~~~~
+                           |
+                           int
      { dg-end-multiline-output "" } */
   /* { dg-message " expected 'int \\(\\*\\)\\(int,  int\\)' but argument is of type 'int'" "" { target *-*-* } callee_7 } */
   /* { dg-begin-multiline-output "" }
@@ -130,3 +144,43 @@
                                ^~~~~~~~~~~~~~~~~
      { dg-end-multiline-output "" } */
 }
+
+/* -Wincompatible-pointer-types for a parameter.  */
+
+extern int callee_8 (int one, float *two, float (three)); /* { dg-line callee_8 } */
+
+int test_8 (int first, int *second, float third)
+{
+  return callee_8 (first, second, third); /* { dg-warning "passing argument 2 of 'callee_8' from incompatible pointer type" } */
+  /* { dg-begin-multiline-output "" }
+   return callee_8 (first, second, third);
+                           ^~~~~~
+                           |
+                           int *
+     { dg-end-multiline-output "" } */
+  /* { dg-message "expected 'float \\*' but argument is of type 'int \\*'" "" { target *-*-* } callee_8 } */
+  /* { dg-begin-multiline-output "" }
+ extern int callee_8 (int one, float *two, float (three));
+                               ~~~~~~~^~~
+     { dg-end-multiline-output "" } */
+}
+
+/* -Wpointer-sign for a parameter.  */
+
+extern int callee_9 (int one, int *two, float (three)); /* { dg-line callee_9 } */
+
+int test_9 (int first, unsigned int *second, float third)
+{
+  return callee_9 (first, second, third); /* { dg-warning "pointer targets in passing argument 2 of 'callee_9' differ in signedness" } */
+  /* { dg-begin-multiline-output "" }
+   return callee_9 (first, second, third);
+                           ^~~~~~
+                           |
+                           unsigned int *
+     { dg-end-multiline-output "" } */
+  /* { dg-message "expected 'int \\*' but argument is of type 'unsigned int \\*'" "" { target *-*-* } callee_9 } */
+  /* { dg-begin-multiline-output "" }
+ extern int callee_9 (int one, int *two, float (three));
+                               ~~~~~^~~
+     { dg-end-multiline-output "" } */
+}