GDB testsuite: Fix warnings with -std=gnu11
authorAndreas Arnez <arnez@linux.vnet.ibm.com>
Tue, 28 Oct 2014 12:39:22 +0000 (12:39 +0000)
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Thu, 13 Nov 2014 09:20:44 +0000 (10:20 +0100)
Since upstream GCC has changed the default C language dialect to
'gnu11', it yields multiple warnings in the GDB testsuite for missing
function return types and implicit function declarations.  This patch
attempts to fix these.

gdb/testsuite/ChangeLog:

* gdb.ada/cond_lang/foo.c (callme): Add return type.
* gdb.base/call-sc.c (zed): Likewise.
* gdb.base/checkpoint.c (main): Likewise.
* gdb.base/dump.c (main): Likewise.
* gdb.base/gcore.c (main): Likewise.
* gdb.base/huge.c (main): Likewise.
* gdb.base/multi-forks.c (main): Likewise.
* gdb.base/pr10179-a.c (main): Likewise.
* gdb.base/savedregs.c (main): Likewise.
* gdb.base/sigaltstack.c (main): Likewise.
* gdb.base/siginfo.c (main): Likewise.
* gdb.base/structs.c (zed): Likewise.
* gdb.mi/mi-stack.c (callee3, callee2, callee1, main): Likewise.
* gdb.mi/mi-syn-frame.c (main): Likewise.
* gdb.mi/until.c (foo, main): Likewise.
* gdb.base/global-var-nested-by-dso.c (b_main, c_main): Declare.
* gdb.base/solib-weak.c (foo): Declare.
* gdb.base/attach-twice.c: Include stdio.h.
* gdb.base/weaklib1.c: Likewise.
* gdb.base/weaklib2.c: Likewise.
* gdb.base/catch-signal-fork.c: Include stdio.h and sys/wait.h.
* gdb.mi/mi-condbreak-call-thr-state-mt.c: Include stdio.h and
unistd.h.
* gdb.base/attach-pie-misread.c: Include stdlib.h.
* gdb.mi/mi-exit-code.c: Likewise.
* gdb.base/break-interp-lib.c: Include string.h.
* gdb.base/coremaker.c: Likewise.
* gdb.base/testenv.c: Likewise.
* gdb.python/py-finish-breakpoint.c: Likewise.
* gdb.base/inferior-died.c: Include sys/wait.h.
* gdb.base/fileio.c: Include time.h.
* gdb.base/async-shell.c: Include unistd.h.
* gdb.base/dprintf-non-stop.c: Likewise.
* gdb.base/info-os.c: Likewise.
* gdb.mi/mi-console.c: Likewise.
* gdb.mi/watch-nonstop.c: Likewise.
* gdb.python/py-events.c: Likewise.
* gdb.base/async.c (baz): Move up before its invocation.
* gdb.base/code_elim2.c (my_global_func): Likewise.
* gdb.base/skip-solib-lib.c (multiply): Likewise.
* gdb.base/advance.c (func2): Likewise.

41 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/cond_lang/foo.c
gdb/testsuite/gdb.base/advance.c
gdb/testsuite/gdb.base/async-shell.c
gdb/testsuite/gdb.base/async.c
gdb/testsuite/gdb.base/attach-pie-misread.c
gdb/testsuite/gdb.base/attach-twice.c
gdb/testsuite/gdb.base/break-interp-lib.c
gdb/testsuite/gdb.base/call-sc.c
gdb/testsuite/gdb.base/catch-signal-fork.c
gdb/testsuite/gdb.base/checkpoint.c
gdb/testsuite/gdb.base/code_elim2.c
gdb/testsuite/gdb.base/coremaker.c
gdb/testsuite/gdb.base/dprintf-non-stop.c
gdb/testsuite/gdb.base/dump.c
gdb/testsuite/gdb.base/fileio.c
gdb/testsuite/gdb.base/gcore.c
gdb/testsuite/gdb.base/global-var-nested-by-dso.c
gdb/testsuite/gdb.base/huge.c
gdb/testsuite/gdb.base/inferior-died.c
gdb/testsuite/gdb.base/info-os.c
gdb/testsuite/gdb.base/multi-forks.c
gdb/testsuite/gdb.base/pr10179-a.c
gdb/testsuite/gdb.base/savedregs.c
gdb/testsuite/gdb.base/sigaltstack.c
gdb/testsuite/gdb.base/siginfo.c
gdb/testsuite/gdb.base/skip-solib-lib.c
gdb/testsuite/gdb.base/solib-weak.c
gdb/testsuite/gdb.base/structs.c
gdb/testsuite/gdb.base/testenv.c
gdb/testsuite/gdb.base/weaklib1.c
gdb/testsuite/gdb.base/weaklib2.c
gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state-mt.c
gdb/testsuite/gdb.mi/mi-console.c
gdb/testsuite/gdb.mi/mi-exit-code.c
gdb/testsuite/gdb.mi/mi-stack.c
gdb/testsuite/gdb.mi/mi-syn-frame.c
gdb/testsuite/gdb.mi/until.c
gdb/testsuite/gdb.mi/watch-nonstop.c
gdb/testsuite/gdb.python/py-events.c
gdb/testsuite/gdb.python/py-finish-breakpoint.c

index a3ee493..405548e 100644 (file)
@@ -1,5 +1,49 @@
 2014-11-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>
 
+       * gdb.ada/cond_lang/foo.c (callme): Add return type.
+       * gdb.base/call-sc.c (zed): Likewise.
+       * gdb.base/checkpoint.c (main): Likewise.
+       * gdb.base/dump.c (main): Likewise.
+       * gdb.base/gcore.c (main): Likewise.
+       * gdb.base/huge.c (main): Likewise.
+       * gdb.base/multi-forks.c (main): Likewise.
+       * gdb.base/pr10179-a.c (main): Likewise.
+       * gdb.base/savedregs.c (main): Likewise.
+       * gdb.base/sigaltstack.c (main): Likewise.
+       * gdb.base/siginfo.c (main): Likewise.
+       * gdb.base/structs.c (zed): Likewise.
+       * gdb.mi/mi-stack.c (callee3, callee2, callee1, main): Likewise.
+       * gdb.mi/mi-syn-frame.c (main): Likewise.
+       * gdb.mi/until.c (foo, main): Likewise.
+       * gdb.base/global-var-nested-by-dso.c (b_main, c_main): Declare.
+       * gdb.base/solib-weak.c (foo): Declare.
+       * gdb.base/attach-twice.c: Include stdio.h.
+       * gdb.base/weaklib1.c: Likewise.
+       * gdb.base/weaklib2.c: Likewise.
+       * gdb.base/catch-signal-fork.c: Include stdio.h and sys/wait.h.
+       * gdb.mi/mi-condbreak-call-thr-state-mt.c: Include stdio.h and
+       unistd.h.
+       * gdb.base/attach-pie-misread.c: Include stdlib.h.
+       * gdb.mi/mi-exit-code.c: Likewise.
+       * gdb.base/break-interp-lib.c: Include string.h.
+       * gdb.base/coremaker.c: Likewise.
+       * gdb.base/testenv.c: Likewise.
+       * gdb.python/py-finish-breakpoint.c: Likewise.
+       * gdb.base/inferior-died.c: Include sys/wait.h.
+       * gdb.base/fileio.c: Include time.h.
+       * gdb.base/async-shell.c: Include unistd.h.
+       * gdb.base/dprintf-non-stop.c: Likewise.
+       * gdb.base/info-os.c: Likewise.
+       * gdb.mi/mi-console.c: Likewise.
+       * gdb.mi/watch-nonstop.c: Likewise.
+       * gdb.python/py-events.c: Likewise.
+       * gdb.base/async.c (baz): Move up before its invocation.
+       * gdb.base/code_elim2.c (my_global_func): Likewise.
+       * gdb.base/skip-solib-lib.c (multiply): Likewise.
+       * gdb.base/advance.c (func2): Likewise.
+
+2014-11-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>
+
        * gdb.base/annota1.c: Remove #ifdef PROTOTYPES, keep prototyped
        variant.
        * gdb.base/annota3.c: Likewise.
index 3861da7..d701f62 100644 (file)
@@ -15,7 +15,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-extern callme (void);
+extern void callme (void);
 
 void
 c_function (void)
index 8066dee..ab86b0e 100644 (file)
@@ -13,15 +13,15 @@ int bar (int y)
   return z;
 }
 
-void func()
+int func2 ()
 {
-  x = x + 5;
-  func2 ();
+  x = 6;
 }
 
-int func2 ()
+void func()
 {
-  x = 6;
+  x = x + 5;
+  func2 ();
 }
 
 int func3 ()
index 3629d77..1b63be1 100644 (file)
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include <unistd.h>
+
 int
 main (void)
 {
index 32779d9..9148b19 100644 (file)
@@ -13,6 +13,12 @@ foo (void)
 }
 
 int
+baz (void)
+{
+  return 5;
+}
+
+int
 main (void)
 {
  int y, z;
@@ -25,10 +31,3 @@ main (void)
  y = baz ();
  return 0; /* until here */
 }
-
-
-int
-baz (void)
-{ 
-  return 5;
-}
index 7de2ad3..08789d0 100644 (file)
@@ -16,6 +16,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 const char stub[] = {
index 74ee332..efe14f0 100644 (file)
@@ -15,6 +15,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/ptrace.h>
index 314dc66..0df2934 100644 (file)
@@ -19,6 +19,7 @@
 #include <unistd.h>
 #include <assert.h>
 #include <stdio.h>
+#include <string.h>
 
 /* Force REL->RELA conversion on i386, see "Prelink", March 4, 2004.  */
 volatile int v[2];
index 56c18da..98c0229 100644 (file)
@@ -46,7 +46,7 @@ void Fun(T foo)
   L = foo;
 }
 
-zed ()
+void zed ()
 {
   L = 'Z';
 }
index 87fe417..5ae83d6 100644 (file)
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+#include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
+#include <sys/wait.h>
 #include <unistd.h>
 
 void
index b6f7ecd..8f9d6da 100644 (file)
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <unistd.h>
 
 long lines = 0;
 
-main()
+int main()
 {
   char linebuf[128];
   FILE *in, *out;
@@ -34,7 +35,7 @@ main()
   if (!in || !out)
     {
       fprintf (stderr, "File open failed\n");
-      exit (1);
+      return 1;
     }
 
   for (i = 0; ; i++)
@@ -55,5 +56,5 @@ main()
   fclose (out);
   printf ("Deleting copy.\n"); /* breakpoint 3 */
   unlink (COPY1_TXT);
-  exit (0);                    /* breakpoint 4 */
+  return 0;                    /* breakpoint 4 */
 }
index 64ecc04..875228a 100644 (file)
@@ -20,15 +20,15 @@ int my_global_symbol = 42;
 static int my_static_symbol;
 
 int
-main ()
-{
-  return my_global_func ();
-}
-
-int
 my_global_func ()
 {
   my_static_symbol = my_global_symbol;
   my_global_symbol = my_static_symbol + my_global_symbol;
   return my_global_symbol;
 }
+
+int
+main ()
+{
+  return my_global_func ();
+}
index f05a111..22c1442 100644 (file)
@@ -25,6 +25,7 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <string.h>
 
 #ifndef __STDC__
 #define        const   /**/
index 23c55fa..c7eeca9 100644 (file)
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include <unistd.h>
+
 void
 foo ()
 {
index bc68778..bdcafbf 100644 (file)
@@ -27,6 +27,7 @@ zero_all ()
   memset ((char *) &intstruct2, 0, sizeof (intstruct2));
 }
 
+int
 main()
 {
   int i;
@@ -43,4 +44,5 @@ main()
   intstruct.g = 12 * 7;
 
   checkpoint1 ();
+  return 0;
 }
index 29c32e0..e443173 100644 (file)
@@ -9,6 +9,7 @@
 #include <errno.h>
 #include <sys/wait.h>
 #include <unistd.h>
+#include <time.h>
 /* TESTS :
  * - open(const char *pathname, int flags, mode_t mode);
 1) Attempt to create file that already exists - EEXIST
index ee826a5..f74516d 100644 (file)
@@ -58,6 +58,7 @@ int factorial_func (int value)
   return (value);
 }
 
+int
 main()
 {
   factorial_func (6);
index 3b63096..a77b8c2 100644 (file)
@@ -15,6 +15,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+extern void b_main (void);
+extern void c_main (void);
+
 int
 main (int argc, char *argv[])
 {
index 27ba04e..57727e9 100644 (file)
@@ -12,6 +12,7 @@
 #endif
 static int a[CRASH_GDB], b[CRASH_GDB];
 
+int
 main()
 {
   memcpy (a, b, sizeof (a));
index 5c4c5b2..bb635c0 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <stdlib.h>
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <unistd.h>
 
 void function(void)
index 1a52348..23257d4 100644 (file)
@@ -22,6 +22,7 @@
 #include <pthread.h>
 #include <arpa/inet.h>
 #include <sys/socket.h>
+#include <unistd.h>
 
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
index c090c57..bbe06c3 100644 (file)
@@ -22,6 +22,7 @@
 
 pid_t pids[4];
 
+int
 main()
 {
   int i;
@@ -32,5 +33,5 @@ main()
   printf ("%d ready\n", getpid ());
   sleep (2);
   printf ("%d done\n", getpid ());
-  exit (0);    /* Set exit breakpoint here.  */
+  return 0;    /* Set exit breakpoint here.  */
 }
index b886787..7b93b9b 100644 (file)
@@ -61,9 +61,11 @@ thrower (void)
 
 }
 
+int
 main ()
 {
   signal (SIGILL, catcher);
   signal (SIGSEGV, catcher);
   thrower ();
+  return 0;
 }
index 338501b..2ee1b1d 100644 (file)
@@ -72,6 +72,7 @@ catcher (int signal)
 }
 
 
+int
 main ()
 {
   /* Set up the altstack.  */
@@ -90,4 +91,5 @@ main ()
   }
   level = MAIN;
   catcher (0);
+  return 0;
 }
index 518083c..041102f 100644 (file)
@@ -38,6 +38,7 @@ handler (int sig)
 } /* handler */
 #endif
 
+int
 main ()
 {
   /* Set up the signal handler.  */
index 792cd01..b2c4d86 100644 (file)
@@ -1,11 +1,11 @@
 /* Simple shared library */
 
-int square(int num)
+int multiply(int a, int b)
 {
-  return multiply(num, num);
+  return a * b;
 }
 
-int multiply(int a, int b)
+int square(int num)
 {
-  return a * b;
+  return multiply(num, num);
 }
index f54ea3d..c1ee8d4 100644 (file)
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+extern void foo (void);
+
 int
 main()
 {
index 1fb4250..1f45239 100644 (file)
@@ -266,6 +266,7 @@ void Fun18(struct struct18 foo18)
   L18 = foo18; 
 }
 
+void
 zed ()
 {
 
index ef8035a..3eb9dd4 100644 (file)
@@ -22,6 +22,7 @@
     inferior environment list.  */
 
 #include <stdio.h>
+#include <string.h>
 
 int main (int argc, char **argv, char **envp)
 
index 95360ac..8782be1 100644 (file)
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include <stdio.h>
+
 void __attribute__((weak))
 bar (void)
 {
index ecd8321..b6458c0 100644 (file)
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include <stdio.h>
+
 void bar (void);
 void
 foo (void)
index e9ca92d..a466c54 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <stdlib.h>
 #include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
 
 extern int test (void);
 
index 0cd2243..5ca046f 100644 (file)
@@ -1,3 +1,5 @@
+#include <unistd.h>
+
 void
 hello ()
 {
index df711a6..47bf15c 100644 (file)
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see http://www.gnu.org/licenses/>.  */
 
+#include <stdlib.h>
+
 int exit_code = 0;
 
 int
index 5f2452c..d41f9a0 100644 (file)
@@ -32,22 +32,23 @@ int callee4 (void)
   C = A + B;
   return 0;
 }
-callee3 (char *strarg)
+
+void callee3 (char *strarg)
 {
   callee4 ();
 }
 
-callee2 (int intarg, char *strarg)
+void callee2 (int intarg, char *strarg)
 {
   callee3 (strarg);
 }
 
-callee1 (int intarg, char *strarg, double fltarg)
+void callee1 (int intarg, char *strarg, double fltarg)
 {
   callee2 (intarg, strarg);
 }
 
-main ()
+int main ()
 {
   callee1 (2, "A string argument.", 3.5);
   callee1 (2, "A string argument.", 3.5);
index 332f246..c260112 100644 (file)
@@ -9,12 +9,14 @@ void subroutine (int);
 void handler (int);
 void have_a_very_merry_interrupt (void);
 
+int
 main ()
 {
   foo ();   /* Put a breakpoint on foo() and call it to see a dummy frame */
 
 
   have_a_very_merry_interrupt ();
+  return 0;
 }
 
 void
index df4a68d..21bdeda 100644 (file)
@@ -1,3 +1,4 @@
+void
 foo (void)
 {
  int i, x, y, z;
@@ -17,6 +18,7 @@ foo (void)
  y = 10;
 }
 
+int
 main ()
 {
   int a = 1;
index 3f8a18c..ea4406b 100644 (file)
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include <unistd.h>
+
 int global;
 
 int main ()
index 17e9f21..2dabdbd 100644 (file)
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see  <http://www.gnu.org/licenses/>.  */
 
+#include <unistd.h>
+
 extern void do_nothing (void);
 
 int second(){
index 0eda8b9..5c8663a 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <setjmp.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 /* Defined in py-events-shlib.h.  */