When SYSTEM_IMPLICIT_EXTERN_C is in effect, we have a couple of hacks to
allow unprototyped declarations.
1) in decls_match we look at the promoted return types
2) in decls_match and in the parser we allow '()' to mean '(...)'.
This is of course horrible, #2 will fail badly on modern ABIs. #1 may
well break sign extension behaviour of smaller-than-int return types.
As it happens the only remaining SIEC target is AIX, and its system
header files are sufficiently prototyped (including 'int open (const
char *, int, ...)').
I've bootstrapped this patch on powerpc8-aix with no change in test
results. (Thanks David on helping with that.)
IMHO we don't need to warn about this going way first. If it did affect
a target it'd be very noisy.
I'll commit in a few days, unless there are objections.
nathan
--
Nathan Sidwell
2018-08-29 Nathan Sidwell <nat...@acm.org>
gcc/
* doc/extend.texi (Backwards Compatibility): Remove implicit
extern C leeway of () being (...).
gcc/cp/
* decl.c (decls_match): Remove SYSTEM_IMPLICIT_EXTERN_C matching
of return types and parms.
* parser.c (cp_parser_parameter_declaration_clause): Likewise,
'()' always means '(void)'.
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c (revision 263897)
+++ gcc/cp/decl.c (working copy)
@@ -968,30 +968,12 @@ decls_match (tree newdecl, tree olddecl,
if (same_type_p (TREE_TYPE (f1), r2))
{
if (!prototype_p (f2) && DECL_EXTERN_C_P (olddecl)
- && (fndecl_built_in_p (olddecl)
-#ifdef SYSTEM_IMPLICIT_EXTERN_C
- || (DECL_IN_SYSTEM_HEADER (newdecl) && !DECL_CLASS_SCOPE_P (newdecl))
- || (DECL_IN_SYSTEM_HEADER (olddecl) && !DECL_CLASS_SCOPE_P (olddecl))
-#endif
- ))
+ && fndecl_built_in_p (olddecl))
{
types_match = self_promoting_args_p (p1);
if (p1 == void_list_node)
TREE_TYPE (newdecl) = TREE_TYPE (olddecl);
}
-#ifdef SYSTEM_IMPLICIT_EXTERN_C
- else if (!prototype_p (f1)
- && (DECL_EXTERN_C_P (olddecl)
- && DECL_IN_SYSTEM_HEADER (olddecl)
- && !DECL_CLASS_SCOPE_P (olddecl))
- && (DECL_EXTERN_C_P (newdecl)
- && DECL_IN_SYSTEM_HEADER (newdecl)
- && !DECL_CLASS_SCOPE_P (newdecl)))
- {
- types_match = self_promoting_args_p (p2);
- TREE_TYPE (newdecl) = TREE_TYPE (olddecl);
- }
-#endif
else
types_match =
compparms (p1, p2)
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c (revision 263897)
+++ gcc/cp/parser.c (working copy)
@@ -21372,16 +21372,7 @@ cp_parser_parameter_declaration_clause (
}
else if (token->type == CPP_CLOSE_PAREN)
/* There are no parameters. */
- {
-#ifdef SYSTEM_IMPLICIT_EXTERN_C
- if (in_system_header_at (input_location)
- && current_class_type == NULL
- && current_lang_name == lang_name_c)
- return NULL_TREE;
- else
-#endif
- return void_list_node;
- }
+ return void_list_node;
/* Check for `(void)', too, which is a special case. */
else if (token->keyword == RID_VOID
&& (cp_lexer_peek_nth_token (parser->lexer, 2)->type
Index: gcc/doc/extend.texi
===================================================================
--- gcc/doc/extend.texi (revision 263897)
+++ gcc/doc/extend.texi (working copy)
@@ -23685,9 +23685,9 @@ deprecated. @xref{Deprecated Features}
@item Implicit C language
Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
scope to set the language. On such systems, all system header files are
-implicitly scoped inside a C language scope. Also, an empty prototype
-@code{()} is treated as an unspecified number of arguments, rather
-than no arguments, as C++ demands.
+implicitly scoped inside a C language scope. Such headers must
+correctly prototype function argument types, there is no leeway for
+@code{()} to indicate an unspecified set of arguments.
@end table