#include "diagnostic.h"
#include "lang_features.h"
#include "types.h"
+#include "warning.h"
#include "driver/firm_opt.h"
#include "driver/firm_cmdline.h"
in[0] = new_Const(mode, get_mode_null(mode));
} else {
in[0] = new_Unknown(mode);
- warningf(&declaration->source_position, "missing return statement at end of non-void function '%Y'",
- declaration->symbol);
-
+ if(warning.return_type) {
+ warningf(&declaration->source_position,
+ "missing return statement at end of non-void function '%Y'",
+ declaration->symbol);
+ }
}
ret = new_Return(get_store(), 1, in);
}
.unused_label = false,
.unused_parameter = false,
.unused_value = true,
- .unused_variable = false
+ .unused_variable = false,
+ .return_type = true
};
void set_warning_opt(const char *const opt)
SET(unused_parameter)
SET(unused_value)
SET(unused_variable)
+ SET(return_type)
}
OPT("attribute", attribute)
OPT("char-subscripts", char_subscripts)
OPT("unused-parameter", unused_parameter)
OPT("unused-value", unused_value)
OPT("unused-variable", unused_variable)
+ OPT("return-type", return_type)
#undef OPT
#undef SET
#undef OPT_X
#if 0 // TODO
bool write_strings:1; /**< Give string constants the type 'const char[LENGTH]' so that copying the address of one into a 'char *' pointer will get a warning */
#endif
+ bool return_type:1; /**< Warn whenever a function is defined with a return-type that
+ defaults to `int'. Also warn about any `return' statement with no
+ return-value in a function whose return-type is not `void'. */
} warning_t;
extern warning_t warning;