TREE_USED (decl) = 1;
DECL_READ_P (decl) = 1;
TREE_TYPE (decl) = type;
- TREE_READONLY (decl) = TYPE_READONLY (type);
+ TREE_READONLY (decl) = (TYPE_READONLY (type)
+ || (TREE_CODE (type) == ARRAY_TYPE
+ && TYPE_READONLY (TREE_TYPE (type))));
store_init_value (loc, decl, init, NULL_TREE);
if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
}
}
- /* Did array size calculations overflow? */
-
+ /* Did array size calculations overflow or does the array cover more
+ than half of the address-space? */
if (TREE_CODE (type) == ARRAY_TYPE
&& COMPLETE_TYPE_P (type)
&& TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST
- && TREE_OVERFLOW (TYPE_SIZE_UNIT (type)))
+ && ! valid_constant_size_p (TYPE_SIZE_UNIT (type)))
{
if (name)
error_at (loc, "size of array %qE is too large", name);
if (c_dialect_objc ())
objc_check_decl (decl);
rest_of_decl_compilation (decl, toplevel, 0);
- if (!toplevel)
- expand_decl (decl);
}
}
C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)) = 0;
void
c_push_function_context (void)
{
- struct language_function *p = cfun->language;
- /* cfun->language might have been already allocated by the use of
- -Wunused-local-typedefs. In that case, just re-use it. */
- if (p == NULL)
- cfun->language = p = ggc_alloc_cleared_language_function ();
+ struct language_function *p;
+ p = ggc_alloc_language_function ();
+ cfun->language = p;
p->base.x_stmt_tree = c_stmt_tree;
c_stmt_tree.x_cur_stmt_list
pop_function_context ();
p = cfun->language;
- /* When -Wunused-local-typedefs is in effect, cfun->languages is
- used to store data throughout the life time of the current cfun,
- So don't deallocate it. */
- if (!warn_unused_local_typedefs)
- cfun->language = NULL;
+ cfun->language = NULL;
if (DECL_STRUCT_FUNCTION (current_function_decl) == 0
&& DECL_SAVED_TREE (current_function_decl) == NULL_TREE)
build_null_declspecs (void)
{
struct c_declspecs *ret = XOBNEW (&parser_obstack, struct c_declspecs);
+ memset (&ret->locations, 0, cdw_number_of_elements);
ret->type = 0;
ret->expr = 0;
ret->decl_attr = 0;
SPECS, returning SPECS. */
struct c_declspecs *
-declspecs_add_addrspace (struct c_declspecs *specs, addr_space_t as)
+declspecs_add_addrspace (source_location location,
+ struct c_declspecs *specs, addr_space_t as)
{
specs->non_sc_seen_p = true;
specs->declspecs_seen_p = true;
c_addr_space_name (as),
c_addr_space_name (specs->address_space));
else
- specs->address_space = as;
+ {
+ specs->address_space = as;
+ specs->locations[cdw_address_space] = location;
+ }
return specs;
}
returning SPECS. */
struct c_declspecs *
-declspecs_add_qual (struct c_declspecs *specs, tree qual)
+declspecs_add_qual (source_location loc,
+ struct c_declspecs *specs, tree qual)
{
enum rid i;
bool dupe = false;
case RID_CONST:
dupe = specs->const_p;
specs->const_p = true;
+ specs->locations[cdw_const] = loc;
break;
case RID_VOLATILE:
dupe = specs->volatile_p;
specs->volatile_p = true;
+ specs->locations[cdw_volatile] = loc;
break;
case RID_RESTRICT:
dupe = specs->restrict_p;
specs->restrict_p = true;
+ specs->locations[cdw_restrict] = loc;
break;
default:
gcc_unreachable ();
}
if (dupe && !flag_isoc99)
- pedwarn (input_location, OPT_Wpedantic, "duplicate %qE", qual);
+ pedwarn (loc, OPT_Wpedantic, "duplicate %qE", qual);
return specs;
}
pedwarn_c90 (loc, OPT_Wlong_long,
"ISO C90 does not support %<long long%>");
specs->long_long_p = 1;
+ specs->locations[cdw_long_long] = loc;
break;
}
if (specs->short_p)
("both %<long%> and %<_Decimal128%> in "
"declaration specifiers"));
else
- specs->long_p = true;
+ {
+ specs->long_p = true;
+ specs->locations[cdw_long] = loc;
+ }
break;
case RID_SHORT:
dupe = specs->short_p;
("both %<short%> and %<_Decimal128%> in "
"declaration specifiers"));
else
- specs->short_p = true;
+ {
+ specs->short_p = true;
+ specs->locations[cdw_short] = loc;
+ }
break;
case RID_SIGNED:
dupe = specs->signed_p;
("both %<signed%> and %<_Decimal128%> in "
"declaration specifiers"));
else
- specs->signed_p = true;
+ {
+ specs->signed_p = true;
+ specs->locations[cdw_signed] = loc;
+ }
break;
case RID_UNSIGNED:
dupe = specs->unsigned_p;
("both %<unsigned%> and %<_Decimal128%> in "
"declaration specifiers"));
else
- specs->unsigned_p = true;
+ {
+ specs->unsigned_p = true;
+ specs->locations[cdw_unsigned] = loc;
+ }
break;
case RID_COMPLEX:
dupe = specs->complex_p;
- if (!flag_isoc99 && !in_system_header)
+ if (!flag_isoc99 && !in_system_header_at (loc))
pedwarn (loc, OPT_Wpedantic,
"ISO C90 does not support complex types");
if (specs->typespec_word == cts_void)
("both %<complex%> and %<_Sat%> in "
"declaration specifiers"));
else
- specs->complex_p = true;
+ {
+ specs->complex_p = true;
+ specs->locations[cdw_complex] = loc;
+ }
break;
case RID_SAT:
dupe = specs->saturating_p;
("both %<_Sat%> and %<complex%> in "
"declaration specifiers"));
else
- specs->saturating_p = true;
+ {
+ specs->saturating_p = true;
+ specs->locations[cdw_saturating] = loc;
+ }
break;
default:
gcc_unreachable ();
("both %<__int128%> and %<short%> in "
"declaration specifiers"));
else
- specs->typespec_word = cts_int128;
+ {
+ specs->typespec_word = cts_int128;
+ specs->locations[cdw_typespec] = loc;
+ }
return specs;
case RID_VOID:
if (specs->long_p)
("both %<_Sat%> and %<void%> in "
"declaration specifiers"));
else
- specs->typespec_word = cts_void;
+ {
+ specs->typespec_word = cts_void;
+ specs->locations[cdw_typespec] = loc;
+ }
return specs;
case RID_BOOL:
if (specs->long_p)
("both %<_Sat%> and %<_Bool%> in "
"declaration specifiers"));
else
- specs->typespec_word = cts_bool;
+ {
+ specs->typespec_word = cts_bool;
+ specs->locations[cdw_typespec] = loc;
+ }
return specs;
case RID_CHAR:
if (specs->long_p)
("both %<_Sat%> and %<char%> in "
"declaration specifiers"));
else
- specs->typespec_word = cts_char;
+ {
+ specs->typespec_word = cts_char;
+ specs->locations[cdw_typespec] = loc;
+ }
return specs;
case RID_INT:
if (specs->saturating_p)
("both %<_Sat%> and %<int%> in "
"declaration specifiers"));
else
- specs->typespec_word = cts_int;
+ {
+ specs->typespec_word = cts_int;
+ specs->locations[cdw_typespec] = loc;
+ }
return specs;
case RID_FLOAT:
if (specs->long_p)
("both %<_Sat%> and %<float%> in "
"declaration specifiers"));
else
- specs->typespec_word = cts_float;
+ {
+ specs->typespec_word = cts_float;
+ specs->locations[cdw_typespec] = loc;
+ }
return specs;
case RID_DOUBLE:
if (specs->long_long_p)
("both %<_Sat%> and %<double%> in "
"declaration specifiers"));
else
- specs->typespec_word = cts_double;
+ {
+ specs->typespec_word = cts_double;
+ specs->locations[cdw_typespec] = loc;
+ }
return specs;
case RID_DFLOAT32:
case RID_DFLOAT64:
specs->typespec_word = cts_dfloat64;
else
specs->typespec_word = cts_dfloat128;
+ specs->locations[cdw_typespec] = loc;
}
if (!targetm.decimal_float_supported_p ())
error_at (loc,
specs->typespec_word = cts_fract;
else
specs->typespec_word = cts_accum;
+ specs->locations[cdw_typespec] = loc;
}
if (!targetm.fixed_point_supported_p ())
error_at (loc,
specs->decl_attr = DECL_ATTRIBUTES (type);
specs->typedef_p = true;
specs->explicit_signed_p = C_TYPEDEF_EXPLICITLY_SIGNED (type);
+ specs->locations[cdw_typedef] = loc;
/* If this typedef name is defined in a struct, then a C++
lookup would return a different value. */
else if (TREE_TYPE (t) == error_mark_node)
;
else
- specs->type = TREE_TYPE (t);
+ {
+ specs->type = TREE_TYPE (t);
+ specs->locations[cdw_typespec] = loc;
+ }
}
else
{
if (TREE_CODE (type) != ERROR_MARK && spec.kind == ctsk_typeof)
{
specs->typedef_p = true;
+ specs->locations[cdw_typedef] = loc;
if (spec.expr)
{
if (specs->expr)
declaration specifiers SPECS, returning SPECS. */
struct c_declspecs *
-declspecs_add_scspec (struct c_declspecs *specs, tree scspec)
+declspecs_add_scspec (source_location loc,
+ struct c_declspecs *specs,
+ tree scspec)
{
enum rid i;
enum c_storage_class n = csc_none;
difference between gnu89 and C99 inline. */
dupe = false;
specs->inline_p = true;
+ specs->locations[cdw_inline] = loc;
break;
case RID_NORETURN:
/* Duplicate _Noreturn is permitted. */
dupe = false;
specs->noreturn_p = true;
+ specs->locations[cdw_noreturn] = loc;
break;
case RID_THREAD:
dupe = specs->thread_p;
else if (specs->storage_class == csc_typedef)
error ("%<__thread%> used with %<typedef%>");
else
- specs->thread_p = true;
+ {
+ specs->thread_p = true;
+ specs->locations[cdw_thread] = loc;
+ }
break;
case RID_AUTO:
n = csc_auto;
else
{
specs->storage_class = n;
+ specs->locations[cdw_storage_class] = loc;
if (n != csc_extern && n != csc_static && specs->thread_p)
{
error ("%<__thread%> used with %qE", scspec);
returning SPECS. */
struct c_declspecs *
-declspecs_add_attrs (struct c_declspecs *specs, tree attrs)
+declspecs_add_attrs (source_location loc, struct c_declspecs *specs, tree attrs)
{
specs->attrs = chainon (attrs, specs->attrs);
+ specs->locations[cdw_attributes] = loc;
specs->declspecs_seen_p = true;
return specs;
}
alignment is ALIGN) to the declaration specifiers SPECS, returning
SPECS. */
struct c_declspecs *
-declspecs_add_alignas (struct c_declspecs *specs, tree align)
+declspecs_add_alignas (source_location loc,
+ struct c_declspecs *specs, tree align)
{
int align_log;
specs->alignas_p = true;
+ specs->locations[cdw_alignas] = loc;
if (align == error_mark_node)
return specs;
align_log = check_user_alignment (align, true);
{
if (specs->saturating_p)
{
- error ("%<_Sat%> is used without %<_Fract%> or %<_Accum%>");
+ error_at (specs->locations[cdw_saturating],
+ "%<_Sat%> is used without %<_Fract%> or %<_Accum%>");
if (!targetm.fixed_point_supported_p ())
- error ("fixed-point types not supported for this target");
+ error_at (specs->locations[cdw_saturating],
+ "fixed-point types not supported for this target");
specs->typespec_word = cts_fract;
}
else if (specs->long_p || specs->short_p
else if (specs->complex_p)
{
specs->typespec_word = cts_double;
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
"ISO C does not support plain %<complex%> meaning "
"%<double complex%>");
}
specs->type = char_type_node;
if (specs->complex_p)
{
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
"ISO C does not support complex integer types");
specs->type = build_complex_type (specs->type);
}
: int128_integer_type_node);
if (specs->complex_p)
{
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
"ISO C does not support complex integer types");
specs->type = build_complex_type (specs->type);
}
: integer_type_node);
if (specs->complex_p)
{
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
"ISO C does not support complex integer types");
specs->type = build_complex_type (specs->type);
}
/* We're done parsing; proceed to optimize and emit assembly.
FIXME: shouldn't be the front end's responsibility to call this. */
- cgraph_finalize_compilation_unit ();
+ finalize_compilation_unit ();
timevar_stop (TV_PHASE_CGRAPH);
timevar_start (TV_PHASE_DBGINFO);