Hi Joseph,
Jan-Benedict reported a build-bot error for the nios2 port under 
--enable-werror-always:

options-save.cc: In function 'bool cl_target_option_eq(const cl_target_option*, 
const cl_target_option*)':
options-save.cc:9291:38: error: comparison between two arrays 
[-Werror=array-compare]
 9291 |   if (ptr1->saved_custom_code_status != ptr2->saved_custom_code_status
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
options-save.cc:9291:38: note: use unary '+' which decays operands to pointers 
or '&'component_ref' not supported by dump_decl<declaration error>[0] != 
&'component_ref' not supported by dump_decl<declaration error>[0]' to compare 
the addresses
options-save.cc:9294:37: error: comparison between two arrays 
[-Werror=array-compare]
 9294 |   if (ptr1->saved_custom_code_index != ptr2->saved_custom_code_index
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

This is due to an array-typed TargetSave state in config/nios2/nios2.opt:
...
TargetSave
enum nios2_ccs_code saved_custom_code_status[256]

TargetSave
int saved_custom_code_index[256]
...


This patch adjusts the generated array state compare from 'ptr1->array' into 
'&ptr1->array[0]' in gcc/optc-save-gen.awk,
seems sufficient to pass the tougher checks.

Tested by ensuring the compiler builds, which should be sufficient here.
Okay to commit to mainline?

Thanks,
Chung-Lin

        * optc-save-gen.awk: Adjust array compare to use '&ptr->name[0]'
        instead of 'ptr->name'.
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 233d1fbb637..27aabf2955e 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -1093,7 +1093,7 @@ for (i = 0; i < n_target_array; i++) {
        name = var_target_array[i]
        size = var_target_array_size[i]
        type = var_target_array_type[i]
-       print "  if (ptr1->" name" != ptr2->" name "";
+       print "  if (&ptr1->" name"[0] != &ptr2->" name "[0]";
        print "      || memcmp (ptr1->" name ", ptr2->" name ", " size " * 
sizeof(" type ")))"
        print "    return false;";
 }

Reply via email to