colis-anr / morbig

A static parser for POSIX Shell
Other
190 stars 8 forks source link

Warnings when compiling cstubs.c #129

Closed treinen closed 3 years ago

treinen commented 3 years ago

I get a bunch of annoying compiler warnings in the file cstubs.c:

 stub.c: In function ‘parse_file’:
cstub.c:31:13: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   31 |     closure = caml_named_value ("untyped_parse_file");
      |             ^
cstub.c:35:15: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   35 |     error_msg = String_val (Field (result, 1));
      |               ^
cstub.c: In function ‘dispose_cst’:
cstub.c:50:13: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   50 |     closure = caml_named_value ("dispose_cst");
      |             ^
In file included from cstub.c:17:
cstub.c: In function ‘get_filename_of_position’:
/usr/lib/ocaml/caml/mlvalues.h:265:24: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  265 | #define String_val(x) ((const char *) Bp_val(x))
      |                       ~^~~~~~~~~~~~~~~~~~~~~~~~~
cstub.c:94:10: note: in expansion of macro ‘String_val’
   94 |   return String_val (Field (p, 0));
      |          ^~~~~~~~~~
cstub.c: In function ‘get_rule_name’:
/usr/lib/ocaml/caml/mlvalues.h:265:24: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  265 | #define String_val(x) ((const char *) Bp_val(x))
      |                       ~^~~~~~~~~~~~~~~~~~~~~~~~~
cstub.c:118:10: note: in expansion of macro ‘String_val’
  118 |   return String_val (Field (cst, 0));
      |          ^~~~~~~~~~
cstub.c: In function ‘get_data’:
/usr/lib/ocaml/caml/mlvalues.h:265:24: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  265 | #define String_val(x) ((const char *) Bp_val(x))
      |                       ~^~~~~~~~~~~~~~~~~~~~~~~~~
cstub.c:140:10: note: in expansion of macro ‘String_val’
  140 |   return String_val (Field (cst, 0));
      |          ^~~~~~~~~~

-Ralf

Niols commented 3 years ago

I can confirm that I get the same warnings on various versions on the OCaml compiler and of Morbig. They all seem to be related to the macros that handle conversion from OCaml values to C (or the other direction).

treinen commented 3 years ago

I should have said that I am using ocaml 4.11.1 (the version that is going to be released with debian/bullseye). -Ralf.