Commit 3c01e5df by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (cp_cv_quals): New type.

	* cp-tree.h (cp_cv_quals): New type.
	(cp_declarator): Use it instead of "tree" as appropriate.
	(grok_method_quals): Adjust prototype.
	(grokclassfn): Likewise.
	(do_friend): Likewise.
	* decl.c (grokfndecl): Use cp_cv_quals, not tree.
	(grokdeclarator): Likewise.
	* decl2.c (grok_method_quals): Likewise.
	(grokclassfn): Likewise.
	* friend.c (do_friend): Likewise.
	* method.c (implicitly_declare_fn): Adjust call to grokclassfn.
	* parser.c (make_call_declarator): Use cp_cv_quals, not tree.
	(make_pointer_declarator): Likewise.
	(make_reference_declarator): Likewise.
	(make_ptrmem_declarator): Likewise.
	(cp_parser_ptr_operator): Likewise.
	(cp_parser_cv_qualifier_seq_opt): Likewise.
	(cp_parser_cv_qualifier_opt): Remove.
	(cp_parser_new_declarator_opt): Adjust call to
	cp_parser_ptr_operator.
	(cp_parser_conversion_declaration_opt): Likewise.
	(cp_parser_declarator): Use cp_cv_quals, not tree.
	(cp_parser_direct_declarator): Likewise.

From-SVN: r83729
parent 808fd801
2004-06-26 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (cp_cv_quals): New type.
(cp_declarator): Use it instead of "tree" as appropriate.
(grok_method_quals): Adjust prototype.
(grokclassfn): Likewise.
(do_friend): Likewise.
* decl.c (grokfndecl): Use cp_cv_quals, not tree.
(grokdeclarator): Likewise.
* decl2.c (grok_method_quals): Likewise.
(grokclassfn): Likewise.
* friend.c (do_friend): Likewise.
* method.c (implicitly_declare_fn): Adjust call to grokclassfn.
* parser.c (make_call_declarator): Use cp_cv_quals, not tree.
(make_pointer_declarator): Likewise.
(make_reference_declarator): Likewise.
(make_ptrmem_declarator): Likewise.
(cp_parser_ptr_operator): Likewise.
(cp_parser_cv_qualifier_seq_opt): Likewise.
(cp_parser_cv_qualifier_opt): Remove.
(cp_parser_new_declarator_opt): Adjust call to
cp_parser_ptr_operator.
(cp_parser_conversion_declaration_opt): Likewise.
(cp_parser_declarator): Use cp_cv_quals, not tree.
(cp_parser_direct_declarator): Likewise.
2004-06-26 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* call.c, cp-tree.h, cxx-pretty-print.c, decl.c, decl2.c:
......
......@@ -3503,6 +3503,11 @@ extern GTY(()) operator_name_info_t operator_name_info
extern GTY(()) operator_name_info_t assignment_operator_name_info
[(int) LAST_CPLUS_TREE_CODE];
/* A type-qualifier, or bitmask therefore, using the TYPE_QUAL
constants. */
typedef int cp_cv_quals;
/* A storage class. */
typedef enum cp_storage_class {
......@@ -3628,7 +3633,7 @@ struct cp_declarator {
/* The parameters to the function. */
cp_parameter_declarator *parameters;
/* The cv-qualifiers for the function. */
tree qualifiers;
cp_cv_quals qualifiers;
/* The exception-specification for the function. */
tree exception_specification;
} function;
......@@ -3640,7 +3645,7 @@ struct cp_declarator {
/* For cdk_pointer, cdk_reference, and cdk_ptrmem. */
struct {
/* The cv-qualifiers for the pointer. */
tree qualifiers;
cp_cv_quals qualifiers;
/* For cdk_ptrmem, the class type containing the member. */
tree class_type;
} pointer;
......@@ -3866,10 +3871,10 @@ extern bool have_extern_spec;
/* in decl2.c */
extern bool check_java_method (tree);
extern int grok_method_quals (tree, tree, tree);
extern cp_cv_quals grok_method_quals (tree, tree, cp_cv_quals);
extern void maybe_retrofit_in_chrg (tree);
extern void maybe_make_one_only (tree);
extern void grokclassfn (tree, tree, enum overload_flags, tree);
extern void grokclassfn (tree, tree, enum overload_flags, cp_cv_quals);
extern tree grok_array_decl (tree, tree);
extern tree delete_sanity (tree, tree, bool, int);
extern tree check_classfn (tree, tree, tree);
......@@ -3941,7 +3946,7 @@ extern tree cplus_expand_constant (tree);
extern int is_friend (tree, tree);
extern void make_friend_class (tree, tree, bool);
extern void add_friend (tree, tree, bool);
extern tree do_friend (tree, tree, tree, tree, enum overload_flags, tree, int);
extern tree do_friend (tree, tree, tree, tree, enum overload_flags, cp_cv_quals, int);
/* in init.c */
extern tree expand_member_init (tree);
......
......@@ -62,7 +62,7 @@ static int unary_op_p (enum tree_code);
static void push_local_name (tree);
static tree grok_reference_init (tree, tree, tree, tree *);
static tree grokfndecl (tree, tree, tree, tree, tree, int,
enum overload_flags, tree,
enum overload_flags, cp_cv_quals,
tree, int, int, int, int, int, int, tree);
static tree grokvardecl (tree, tree, cp_decl_specifier_seq *, int, int, tree);
static void record_unknown_type (tree, const char *);
......@@ -5424,7 +5424,7 @@ grokfndecl (tree ctype,
tree orig_declarator,
int virtualp,
enum overload_flags flags,
tree quals,
cp_cv_quals quals,
tree raises,
int check,
int friendp,
......@@ -5544,11 +5544,11 @@ grokfndecl (tree ctype,
DECL_INLINE (decl) = 1;
DECL_EXTERNAL (decl) = 1;
if (quals != NULL_TREE && TREE_CODE (type) == FUNCTION_TYPE)
if (quals && TREE_CODE (type) == FUNCTION_TYPE)
{
error ("%smember function `%D' cannot have `%T' method qualifier",
(ctype ? "static " : "non-"), decl, TREE_VALUE (quals));
quals = NULL_TREE;
error ("%smember function `%D' cannot have cv-qualifier",
(ctype ? "static " : "non-"), decl);
quals = TYPE_UNQUALIFIED;
}
if (IDENTIFIER_OPNAME_P (DECL_NAME (decl)))
......@@ -6287,7 +6287,7 @@ grokdeclarator (const cp_declarator *declarator,
tree dname = NULL_TREE;
tree ctor_return_type = NULL_TREE;
enum overload_flags flags = NO_SPECIAL;
tree quals = NULL_TREE;
cp_cv_quals quals = TYPE_UNQUALIFIED;
tree raises = NULL_TREE;
int template_count = 0;
tree returned_attrs = NULL_TREE;
......@@ -6546,7 +6546,7 @@ grokdeclarator (const cp_declarator *declarator,
}
else if (declspecs->specs[(int)ds] > 1)
{
static const char *decl_spec_names[] = {
static const char *const decl_spec_names[] = {
"signed",
"unsigned",
"short",
......@@ -7049,9 +7049,8 @@ grokdeclarator (const cp_declarator *declarator,
error ("destructor cannot be static member function");
if (quals)
{
error ("destructors may not be `%E'",
TREE_VALUE (quals));
quals = NULL_TREE;
error ("destructors may not be cv-qualified");
quals = TYPE_UNQUALIFIED;
}
if (decl_context == FIELD)
{
......@@ -7078,9 +7077,8 @@ grokdeclarator (const cp_declarator *declarator,
}
if (quals)
{
error ("constructors may not be `%E'",
TREE_VALUE (quals));
quals = NULL_TREE;
error ("constructors may not be cv-qualified");
quals = TYPE_UNQUALIFIED;
}
if (decl_context == FIELD)
{
......@@ -7163,7 +7161,7 @@ grokdeclarator (const cp_declarator *declarator,
grok_method_quals (declarator->u.pointer.class_type,
dummy, quals);
type = TREE_TYPE (dummy);
quals = NULL_TREE;
quals = TYPE_UNQUALIFIED;
}
if (declarator->kind == cdk_reference)
......@@ -7184,45 +7182,9 @@ grokdeclarator (const cp_declarator *declarator,
if (declarator->u.pointer.qualifiers)
{
tree typemodlist;
int erred = 0;
int constp = 0;
int volatilep = 0;
int restrictp = 0;
for (typemodlist = declarator->u.pointer.qualifiers; typemodlist;
typemodlist = TREE_CHAIN (typemodlist))
{
tree qualifier = TREE_VALUE (typemodlist);
if (qualifier == ridpointers[(int) RID_CONST])
{
constp++;
type_quals |= TYPE_QUAL_CONST;
}
else if (qualifier == ridpointers[(int) RID_VOLATILE])
{
volatilep++;
type_quals |= TYPE_QUAL_VOLATILE;
}
else if (qualifier == ridpointers[(int) RID_RESTRICT])
{
restrictp++;
type_quals |= TYPE_QUAL_RESTRICT;
}
else if (!erred)
{
erred = 1;
error ("invalid type modifier within pointer declarator");
}
}
if (constp > 1)
pedwarn ("duplicate `const'");
if (volatilep > 1)
pedwarn ("duplicate `volatile'");
if (restrictp > 1)
pedwarn ("duplicate `restrict'");
type = cp_build_qualified_type (type, type_quals);
type
= cp_build_qualified_type (type,
declarator->u.pointer.qualifiers);
type_quals = cp_type_quals (type);
}
ctype = NULL_TREE;
......@@ -7488,7 +7450,7 @@ grokdeclarator (const cp_declarator *declarator,
|| (typedef_decl && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
bad_specifiers (decl, "type", virtualp, quals != NULL_TREE,
bad_specifiers (decl, "type", virtualp, quals != TYPE_UNQUALIFIED,
inlinep, friendp, raises != NULL_TREE);
return decl;
......@@ -7654,7 +7616,7 @@ grokdeclarator (const cp_declarator *declarator,
{
decl = cp_build_parm_decl (unqualified_id, type);
bad_specifiers (decl, "parameter", virtualp, quals != NULL_TREE,
bad_specifiers (decl, "parameter", virtualp, quals != TYPE_UNQUALIFIED,
inlinep, friendp, raises != NULL_TREE);
}
else if (decl_context == FIELD)
......@@ -7908,7 +7870,7 @@ grokdeclarator (const cp_declarator *declarator,
}
}
bad_specifiers (decl, "field", virtualp, quals != NULL_TREE,
bad_specifiers (decl, "field", virtualp, quals != TYPE_UNQUALIFIED,
inlinep, friendp, raises != NULL_TREE);
}
}
......@@ -8009,7 +7971,7 @@ grokdeclarator (const cp_declarator *declarator,
initialized,
(type_quals & TYPE_QUAL_CONST) != 0,
ctype ? ctype : in_namespace);
bad_specifiers (decl, "variable", virtualp, quals != NULL_TREE,
bad_specifiers (decl, "variable", virtualp, quals != TYPE_UNQUALIFIED,
inlinep, friendp, raises != NULL_TREE);
if (ctype)
......
......@@ -118,31 +118,15 @@ tree static_dtors;
TYPE_UNQUALIFIED will be an extension. */
int
grok_method_quals (tree ctype, tree function, tree quals)
grok_method_quals (tree ctype, tree function, cp_cv_quals quals)
{
tree fntype = TREE_TYPE (function);
tree raises = TYPE_RAISES_EXCEPTIONS (fntype);
int type_quals = TYPE_UNQUALIFIED;
int dup_quals = TYPE_UNQUALIFIED;
int this_quals = TYPE_UNQUALIFIED;
while (quals)
{
int tq = cp_type_qual_from_rid (TREE_VALUE (quals));
if ((type_quals | this_quals) & tq)
dup_quals |= tq;
else if (tq & TYPE_QUAL_RESTRICT)
this_quals |= tq;
else
type_quals |= tq;
quals = TREE_CHAIN (quals);
}
if (dup_quals != TYPE_UNQUALIFIED)
error ("duplicate type qualifiers in %s declaration",
TREE_CODE (function) == FUNCTION_DECL
? "member function" : "type");
type_quals = quals & ~TYPE_QUAL_RESTRICT;
this_quals = quals & TYPE_QUAL_RESTRICT;
ctype = cp_build_qualified_type (ctype, type_quals);
fntype = build_method_type_directly (ctype, TREE_TYPE (fntype),
......@@ -281,10 +265,11 @@ maybe_retrofit_in_chrg (tree fn)
QUALS are the qualifiers for the this pointer. */
void
grokclassfn (tree ctype, tree function, enum overload_flags flags, tree quals)
grokclassfn (tree ctype, tree function, enum overload_flags flags,
cp_cv_quals quals)
{
tree fn_name = DECL_NAME (function);
int this_quals = TYPE_UNQUALIFIED;
cp_cv_quals this_quals = TYPE_UNQUALIFIED;
/* Even within an `extern "C"' block, members get C++ linkage. See
[dcl.link] for details. */
......
......@@ -325,7 +325,8 @@ make_friend_class (tree type, tree friend_type, bool complain)
tree
do_friend (tree ctype, tree declarator, tree decl,
tree attrlist, enum overload_flags flags, tree quals,
tree attrlist, enum overload_flags flags,
cp_cv_quals quals,
int funcdef_flag)
{
/* Every decl that gets here is a friend of something. */
......
......@@ -1020,7 +1020,7 @@ implicitly_declare_fn (special_function_kind kind, tree type, bool const_p)
}
grokclassfn (type, fn, kind == sfk_destructor ? DTOR_FLAG : NO_SPECIAL,
/*quals=*/NULL_TREE);
TYPE_UNQUALIFIED);
grok_special_member_properties (fn);
cp_finish_decl (fn, /*init=*/NULL_TREE, /*asmspec_tree=*/NULL_TREE,
/*flags=*/LOOKUP_ONLYCONVERTING);
......
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