diff options
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 127 |
1 files changed, 98 insertions, 29 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 3153cf4..41688a7 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -8787,6 +8787,7 @@ struct c_declspecs * 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; @@ -8824,7 +8825,8 @@ build_null_declspecs (void) 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; @@ -8835,7 +8837,10 @@ declspecs_add_addrspace (struct c_declspecs *specs, addr_space_t as) 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; } @@ -8843,7 +8848,8 @@ declspecs_add_addrspace (struct c_declspecs *specs, addr_space_t as) 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; @@ -8857,20 +8863,23 @@ declspecs_add_qual (struct c_declspecs *specs, tree qual) 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; } @@ -8923,6 +8932,7 @@ declspecs_add_type (location_t loc, struct c_declspecs *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) @@ -8962,7 +8972,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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; @@ -9007,7 +9020,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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; @@ -9044,7 +9060,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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; @@ -9081,11 +9100,14 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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) @@ -9121,7 +9143,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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; @@ -9174,7 +9199,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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 (); @@ -9220,7 +9248,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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) @@ -9248,7 +9279,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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) @@ -9276,7 +9310,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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) @@ -9292,7 +9329,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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) @@ -9300,7 +9340,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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) @@ -9324,7 +9367,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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) @@ -9348,7 +9394,10 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, ("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: @@ -9402,6 +9451,7 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, 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, @@ -9427,6 +9477,7 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, 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, @@ -9460,6 +9511,7 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, 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. */ @@ -9483,13 +9535,17 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, 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) @@ -9510,7 +9566,9 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, 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; @@ -9531,11 +9589,13 @@ declspecs_add_scspec (struct c_declspecs *specs, tree scspec) 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; @@ -9546,7 +9606,10 @@ declspecs_add_scspec (struct c_declspecs *specs, tree scspec) 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; @@ -9585,6 +9648,7 @@ declspecs_add_scspec (struct c_declspecs *specs, tree scspec) 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); @@ -9599,9 +9663,10 @@ declspecs_add_scspec (struct c_declspecs *specs, tree 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; } @@ -9610,10 +9675,12 @@ declspecs_add_attrs (struct c_declspecs *specs, tree attrs) 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); @@ -9654,9 +9721,11 @@ finish_declspecs (struct c_declspecs *specs) { 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 @@ -9667,7 +9736,7 @@ finish_declspecs (struct c_declspecs *specs) 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%>"); } @@ -9712,7 +9781,7 @@ finish_declspecs (struct c_declspecs *specs) 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); } @@ -9725,7 +9794,7 @@ finish_declspecs (struct c_declspecs *specs) : 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); } @@ -9751,7 +9820,7 @@ finish_declspecs (struct c_declspecs *specs) : 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); } |