aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/jit-elf-util.h
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2022-01-03 15:36:36 +0100
committerTom de Vries <tdevries@suse.de>2022-01-03 15:36:36 +0100
commitb19f4f61785c8bf81b6a4a3dada9c446998aad35 (patch)
tree5acb0ba8ac24018102db7808034d28899e465e77 /gdb/testsuite/gdb.base/jit-elf-util.h
parent1eeb0316304f2d4e2c48aa8887e28c936bfe4f4d (diff)
downloadgdb-b19f4f61785c8bf81b6a4a3dada9c446998aad35.zip
gdb-b19f4f61785c8bf81b6a4a3dada9c446998aad35.tar.gz
gdb-b19f4f61785c8bf81b6a4a3dada9c446998aad35.tar.bz2
[gdb/testsuite] Handle for loop initial decl with gcc 4.8.5
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.
Diffstat (limited to 'gdb/testsuite/gdb.base/jit-elf-util.h')
-rw-r--r--gdb/testsuite/gdb.base/jit-elf-util.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/gdb/testsuite/gdb.base/jit-elf-util.h b/gdb/testsuite/gdb.base/jit-elf-util.h
index 80dfd0c..419a781 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)