public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Handle for loop initial decl with gcc 4.8.5
@ 2021-12-07 15:56 Tom de Vries
  2022-01-03 14:37 ` [pushed][gdb/testsuite] " Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2021-12-07 15:56 UTC (permalink / raw)
  To: gdb-patches

When running test-case gdb.threads/schedlock-thread-exit.exp on a system with
system compiler gcc 4.8.5, I run into:
...
src/gdb/testsuite/gdb.threads/schedlock-thread-exit.c:33:3: error: \
  'for' loop initial declarations are only allowed in C99 mode
...

Fix this by:
- using -std=c99, or
- using -std=gnu99, in case that's required, or
- in the case of the jit test-cases, rewriting the for loops.

Tested on x86_64-linux, both with gcc 4.8.5 and gcc 7.5.0.
---
 gdb/testsuite/gdb.base/inferior-args.exp                  | 3 ++-
 gdb/testsuite/gdb.base/jit-elf-util.h                     | 7 ++++---
 gdb/testsuite/gdb.base/run-attach-while-running.exp       | 3 ++-
 gdb/testsuite/gdb.mi/interrupt-thread-group.exp           | 2 +-
 gdb/testsuite/gdb.python/py-format-string.exp             | 8 +++++++-
 gdb/testsuite/gdb.threads/multiple-successive-infcall.exp | 2 +-
 gdb/testsuite/gdb.threads/schedlock-thread-exit.exp       | 3 ++-
 7 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/gdb.base/inferior-args.exp b/gdb/testsuite/gdb.base/inferior-args.exp
index 0a5346c8aba..c82f8b0681e 100644
--- a/gdb/testsuite/gdb.base/inferior-args.exp
+++ b/gdb/testsuite/gdb.base/inferior-args.exp
@@ -23,7 +23,8 @@ if [target_info exists noargs] then {
 
 standard_testfile .c
 
-if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} {
+if {[build_executable "failed to prepare" $testfile $srcfile \
+	 {debug additional_flags=-std=c99}] == -1} {
     return
 }
 
diff --git a/gdb/testsuite/gdb.base/jit-elf-util.h b/gdb/testsuite/gdb.base/jit-elf-util.h
index b76817d24f7..a2bb45a003e 100644
--- a/gdb/testsuite/gdb.base/jit-elf-util.h
+++ b/gdb/testsuite/gdb.base/jit-elf-util.h
@@ -54,8 +54,8 @@ load_symbol (void *addr, const char *sym_name)
   ElfW (Addr) sym_new_addr = 0;
 
   /* Find `func_name` in symbol_table and return its address.  */
-
-  for (int i = 0; i < ehdr->e_shnum; ++i)
+  int i;
+  for (i = 0; i < ehdr->e_shnum; ++i)
     {
       if (shdr[i].sh_type == SHT_SYMTAB)
 	{
@@ -65,7 +65,8 @@ load_symbol (void *addr, const char *sym_name)
 	  char *const strtab
 	      = (char *) (addr + shdr[shdr[i].sh_link].sh_offset);
 
-	  for (ElfW (Sym) *p = symtab; p < symtab_end; ++p)
+	  ElfW (Sym) *p;
+	  for (p = symtab; p < symtab_end; ++p)
 	    {
 	      const char *s = strtab + p->st_name;
 	      if (strcmp (s, sym_name) == 0)
diff --git a/gdb/testsuite/gdb.base/run-attach-while-running.exp b/gdb/testsuite/gdb.base/run-attach-while-running.exp
index 581fc484997..20eea12a0ca 100644
--- a/gdb/testsuite/gdb.base/run-attach-while-running.exp
+++ b/gdb/testsuite/gdb.base/run-attach-while-running.exp
@@ -106,7 +106,8 @@ proc_with_prefix test { non-stop threaded run-or-attach } {
 }
 
 foreach_with_prefix threaded {0 1} {
-    set options [list debug additional_flags=-DWITH_THREADS=$threaded]
+    set options [list debug additional_flags=-DWITH_THREADS=$threaded \
+		    additional_flags=-std=gnu99]
     if { $threaded } {
 	set binfile $binfile_threads
 	lappend options pthreads
diff --git a/gdb/testsuite/gdb.mi/interrupt-thread-group.exp b/gdb/testsuite/gdb.mi/interrupt-thread-group.exp
index 88da82931cf..ab0ea5a117e 100644
--- a/gdb/testsuite/gdb.mi/interrupt-thread-group.exp
+++ b/gdb/testsuite/gdb.mi/interrupt-thread-group.exp
@@ -24,7 +24,7 @@ set MIFLAGS "-i=mi"
 standard_testfile .c
 
 if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
-	executable debug] != "" } {
+	 executable {debug additional_flags=-std=gnu99}] != "" } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index ea5e958b17d..37e3a3c4946 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -33,7 +33,13 @@ if { [skip_python_tests] } { continue }
 proc build_inferior {exefile lang} {
   global srcdir subdir srcfile testfile hex
 
-  if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${exefile}" executable "debug $lang"] != "" } {
+  set flags [list debug $lang]
+  if { $lang == "c" } {
+    lappend flags additional_flags=-std=c99
+  }
+
+  if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${exefile}" \
+	    executable $flags] != "" } {
       untested "failed to compile in $lang mode"
       return -1
   }
diff --git a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp
index 921c213721f..31268926b35 100644
--- a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp
+++ b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp
@@ -23,7 +23,7 @@ if [get_compiler_info] {
 }
 
 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
-  executable {debug}] != "" } {
+  executable {debug additional_flags=-std=gnu99}] != "" } {
   return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp b/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp
index 818baa781db..4c58fc4955b 100644
--- a/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp
+++ b/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp
@@ -22,7 +22,8 @@
 
 standard_testfile
 
-if { [build_executable "failed to prepare" ${testfile} ${srcfile} {debug pthreads}] } {
+if { [build_executable "failed to prepare" ${testfile} ${srcfile} \
+	  {debug pthreads additional_flags=-std=c99}] } {
     return
 }
 

base-commit: 4281b0c8fcb19325496094491ce1e046a6401a36
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pushed][gdb/testsuite] Handle for loop initial decl with gcc 4.8.5
  2021-12-07 15:56 [PATCH] [gdb/testsuite] Handle for loop initial decl with gcc 4.8.5 Tom de Vries
@ 2022-01-03 14:37 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2022-01-03 14:37 UTC (permalink / raw)
  To: gdb-patches

On 12/7/21 16:56, Tom de Vries via Gdb-patches wrote:
> When running test-case gdb.threads/schedlock-thread-exit.exp on a system with
> system compiler gcc 4.8.5, I run into:
> ...
> src/gdb/testsuite/gdb.threads/schedlock-thread-exit.c:33:3: error: \
>    'for' loop initial declarations are only allowed in C99 mode
> ...
> 
> Fix this by:
> - using -std=c99, or
> - using -std=gnu99, in case that's required, or
> - in the case of the jit test-cases, rewriting the for loops.
> 
> Tested on x86_64-linux, both with gcc 4.8.5 and gcc 7.5.0.

Pushed.

Thanks,
- Tom

> ---
>   gdb/testsuite/gdb.base/inferior-args.exp                  | 3 ++-
>   gdb/testsuite/gdb.base/jit-elf-util.h                     | 7 ++++---
>   gdb/testsuite/gdb.base/run-attach-while-running.exp       | 3 ++-
>   gdb/testsuite/gdb.mi/interrupt-thread-group.exp           | 2 +-
>   gdb/testsuite/gdb.python/py-format-string.exp             | 8 +++++++-
>   gdb/testsuite/gdb.threads/multiple-successive-infcall.exp | 2 +-
>   gdb/testsuite/gdb.threads/schedlock-thread-exit.exp       | 3 ++-
>   7 files changed, 19 insertions(+), 9 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.base/inferior-args.exp b/gdb/testsuite/gdb.base/inferior-args.exp
> index 0a5346c8aba..c82f8b0681e 100644
> --- a/gdb/testsuite/gdb.base/inferior-args.exp
> +++ b/gdb/testsuite/gdb.base/inferior-args.exp
> @@ -23,7 +23,8 @@ if [target_info exists noargs] then {
>   
>   standard_testfile .c
>   
> -if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} {
> +if {[build_executable "failed to prepare" $testfile $srcfile \
> +	 {debug additional_flags=-std=c99}] == -1} {
>       return
>   }
>   
> diff --git a/gdb/testsuite/gdb.base/jit-elf-util.h b/gdb/testsuite/gdb.base/jit-elf-util.h
> index b76817d24f7..a2bb45a003e 100644
> --- a/gdb/testsuite/gdb.base/jit-elf-util.h
> +++ b/gdb/testsuite/gdb.base/jit-elf-util.h
> @@ -54,8 +54,8 @@ load_symbol (void *addr, const char *sym_name)
>     ElfW (Addr) sym_new_addr = 0;
>   
>     /* Find `func_name` in symbol_table and return its address.  */
> -
> -  for (int i = 0; i < ehdr->e_shnum; ++i)
> +  int i;
> +  for (i = 0; i < ehdr->e_shnum; ++i)
>       {
>         if (shdr[i].sh_type == SHT_SYMTAB)
>   	{
> @@ -65,7 +65,8 @@ load_symbol (void *addr, const char *sym_name)
>   	  char *const strtab
>   	      = (char *) (addr + shdr[shdr[i].sh_link].sh_offset);
>   
> -	  for (ElfW (Sym) *p = symtab; p < symtab_end; ++p)
> +	  ElfW (Sym) *p;
> +	  for (p = symtab; p < symtab_end; ++p)
>   	    {
>   	      const char *s = strtab + p->st_name;
>   	      if (strcmp (s, sym_name) == 0)
> diff --git a/gdb/testsuite/gdb.base/run-attach-while-running.exp b/gdb/testsuite/gdb.base/run-attach-while-running.exp
> index 581fc484997..20eea12a0ca 100644
> --- a/gdb/testsuite/gdb.base/run-attach-while-running.exp
> +++ b/gdb/testsuite/gdb.base/run-attach-while-running.exp
> @@ -106,7 +106,8 @@ proc_with_prefix test { non-stop threaded run-or-attach } {
>   }
>   
>   foreach_with_prefix threaded {0 1} {
> -    set options [list debug additional_flags=-DWITH_THREADS=$threaded]
> +    set options [list debug additional_flags=-DWITH_THREADS=$threaded \
> +		    additional_flags=-std=gnu99]
>       if { $threaded } {
>   	set binfile $binfile_threads
>   	lappend options pthreads
> diff --git a/gdb/testsuite/gdb.mi/interrupt-thread-group.exp b/gdb/testsuite/gdb.mi/interrupt-thread-group.exp
> index 88da82931cf..ab0ea5a117e 100644
> --- a/gdb/testsuite/gdb.mi/interrupt-thread-group.exp
> +++ b/gdb/testsuite/gdb.mi/interrupt-thread-group.exp
> @@ -24,7 +24,7 @@ set MIFLAGS "-i=mi"
>   standard_testfile .c
>   
>   if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
> -	executable debug] != "" } {
> +	 executable {debug additional_flags=-std=gnu99}] != "" } {
>       return -1
>   }
>   
> diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
> index ea5e958b17d..37e3a3c4946 100644
> --- a/gdb/testsuite/gdb.python/py-format-string.exp
> +++ b/gdb/testsuite/gdb.python/py-format-string.exp
> @@ -33,7 +33,13 @@ if { [skip_python_tests] } { continue }
>   proc build_inferior {exefile lang} {
>     global srcdir subdir srcfile testfile hex
>   
> -  if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${exefile}" executable "debug $lang"] != "" } {
> +  set flags [list debug $lang]
> +  if { $lang == "c" } {
> +    lappend flags additional_flags=-std=c99
> +  }
> +
> +  if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${exefile}" \
> +	    executable $flags] != "" } {
>         untested "failed to compile in $lang mode"
>         return -1
>     }
> diff --git a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp
> index 921c213721f..31268926b35 100644
> --- a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp
> +++ b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp
> @@ -23,7 +23,7 @@ if [get_compiler_info] {
>   }
>   
>   if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
> -  executable {debug}] != "" } {
> +  executable {debug additional_flags=-std=gnu99}] != "" } {
>     return -1
>   }
>   
> diff --git a/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp b/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp
> index 818baa781db..4c58fc4955b 100644
> --- a/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp
> +++ b/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp
> @@ -22,7 +22,8 @@
>   
>   standard_testfile
>   
> -if { [build_executable "failed to prepare" ${testfile} ${srcfile} {debug pthreads}] } {
> +if { [build_executable "failed to prepare" ${testfile} ${srcfile} \
> +	  {debug pthreads additional_flags=-std=c99}] } {
>       return
>   }
>   
> 
> base-commit: 4281b0c8fcb19325496094491ce1e046a6401a36

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-03 14:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 15:56 [PATCH] [gdb/testsuite] Handle for loop initial decl with gcc 4.8.5 Tom de Vries
2022-01-03 14:37 ` [pushed][gdb/testsuite] " Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).