&& TREE_PUBLIC (p)
&& !DECL_INITIAL (p)
&& !flag_gnu89_inline)
- pedwarn (0, "inline function %q+D declared but never defined", p);
+ pedwarn (input_location, 0, "inline function %q+D declared but never defined", p);
goto common_symbol;
if (TREE_CHAIN (t) == 0
&& TYPE_MAIN_VARIANT (type) != void_type_node)
{
- inform ("a parameter list with an ellipsis can%'t match "
+ inform (input_location, "a parameter list with an ellipsis can%'t match "
"an empty parameter name list declaration");
break;
}
if (c_type_promotes_to (type) != type)
{
- inform ("an argument type that has a default promotion can%'t match "
+ inform (input_location, "an argument type that has a default promotion can%'t match "
"an empty parameter name list declaration");
break;
}
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
;
else if (DECL_INITIAL (decl))
- inform ("previous definition of %q+D was here", decl);
+ inform (input_location, "previous definition of %q+D was here", decl);
else if (C_DECL_IMPLICIT (decl))
- inform ("previous implicit declaration of %q+D was here", decl);
+ inform (input_location, "previous implicit declaration of %q+D was here", decl);
else
- inform ("previous declaration of %q+D was here", decl);
+ inform (input_location, "previous declaration of %q+D was here", decl);
}
/* Subroutine of duplicate_decls. Compare NEWDECL to OLDDECL.
&& TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node
&& C_FUNCTION_IMPLICIT_INT (newdecl) && !DECL_INITIAL (olddecl))
{
- pedwarned = pedwarn (0, "conflicting types for %q+D", newdecl);
+ pedwarned = pedwarn (input_location, 0,
+ "conflicting types for %q+D", newdecl);
/* Make sure we keep void as the return type. */
TREE_TYPE (newdecl) = *newtypep = newtype = oldtype;
C_FUNCTION_IMPLICIT_INT (newdecl) = 0;
&& TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == integer_type_node
&& C_DECL_IMPLICIT (olddecl) && !DECL_INITIAL (olddecl))
{
- pedwarned = pedwarn (0, "conflicting types for %q+D", newdecl);
+ pedwarned = pedwarn (input_location, 0,
+ "conflicting types for %q+D", newdecl);
/* Make sure we keep void as the return type. */
TREE_TYPE (olddecl) = *oldtypep = oldtype = newtype;
}
throw it away, in case it was inlined into a function that
hasn't been written out yet. */
if (new_is_definition && DECL_INITIAL (olddecl))
- {
- if (TREE_USED (olddecl)
- /* We never inline re-defined extern inline functions.
- FIXME: This would be better handled by keeping both functions
- as separate declarations. */
- && cgraph_function_possibly_inlined_p (olddecl))
- (*debug_hooks->outlining_inline_function) (olddecl);
-
- /* The new defn must not be inline. */
- DECL_UNINLINABLE (newdecl) = 1;
- }
+ /* The new defn must not be inline. */
+ DECL_UNINLINABLE (newdecl) = 1;
else
{
/* If either decl says `inline', this fn is inline, unless
bool warned;
if (flag_isoc99)
- warned = pedwarn (OPT_Wimplicit_function_declaration,
- G_("implicit declaration of function %qE"), id);
+ warned = pedwarn (input_location, OPT_Wimplicit_function_declaration,
+ "implicit declaration of function %qE", id);
else
warned = warning (OPT_Wimplicit_function_declaration,
G_("implicit declaration of function %qE"), id);
return decl;
}
+
+tree
+c_builtin_function_ext_scope (tree decl)
+{
+ tree type = TREE_TYPE (decl);
+ tree id = DECL_NAME (decl);
+
+ const char *name = IDENTIFIER_POINTER (id);
+ C_DECL_BUILTIN_PROTOTYPE (decl) = (TYPE_ARG_TYPES (type) != 0);
+
+ /* Should never be called on a symbol with a preexisting meaning. */
+ gcc_assert (!I_SYMBOL_BINDING (id));
+
+ bind (id, decl, external_scope, /*invisible=*/false, /*nested=*/false);
+
+ /* Builtins in the implementation namespace are made visible without
+ needing to be explicitly declared. See push_file_scope. */
+ if (name[0] == '_' && (name[1] == '_' || ISUPPER (name[1])))
+ {
+ TREE_CHAIN (decl) = visible_builtins;
+ visible_builtins = decl;
+ }
+
+ return decl;
+}
\f
/* Called when a declaration is seen that contains no names to declare.
If its type is a reference to a structure, union or enum inherited
if (warned != 1 && code != ENUMERAL_TYPE)
/* Empty unnamed enum OK */
{
- pedwarn (0, "unnamed struct/union that defines no instances");
+ pedwarn (input_location, 0,
+ "unnamed struct/union that defines no instances");
warned = 1;
}
}
&& declspecs->storage_class != csc_none)
{
if (warned != 1)
- pedwarn (0, "empty declaration with storage class specifier "
- "does not redeclare tag");
+ pedwarn (input_location, 0,
+ "empty declaration with storage class specifier "
+ "does not redeclare tag");
warned = 1;
pending_xref_error ();
}
|| declspecs->restrict_p))
{
if (warned != 1)
- pedwarn (0, "empty declaration with type qualifier "
+ pedwarn (input_location, 0,
+ "empty declaration with type qualifier "
"does not redeclare tag");
warned = 1;
pending_xref_error ();
{
if (warned != 1 && !in_system_header)
{
- pedwarn (0, "useless type name in empty declaration");
+ pedwarn (input_location, 0,
+ "useless type name in empty declaration");
warned = 1;
}
}
}
else if (warned != 1 && !in_system_header && declspecs->typedef_p)
{
- pedwarn (0, "useless type name in empty declaration");
+ pedwarn (input_location, 0, "useless type name in empty declaration");
warned = 1;
}
if (warned != 1)
{
if (!found_tag)
- pedwarn (0, "empty declaration");
+ pedwarn (input_location, 0, "empty declaration");
}
}
\f
if (!flag_isoc99)
{
if (static_p || quals != NULL)
- pedwarn (OPT_pedantic, "ISO C90 does not support %<static%> or type "
+ pedwarn (input_location, OPT_pedantic,
+ "ISO C90 does not support %<static%> or type "
"qualifiers in parameter array declarators");
if (vla_unspec_p)
- pedwarn (OPT_pedantic, "ISO C90 does not support %<[*]%> array declarators");
+ pedwarn (input_location, OPT_pedantic,
+ "ISO C90 does not support %<[*]%> array declarators");
}
if (vla_unspec_p)
{
if (!decl)
return 0;
- if (warn_main > 0 && TREE_CODE (decl) != FUNCTION_DECL
- && MAIN_NAME_P (DECL_NAME (decl)))
+ if (TREE_CODE (decl) != FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (decl)))
warning (OPT_Wmain, "%q+D is usually a function", decl);
if (initialized)
&& !TREE_READONLY (decl)
&& DECL_DECLARED_INLINE_P (current_function_decl)
&& DECL_EXTERNAL (current_function_decl))
- pedwarn (0, "%q+D is static but declared in inline function %qD "
- "which is not static", decl, current_function_decl);
+ pedwarn (input_location, 0,
+ "%q+D is static but declared in inline function %qD "
+ "which is not static", decl, current_function_decl);
/* Add this decl to the current scope.
TEM may equal DECL or it may be a previous decl of the same name. */
tree cleanup;
/* Build "cleanup(&decl)" for the destructor. */
- cleanup = build_unary_op (ADDR_EXPR, decl, 0);
+ cleanup = build_unary_op (input_location, ADDR_EXPR, decl, 0);
cleanup = build_tree_list (NULL_TREE, cleanup);
cleanup = build_function_call (cleanup_decl, cleanup);
if (pedantic && !current_scope->warned_forward_parm_decls)
{
- pedwarn (OPT_pedantic, "ISO C forbids forward parameter declarations");
+ pedwarn (input_location, OPT_pedantic,
+ "ISO C forbids forward parameter declarations");
current_scope->warned_forward_parm_decls = true;
}
&& type_mv != integer_type_node
&& type_mv != unsigned_type_node
&& type_mv != boolean_type_node)
- pedwarn (OPT_pedantic, "type of bit-field %qs is a GCC extension", name);
+ pedwarn (input_location, OPT_pedantic,
+ "type of bit-field %qs is a GCC extension", name);
max_width = TYPE_PRECISION (*type);
if (const_size)
{
if (name)
- pedwarn (OPT_Wvla, "ISO C90 forbids array %qs whose size "
+ pedwarn (input_location, OPT_Wvla, "ISO C90 forbids array %qs whose size "
"can%'t be evaluated",
name);
else
- pedwarn (OPT_Wvla, "ISO C90 forbids array whose size "
+ pedwarn (input_location, OPT_Wvla, "ISO C90 forbids array whose size "
"can%'t be evaluated");
}
else
{
if (name)
- pedwarn (OPT_Wvla, "ISO C90 forbids variable length array %qs",
+ pedwarn (input_location, OPT_Wvla, "ISO C90 forbids variable length array %qs",
name);
else
- pedwarn (OPT_Wvla, "ISO C90 forbids variable length array");
+ pedwarn (input_location, OPT_Wvla, "ISO C90 forbids variable length array");
}
}
else if (warn_vla > 0)
&& funcdef_flag)
warn_about_return_type = 1;
else
- pedwarn_c99 (flag_isoc99 ? 0 : OPT_Wimplicit_int,
+ pedwarn_c99 (input_location, flag_isoc99 ? 0 : OPT_Wimplicit_int,
"type defaults to %<int%> in declaration of %qs", name);
}
if (pedantic && !flag_isoc99)
{
if (constp > 1)
- pedwarn (OPT_pedantic, "duplicate %<const%>");
+ pedwarn (input_location, OPT_pedantic, "duplicate %<const%>");
if (restrictp > 1)
- pedwarn (OPT_pedantic, "duplicate %<restrict%>");
+ pedwarn (input_location, OPT_pedantic, "duplicate %<restrict%>");
if (volatilep > 1)
- pedwarn (OPT_pedantic, "duplicate %<volatile%>");
+ pedwarn (input_location, OPT_pedantic, "duplicate %<volatile%>");
}
if (!flag_gen_aux_info && (TYPE_QUALS (element_type)))
type = TYPE_MAIN_VARIANT (type);
|| storage_class == csc_typedef))
{
if (storage_class == csc_auto)
- pedwarn ((current_scope == file_scope) ? 0 : OPT_pedantic,
+ pedwarn (input_location,
+ (current_scope == file_scope) ? 0 : OPT_pedantic,
"function definition declared %<auto%>");
if (storage_class == csc_register)
error ("function definition declared %<register%>");
if (storage_class == csc_auto)
error ("file-scope declaration of %qs specifies %<auto%>", name);
if (pedantic && storage_class == csc_register)
- pedwarn (OPT_pedantic, "file-scope declaration of %qs specifies %<register%>", name);
+ pedwarn (input_location, OPT_pedantic,
+ "file-scope declaration of %qs specifies %<register%>", name);
}
else
{
}
if (pedantic && !in_system_header && flexible_array_type_p (type))
- pedwarn (OPT_pedantic, "invalid use of structure with flexible array member");
+ pedwarn (input_location, OPT_pedantic,
+ "invalid use of structure with flexible array member");
if (size == error_mark_node)
type = error_mark_node;
}
if (pedantic && integer_zerop (size))
- pedwarn (OPT_pedantic, "ISO C forbids zero-size array %qs", name);
+ pedwarn (input_location, OPT_pedantic,
+ "ISO C forbids zero-size array %qs", name);
if (TREE_CODE (size) == INTEGER_CST)
{
else if (decl_context == FIELD)
{
if (pedantic && !flag_isoc99 && !in_system_header)
- pedwarn (OPT_pedantic, "ISO C90 does not support flexible array members");
+ pedwarn (input_location, OPT_pedantic,
+ "ISO C90 does not support flexible array members");
/* ISO C99 Flexible array members are effectively
identical to GCC's zero-length array extension. */
function definitions in ISO C; GCC used to used
them for noreturn functions. */
if (VOID_TYPE_P (type) && really_funcdef)
- pedwarn (0, "function definition has qualified void return type");
+ pedwarn (input_location, 0,
+ "function definition has qualified void return type");
else
warning (OPT_Wignored_qualifiers,
"type qualifiers ignored on function return type");
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
&& type_quals)
- pedwarn (OPT_pedantic, "ISO C forbids qualified function types");
+ pedwarn (input_location, OPT_pedantic,
+ "ISO C forbids qualified function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
size_varies = 0;
tree decl;
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
&& type_quals)
- pedwarn (OPT_pedantic, "ISO C forbids qualified function types");
+ pedwarn (input_location, OPT_pedantic,
+ "ISO C forbids qualified function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
decl = build_decl (TYPE_DECL, declarator->u.id, type);
if (declspecs->explicit_signed_p)
C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
if (declspecs->inline_p)
- pedwarn (0, "typedef %q+D declared %<inline%>", decl);
+ pedwarn (input_location, 0,"typedef %q+D declared %<inline%>", decl);
return decl;
}
&& !declspecs->inline_p);
if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
&& type_quals)
- pedwarn (OPT_pedantic, "ISO C forbids const or volatile function types");
+ pedwarn (input_location, OPT_pedantic,
+ "ISO C forbids const or volatile function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
return type;
&& variably_modified_type_p (type, NULL_TREE))
{
/* C99 6.7.2.1p8 */
- pedwarn (OPT_pedantic,
+ pedwarn (input_location, OPT_pedantic,
"a member of a structure or union cannot have a variably modified type");
}
else if (TREE_CODE (type) == FUNCTION_TYPE)
{
if (type_quals)
- pedwarn (OPT_pedantic, "ISO C forbids qualified function types");
+ pedwarn (input_location, OPT_pedantic,
+ "ISO C forbids qualified function types");
if (type_quals)
type = c_build_qualified_type (type, type_quals);
type = build_pointer_type (type);
DECL_ARG_TYPE (decl) = promoted_type;
if (declspecs->inline_p)
- pedwarn (0, "parameter %q+D declared %<inline%>", decl);
+ pedwarn (input_location, 0, "parameter %q+D declared %<inline%>", decl);
}
else if (decl_context == FIELD)
{
GCC allows 'auto', perhaps with 'inline', to support
nested functions. */
if (storage_class == csc_auto)
- pedwarn (OPT_pedantic, "invalid storage class for function %qs", name);
+ pedwarn (input_location, OPT_pedantic, "invalid storage class for function %qs", name);
else if (storage_class == csc_static)
{
error ("invalid storage class for function %qs", name);
decl = build_decl_attribute_variant (decl, decl_attr);
if (pedantic && type_quals && !DECL_IN_SYSTEM_HEADER (decl))
- pedwarn (OPT_pedantic,
+ pedwarn (input_location, OPT_pedantic,
"ISO C forbids qualified function types");
/* GNU C interprets a volatile-qualified function type to indicate
if (flag_hosted && MAIN_NAME_P (declarator->u.id))
{
if (declspecs->inline_p)
- pedwarn (0, "cannot inline function %<main%>");
+ pedwarn (input_location, 0, "cannot inline function %<main%>");
}
else if (declspecs->inline_p)
/* Record that the function is declared `inline'. */
C_DECL_VARIABLE_SIZE (decl) = 1;
if (declspecs->inline_p)
- pedwarn (0, "variable %q+D declared %<inline%>", decl);
+ pedwarn (input_location, 0, "variable %q+D declared %<inline%>", decl);
/* At file scope, an initialized extern declaration may follow
a static declaration. In that case, DECL_EXTERNAL will be
else if (arg_types && TREE_CODE (TREE_VALUE (arg_types)) == IDENTIFIER_NODE)
{
if (!funcdef_flag)
- pedwarn (0, "parameter names (without types) in function declaration");
+ pedwarn (input_location, 0, "parameter names (without types) in function declaration");
arg_info->parms = arg_info->types;
arg_info->types = 0;
WIDTH is non-NULL for bit-fields only, and is an INTEGER_CST node.
DECL_ATTRS is as for grokdeclarator.
+ LOC is the location of the structure component.
+
This is done during the parsing of the struct declaration.
The FIELD_DECL nodes are chained together and the lot of them
are ultimately passed to `build_struct' to make the RECORD_TYPE node. */
tree
-grokfield (struct c_declarator *declarator, struct c_declspecs *declspecs,
+grokfield (location_t loc,
+ struct c_declarator *declarator, struct c_declspecs *declspecs,
tree width, tree *decl_attrs)
{
tree value;
}
if (!ok)
{
- pedwarn (0, "declaration does not declare anything");
+ pedwarn (loc, 0, "declaration does not declare anything");
return NULL_TREE;
}
- pedwarn (OPT_pedantic, "ISO C doesn%'t support unnamed structs/unions");
+ pedwarn (loc, OPT_pedantic, "ISO C doesn%'t support unnamed structs/unions");
}
value = grokdeclarator (declarator, declspecs, FIELD, false,
if (TREE_CODE (t) == UNION_TYPE)
{
if (fieldlist)
- pedwarn (OPT_pedantic, "union has no named members");
+ pedwarn (input_location, OPT_pedantic, "union has no named members");
else
- pedwarn (OPT_pedantic, "union has no members");
+ pedwarn (input_location, OPT_pedantic, "union has no members");
}
else
{
if (fieldlist)
- pedwarn (OPT_pedantic, "struct has no named members");
+ pedwarn (input_location, OPT_pedantic, "struct has no named members");
else
- pedwarn (OPT_pedantic, "struct has no members");
+ pedwarn (input_location, OPT_pedantic, "struct has no members");
}
}
}
if (pedantic && !in_system_header && TREE_CODE (t) == RECORD_TYPE
&& flexible_array_type_p (TREE_TYPE (x)))
- pedwarn (OPT_pedantic,
+ pedwarn (input_location, OPT_pedantic,
"%Jinvalid use of structure with flexible array member", x);
if (DECL_NAME (x))
/* The ISO C Standard mandates enumerators to have type int,
even though the underlying type of an enum type is
- unspecified. Here we convert any enumerators that fit in
- an int to type int, to avoid promotions to unsigned types
- when comparing integers with enumerators that fit in the
- int range. When -pedantic is given, build_enumerator()
- would have already taken care of those that don't fit. */
- if (int_fits_type_p (ini, integer_type_node))
- tem = integer_type_node;
- else
- tem = enumtype;
- ini = convert (tem, ini);
+ unspecified. However, GCC allows enumerators of any
+ integer type as an extensions. build_enumerator()
+ converts any enumerators that fit in an int to type int,
+ to avoid promotions to unsigned types when comparing
+ integers with enumerators that fit in the int range.
+ When -pedantic is given, build_enumerator() would have
+ already warned about those that don't fit. Here we
+ convert the rest to the enumerator type. */
+ if (TREE_TYPE (ini) != integer_type_node)
+ ini = convert (enumtype, ini);
DECL_INITIAL (enu) = ini;
TREE_PURPOSE (pair) = DECL_NAME (enu);
Assignment of sequential values by default is handled here. */
tree
-build_enumerator (struct c_enum_contents *the_enum, tree name, tree value)
+build_enumerator (struct c_enum_contents *the_enum, tree name, tree value,
+ location_t value_loc)
{
tree decl, type;
if (the_enum->enum_overflow)
error ("overflow in enumeration values");
}
-
- if (pedantic && !int_fits_type_p (value, integer_type_node))
- {
- pedwarn (OPT_pedantic, "ISO C restricts enumerator values to range of %<int%>");
- /* XXX This causes -pedantic to change the meaning of the program.
- Remove? -zw 2004-03-15 */
- value = convert (integer_type_node, value);
- }
+ /* Even though the underlying type of an enum is unspecified, the
+ type of enumeration constants is explicitly defined as int
+ (6.4.4.3/2 in the C99 Standard). GCC allows any integer type as
+ an extension. */
+ else if (!int_fits_type_p (value, integer_type_node))
+ pedwarn (value_loc, OPT_pedantic,
+ "ISO C restricts enumerator values to range of %<int%>");
+
+ /* The ISO C Standard mandates enumerators to have type int, even
+ though the underlying type of an enum type is unspecified.
+ However, GCC allows enumerators of any integer type as an
+ extensions. Here we convert any enumerators that fit in an int
+ to type int, to avoid promotions to unsigned types when comparing
+ integers with enumerators that fit in the int range. When
+ -pedantic is given, we would have already warned about those that
+ don't fit. We have to do this here rather than in finish_enum
+ because this value may be used to define more enumerators. */
+ if (int_fits_type_p (value, integer_type_node))
+ value = convert (integer_type_node, value);
/* Set basis for default for next value. */
- the_enum->enum_next_value = build_binary_op (PLUS_EXPR, value,
- integer_one_node, 0);
+ the_enum->enum_next_value
+ = build_binary_op
+ (EXPR_HAS_LOCATION (value) ? EXPR_LOCATION (value) : input_location,
+ PLUS_EXPR, value, integer_one_node, 0);
the_enum->enum_overflow = tree_int_cst_lt (the_enum->enum_next_value, value);
/* Now create a declaration for the enum value name. */
}
if (warn_about_return_type)
- pedwarn_c99 (flag_isoc99 ? 0
+ pedwarn_c99 (input_location, flag_isoc99 ? 0
: (warn_return_type ? OPT_Wreturn_type : OPT_Wimplicit_int),
"return type defaults to %<int%>");
maybe_apply_pragma_weak (decl1);
/* Warn for unlikely, improbable, or stupid declarations of `main'. */
- if (warn_main > 0 && MAIN_NAME_P (DECL_NAME (decl1)))
+ if (warn_main && MAIN_NAME_P (DECL_NAME (decl1)))
{
if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
!= integer_type_node)
- pedwarn (OPT_Wmain, "return type of %q+D is not %<int%>", decl1);
+ pedwarn (input_location, OPT_Wmain, "return type of %q+D is not %<int%>", decl1);
- check_main_parameter_types(decl1);
+ check_main_parameter_types (decl1);
if (!TREE_PUBLIC (decl1))
- pedwarn (OPT_Wmain, "%q+D is normally a non-static function", decl1);
+ pedwarn (input_location, OPT_Wmain, "%q+D is normally a non-static function", decl1);
}
/* Record the decl so that the function name is defined.
warn_if_shadowing (decl);
if (flag_isoc99)
- pedwarn (0, "type of %q+D defaults to %<int%>", decl);
+ pedwarn (input_location, 0, "type of %q+D defaults to %<int%>", decl);
else
warning (OPT_Wmissing_parameter_type, "type of %q+D defaults to %<int%>", decl);
}
"doesn%'t match built-in prototype", parm);
else
{
- pedwarn (OPT_pedantic, "promoted argument %qD "
+ pedwarn (input_location, OPT_pedantic, "promoted argument %qD "
"doesn%'t match prototype", parm);
- pedwarn (OPT_pedantic, "%Hprototype declaration",
- ¤t_function_prototype_locus);
+ pedwarn (current_function_prototype_locus, OPT_pedantic,
+ "prototype declaration");
}
}
else
if (DECL_RESULT (fndecl) && DECL_RESULT (fndecl) != error_mark_node)
DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
- if (MAIN_NAME_P (DECL_NAME (fndecl)) && flag_hosted)
+ if (MAIN_NAME_P (DECL_NAME (fndecl)) && flag_hosted
+ && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
+ == integer_type_node && flag_isoc99)
{
- if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
- != integer_type_node)
- {
- /* If warn_main is 1 (-Wmain) or 2 (-Wall), we have already warned.
- If warn_main is -1 (-Wno-main) we don't want to be warned. */
- if (!warn_main)
- pedwarn (0, "return type of %q+D is not %<int%>", fndecl);
- }
- else
- {
- if (flag_isoc99)
- {
- tree stmt = c_finish_return (integer_zero_node);
- /* Hack. We don't want the middle-end to warn that this return
- is unreachable, so we mark its location as special. Using
- UNKNOWN_LOCATION has the problem that it gets clobbered in
- annotate_one_with_locus. A cleaner solution might be to
- ensure ! should_carry_locus_p (stmt), but that needs a flag.
- */
- SET_EXPR_LOCATION (stmt, BUILTINS_LOCATION);
- }
- }
+ tree stmt = c_finish_return (integer_zero_node);
+ /* Hack. We don't want the middle-end to warn that this return
+ is unreachable, so we mark its location as special. Using
+ UNKNOWN_LOCATION has the problem that it gets clobbered in
+ annotate_one_with_locus. A cleaner solution might be to
+ ensure ! should_carry_locus_p (stmt), but that needs a flag.
+ */
+ SET_EXPR_LOCATION (stmt, BUILTINS_LOCATION);
}
/* Tie off the statement tree for this function. */
tree one_decl = NULL_TREE;
int n_decls = 0;
-
if (!flag_isoc99)
{
+ static bool hint = true;
/* If we get here, declarations have been used in a for loop without
the C99 for loop scope. This doesn't make much sense, so don't
allow it. */
- error ("%<for%> loop initial declaration used outside C99 mode");
+ error ("%<for%> loop initial declarations are only allowed in C99 mode");
+ if (hint)
+ {
+ inform (input_location,
+ "use option -std=c99 or -std=gnu99 to compile your code");
+ hint = false;
+ }
return NULL_TREE;
}
/* C99 subclause 6.8.5 paragraph 3:
return &c_stmt_tree;
}
-/* Nonzero if TYPE is an anonymous union or struct type. Always 0 in
- C. */
-
-int
-anon_aggr_type_p (const_tree ARG_UNUSED (node))
-{
- return 0;
-}
-
/* Return the global value of T as a symbol. */
tree
gcc_unreachable ();
}
if (dupe && !flag_isoc99)
- pedwarn (OPT_pedantic, "duplicate %qE", qual);
+ pedwarn (input_location, OPT_pedantic, "duplicate %qE", qual);
return specs;
}
break;
}
if (pedantic && !flag_isoc99 && !in_system_header)
- pedwarn (OPT_Wlong_long, "ISO C90 does not support %<long long%>");
+ pedwarn (input_location, OPT_Wlong_long, "ISO C90 does not support %<long long%>");
specs->long_long_p = 1;
break;
}
case RID_COMPLEX:
dupe = specs->complex_p;
if (!flag_isoc99 && !in_system_header)
- pedwarn (OPT_pedantic, "ISO C90 does not support complex types");
+ pedwarn (input_location, OPT_pedantic, "ISO C90 does not support complex types");
if (specs->typespec_word == cts_void)
error ("both %<complex%> and %<void%> in "
"declaration specifiers");
break;
case RID_SAT:
dupe = specs->saturating_p;
- pedwarn (OPT_pedantic, "ISO C does not support saturating types");
+ pedwarn (input_location, OPT_pedantic, "ISO C does not support saturating types");
if (specs->typespec_word == cts_void)
error ("both %<_Sat%> and %<void%> in "
"declaration specifiers");
}
if (!targetm.decimal_float_supported_p ())
error ("decimal floating point not supported for this target");
- pedwarn (OPT_pedantic,
+ pedwarn (input_location, OPT_pedantic,
"ISO C does not support decimal floating point");
return specs;
case RID_FRACT:
}
if (!targetm.fixed_point_supported_p ())
error ("fixed-point types not supported for this target");
- pedwarn (OPT_pedantic,
+ pedwarn (input_location, OPT_pedantic,
"ISO C does not support fixed-point types");
return specs;
default:
else if (specs->complex_p)
{
specs->typespec_word = cts_double;
- pedwarn (OPT_pedantic,
+ pedwarn (input_location, OPT_pedantic,
"ISO C does not support plain %<complex%> meaning "
"%<double complex%>");
}
specs->type = char_type_node;
if (specs->complex_p)
{
- pedwarn (OPT_pedantic,
+ pedwarn (input_location, OPT_pedantic,
"ISO C does not support complex integer types");
specs->type = build_complex_type (specs->type);
}
: integer_type_node);
if (specs->complex_p)
{
- pedwarn (OPT_pedantic,
+ pedwarn (input_location, OPT_pedantic,
"ISO C does not support complex integer types");
specs->type = build_complex_type (specs->type);
}
&& !TREE_PUBLIC (decl)
&& C_DECL_USED (decl))
{
- pedwarn (0, "%q+F used but never defined", decl);
+ pedwarn (input_location, 0, "%q+F used but never defined", decl);
TREE_NO_WARNING (decl) = 1;
}