Commit 1d02ac83 by Jason Merrill

decl2.c (reparse_absdcl_as_casts): Don't warn about old-style casts in system…

decl2.c (reparse_absdcl_as_casts): Don't warn about old-style casts in system headers or extern "C" blocks.

	* decl2.c (reparse_absdcl_as_casts): Don't warn about old-style
	casts in system headers or extern "C" blocks.
	* decl2.c (write_virtuals): Deleted declaration.
	* cp-tree.h (write_virtuals): Deleted extern declaration.
	* class.c (finish_struct_1): Removed #if 0'd code that mentions
	write_virtuals.
	* semantics.c (begin_class_definition): Rewrite code to not depend
	on write_virtuals.
	* lex.c (cp_pragma_interface): New function.
	(cp_pragma_implementation): Likewise.
	(handle_cp_pragma): Call them.

From-SVN: r28045
parent 6f1b4c42
1999-07-09 Jason Merrill <jason@yorick.cygnus.com> 1999-07-09 Jason Merrill <jason@yorick.cygnus.com>
* decl2.c (reparse_absdcl_as_casts): Don't warn about old-style
casts in system headers or extern "C" blocks.
* pt.c (do_decl_instantiation): Downgrade duplicate instantiation * pt.c (do_decl_instantiation): Downgrade duplicate instantiation
errors to pedwarn. errors to pedwarn.
1999-07-09 Michael Tiemann <tiemann@happy.cygnus.com> 1999-07-09 Michael Tiemann <tiemann@happy.cygnus.com>
* decl2.c (write_virtuals): Deleted declaration.
* cp-tree.h (write_virtuals): Deleted extern declaration.
* class.c (finish_struct_1): Removed #if 0'd code that mentions
write_virtuals.
* semantics.c (begin_class_definition): Rewrite code to not depend
on write_virtuals.
* lex.c (cp_pragma_interface): New function.
(cp_pragma_implementation): Likewise.
(handle_cp_pragma): Call them.
* typeck.c (comptypes): Simplify C code in look_hard. * typeck.c (comptypes): Simplify C code in look_hard.
* xref.c (PALLOC): Use xcalloc, not calloc. * xref.c (PALLOC): Use xcalloc, not calloc.
...@@ -25,6 +39,8 @@ ...@@ -25,6 +39,8 @@
* class.c (duplicate_tag_error): Set TYPE_NONCOPIED_PARTS to * class.c (duplicate_tag_error): Set TYPE_NONCOPIED_PARTS to
NULL_TREE. NULL_TREE.
* ptree.c (print_lang_type): Added vtable-needs-writing.
Wed Jul 7 01:26:47 1999 Alexandre Oliva <oliva@dcc.unicamp.br> Wed Jul 7 01:26:47 1999 Alexandre Oliva <oliva@dcc.unicamp.br>
* decl2.c (mark_vtable_entries): Fix check for rtti offset. * decl2.c (mark_vtable_entries): Fix check for rtti offset.
......
...@@ -3212,16 +3212,6 @@ finish_struct_1 (t, warn_anon) ...@@ -3212,16 +3212,6 @@ finish_struct_1 (t, warn_anon)
no_const_asn_ref = 0; no_const_asn_ref = 0;
} }
#if 0
/* Both of these should be done before now. */
if (write_virtuals == 3 && CLASSTYPE_INTERFACE_KNOWN (t)
&& ! IS_SIGNATURE (t))
{
my_friendly_assert (CLASSTYPE_INTERFACE_ONLY (t) == interface_only, 999);
my_friendly_assert (CLASSTYPE_VTABLE_NEEDS_WRITING (t) == ! interface_only, 999);
}
#endif
/* The three of these are approximations which may later be /* The three of these are approximations which may later be
modified. Needed at this point to make add_virtual_function modified. Needed at this point to make add_virtual_function
and modify_vtable_entries work. */ and modify_vtable_entries work. */
......
...@@ -490,18 +490,6 @@ extern int warn_old_style_cast; ...@@ -490,18 +490,6 @@ extern int warn_old_style_cast;
extern int flag_signed_bitfields; extern int flag_signed_bitfields;
/* 3 means write out only virtuals function tables `defined'
in this implementation file.
2 means write out only specific virtual function tables
and give them (C) public access.
1 means write out virtual function tables and give them
(C) public access.
0 means write out virtual function tables and give them
(C) static access (default).
-1 means declare virtual function tables extern. */
extern int write_virtuals;
/* True for more efficient but incompatible (not fully tested) /* True for more efficient but incompatible (not fully tested)
vtable implementation (using thunks). vtable implementation (using thunks).
0 is old behavior; 1 is new behavior. */ 0 is old behavior; 1 is new behavior. */
......
...@@ -375,13 +375,6 @@ int flag_detailed_statistics; ...@@ -375,13 +375,6 @@ int flag_detailed_statistics;
int flag_this_is_variable; int flag_this_is_variable;
/* 3 means write out only virtuals function tables `defined'
in this implementation file.
0 means write out virtual function tables and give them
(C) static access (default). */
int write_virtuals;
/* Nonzero means we should attempt to elide constructors when possible. */ /* Nonzero means we should attempt to elide constructors when possible. */
int flag_elide_constructors = 1; int flag_elide_constructors = 1;
...@@ -3818,7 +3811,8 @@ reparse_absdcl_as_casts (decl, expr) ...@@ -3818,7 +3811,8 @@ reparse_absdcl_as_casts (decl, expr)
expr = build_c_cast (type, expr); expr = build_c_cast (type, expr);
} }
if (warn_old_style_cast) if (warn_old_style_cast && ! in_system_header
&& current_lang_name != lang_name_c)
warning ("use of old-style cast"); warning ("use of old-style cast");
return expr; return expr;
......
...@@ -71,6 +71,8 @@ static int set_vardecl_interface_info PROTO((tree *, void *)); ...@@ -71,6 +71,8 @@ static int set_vardecl_interface_info PROTO((tree *, void *));
static void store_pending_inline PROTO((tree, struct pending_inline *)); static void store_pending_inline PROTO((tree, struct pending_inline *));
static void reinit_parse_for_expr PROTO((struct obstack *)); static void reinit_parse_for_expr PROTO((struct obstack *));
static int *init_cpp_parse PROTO((void)); static int *init_cpp_parse PROTO((void));
static void cp_pragma_interface PROTO((char *));
static void cp_pragma_implementation PROTO ((char *));
static int handle_cp_pragma PROTO((const char *)); static int handle_cp_pragma PROTO((const char *));
#ifdef HANDLE_GENERIC_PRAGMAS #ifdef HANDLE_GENERIC_PRAGMAS
static int handle_generic_pragma PROTO((int)); static int handle_generic_pragma PROTO((int));
...@@ -1136,6 +1138,93 @@ interface_strcmp (s) ...@@ -1136,6 +1138,93 @@ interface_strcmp (s)
return 1; return 1;
} }
static void
cp_pragma_interface (main_filename)
char *main_filename;
{
tree fileinfo
= TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
if (impl_file_chain == 0)
{
/* If this is zero at this point, then we are
auto-implementing. */
if (main_input_filename == 0)
main_input_filename = input_filename;
#ifdef AUTO_IMPLEMENT
filename = file_name_nondirectory (main_input_filename);
fi = get_time_identifier (filename);
fi = TIME_IDENTIFIER_FILEINFO (fi);
TREE_INT_CST_LOW (fi) = 0;
TREE_INT_CST_HIGH (fi) = 1;
/* Get default. */
impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
impl_file_chain->filename = filename;
impl_file_chain->next = 0;
#endif
}
interface_only = interface_strcmp (main_filename);
#ifdef MULTIPLE_SYMBOL_SPACES
if (! interface_only)
interface_unknown = 0;
#else /* MULTIPLE_SYMBOL_SPACES */
interface_unknown = 0;
#endif /* MULTIPLE_SYMBOL_SPACES */
TREE_INT_CST_LOW (fileinfo) = interface_only;
TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
}
static void
cp_pragma_implementation (main_filename)
char *main_filename;
{
tree fileinfo
= TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
if (impl_file_chain)
{
struct impl_files *ifiles = impl_file_chain;
while (ifiles)
{
if (! strcmp (ifiles->filename, main_filename))
break;
ifiles = ifiles->next;
}
if (ifiles == 0)
{
ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
ifiles->filename = main_filename;
ifiles->next = impl_file_chain;
impl_file_chain = ifiles;
}
}
else if ((main_input_filename != 0
&& ! strcmp (main_input_filename, input_filename))
|| ! strcmp (main_filename, input_filename))
{
impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
impl_file_chain->filename = main_filename;
impl_file_chain->next = 0;
}
else
error ("`#pragma implementation' can only appear at top-level");
interface_only = 0;
#if 1
/* We make this non-zero so that we infer decl linkage
in the impl file only for variables first declared
in the interface file. */
interface_unknown = 1;
#else
/* We make this zero so that templates in the impl
file will be emitted properly. */
interface_unknown = 0;
#endif
TREE_INT_CST_LOW (fileinfo) = interface_only;
TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
}
static int static int
set_typedecl_interface_info (t, data) set_typedecl_interface_info (t, data)
tree *t; tree *t;
...@@ -2465,15 +2554,6 @@ linenum: ...@@ -2465,15 +2554,6 @@ linenum:
} }
main_input_filename = input_filename; main_input_filename = input_filename;
if (write_virtuals == 3)
{
walk_globals (vtable_decl_p,
set_vardecl_interface_info,
/*data=*/0);
walk_globals (vtype_decl_p,
set_typedecl_interface_info,
/*data=*/0);
}
} }
extract_interface_info (); extract_interface_info ();
...@@ -4804,11 +4884,6 @@ handle_cp_pragma (pname) ...@@ -4804,11 +4884,6 @@ handle_cp_pragma (pname)
return -1; return -1;
} }
if (write_virtuals != 2)
{
warning ("use `+e2' option to enable #pragma vtable");
return -1;
}
pending_vtables pending_vtables
= perm_tree_cons (NULL_TREE, = perm_tree_cons (NULL_TREE,
get_identifier (TREE_STRING_POINTER (yylval.ttype)), get_identifier (TREE_STRING_POINTER (yylval.ttype)),
...@@ -4834,8 +4909,6 @@ handle_cp_pragma (pname) ...@@ -4834,8 +4909,6 @@ handle_cp_pragma (pname)
} }
else if (! strcmp (pname, "interface")) else if (! strcmp (pname, "interface"))
{ {
tree fileinfo
= TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
char *main_filename = input_filename; char *main_filename = input_filename;
main_filename = file_name_nondirectory (main_filename); main_filename = file_name_nondirectory (main_filename);
...@@ -4857,48 +4930,18 @@ handle_cp_pragma (pname) ...@@ -4857,48 +4930,18 @@ handle_cp_pragma (pname)
if (token != END_OF_LINE) if (token != END_OF_LINE)
warning ("garbage after `#pragma interface' ignored"); warning ("garbage after `#pragma interface' ignored");
write_virtuals = 3; cp_pragma_interface (main_filename);
if (impl_file_chain == 0)
{
/* If this is zero at this point, then we are
auto-implementing. */
if (main_input_filename == 0)
main_input_filename = input_filename;
#ifdef AUTO_IMPLEMENT
filename = file_name_nondirectory (main_input_filename);
fi = get_time_identifier (filename);
fi = TIME_IDENTIFIER_FILEINFO (fi);
TREE_INT_CST_LOW (fi) = 0;
TREE_INT_CST_HIGH (fi) = 1;
/* Get default. */
impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
impl_file_chain->filename = filename;
impl_file_chain->next = 0;
#endif
}
interface_only = interface_strcmp (main_filename);
#ifdef MULTIPLE_SYMBOL_SPACES
if (! interface_only)
interface_unknown = 0;
#else /* MULTIPLE_SYMBOL_SPACES */
interface_unknown = 0;
#endif /* MULTIPLE_SYMBOL_SPACES */
TREE_INT_CST_LOW (fileinfo) = interface_only;
TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
return 1; return 1;
} }
else if (! strcmp (pname, "implementation")) else if (! strcmp (pname, "implementation"))
{ {
tree fileinfo
= TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
char *main_filename = main_input_filename ? main_input_filename : input_filename; char *main_filename = main_input_filename ? main_input_filename : input_filename;
main_filename = file_name_nondirectory (main_filename); main_filename = file_name_nondirectory (main_filename);
token = real_yylex (); token = real_yylex ();
if (token != END_OF_LINE) if (token != END_OF_LINE)
{ {
if (token != STRING if (token != STRING
...@@ -4914,50 +4957,7 @@ handle_cp_pragma (pname) ...@@ -4914,50 +4957,7 @@ handle_cp_pragma (pname)
if (token != END_OF_LINE) if (token != END_OF_LINE)
warning ("garbage after `#pragma implementation' ignored"); warning ("garbage after `#pragma implementation' ignored");
if (write_virtuals == 3) cp_pragma_implementation (main_filename);
{
struct impl_files *ifiles = impl_file_chain;
while (ifiles)
{
if (! strcmp (ifiles->filename, main_filename))
break;
ifiles = ifiles->next;
}
if (ifiles == 0)
{
ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
ifiles->filename = main_filename;
ifiles->next = impl_file_chain;
impl_file_chain = ifiles;
}
}
else if ((main_input_filename != 0
&& ! strcmp (main_input_filename, input_filename))
|| ! strcmp (input_filename, main_filename))
{
write_virtuals = 3;
if (impl_file_chain == 0)
{
impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
impl_file_chain->filename = main_filename;
impl_file_chain->next = 0;
}
}
else
error ("`#pragma implementation' can only appear at top-level");
interface_only = 0;
#if 1
/* We make this non-zero so that we infer decl linkage
in the impl file only for variables first declared
in the interface file. */
interface_unknown = 1;
#else
/* We make this zero so that templates in the impl
file will be emitted properly. */
interface_unknown = 0;
#endif
TREE_INT_CST_LOW (fileinfo) = interface_only;
TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
return 1; return 1;
} }
......
...@@ -1329,16 +1329,12 @@ begin_class_definition (t) ...@@ -1329,16 +1329,12 @@ begin_class_definition (t)
SET_CLASSTYPE_INTERFACE_UNKNOWN_X SET_CLASSTYPE_INTERFACE_UNKNOWN_X
(t, interface_unknown); (t, interface_unknown);
} }
/* Record how to set the access of this class's /* Only leave this bit clear if we know this
virtual functions. If write_virtuals == 3, then class is part of an interface-only specification. */
inline virtuals are ``extern inline''. */ if (! CLASSTYPE_INTERFACE_KNOWN (t)
if (write_virtuals == 3) || ! CLASSTYPE_INTERFACE_ONLY (t))
needs_writing = ! CLASSTYPE_INTERFACE_ONLY (t) CLASSTYPE_VTABLE_NEEDS_WRITING (t) = 1;
&& CLASSTYPE_INTERFACE_KNOWN (t);
else
needs_writing = 1;
CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing;
} }
#if 0 #if 0
tmp = TYPE_IDENTIFIER ($<ttype>0); tmp = TYPE_IDENTIFIER ($<ttype>0);
......
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