Commit 2884c41e by Kaveh R. Ghazi Committed by Kaveh Ghazi

parse.h (OBSOLETE_MODIFIER_WARNING): Don't use ANSI string concatenation.

	* parse.h (OBSOLETE_MODIFIER_WARNING): Don't use ANSI string
	concatenation.
	(OBSOLETE_MODIFIER_WARNING2): New macro allowing two args.

	* parse.y (register_fields): Don't pass a format specifier to
	OBSOLETE_MODIFIER_WARNING.
	(check_abstract_method_header): Use OBSOLETE_MODIFIER_WARNING2
	instead of OBSOLETE_MODIFIER_WARNING, and don't pass a format
	specifier.
	(check_modifiers): Change function into a macro.
	(check_class_interface_creation): Pass a literal format string.

From-SVN: r31614
parent 8c135f84
2000-01-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* parse.h (OBSOLETE_MODIFIER_WARNING): Don't use ANSI string
concatenation.
(OBSOLETE_MODIFIER_WARNING2): New macro allowing two args.
* parse.y (register_fields): Don't pass a format specifier to
OBSOLETE_MODIFIER_WARNING.
(check_abstract_method_header): Use OBSOLETE_MODIFIER_WARNING2
instead of OBSOLETE_MODIFIER_WARNING, and don't pass a format
specifier.
(check_modifiers): Change function into a macro.
(check_class_interface_creation): Pass a literal format string.
2000-01-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2000-01-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* buffer.h: PROTO -> PARAMS. * buffer.h: PROTO -> PARAMS.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -138,13 +138,20 @@ extern tree stabilize_reference PARAMS ((tree)); ...@@ -138,13 +138,20 @@ extern tree stabilize_reference PARAMS ((tree));
/* Pedantic warning on obsolete modifiers. Note: when cl is NULL, /* Pedantic warning on obsolete modifiers. Note: when cl is NULL,
flags was set artificially, such as for a interface method */ flags was set artificially, such as for a interface method */
#define OBSOLETE_MODIFIER_WARNING(cl, flags, __modifier, format, arg) \ #define OBSOLETE_MODIFIER_WARNING(cl, flags, __modifier, arg) \
{ \ { \
if (flag_redundant && (cl) && ((flags) & (__modifier))) \ if (flag_redundant && (cl) && ((flags) & (__modifier))) \
parse_warning_context (cl, \ parse_warning_context (cl, \
"Discouraged redundant use of `%s' modifier in declaration of " format, \ "Discouraged redundant use of `%s' modifier in declaration of %s", \
java_accstring_lookup (__modifier), arg); \ java_accstring_lookup (__modifier), arg); \
} }
#define OBSOLETE_MODIFIER_WARNING2(cl, flags, __modifier, arg1, arg2) \
{ \
if (flag_redundant && (cl) && ((flags) & (__modifier))) \
parse_warning_context (cl, \
"Discouraged redundant use of `%s' modifier in declaration of %s `%s'", \
java_accstring_lookup (__modifier), arg1, arg2);\
}
/* Quickly build a temporary pointer on hypothetical type NAME. */ /* Quickly build a temporary pointer on hypothetical type NAME. */
#define BUILD_PTR_FROM_NAME(ptr, name) \ #define BUILD_PTR_FROM_NAME(ptr, name) \
......
...@@ -70,7 +70,6 @@ definitions and other extensions. */ ...@@ -70,7 +70,6 @@ definitions and other extensions. */
static char *java_accstring_lookup PARAMS ((int)); static char *java_accstring_lookup PARAMS ((int));
static void classitf_redefinition_error PARAMS ((const char *,tree, tree, tree)); static void classitf_redefinition_error PARAMS ((const char *,tree, tree, tree));
static void variable_redefinition_error PARAMS ((tree, tree, tree, int)); static void variable_redefinition_error PARAMS ((tree, tree, tree, int));
static void check_modifiers PARAMS ((const char *, int, int));
static tree create_class PARAMS ((int, tree, tree, tree)); static tree create_class PARAMS ((int, tree, tree, tree));
static tree create_interface PARAMS ((int, tree, tree)); static tree create_interface PARAMS ((int, tree, tree));
static tree find_field PARAMS ((tree, tree)); static tree find_field PARAMS ((tree, tree));
...@@ -326,6 +325,22 @@ static tree current_static_block = NULL_TREE; ...@@ -326,6 +325,22 @@ static tree current_static_block = NULL_TREE;
/* The list of all packages we've seen so far */ /* The list of all packages we've seen so far */
static tree package_list = NULL_TREE; static tree package_list = NULL_TREE;
/* Check modifiers. If one doesn't fit, retrieve it in its declaration
line and point it out. */
/* Should point out the one that don't fit. ASCII/unicode, going
backward. FIXME */
#define check_modifiers(__message, __value, __mask) do { \
if ((__value) & ~(__mask)) \
{ \
int i, remainder = (__value) & ~(__mask); \
for (i = 0; i <= 10; i++) \
if ((1 << i) & remainder) \
parse_error_context (ctxp->modifier_ctx [i], (__message), \
java_accstring_lookup (1 << i)); \
} \
} while (0)
%} %}
%union { %union {
...@@ -2882,27 +2897,6 @@ build_unresolved_array_type (type_or_wfl) ...@@ -2882,27 +2897,6 @@ build_unresolved_array_type (type_or_wfl)
EXPR_WFL_COLNO (type_or_wfl)); EXPR_WFL_COLNO (type_or_wfl));
} }
/* Check modifiers. If one doesn't fit, retrieve it in its declaration line
and point it out. */
static void
check_modifiers (message, value, mask)
const char *message;
int value;
int mask;
{
/* Should point out the one that don't fit. ASCII/unicode,
going backward. FIXME */
if (value & ~mask)
{
int i, remainder = value & ~mask;
for (i = 0; i <= 10; i++)
if ((1 << i) & remainder)
parse_error_context (ctxp->modifier_ctx [i], message,
java_accstring_lookup (1 << i));
}
}
static void static void
parser_add_interface (class_decl, interface_decl, wfl) parser_add_interface (class_decl, interface_decl, wfl)
tree class_decl, interface_decl, wfl; tree class_decl, interface_decl, wfl;
...@@ -2967,10 +2961,12 @@ check_class_interface_creation (is_interface, flags, raw_name, qualified_name, d ...@@ -2967,10 +2961,12 @@ check_class_interface_creation (is_interface, flags, raw_name, qualified_name, d
IDENTIFIER_POINTER (raw_name)); IDENTIFIER_POINTER (raw_name));
} }
check_modifiers ((is_interface ? if (is_interface)
"Illegal modifier `%s' for interface declaration" : check_modifiers ("Illegal modifier `%s' for interface declaration",
"Illegal modifier `%s' for class declaration"), flags, flags, INTERFACE_MODIFIERS);
(is_interface ? INTERFACE_MODIFIERS : CLASS_MODIFIERS)); else
check_modifiers ("Illegal modifier `%s' for class declaration",
flags, CLASS_MODIFIERS);
return 0; return 0;
} }
...@@ -3239,13 +3235,11 @@ register_fields (flags, type, variable_list) ...@@ -3239,13 +3235,11 @@ register_fields (flags, type, variable_list)
if (CLASS_INTERFACE (TYPE_NAME (class_type))) if (CLASS_INTERFACE (TYPE_NAME (class_type)))
{ {
OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK), OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
flags, ACC_PUBLIC, flags, ACC_PUBLIC, "interface field(s)");
"%s", "interface field(s)");
OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK), OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
flags, ACC_STATIC, flags, ACC_STATIC, "interface field(s)");
"%s", "interface field(s)");
OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK), OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
flags, ACC_FINAL, "%s", "interface field(s)"); flags, ACC_FINAL, "interface field(s)");
check_modifiers ("Illegal interface member modifier `%s'", flags, check_modifiers ("Illegal interface member modifier `%s'", flags,
INTERFACE_FIELD_MODIFIERS); INTERFACE_FIELD_MODIFIERS);
flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL); flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
...@@ -3754,11 +3748,11 @@ check_abstract_method_header (meth) ...@@ -3754,11 +3748,11 @@ check_abstract_method_header (meth)
/* DECL_NAME might still be a WFL node */ /* DECL_NAME might still be a WFL node */
tree name = GET_METHOD_NAME (meth); tree name = GET_METHOD_NAME (meth);
OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (ABSTRACT_TK), flags, OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (ABSTRACT_TK), flags,
ACC_ABSTRACT, "abstract method `%s'", ACC_ABSTRACT, "abstract method",
IDENTIFIER_POINTER (name)); IDENTIFIER_POINTER (name));
OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK), flags, OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (PUBLIC_TK), flags,
ACC_PUBLIC, "abstract method `%s'", ACC_PUBLIC, "abstract method",
IDENTIFIER_POINTER (name)); IDENTIFIER_POINTER (name));
check_modifiers ("Illegal modifier `%s' for interface method", check_modifiers ("Illegal modifier `%s' for interface method",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment