i386.c (legitimize_tls_address): Generate tls_initial_exec_64_sun only when !TARGET_X32.
[gcc.git] / gcc / c-decl.c
index e34c843bedfc46bfffd6e00ff4cd326d336ded8a..0c7e80e13c5e39000deb2af64127e0d3dae2a831 100644 (file)
@@ -4622,7 +4622,9 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const)
   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))
@@ -5809,12 +5811,12 @@ grokdeclarator (const struct c_declarator *declarator,
        }
     }
 
-  /* 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);
@@ -7315,8 +7317,6 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
          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;
@@ -8577,11 +8577,9 @@ check_for_loop_decls (location_t loc, bool turn_off_iso_c99_error)
 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
@@ -8607,11 +8605,7 @@ c_pop_function_context (void)
 
   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)
@@ -8785,6 +8779,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;
@@ -8822,7 +8817,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;
@@ -8833,7 +8829,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;
 }
 
@@ -8841,7 +8840,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;
@@ -8855,20 +8855,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;
 }
 
@@ -8921,6 +8924,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)
@@ -8960,7 +8964,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;
@@ -9005,7 +9012,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;
@@ -9042,7 +9052,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;
@@ -9079,11 +9092,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)
@@ -9119,7 +9135,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;
@@ -9172,7 +9191,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 ();
@@ -9218,7 +9240,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)
@@ -9246,7 +9271,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)
@@ -9274,7 +9302,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)
@@ -9290,7 +9321,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)
@@ -9298,7 +9332,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)
@@ -9322,7 +9359,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)
@@ -9346,7 +9386,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:
@@ -9400,6 +9443,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,
@@ -9425,6 +9469,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,
@@ -9458,6 +9503,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.  */
@@ -9481,13 +9527,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)
@@ -9508,7 +9558,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;
@@ -9529,11 +9581,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;
@@ -9544,7 +9598,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;
@@ -9583,6 +9640,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);
@@ -9597,9 +9655,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;
 }
@@ -9608,10 +9667,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);
@@ -9652,9 +9713,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
@@ -9665,7 +9728,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%>");
        }
@@ -9710,7 +9773,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);
        }
@@ -9723,7 +9786,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);
        }
@@ -9749,7 +9812,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);
        }
@@ -10040,7 +10103,7 @@ c_write_global_declarations (void)
 
   /* 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);