Commit 421844e7 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (IDENTIFIER_TYPENAME_P): Use a flag, not strncmp.

	* cp-tree.h (IDENTIFIER_TYPENAME_P): Use a flag, not strncmp.
	(DECL_CONV_FN_P): Simplify.
	(DECL_OPERATOR): Remove.
	(language_to_string): Declare.
	* decl.c (duplicate_decls): Fix typo in comment.
	(grokdeclarator): Adjust use of IDENTIFIER_TYPENAME_P.
	(grok_op_properties): Use DECL_CONV_FN_P instead of
	IDENTIFIER_TYPENAME_P.
	* dump.c (dequeue_and_dump): Dump the language linkage of
	declarations.
	* error.c (language_to_string): Give it external linkage.
	* method.c (build_typename_overload): Set IDENTIFIER_TYPENAME_P.
	(implicitly_declare_fn): Set DECL_LANGUAGE.
	* pt.c (check_explicit_specialization): Use DECL_CONV_FN_P, not
	IDENTIFIER_TYPENAME_P.
	(tsubst_decl): Likewise.
	(tsubst_copy): Adjust use of IDENTIFIER_TYPENAME_P.
	* semantics.c (finish_member_declaration): Don't mark members of
	classes declared in an extern "C" region as extern "C".

From-SVN: r34095
parent 46972a36
2000-05-22 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (IDENTIFIER_TYPENAME_P): Use a flag, not strncmp.
(DECL_CONV_FN_P): Simplify.
(DECL_OPERATOR): Remove.
(language_to_string): Declare.
* decl.c (duplicate_decls): Fix typo in comment.
(grokdeclarator): Adjust use of IDENTIFIER_TYPENAME_P.
(grok_op_properties): Use DECL_CONV_FN_P instead of
IDENTIFIER_TYPENAME_P.
* dump.c (dequeue_and_dump): Dump the language linkage of
declarations.
* error.c (language_to_string): Give it external linkage.
* method.c (build_typename_overload): Set IDENTIFIER_TYPENAME_P.
(implicitly_declare_fn): Set DECL_LANGUAGE.
* pt.c (check_explicit_specialization): Use DECL_CONV_FN_P, not
IDENTIFIER_TYPENAME_P.
(tsubst_decl): Likewise.
(tsubst_copy): Adjust use of IDENTIFIER_TYPENAME_P.
* semantics.c (finish_member_declaration): Don't mark members of
classes declared in an extern "C" region as extern "C".
2000-05-22 Martin v. Lwis <loewis@informatik.hu-berlin.de> 2000-05-22 Martin v. Lwis <loewis@informatik.hu-berlin.de>
* decl2.c (qualified_lookup_using_namespace): Look through * decl2.c (qualified_lookup_using_namespace): Look through
......
...@@ -73,6 +73,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -73,6 +73,7 @@ Boston, MA 02111-1307, USA. */
or FIELD_DECL). or FIELD_DECL).
NEED_TEMPORARY_P (in REF_BIND, BASE_CONV) NEED_TEMPORARY_P (in REF_BIND, BASE_CONV)
SCOPE_PARTIAL_P (in SCOPE_STMT) SCOPE_PARTIAL_P (in SCOPE_STMT)
IDENTIFIER_TYPENAME_P (in IDENTIFIER_NODE)
5: BINFO_PRIMARY_MARKED_P (in BINFO) 5: BINFO_PRIMARY_MARKED_P (in BINFO)
6: BINFO_VBASE_PRIMARY_P (in BINFO) 6: BINFO_VBASE_PRIMARY_P (in BINFO)
...@@ -484,10 +485,8 @@ struct tree_srcloc ...@@ -484,10 +485,8 @@ struct tree_srcloc
/* Nonzero if this identifier is the name of a type-conversion /* Nonzero if this identifier is the name of a type-conversion
operator. */ operator. */
#define IDENTIFIER_TYPENAME_P(NODE) \ #define IDENTIFIER_TYPENAME_P(NODE) \
(! strncmp (IDENTIFIER_POINTER (NODE), \ (TREE_LANG_FLAG_4 (NODE))
OPERATOR_TYPENAME_FORMAT, \
strlen (OPERATOR_TYPENAME_FORMAT)))
/* Nonzero if this identifier is the name of a constructor or /* Nonzero if this identifier is the name of a constructor or
destructor. */ destructor. */
...@@ -1972,8 +1971,8 @@ struct lang_decl ...@@ -1972,8 +1971,8 @@ struct lang_decl
(DECL_LANG_SPECIFIC (NODE)->cloned_function) (DECL_LANG_SPECIFIC (NODE)->cloned_function)
/* Non-zero if NODE is a user-defined conversion operator. */ /* Non-zero if NODE is a user-defined conversion operator. */
#define DECL_CONV_FN_P(NODE) \ #define DECL_CONV_FN_P(NODE) \
(IDENTIFIER_TYPENAME_P (DECL_NAME (NODE)) && TREE_TYPE (DECL_NAME (NODE))) (IDENTIFIER_TYPENAME_P (DECL_NAME (NODE)))
/* Non-zero if NODE is an overloaded operator. */ /* Non-zero if NODE is an overloaded operator. */
#define DECL_OVERLOADED_OPERATOR_P(NODE) \ #define DECL_OVERLOADED_OPERATOR_P(NODE) \
...@@ -2684,11 +2683,6 @@ extern int flag_new_for_scope; ...@@ -2684,11 +2683,6 @@ extern int flag_new_for_scope;
#define DECL_THIS_STATIC(NODE) \ #define DECL_THIS_STATIC(NODE) \
DECL_LANG_FLAG_6 (VAR_FUNCTION_OR_PARM_DECL_CHECK (NODE)) DECL_LANG_FLAG_6 (VAR_FUNCTION_OR_PARM_DECL_CHECK (NODE))
/* Nonzero in FUNCTION_DECL means it is really an operator.
Just used to communicate formatting information to dbxout.c. */
#define DECL_OPERATOR(NODE) \
(DECL_LANG_SPECIFIC(FUNCTION_DECL_CHECK (NODE))->decl_flags.operator_attr)
/* Nonzero if TYPE is an anonymous union or struct type. We have to use a /* Nonzero if TYPE is an anonymous union or struct type. We have to use a
flag for this because "A union for which objects or pointers are flag for this because "A union for which objects or pointers are
declared is not an anonymous union" [class.union]. */ declared is not an anonymous union" [class.union]. */
...@@ -4084,6 +4078,7 @@ extern const char *context_as_string PARAMS ((tree, enum tree_string_ ...@@ -4084,6 +4078,7 @@ extern const char *context_as_string PARAMS ((tree, enum tree_string_
extern const char *lang_decl_name PARAMS ((tree, int)); extern const char *lang_decl_name PARAMS ((tree, int));
extern const char *cp_file_of PARAMS ((tree)); extern const char *cp_file_of PARAMS ((tree));
extern int cp_line_of PARAMS ((tree)); extern int cp_line_of PARAMS ((tree));
extern const char *language_to_string PARAMS ((enum languages, int));
/* in except.c */ /* in except.c */
extern void init_exception_processing PARAMS ((void)); extern void init_exception_processing PARAMS ((void));
......
...@@ -3126,9 +3126,9 @@ duplicate_decls (newdecl, olddecl) ...@@ -3126,9 +3126,9 @@ duplicate_decls (newdecl, olddecl)
DECL_THIS_STATIC (olddecl) = 1; DECL_THIS_STATIC (olddecl) = 1;
TREE_PUBLIC (olddecl) = 0; TREE_PUBLIC (olddecl) = 0;
/* Make the olddeclaration consistent with the new one so that /* Make the old declaration consistent with the new one so
all remnants of the builtin-ness of this function will be that all remnants of the builtin-ness of this function
banished. */ will be banished. */
DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl); DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl);
DECL_RTL (olddecl) = DECL_RTL (newdecl); DECL_RTL (olddecl) = DECL_RTL (newdecl);
DECL_ASSEMBLER_NAME (olddecl) = DECL_ASSEMBLER_NAME (newdecl); DECL_ASSEMBLER_NAME (olddecl) = DECL_ASSEMBLER_NAME (newdecl);
...@@ -9643,9 +9643,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -9643,9 +9643,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
dname); dname);
name = IDENTIFIER_POINTER (dname); name = IDENTIFIER_POINTER (dname);
} }
if (! IDENTIFIER_OPNAME_P (dname) else if (!IDENTIFIER_OPNAME_P (dname))
/* GNU/Linux headers use '__op'. Arrgh. */
|| (IDENTIFIER_TYPENAME_P (dname) && ! TREE_TYPE (dname)))
name = IDENTIFIER_POINTER (dname); name = IDENTIFIER_POINTER (dname);
else else
{ {
...@@ -12183,7 +12181,7 @@ grok_op_properties (decl, virtualp, friendp) ...@@ -12183,7 +12181,7 @@ grok_op_properties (decl, virtualp, friendp)
an enumeration, or a reference to an enumeration. 13.4.0.6 */ an enumeration, or a reference to an enumeration. 13.4.0.6 */
if (! methodp || DECL_STATIC_FUNCTION_P (decl)) if (! methodp || DECL_STATIC_FUNCTION_P (decl))
{ {
if (IDENTIFIER_TYPENAME_P (name) if (DECL_CONV_FN_P (decl)
|| name == ansi_opname[(int) CALL_EXPR] || name == ansi_opname[(int) CALL_EXPR]
|| name == ansi_opname[(int) MODIFY_EXPR] || name == ansi_opname[(int) MODIFY_EXPR]
|| name == ansi_opname[(int) COMPONENT_REF] || name == ansi_opname[(int) COMPONENT_REF]
......
...@@ -395,6 +395,8 @@ dequeue_and_dump (di) ...@@ -395,6 +395,8 @@ dequeue_and_dump (di)
dump_string (di, "artificial"); dump_string (di, "artificial");
if (TREE_CHAIN (t)) if (TREE_CHAIN (t))
dump_child ("chan", TREE_CHAIN (t)); dump_child ("chan", TREE_CHAIN (t));
if (DECL_LANG_SPECIFIC (t) && DECL_LANGUAGE (t) != lang_cplusplus)
dump_string (di, language_to_string (DECL_LANGUAGE (t), 0));
} }
else if (code_class == 't') else if (code_class == 't')
{ {
......
...@@ -64,7 +64,6 @@ static const char *cv_to_string PARAMS ((tree, int)); ...@@ -64,7 +64,6 @@ static const char *cv_to_string PARAMS ((tree, int));
static const char *decl_to_string PARAMS ((tree, int)); static const char *decl_to_string PARAMS ((tree, int));
static const char *expr_to_string PARAMS ((tree, int)); static const char *expr_to_string PARAMS ((tree, int));
static const char *fndecl_to_string PARAMS ((tree, int)); static const char *fndecl_to_string PARAMS ((tree, int));
static const char *language_to_string PARAMS ((enum languages, int));
static const char *op_to_string PARAMS ((enum tree_code, int)); static const char *op_to_string PARAMS ((enum tree_code, int));
static const char *parm_to_string PARAMS ((int, int)); static const char *parm_to_string PARAMS ((int, int));
static const char *type_to_string PARAMS ((tree, int)); static const char *type_to_string PARAMS ((tree, int));
...@@ -2267,7 +2266,7 @@ code_to_string (c, v) ...@@ -2267,7 +2266,7 @@ code_to_string (c, v)
return tree_code_name [c]; return tree_code_name [c];
} }
static const char * const char *
language_to_string (c, v) language_to_string (c, v)
enum languages c; enum languages c;
int v ATTRIBUTE_UNUSED; int v ATTRIBUTE_UNUSED;
......
...@@ -1766,6 +1766,7 @@ build_typename_overload (type) ...@@ -1766,6 +1766,7 @@ build_typename_overload (type)
build_mangled_name (type, 0, 1); build_mangled_name (type, 0, 1);
id = get_identifier (obstack_base (&scratch_obstack)); id = get_identifier (obstack_base (&scratch_obstack));
IDENTIFIER_OPNAME_P (id) = 1; IDENTIFIER_OPNAME_P (id) = 1;
IDENTIFIER_TYPENAME_P (id) = 1;
TREE_TYPE (id) = type; TREE_TYPE (id) = type;
end_squangling (); end_squangling ();
return id; return id;
...@@ -2580,6 +2581,9 @@ implicitly_declare_fn (kind, type, const_p) ...@@ -2580,6 +2581,9 @@ implicitly_declare_fn (kind, type, const_p)
DECL_NOT_REALLY_EXTERN (fn) = 1; DECL_NOT_REALLY_EXTERN (fn) = 1;
DECL_THIS_INLINE (fn) = 1; DECL_THIS_INLINE (fn) = 1;
DECL_INLINE (fn) = 1; DECL_INLINE (fn) = 1;
/* Even within an `extern "C"' block, members get C++ linkage. See
[dcl.link] for details. */
DECL_LANGUAGE (fn) = lang_cplusplus;
defer_fn (fn); defer_fn (fn);
return fn; return fn;
......
...@@ -1392,7 +1392,7 @@ check_explicit_specialization (declarator, decl, template_count, flags) ...@@ -1392,7 +1392,7 @@ check_explicit_specialization (declarator, decl, template_count, flags)
name = is_constructor ? ctor_identifier : dtor_identifier; name = is_constructor ? ctor_identifier : dtor_identifier;
} }
if (!IDENTIFIER_TYPENAME_P (name)) if (!DECL_CONV_FN_P (decl))
{ {
idx = lookup_fnfields_1 (ctype, name); idx = lookup_fnfields_1 (ctype, name);
if (idx >= 0) if (idx >= 0)
...@@ -5687,7 +5687,7 @@ tsubst_decl (t, args, type, in_decl) ...@@ -5687,7 +5687,7 @@ tsubst_decl (t, args, type, in_decl)
/*complain=*/1, t, /*complain=*/1, t,
/*entering_scope=*/1); /*entering_scope=*/1);
if (member && IDENTIFIER_TYPENAME_P (DECL_NAME (r))) if (member && DECL_CONV_FN_P (r))
/* Type-conversion operator. Reconstruct the name, in /* Type-conversion operator. Reconstruct the name, in
case it's the name of one of the template's parameters. */ case it's the name of one of the template's parameters. */
DECL_NAME (r) = build_typename_overload (TREE_TYPE (type)); DECL_NAME (r) = build_typename_overload (TREE_TYPE (type));
...@@ -7055,12 +7055,9 @@ tsubst_copy (t, args, complain, in_decl) ...@@ -7055,12 +7055,9 @@ tsubst_copy (t, args, complain, in_decl)
return tsubst (t, args, complain, in_decl); return tsubst (t, args, complain, in_decl);
case IDENTIFIER_NODE: case IDENTIFIER_NODE:
if (IDENTIFIER_TYPENAME_P (t) if (IDENTIFIER_TYPENAME_P (t))
/* Make sure it's not just a variable named `__opr', for instance, return (build_typename_overload
which can occur in some existing code. */ (tsubst (TREE_TYPE (t), args, complain, in_decl)));
&& TREE_TYPE (t))
return build_typename_overload
(tsubst (TREE_TYPE (t), args, complain, in_decl));
else else
return t; return t;
......
...@@ -2004,6 +2004,13 @@ finish_member_declaration (decl) ...@@ -2004,6 +2004,13 @@ finish_member_declaration (decl)
/* Mark the DECL as a member of the current class. */ /* Mark the DECL as a member of the current class. */
DECL_CONTEXT (decl) = current_class_type; DECL_CONTEXT (decl) = current_class_type;
/* [dcl.link]
A C language linkage is ignored for the names of class members
and the member function type of class member functions. */
if (DECL_LANG_SPECIFIC (decl) && DECL_LANGUAGE (decl) == lang_c)
DECL_LANGUAGE (decl) = lang_cplusplus;
/* Put functions on the TYPE_METHODS list and everything else on the /* Put functions on the TYPE_METHODS list and everything else on the
TYPE_FIELDS list. Note that these are built up in reverse order. TYPE_FIELDS list. Note that these are built up in reverse order.
We reverse them (to obtain declaration order) in finish_struct. */ We reverse them (to obtain declaration order) in finish_struct. */
......
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