decl_modifiers_t modifiers = declaration->modifiers;
/* DM_FORCEINLINE handled outside. */
- if((modifiers & ~DM_FORCEINLINE) != 0 ||
- declaration->alignment != 0 || declaration->deprecated != 0 ||
- declaration->get_property_sym != NULL || declaration->put_property_sym != NULL) {
+ if ((modifiers & ~DM_FORCEINLINE) != 0 ||
+ declaration->alignment != 0 ||
+ declaration->get_property_sym != NULL ||
+ declaration->put_property_sym != NULL) {
char *next = "(";
fputs("__declspec", out);
if(modifiers & DM_NOINLINE) {
fputs(next, out); next = ", "; fputs("noinline", out);
}
- if(declaration->deprecated != 0) {
+ if (modifiers & DM_DEPRECATED) {
fputs(next, out); next = ", "; fputs("deprecated", out);
if(declaration->deprecated_string != NULL)
fprintf(out, "(\"%s\")", declaration->deprecated_string);
DM_CDECL = 1 << 20,
DM_FASTCALL = 1 << 21,
DM_STDCALL = 1 << 22,
- DM_THISCALL = 1 << 23
+ DM_THISCALL = 1 << 23,
+ DM_DEPRECATED = 1 << 24
} decl_modifier_t;
typedef unsigned decl_modifiers_t;
unsigned int address_taken : 1;
unsigned int is_inline : 1;
unsigned int used : 1; /**< Set if the declaration is used. */
- unsigned int deprecated : 1; /**< Microsoft or GNU deprecated attribute. */
type_t *type;
symbol_t *symbol;
source_position_t source_position;
switch(kind) {
case GNU_AK_CONST:
case GNU_AK_VOLATILE:
- case GNU_AK_DEPRECATED:
case GNU_AK_NAKED:
case GNU_AK_MALLOC:
case GNU_AK_WEAK:
case GNU_AK_TRANSPARENT_UNION: modifiers |= DM_TRANSPARENT_UNION; goto no_arg;
case GNU_AK_CONSTRUCTOR: modifiers |= DM_CONSTRUCTOR; goto no_arg;
case GNU_AK_DESTRUCTOR: modifiers |= DM_DESTRUCTOR; goto no_arg;
+ case GNU_AK_DEPRECATED: modifiers |= DM_DEPRECATED; goto no_arg;
case GNU_AK_ALIGNED:
/* __align__ may be used without an argument */
declaration_t *const declaration = allocate_declaration_zero();
declaration->declared_storage_class = specifiers->declared_storage_class;
declaration->modifiers = specifiers->modifiers;
- declaration->deprecated = specifiers->deprecated;
declaration->deprecated_string = specifiers->deprecated_string;
declaration->get_property_sym = specifiers->get_property_sym;
declaration->put_property_sym = specifiers->put_property_sym;
declaration->used = true;
/* check for deprecated functions */
- if (declaration->deprecated != 0) {
- const char *prefix = "";
- if (is_type_function(declaration->type))
- prefix = "function ";
+ if (warning.deprecated_declarations &&
+ declaration->modifiers & DM_DEPRECATED) {
+ char const *const prefix = is_type_function(declaration->type) ?
+ "function" : "variable";
if (declaration->deprecated_string != NULL) {
warningf(&source_position,
- "%s'%Y' was declared 'deprecated(\"%s\")'", prefix, declaration->symbol,
+ "%s '%Y' is deprecated (declared %P): \"%s\"", prefix,
+ declaration->symbol, &declaration->source_position,
declaration->deprecated_string);
} else {
warningf(&source_position,
- "%s'%Y' was declared 'deprecated'", prefix, declaration->symbol);
+ "%s '%Y' is deprecated (declared %P)", prefix,
+ declaration->symbol, &declaration->source_position);
}
}
warning_t warning = {
.attribute = true,
.char_subscripts = true,
+ .deprecated_declarations = true,
.empty_statement = false,
.fatal_errors = false,
.float_equal = false,
}
OPT("attribute", attribute);
OPT("char-subscripts", char_subscripts);
+ OPT("deprecated-declarations", deprecated_declarations);
OPT("empty-statement", empty_statement);
OPT("error", s_are_errors);
OPTX("extra") {
bool cast_qual:1; /**< Warn whenever a pointer is cast so as to remove a type qualifier from the target type */
bool conversion:1; /**< Warn if a prototype causes a type conversion that is different from what would happen to the same argument in the absence of a prototype */
bool declaration_after_statement:1; /**< Warn when a declaration is found after a statement in a block */
- bool deprecated_declarations:1; /**< Warn about uses of functions, variables and types marked as deprecated by using the 'deprecated' attribute */
+#endif
+ bool deprecated_declarations:1; /* TODO implement for types */ /**< Warn about uses of functions, variables and types marked as deprecated by using the 'deprecated' attribute */
+#if 0 // TODO
bool div_by_zero:1; /**< Warn about compile-time integer division by zero */
#endif
bool empty_statement:1; /**< Warn about empty statements, i.e. lone ';' */