Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,14 @@ for flag in '-Wimplicit-fallthrough=5' '-Wimplicit-fallthrough'; do
[cc_warnings="$cc_warnings $flag"; break], [], [$warn_error_flag])
done

# Use -Wsuggest-attribute=attribute_name if supported
# Don't apply pure to primitives. const has some false-positive suggestions.
for attribute_name in noreturn malloc format; do
AX_CHECK_COMPILE_FLAG([-Wsuggest-attribute=$attribute_name],
[cc_warnings="$cc_warnings -Wsuggest-attribute=$attribute_name"], [],
[$warn_error_flag])
done

AS_CASE([$enable_warn_error,OCAML__DEVELOPMENT_VERSION],
[yes,*|,true],
[cc_warnings="$cc_warnings $warn_error_flag"])
Expand Down
1 change: 1 addition & 0 deletions ocamltest/run.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
typedef char_os **array;

typedef void Logger(void *, const char *, va_list ap);
#define Logger CAMLformat(__printf__, 2, 0) Logger

typedef struct {
char_os *program;
Expand Down
3 changes: 3 additions & 0 deletions ocamltest/run_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ static int is_defined(const char_os *str)
return (str != NULL) && (*str != 0);
}

CAMLformat(__printf__, 2, 0)
static void defaultLogger(void *where, const char *format, va_list ap)
{
vfprintf(stderr, format, ap);
}

CAMLformat(__printf__, 3, 4)
static void mylog(Logger *logger, void *loggerData, const char *fmt, ...)
{
va_list ap;
Expand All @@ -38,6 +40,7 @@ static void mylog(Logger *logger, void *loggerData, const char *fmt, ...)
va_end(ap);
}

CAMLformat(__printf__, 4, 5)
static void error_with_location(
const char *file, int line,
const command_settings *settings,
Expand Down
1 change: 1 addition & 0 deletions ocamltest/run_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static void free_cstringvect(array v)
caml_stat_free(v);
}

CAMLformat(__printf__, 2, 0)
static void logToChannel(void *voidchannel, const char *fmt, va_list ap)
{
struct channel *channel = (struct channel *) voidchannel;
Expand Down
2 changes: 1 addition & 1 deletion ocamltest/run_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ error_with_location(__FILE__, __LINE__, settings, msg, ## __VA_ARGS__)
For a more portable (but also more complex) solution, see
http://stackoverflow.com/questions/20818800/variadic-macro-and-trailing-comma
*/

CAMLformat(__printf__, 4, 5)
static void myperror_with_location(
const char *file, int line,
const command_settings *settings,
Expand Down
4 changes: 1 addition & 3 deletions otherlibs/unix/execv.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <caml/osdeps.h>
#include "caml/unixsupport.h"

CAMLprim value caml_unix_execv(value path, value args)
CAMLnoret CAMLprim void caml_unix_execv(value path, value args)
{
char_os * wpath;
char_os ** argv;
Expand All @@ -31,6 +31,4 @@ CAMLprim value caml_unix_execv(value path, value args)
caml_stat_free(wpath);
caml_unix_cstringvect_free(argv);
caml_uerror("execv", path);
return Val_unit; /* never reached, but suppress warnings */
/* from smart compilers */
}
4 changes: 1 addition & 3 deletions otherlibs/unix/execve.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <caml/osdeps.h>
#include "caml/unixsupport.h"

CAMLprim value caml_unix_execve(value path, value args, value env)
CAMLnoret CAMLprim void caml_unix_execve(value path, value args, value env)
{
char_os ** argv;
char_os ** envp;
Expand All @@ -34,6 +34,4 @@ CAMLprim value caml_unix_execve(value path, value args, value env)
caml_unix_cstringvect_free(argv);
caml_unix_cstringvect_free(envp);
caml_uerror("execve", path);
return Val_unit; /* never reached, but suppress warnings */
/* from smart compilers */
}
8 changes: 2 additions & 6 deletions otherlibs/unix/execvp.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <caml/osdeps.h>
#include "caml/unixsupport.h"

CAMLprim value caml_unix_execvp(value path, value args)
CAMLnoret CAMLprim void caml_unix_execvp(value path, value args)
{
char_os ** argv;
char_os * wpath;
Expand All @@ -33,8 +33,6 @@ CAMLprim value caml_unix_execvp(value path, value args)
caml_stat_free(wpath);
caml_unix_cstringvect_free(argv);
caml_uerror("execvp", path);
return Val_unit; /* never reached, but suppress warnings */
/* from smart compilers */
}

#ifndef HAS_EXECVPE
Expand All @@ -43,7 +41,7 @@ int caml_unix_execvpe_emulation(const char * name,
char * const envp[]);
#endif

CAMLprim value caml_unix_execvpe(value path, value args, value env)
CAMLnoret CAMLprim void caml_unix_execvpe(value path, value args, value env)
{
char_os ** argv;
char_os ** envp;
Expand All @@ -63,8 +61,6 @@ CAMLprim value caml_unix_execvpe(value path, value args, value env)
caml_unix_cstringvect_free(argv);
caml_unix_cstringvect_free(envp);
caml_unix_error(err, "execvpe", path);
return Val_unit; /* never reached, but suppress warnings */
/* from smart compilers */
}

#ifndef HAS_EXECVPE
Expand Down
4 changes: 1 addition & 3 deletions otherlibs/unix/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include <caml/mlvalues.h>
#include "caml/unixsupport.h"

CAMLprim value caml_unix_exit(value n)
CAMLnoret CAMLprim void caml_unix_exit(value n)
{
_exit(Int_val(n));
return Val_unit; /* never reached, but suppress warnings */
/* from smart compilers */
}
3 changes: 2 additions & 1 deletion runtime/caml/addrmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ value caml_addrmap_lookup(struct addrmap* t, value k);
#define ADDRMAP_NOT_PRESENT ((value)(0))
#define ADDRMAP_INVALID_KEY ((value)(0))

value* caml_addrmap_insert_pos(struct addrmap* t, value k);
value* caml_addrmap_insert_pos(struct addrmap* t, value k)
CAMLreturns_nonnull;

/* must not already be present */
void caml_addrmap_insert(struct addrmap* t, value k, value v);
Expand Down
5 changes: 1 addition & 4 deletions runtime/caml/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ CAMLextern value caml_copy_nativeint (intnat); /* defined in [ints.c] */
CAMLextern value caml_alloc_array (value (*funct) (char const *),
char const * const * array);
CAMLextern value caml_alloc_sprintf(const char * format, ...)
#if __has_attribute(format) || defined(__GNUC__)
__attribute__ ((format (printf, 1, 2)))
#endif
;
CAMLformat(__printf__, 1, 2);
CAMLextern value caml_alloc_some(value);

typedef void (*final_fun)(value);
Expand Down
3 changes: 2 additions & 1 deletion runtime/caml/custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ CAMLextern mlsize_t caml_custom_get_max_major (void);
extern struct custom_operations *
caml_find_custom_operations(const char * ident);
extern struct custom_operations *
caml_final_custom_operations(void (*fn)(value));
caml_final_custom_operations(void (*fn)(value))
CAMLreturns_nonnull;

extern void caml_init_custom_operations(void);

Expand Down
7 changes: 6 additions & 1 deletion runtime/caml/debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ void caml_debugger_init (void);
void caml_debugger (enum event_kind event, value param);
CAMLextern void caml_debugger_cleanup_fork (void);

opcode_t caml_debugger_saved_instruction(code_t pc);
#if !defined(HAS_SOCKETS) || defined(NATIVE_CODE)
CAMLnoret void
#else
opcode_t
#endif
caml_debugger_saved_instruction(code_t pc);

/* Communication protocol */

Expand Down
2 changes: 1 addition & 1 deletion runtime/caml/domain_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ enum {
#define Caml_state_opt caml_state
#else
#if __has_attribute(pure) || defined(__GNUC__)
__attribute__((pure))
__attribute__((__pure__))
#endif
CAMLextern caml_domain_state* caml_get_domain_state(void);
#define Caml_state_opt (caml_get_domain_state())
Expand Down
3 changes: 2 additions & 1 deletion runtime/caml/dynlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ extern void caml_free_shared_libs(void);
/* If found, parse $OCAMLLIB/ld.conf, $CAMLLIB/ld.conf and stdlib/ld.conf in
that order and add the lines read to table. */
extern char_os * caml_parse_ld_conf(const char_os * stdlib,
struct ext_table * table);
struct ext_table * table)
CAMLreturns_nonnull;

#endif /* CAML_INTERNALS */

Expand Down
4 changes: 2 additions & 2 deletions runtime/caml/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ enum {
/* Creating and closing channels from C */

CAMLextern void caml_close_channel (struct channel *);
CAMLalloc(caml_close_channel, 1) CAMLreturns_nonnull()
CAMLalloc(caml_close_channel, 1) CAMLreturns_nonnull
CAMLextern struct channel * caml_open_descriptor_in (int);
CAMLalloc(caml_close_channel, 1) CAMLreturns_nonnull()
CAMLalloc(caml_close_channel, 1) CAMLreturns_nonnull
CAMLextern struct channel * caml_open_descriptor_out (int);
CAMLextern file_offset caml_channel_size (struct channel *);
CAMLextern void caml_seek_in (struct channel *, file_offset);
Expand Down
16 changes: 8 additions & 8 deletions runtime/caml/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ CAMLextern void caml_stat_free(caml_stat_block);
(in bytes) and returns a pointer to it. It throws an OCaml exception in case
the request fails, and so requires the runtime lock to be held.
*/
CAMLmalloc(caml_stat_free, 1, 1) CAMLreturns_nonnull()
CAMLmalloc(caml_stat_free, 1, 1) CAMLreturns_nonnull
CAMLextern caml_stat_block caml_stat_alloc(asize_t);

/* [caml_stat_alloc_noexc(size)] allocates a memory block of the requested
Expand All @@ -102,7 +102,7 @@ CAMLextern caml_stat_block caml_stat_alloc_noexc(asize_t);
well as the unaligned [block] (as an output parameter). It throws an OCaml
exception in case the request fails, and so requires the runtime lock.
*/
CAMLaligned_alloc(caml_stat_free, 1, 1, 2) CAMLreturns_nonnull()
CAMLaligned_alloc(caml_stat_free, 1, 1, 2) CAMLreturns_nonnull
CAMLextern void* caml_stat_alloc_aligned(asize_t, int modulo, caml_stat_block*);

/* [caml_stat_alloc_aligned_noexc] is a variant of [caml_stat_alloc_aligned]
Expand All @@ -129,7 +129,7 @@ CAMLextern caml_stat_block caml_stat_calloc_noexc(asize_t, asize_t);
portion is indeterminate. The function throws an OCaml exception in case the
request fails, and so requires the runtime lock to be held.
*/
CAMLrealloc(2) CAMLreturns_nonnull()
CAMLrealloc(2) CAMLreturns_nonnull
CAMLextern caml_stat_block caml_stat_resize(caml_stat_block, asize_t);

/* [caml_stat_resize_noexc] is a variant of [caml_stat_resize] that returns NULL
Expand All @@ -146,7 +146,7 @@ typedef char* caml_stat_string;
copy of the null-terminated string [s]. It throws an OCaml exception in case
the request fails, and so requires the runtime lock to be held.
*/
CAMLalloc(caml_stat_free, 1) CAMLreturns_nonnull()
CAMLalloc(caml_stat_free, 1) CAMLreturns_nonnull
CAMLextern caml_stat_string caml_stat_strdup(const char *s);

/* [caml_stat_strdup_noexc] is a variant of [caml_stat_strdup] that returns NULL
Expand All @@ -160,7 +160,7 @@ CAMLextern caml_stat_string caml_stat_strdup_noexc(const char *s);
* obvious equivalents of [caml_stat_strdup] and
* [caml_stat_strdup_noexc] for wide characters.
*/
CAMLalloc(caml_stat_free, 1) CAMLreturns_nonnull()
CAMLalloc(caml_stat_free, 1) CAMLreturns_nonnull
CAMLextern wchar_t* caml_stat_wcsdup(const wchar_t *s);
CAMLalloc(caml_stat_free, 1)
CAMLextern wchar_t* caml_stat_wcsdup_noexc(const wchar_t *s);
Expand All @@ -172,7 +172,7 @@ CAMLextern wchar_t* caml_stat_wcsdup_noexc(const wchar_t *s);
implementation of the Windows-only functions
caml_stat_char_array_{to,from}_utf16.
*/
CAMLmalloc(caml_stat_free, 1, 2) CAMLreturns_nonnull()
CAMLmalloc(caml_stat_free, 1, 2) CAMLreturns_nonnull
CAMLextern caml_stat_string caml_stat_memdup(const char *s, asize_t size,
asize_t *out_size);

Expand All @@ -181,10 +181,10 @@ CAMLextern caml_stat_string caml_stat_memdup(const char *s, asize_t size,
except for the very last one. It throws an OCaml exception in case the
request fails, and so requires the runtime lock to be held.
*/
CAMLalloc(caml_stat_free, 1) CAMLreturns_nonnull()
CAMLalloc(caml_stat_free, 1) CAMLreturns_nonnull
CAMLextern caml_stat_string caml_stat_strconcat(int n, ...);
#ifdef _WIN32
CAMLalloc(caml_stat_free, 1) CAMLreturns_nonnull()
CAMLalloc(caml_stat_free, 1) CAMLreturns_nonnull
CAMLextern wchar_t* caml_stat_wcsconcat(int n, ...);
#endif

Expand Down
Loading
Loading