static int warn_about_return_type;
-/* Nonzero when starting a function delcared `extern inline'. */
+/* Nonzero when starting a function declared `extern inline'. */
static int current_extern_inline;
\f
static tree grokparms (), grokdeclarator ();
tree pushdecl ();
-static tree builtin_function ();
+tree builtin_function ();
static tree lookup_tag ();
static tree lookup_tag_reverse ();
/* Warn if adding () is suggested. */
-int warn_parentheses = 1;
+int warn_parentheses;
/* Nonzero means `$' can be in an identifier.
See cccp.c for reasons why this breaks some obscure ANSI C programs. */
warn_switch = 1;
warn_format = 1;
warn_char_subscripts = 1;
+ warn_parentheses = 1;
}
else
return 0;
warning_with_decl (newdecl, "shadowing built-in function `%s'");
}
/* Likewise, if the built-in is not ansi, then programs can
- overide it even globally without an error. */
+ override it even globally without an error. */
else if (DECL_BUILT_IN_NONANSI (olddecl))
warning_with_decl (newdecl,
"built-in function `%s' declared as non-function");
TREE_TYPE (IDENTIFIER_IMPLICIT_DECL (name))))
{
warning_with_decl (x, "type mismatch with previous implicit declaration");
- warning_with_decl (x, "previous implicit declaration of `%s'");
+ warning_with_decl (IDENTIFIER_IMPLICIT_DECL (name),
+ "previous implicit declaration of `%s'");
}
/* In PCC-compatibility mode, extern decls of vars with no current decl
if (TREE_PUBLIC (name)
&& ! TREE_PUBLIC (x) && ! TREE_EXTERNAL (x))
{
- if (IDENTIFIER_IMPLICIT_DECL (name))
+ /* Okay to declare an ANSI built-in as inline static. */
+ if (t != 0 && DECL_BUILT_IN (t)
+ && TREE_INLINE (x))
+ ;
+ /* Okay to declare a non-ANSI built-in as anything. */
+ else if (t != 0 && DECL_BUILT_IN_NONANSI (t))
+ ;
+ else if (IDENTIFIER_IMPLICIT_DECL (name))
pedwarn ("`%s' was declared implicitly `extern' and later `static'",
IDENTIFIER_POINTER (name));
else
sizetype,
endlink))));
- /* ``integer_tpe_node'' mispelling corrected: North-Keys 30 Mar 91 */
+ /* ``integer_tpe_node'' misspelling corrected: North-Keys 30 Mar 91 */
builtin_function ("__builtin_constant_p",
build_function_type (integer_type_node, endlink),
BUILT_IN_CONSTANT_P, 0);
BUILT_IN_STRCPY, "strcpy");
builtin_function ("__builtin_strlen", sizet_ftype_string,
BUILT_IN_STRLEN, "strlen");
+ builtin_function ("__builtin_fsqrt", double_ftype_double,
+ BUILT_IN_FSQRT, "sqrt");
/* In an ANSI C program, it is okay to supply built-in meanings
for these functions, since applications cannot validly use them
with any other meaning.
builtin_function ("strcmp", int_ftype_string_string, BUILT_IN_STRCMP, 0);
builtin_function ("strcpy", string_ftype_ptr_ptr, BUILT_IN_STRCPY, 0);
builtin_function ("strlen", sizet_ftype_string, BUILT_IN_STRLEN, 0);
+#if 0 /* No good, since open-coded implementation fails to set errno.
+ The ANSI committee made a real mistake in specifying math fns. */
+ builtin_function ("sqrt", double_ftype_double, BUILT_IN_FSQRT, 0);
+#endif
}
#if 0
builtin_function ("__builtin_fmod", double_ftype_double_double, BUILT_IN_FMOD, 0);
builtin_function ("__builtin_frem", double_ftype_double_double, BUILT_IN_FREM, 0);
builtin_function ("__builtin_memset", ptr_ftype_ptr_int_int, BUILT_IN_MEMSET, 0);
- builtin_function ("__builtin_fsqrt", double_ftype_double, BUILT_IN_FSQRT, 0);
builtin_function ("__builtin_getexp", double_ftype_double, BUILT_IN_GETEXP, 0);
builtin_function ("__builtin_getman", double_ftype_double, BUILT_IN_GETMAN, 0);
#endif
If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
the name to be called if we can't opencode the function. */
-static tree
+tree
builtin_function (name, type, function_code, library_name)
char *name;
tree type;
tree parm;
{
tree decl;
+ int old_immediate_size_expand = immediate_size_expand;
+ /* Don't try computing parm sizes now -- wait till fn is called. */
+ immediate_size_expand = 0;
/* The corresponding pop_obstacks is in finish_decl. */
push_obstacks_nochange ();
decl = grokdeclarator (TREE_VALUE (parm), TREE_PURPOSE (parm), PARM, 0);
decl = pushdecl (decl);
+ immediate_size_expand = old_immediate_size_expand;
+
current_binding_level->parm_order
= tree_cons (NULL_TREE, decl, current_binding_level->parm_order);
}
\f
/* Make TYPE a complete type based on INITIAL_VALUE.
- Return 0 if successful, 1 if INITIAL_VALUE can't be decyphered,
+ Return 0 if successful, 1 if INITIAL_VALUE can't be deciphered,
2 if there was no information (in which case assume 1 if DO_DEFAULT). */
int
argument type is specified but not the name.
This function is where the complicated C meanings of `static'
- and `extern' are intrepreted. */
+ and `extern' are interpreted. */
static tree
grokdeclarator (declarator, declspecs, decl_context, initialized)
int funcdef_flag = 0;
enum tree_code innermost_code = ERROR_MARK;
int bitfield = 0;
- int variable_size = 0;
+ int size_varies = 0;
if (decl_context == BITFIELD)
bitfield = 1, decl_context = FIELD;
typedef_type = type;
if (type)
- variable_size = C_TYPE_VARIABLE_SIZE (type);
+ size_varies = C_TYPE_VARIABLE_SIZE (type);
/* No type at all: default to `int', and set EXPLICIT_INT
because it was not a user-defined typedef. */
1);
/* Make sure the array size remains visibly nonconstant
even if it is (eg) a const variable with known value. */
- variable_size = 1;
- itype = build_index_type (save_expr (itype));
+ size_varies = 1;
+ itype = variable_size (itype);
+ itype = build_index_type (itype);
}
}
#endif
type = build_array_type (type, itype);
- if (variable_size)
+ if (size_varies)
C_TYPE_VARIABLE_SIZE (type) = 1;
}
else if (TREE_CODE (declarator) == CALL_EXPR)
if (type == error_mark_node)
continue;
- variable_size = 0;
+ size_varies = 0;
/* Warn about some types functions can't return. */
type = c_build_type_variant (type, constp, volatilep);
constp = 0;
volatilep = 0;
- variable_size = 0;
+ size_varies = 0;
type = build_pointer_type (type);
&& TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == 0)
{
type = build_array_type (TREE_TYPE (type), 0);
- if (variable_size)
+ if (size_varies)
C_TYPE_VARIABLE_SIZE (type) = 1;
}
type = build_pointer_type
(c_build_type_variant (TREE_TYPE (type), constp, volatilep));
volatilep = constp = 0;
- variable_size = 0;
+ size_varies = 0;
}
else if (TREE_CODE (type) == FUNCTION_TYPE)
{
error ("parameter `%s' is initialized", name);
decl = build_decl (PARM_DECL, declarator, type);
- if (variable_size)
+ if (size_varies)
C_DECL_VARIABLE_SIZE (decl) = 1;
/* Compute the type actually passed in the parmlist,
#endif
}
decl = build_decl (FIELD_DECL, declarator, type);
- if (variable_size)
+ if (size_varies)
C_DECL_VARIABLE_SIZE (decl) = 1;
}
else if (TREE_CODE (type) == FUNCTION_TYPE)
}
decl = build_decl (VAR_DECL, declarator, type);
- if (variable_size)
+ if (size_varies)
C_DECL_VARIABLE_SIZE (decl) = 1;
if (inlinep)
/* Even if this is the wrong type of tag, return what we found.
There will be an error message anyway, from pending_xref_error.
If we create an empty xref just for an invalid use of the type,
- the main result is to create lots of superflous error messages. */
+ the main result is to create lots of superfluous error messages. */
if (ref)
return ref;
will be a variant of the main variant of the original function
type. */
- TREE_TYPE (fndecl)
- = build_type_copy (TYPE_MAIN_VARIANT (TREE_TYPE (fndecl)),
- TYPE_READONLY (TREE_TYPE (fndecl)),
- TYPE_VOLATILE (TREE_TYPE (fndecl)));
+ TREE_TYPE (fndecl) = build_type_copy (TREE_TYPE (fndecl));
TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = actual;
}