summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>1999-07-09 12:44:37 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>1999-07-09 12:44:37 +0000
commit495d2af2e9476c727801e6bf1f1f31088edb0b55 (patch)
treece533478692fb6b5bbf3b4376582f0ed83cc0394 /gcc/cp
parent8036fa43a36a2df0d9ce3e116398d7e6ff270e9d (diff)
downloadgcc-495d2af2e9476c727801e6bf1f1f31088edb0b55.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@28045 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog16
-rw-r--r--gcc/cp/class.c10
-rw-r--r--gcc/cp/cp-tree.h12
-rw-r--r--gcc/cp/decl2.c10
-rw-r--r--gcc/cp/lex.c186
-rw-r--r--gcc/cp/semantics.c16
6 files changed, 117 insertions, 133 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 442e8531fa7..ff27a479baf 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,10 +1,24 @@
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
errors to pedwarn.
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.
* xref.c (PALLOC): Use xcalloc, not calloc.
@@ -25,6 +39,8 @@
* class.c (duplicate_tag_error): Set TYPE_NONCOPIED_PARTS to
NULL_TREE.
+ * ptree.c (print_lang_type): Added vtable-needs-writing.
+
Wed Jul 7 01:26:47 1999 Alexandre Oliva <oliva@dcc.unicamp.br>
* decl2.c (mark_vtable_entries): Fix check for rtti offset.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 4fcb2fd4216..4d00dfb5475 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -3212,16 +3212,6 @@ finish_struct_1 (t, warn_anon)
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
modified. Needed at this point to make add_virtual_function
and modify_vtable_entries work. */
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index b84a6adda5f..cfbe20274f5 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -490,18 +490,6 @@ extern int warn_old_style_cast;
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)
vtable implementation (using thunks).
0 is old behavior; 1 is new behavior. */
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index d4fcac6c5de..d7b17c54ca8 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -375,13 +375,6 @@ int flag_detailed_statistics;
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. */
int flag_elide_constructors = 1;
@@ -3818,7 +3811,8 @@ reparse_absdcl_as_casts (decl, 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");
return expr;
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 2310345a2b0..aa4b0ede448 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -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 reinit_parse_for_expr PROTO((struct obstack *));
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 *));
#ifdef HANDLE_GENERIC_PRAGMAS
static int handle_generic_pragma PROTO((int));
@@ -1136,6 +1138,93 @@ interface_strcmp (s)
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
set_typedecl_interface_info (t, data)
tree *t;
@@ -2465,15 +2554,6 @@ linenum:
}
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 ();
@@ -4804,11 +4884,6 @@ handle_cp_pragma (pname)
return -1;
}
- if (write_virtuals != 2)
- {
- warning ("use `+e2' option to enable #pragma vtable");
- return -1;
- }
pending_vtables
= perm_tree_cons (NULL_TREE,
get_identifier (TREE_STRING_POINTER (yylval.ttype)),
@@ -4834,8 +4909,6 @@ handle_cp_pragma (pname)
}
else if (! strcmp (pname, "interface"))
{
- tree fileinfo
- = TIME_IDENTIFIER_FILEINFO (get_time_identifier (input_filename));
char *main_filename = input_filename;
main_filename = file_name_nondirectory (main_filename);
@@ -4857,48 +4930,18 @@ handle_cp_pragma (pname)
if (token != END_OF_LINE)
warning ("garbage after `#pragma interface' ignored");
- write_virtuals = 3;
-
- 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;
+ cp_pragma_interface (main_filename);
return 1;
}
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;
main_filename = file_name_nondirectory (main_filename);
+
token = real_yylex ();
+
if (token != END_OF_LINE)
{
if (token != STRING
@@ -4914,50 +4957,7 @@ handle_cp_pragma (pname)
if (token != END_OF_LINE)
warning ("garbage after `#pragma implementation' ignored");
- if (write_virtuals == 3)
- {
- 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;
+ cp_pragma_implementation (main_filename);
return 1;
}
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 1659ec85fe0..059375b5e27 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1329,16 +1329,12 @@ begin_class_definition (t)
SET_CLASSTYPE_INTERFACE_UNKNOWN_X
(t, interface_unknown);
}
-
- /* Record how to set the access of this class's
- virtual functions. If write_virtuals == 3, then
- inline virtuals are ``extern inline''. */
- if (write_virtuals == 3)
- needs_writing = ! CLASSTYPE_INTERFACE_ONLY (t)
- && CLASSTYPE_INTERFACE_KNOWN (t);
- else
- needs_writing = 1;
- CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing;
+
+ /* Only leave this bit clear if we know this
+ class is part of an interface-only specification. */
+ if (! CLASSTYPE_INTERFACE_KNOWN (t)
+ || ! CLASSTYPE_INTERFACE_ONLY (t))
+ CLASSTYPE_VTABLE_NEEDS_WRITING (t) = 1;
}
#if 0
tmp = TYPE_IDENTIFIER ($<ttype>0);