LCOV - code coverage report
Current view: top level - gcc/m2 - gm2-lang.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 70.6 % 671 474
Test Date: 2025-06-21 16:26:05 Functions: 90.3 % 31 28
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* gm2-lang.cc language-dependent hooks for GNU Modula-2.
       2                 :             : 
       3                 :             : Copyright (C) 2002-2025 Free Software Foundation, Inc.
       4                 :             : Contributed by Gaius Mulley <gaius@glam.ac.uk>.
       5                 :             : 
       6                 :             : This file is part of GNU Modula-2.
       7                 :             : 
       8                 :             : GNU Modula-2 is free software; you can redistribute it and/or modify
       9                 :             : it under the terms of the GNU General Public License as published by
      10                 :             : the Free Software Foundation; either version 3, or (at your option)
      11                 :             : any later version.
      12                 :             : 
      13                 :             : GNU Modula-2 is distributed in the hope that it will be useful, but
      14                 :             : WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16                 :             : General Public License for more details.
      17                 :             : 
      18                 :             : You should have received a copy of the GNU General Public License
      19                 :             : along with GCC; see the file COPYING3.  If not see
      20                 :             : <http://www.gnu.org/licenses/>.  */
      21                 :             : 
      22                 :             : #define INCLUDE_VECTOR
      23                 :             : #include "gm2-gcc/gcc-consolidation.h"
      24                 :             : 
      25                 :             : #include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name.  */
      26                 :             : #include "tree-pass.h"     /* FIXME: only for PROP_gimple_any.  */
      27                 :             : #include "toplev.h"
      28                 :             : #include "debug.h"
      29                 :             : 
      30                 :             : #include "opts.h"
      31                 :             : 
      32                 :             : #define GM2_LANG_C
      33                 :             : #include "gm2-lang.h"
      34                 :             : #include "m2block.h"
      35                 :             : #include "dynamicstrings.h"
      36                 :             : #include "m2options.h"
      37                 :             : #include "m2convert.h"
      38                 :             : #include "m2linemap.h"
      39                 :             : #include "init.h"
      40                 :             : #include "m2-tree.h"
      41                 :             : #include "convert.h"
      42                 :             : #include "rtegraph.h"
      43                 :             : 
      44                 :             : static void write_globals (void);
      45                 :             : 
      46                 :             : static int insideCppArgs = FALSE;
      47                 :             : 
      48                 :             : /* We default to pim in the absence of fiso.  */
      49                 :             : static bool iso = false;
      50                 :             : 
      51                 :      643354 : typedef struct named_path_s {
      52                 :             :   std::vector<const char*>path;
      53                 :             :   const char *name;
      54                 :             : } named_path;
      55                 :             : 
      56                 :             : 
      57                 :             : /* The language include paths are based on the libraries in use.  */
      58                 :             : static bool allow_libraries = true;
      59                 :             : static const char *flibs = nullptr;
      60                 :             : static const char *iprefix = nullptr;
      61                 :             : static const char *imultilib = nullptr;
      62                 :             : static std::vector<named_path>Ipaths;
      63                 :             : static std::vector<const char*>isystem;
      64                 :             : static std::vector<const char*>iquote;
      65                 :             : 
      66                 :             : #define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
      67                 :             : 
      68                 :             : /* start of new stuff.  */
      69                 :             : 
      70                 :             : /* Language-dependent contents of a type.  */
      71                 :             : 
      72                 :             : struct GTY (()) lang_type
      73                 :             : {
      74                 :             :   char dummy;
      75                 :             : };
      76                 :             : 
      77                 :             : /* Language-dependent contents of a decl.  */
      78                 :             : 
      79                 :             : struct GTY (()) lang_decl
      80                 :             : {
      81                 :             :   char dummy;
      82                 :             : };
      83                 :             : 
      84                 :             : /* Language-dependent contents of an identifier.  This must include a
      85                 :             :    tree_identifier.  */
      86                 :             : 
      87                 :             : struct GTY (()) lang_identifier
      88                 :             : {
      89                 :             :   struct tree_identifier common;
      90                 :             : };
      91                 :             : 
      92                 :             : /* The resulting tree type.  */
      93                 :             : 
      94                 :             : union GTY ((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
      95                 :             :             chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), "
      96                 :             :                         "TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN "
      97                 :             :                         "(&%h.generic)) : NULL"))) lang_tree_node
      98                 :             : {
      99                 :             :   union tree_node GTY ((tag ("0"),
     100                 :             :                         desc ("tree_node_structure (&%h)"))) generic;
     101                 :             :   struct lang_identifier GTY ((tag ("1"))) identifier;
     102                 :             : };
     103                 :             : 
     104                 :             : struct GTY (()) language_function
     105                 :             : {
     106                 :             : 
     107                 :             :   /* While we are parsing the function, this contains information about
     108                 :             :   the statement-tree that we are building.  */
     109                 :             :   /* struct stmt_tree_s stmt_tree;  */
     110                 :             :   tree stmt_tree;
     111                 :             : };
     112                 :             : 
     113                 :             : /* Language hooks.  */
     114                 :             : 
     115                 :             : static void gm2_langhook_parse_file (void);
     116                 :             : 
     117                 :             : bool
     118                 :       15260 : gm2_langhook_init (void)
     119                 :             : {
     120                 :       15260 :   build_common_tree_nodes (false);
     121                 :       15260 :   build_common_builtin_nodes ();
     122                 :             : 
     123                 :             :   /* The default precision for floating point numbers.  This is used
     124                 :             :      for floating point constants with abstract type.  This may eventually
     125                 :             :      be controllable by a command line option.  */
     126                 :       15260 :   mpfr_set_default_prec (256);
     127                 :             : 
     128                 :             :   /* GNU Modula-2 uses exceptions.  */
     129                 :       15260 :   using_eh_for_cleanups ();
     130                 :             : 
     131                 :       15260 :   if (M2Options_GetPPOnly ())
     132                 :             :     {
     133                 :             :       /* Preprocess the file here.  */
     134                 :           0 :       gm2_langhook_parse_file ();
     135                 :           0 :       return false; /* Finish now, no further compilation.  */
     136                 :             :     }
     137                 :             :   return true;
     138                 :             : }
     139                 :             : 
     140                 :             : /* The option mask.  */
     141                 :             : 
     142                 :             : static unsigned int
     143                 :       33530 : gm2_langhook_option_lang_mask (void)
     144                 :             : {
     145                 :       33530 :   return CL_ModulaX2;
     146                 :             : }
     147                 :             : 
     148                 :             : /* Initialize the options structure.  */
     149                 :             : 
     150                 :             : static void
     151                 :       15260 : gm2_langhook_init_options_struct (struct gcc_options *opts)
     152                 :             : {
     153                 :             :   /* Default to avoiding range issues for complex multiply and divide.  */
     154                 :       15260 :   opts->x_flag_complex_method = 2;
     155                 :             : 
     156                 :             :   /* The builtin math functions should not set errno.  */
     157                 :       15260 :   opts->x_flag_errno_math = 0;
     158                 :       15260 :   opts->frontend_set_flag_errno_math = true;
     159                 :             : 
     160                 :             :   /* Exceptions are used.  */
     161                 :       15260 :   opts->x_flag_exceptions = 1;
     162                 :       15260 :   init_FrontEndInit ();
     163                 :       15260 : }
     164                 :             : 
     165                 :             : /* Infrastructure for a VEC of bool values.  */
     166                 :             : 
     167                 :             : /* This array determines whether the filename is associated with the
     168                 :             :    C preprocessor.  */
     169                 :             : 
     170                 :             : static vec<bool> filename_cpp;
     171                 :             : 
     172                 :             : /* Build the C preprocessor command line here, since we need to include
     173                 :             :    options that are not passed to the handle_option function.  */
     174                 :             : 
     175                 :             : void
     176                 :       15260 : gm2_langhook_init_options (unsigned int decoded_options_count,
     177                 :             :                            struct cl_decoded_option *decoded_options)
     178                 :             : {
     179                 :       15260 :   unsigned int i;
     180                 :       15260 :   bool in_cpp_args = false;
     181                 :       15260 :   bool building_cpp_command = false;
     182                 :             : 
     183                 :      757801 :   for (i = 1; i < decoded_options_count; i++)
     184                 :             :     {
     185                 :      742541 :       enum opt_code code = (enum opt_code)decoded_options[i].opt_index;
     186                 :      742541 :       const struct cl_option *option = &cl_options[code];
     187                 :      742541 :       const char *opt = (const char *)option->opt_text;
     188                 :      742541 :       const char *arg = decoded_options[i].arg;
     189                 :      742541 :       HOST_WIDE_INT value = decoded_options[i].value;
     190                 :      742541 :       switch (code)
     191                 :             :         {
     192                 :         528 :         case OPT_fcpp:
     193                 :         528 :           if (value)
     194                 :         528 :             gcc_checking_assert (building_cpp_command);
     195                 :             :           break;
     196                 :         528 :         case OPT_fcpp_begin:
     197                 :         528 :           in_cpp_args = true;
     198                 :         528 :           building_cpp_command = true;
     199                 :         528 :           break;
     200                 :         528 :         case OPT_fcpp_end:
     201                 :         528 :           in_cpp_args = false;
     202                 :         528 :           break;
     203                 :       15788 :         case OPT_SPECIAL_input_file:
     204                 :       15788 :           filename_cpp.safe_push (in_cpp_args);
     205                 :       15788 :           break;
     206                 :             : 
     207                 :             :         /* C and driver opts that are not passed to the preprocessor for
     208                 :             :            modula-2, but that we use internally for building preprocesor
     209                 :             :            command lines.  */
     210                 :       15260 :         case OPT_B:
     211                 :       15260 :           M2Options_SetB (arg);
     212                 :       15260 :           break;
     213                 :       12638 :         case OPT_c:
     214                 :       12638 :           M2Options_Setc (value);
     215                 :       12638 :           break;
     216                 :       12468 :         case OPT_dumpdir:
     217                 :       12468 :           M2Options_SetDumpDir (arg);
     218                 :       12468 :           break;
     219                 :           0 :         case OPT_save_temps:
     220                 :           0 :           if (building_cpp_command)
     221                 :           0 :             M2Options_SetSaveTemps (value);
     222                 :             :           break;
     223                 :           0 :         case OPT_save_temps_:
     224                 :           0 :           if (building_cpp_command)
     225                 :             :             /* Also sets SaveTemps. */
     226                 :           0 :             M2Options_SetSaveTempsDir (arg);
     227                 :             :           break;
     228                 :             : 
     229                 :         528 :         case OPT_E:
     230                 :         528 :           if (!in_cpp_args)
     231                 :             :             {
     232                 :           0 :               M2Options_SetPPOnly (value);
     233                 :           0 :               building_cpp_command = true;
     234                 :             :             }
     235                 :        1056 :           M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
     236                 :         528 :                             && !(option->flags & CL_SEPARATE));
     237                 :         528 :           break;
     238                 :             : 
     239                 :           0 :         case OPT_M:
     240                 :             :           /* Output a rule suitable for make describing the dependencies of the
     241                 :             :              main source file.  */
     242                 :           0 :           if (in_cpp_args)
     243                 :             :             {
     244                 :           0 :               gcc_checking_assert (building_cpp_command);
     245                 :             :               /* This is a preprocessor command.  */
     246                 :           0 :               M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
     247                 :           0 :                                 && !(option->flags & CL_SEPARATE));
     248                 :             :             }
     249                 :           0 :           M2Options_SetPPOnly (value);
     250                 :           0 :           M2Options_SetM (value);
     251                 :           0 :           break;
     252                 :             : 
     253                 :           0 :         case OPT_MM:
     254                 :           0 :           if (in_cpp_args)
     255                 :             :             {
     256                 :           0 :               gcc_checking_assert (building_cpp_command);
     257                 :             :               /* This is a preprocessor command.  */
     258                 :           0 :               M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
     259                 :           0 :                                 && !(option->flags & CL_SEPARATE));
     260                 :             :             }
     261                 :           0 :           M2Options_SetPPOnly (value);
     262                 :           0 :           M2Options_SetMM (value);
     263                 :           0 :           break;
     264                 :             : 
     265                 :           0 :         case OPT_MF:
     266                 :           0 :           if (!in_cpp_args)
     267                 :           0 :             M2Options_SetMF (arg);
     268                 :             :           break;
     269                 :             : 
     270                 :           0 :         case OPT_MP:
     271                 :           0 :           M2Options_SetMP (value);
     272                 :           0 :           break;
     273                 :             : 
     274                 :             :         /* We can only use MQ and MT when the command line is either PP-only, or
     275                 :             :            when there is a MD/MMD on it.  */
     276                 :           0 :         case OPT_MQ:
     277                 :           0 :           M2Options_SetMQ (arg);
     278                 :           0 :           break;
     279                 :             : 
     280                 :           0 :         case OPT_MT:
     281                 :           0 :           M2Options_SetMT (arg);
     282                 :           0 :           break;
     283                 :             : 
     284                 :       15260 :         case OPT_o:
     285                 :       15260 :           M2Options_SetObj (arg);
     286                 :       15260 :           break;
     287                 :             : 
     288                 :             :         /* C and driver options that we ignore for the preprocessor lines.  */
     289                 :             :         case OPT_fpch_deps:
     290                 :             :         case OPT_fpch_preprocess:
     291                 :             :           break;
     292                 :             : 
     293                 :             :         case OPT_fplugin_:
     294                 :             :           /* FIXME: We might need to handle this specially, since the modula-2
     295                 :             :              plugin is not usable here, but others might be.
     296                 :             :              For now skip all plugins to avoid fails with the m2 one.  */
     297                 :             :           break;
     298                 :             : 
     299                 :             :         /* Preprocessor arguments with a following filename.  */
     300                 :           0 :         case OPT_MD:
     301                 :           0 :           M2Options_SetMD (value);
     302                 :           0 :           if (value)
     303                 :             :             {
     304                 :           0 :               M2Options_SetM (true);
     305                 :           0 :               M2Options_SetMF (arg);
     306                 :             :             }
     307                 :             :           break;
     308                 :             : 
     309                 :           0 :         case OPT_MMD:
     310                 :           0 :           M2Options_SetMMD (value);
     311                 :           0 :           if (value)
     312                 :             :             {
     313                 :           0 :               M2Options_SetMM (true);
     314                 :           0 :               M2Options_SetMF (arg);
     315                 :             :             }
     316                 :             :           break;
     317                 :             : 
     318                 :             :         /* Modula 2 claimed options we pass to the preprocessor.  */
     319                 :        1056 :         case OPT_ansi:
     320                 :        1056 :         case OPT_traditional_cpp:
     321                 :        1056 :           if (building_cpp_command)
     322                 :        1056 :             M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
     323                 :        1056 :                               && !(option->flags & CL_SEPARATE));
     324                 :             :           break;
     325                 :             : 
     326                 :             :         /* Options we act on and also pass to the preprocessor.  */
     327                 :        7660 :         case OPT_O:
     328                 :        7660 :           M2Options_SetOptimizing (value);
     329                 :        7660 :           if (building_cpp_command)
     330                 :         352 :             M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
     331                 :         352 :                               && !(option->flags & CL_SEPARATE));
     332                 :             :           break;
     333                 :       15788 :         case OPT_quiet:
     334                 :       15788 :           M2Options_SetQuiet (value);
     335                 :       15788 :           if (building_cpp_command)
     336                 :        1056 :             M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
     337                 :        1056 :                               && !(option->flags & CL_SEPARATE));
     338                 :             :           break;
     339                 :           0 :         case OPT_v:
     340                 :           0 :           M2Options_SetVerbose (value);
     341                 :             :           /* FALLTHROUGH */
     342                 :      644404 :         default:
     343                 :             :           /* We handled input files above.  */
     344                 :      644404 :           if (code >= N_OPTS)
     345                 :             :             break;
     346                 :             :           /* Do not pass Modula-2 args to the preprocessor, any that we care
     347                 :             :              about here should already have been handled above.  */
     348                 :      644404 :           if (option->flags & CL_ModulaX2)
     349                 :             :             break;
     350                 :             :           /* Otherwise, add this to the CPP command line.  */
     351                 :      175812 :           if (building_cpp_command)
     352                 :        5280 :             M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
     353                 :        5280 :                               && !(option->flags & CL_SEPARATE));
     354                 :             :           break;
     355                 :             :         }
     356                 :             :     }
     357                 :       15260 :   filename_cpp.safe_push (false);
     358                 :       15260 : }
     359                 :             : 
     360                 :             : static bool
     361                 :       15788 : is_cpp_filename (unsigned int i)
     362                 :             : {
     363                 :       15788 :   gcc_assert (i < filename_cpp.length ());
     364                 :       15788 :   return filename_cpp[i];
     365                 :             : }
     366                 :             : 
     367                 :             : static void
     368                 :      215686 : push_back_Ipath (const char *arg)
     369                 :             : {
     370                 :      215686 :   if (Ipaths.empty ())
     371                 :             :     {
     372                 :       15260 :       named_path np;
     373                 :       15260 :       np.path.push_back (arg);
     374                 :       15260 :       np.name = xstrdup (M2Options_GetM2PathName ());
     375                 :       15260 :       Ipaths.push_back (np);
     376                 :       15260 :     }
     377                 :             :   else
     378                 :             :     {
     379                 :      200426 :       if (strcmp (Ipaths.back ().name,
     380                 :      200426 :                   M2Options_GetM2PathName ()) == 0)
     381                 :       66208 :         Ipaths.back ().path.push_back (arg);
     382                 :             :       else
     383                 :             :         {
     384                 :      134218 :           named_path np;
     385                 :      134218 :           np.path.push_back (arg);
     386                 :      134218 :           np.name = xstrdup (M2Options_GetM2PathName ());
     387                 :      134218 :           Ipaths.push_back (np);
     388                 :      134218 :         }
     389                 :             :     }
     390                 :      215686 : }
     391                 :             : 
     392                 :             : /* Handle gm2 specific options.  Return 0 if we didn't do anything.  */
     393                 :             : 
     394                 :             : bool
     395                 :      499677 : gm2_langhook_handle_option (
     396                 :             :     size_t scode, const char *arg, HOST_WIDE_INT value, int kind ATTRIBUTE_UNUSED,
     397                 :             :     location_t loc ATTRIBUTE_UNUSED,
     398                 :             :     const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
     399                 :             : {
     400                 :      499677 :   enum opt_code code = (enum opt_code)scode;
     401                 :             : 
     402                 :      499677 :   const struct cl_option *option = &cl_options[scode];
     403                 :             :   /* ignore file names.  */
     404                 :      499677 :   if (code == N_OPTS)
     405                 :             :     return 1;
     406                 :             : 
     407                 :      499677 :   switch (code)
     408                 :             :     {
     409                 :           0 :     case OPT_dumpdir:
     410                 :           0 :       M2Options_SetDumpDir (arg);
     411                 :           0 :       return 1;
     412                 :           0 :     case OPT_I:
     413                 :           0 :       push_back_Ipath (arg);
     414                 :           0 :       return 1;
     415                 :        4090 :     case OPT_fiso:
     416                 :        4090 :       M2Options_SetISO (value);
     417                 :        4090 :       iso = value;
     418                 :        4090 :       return 1;
     419                 :       10689 :     case OPT_fpim:
     420                 :       10689 :       M2Options_SetPIM (value);
     421                 :       10689 :       iso = value ? false : iso;
     422                 :       10689 :       return 1;
     423                 :          86 :     case OPT_fpim2:
     424                 :          86 :       M2Options_SetPIM2 (value);
     425                 :          86 :       iso = value ? false : iso;
     426                 :          86 :       return 1;
     427                 :          12 :     case OPT_fpim3:
     428                 :          12 :       M2Options_SetPIM3 (value);
     429                 :          12 :       iso = value ? false : iso;
     430                 :          12 :       return 1;
     431                 :          75 :     case OPT_fpim4:
     432                 :          75 :       M2Options_SetPIM4 (value);
     433                 :          75 :       iso = value ? false : iso;
     434                 :          75 :       return 1;
     435                 :           0 :     case OPT_fpositive_mod_floor_div:
     436                 :           0 :       M2Options_SetPositiveModFloor (value);
     437                 :           0 :       return 1;
     438                 :       15260 :     case OPT_flibs_:
     439                 :       15260 :       allow_libraries = value;
     440                 :       15260 :       flibs = arg;
     441                 :       15260 :       return 1;
     442                 :        2606 :     case OPT_fgen_module_list_:
     443                 :        2606 :       M2Options_SetGenModuleList (value, arg);
     444                 :        2606 :       return 1;
     445                 :           0 :     case OPT_fnil:
     446                 :           0 :       M2Options_SetNilCheck (value);
     447                 :           0 :       return 1;
     448                 :           0 :     case OPT_fwholediv:
     449                 :           0 :       M2Options_SetWholeDiv (value);
     450                 :           0 :       return 1;
     451                 :           0 :     case OPT_findex:
     452                 :           0 :       M2Options_SetIndex (value);
     453                 :           0 :       return 1;
     454                 :           6 :     case OPT_frange:
     455                 :           6 :       M2Options_SetRange (value);
     456                 :           6 :       return 1;
     457                 :           0 :     case OPT_ffloatvalue:
     458                 :           0 :       M2Options_SetFloatValueCheck (value);
     459                 :           0 :       return 1;
     460                 :           0 :     case OPT_fwholevalue:
     461                 :           0 :       M2Options_SetWholeValueCheck (value);
     462                 :           0 :       return 1;
     463                 :           0 :     case OPT_freturn:
     464                 :           0 :       M2Options_SetReturnCheck (value);
     465                 :           0 :       return 1;
     466                 :         600 :     case OPT_fcase:
     467                 :         600 :       M2Options_SetCaseCheck (value);
     468                 :         600 :       return 1;
     469                 :           0 :     case OPT_fd:
     470                 :           0 :       M2Options_SetCompilerDebugging (value);
     471                 :           0 :       return 1;
     472                 :           0 :     case OPT_fdebug_builtins:
     473                 :           0 :       M2Options_SetDebugBuiltins (value);
     474                 :           0 :       return 1;
     475                 :           0 :     case OPT_fdebug_function_line_numbers:
     476                 :           0 :       M2Options_SetDebugFunctionLineNumbers (value);
     477                 :           0 :       return 1;
     478                 :          12 :     case OPT_fauto_init:
     479                 :          12 :       M2Options_SetAutoInit (value);
     480                 :          12 :       return 1;
     481                 :        1851 :     case OPT_fsoft_check_all:
     482                 :        1851 :       M2Options_SetCheckAll (value);
     483                 :        1851 :       return 1;
     484                 :          18 :     case OPT_fexceptions:
     485                 :          18 :       M2Options_SetExceptions (value);
     486                 :          18 :       return 1;
     487                 :           0 :     case OPT_Wstyle:
     488                 :           0 :       M2Options_SetStyle (value);
     489                 :           0 :       return 1;
     490                 :         354 :     case OPT_Wpedantic:
     491                 :         354 :       M2Options_SetPedantic (value);
     492                 :         354 :       return 1;
     493                 :           6 :     case OPT_Wpedantic_param_names:
     494                 :           6 :       M2Options_SetPedanticParamNames (value);
     495                 :           6 :       return 1;
     496                 :           0 :     case OPT_Wpedantic_cast:
     497                 :           0 :       M2Options_SetPedanticCast (value);
     498                 :           0 :       return 1;
     499                 :         324 :     case OPT_fextended_opaque:
     500                 :         324 :       M2Options_SetExtendedOpaque (value);
     501                 :         324 :       return 1;
     502                 :           0 :     case OPT_Wverbose_unbounded:
     503                 :           0 :       M2Options_SetVerboseUnbounded (value);
     504                 :           0 :       return 1;
     505                 :         342 :     case OPT_Wunused_variable:
     506                 :         342 :       M2Options_SetUnusedVariableChecking (value);
     507                 :         342 :       return 1;
     508                 :           0 :     case OPT_Wunused_parameter:
     509                 :           0 :       M2Options_SetUnusedParameterChecking (value);
     510                 :           0 :       return 1;
     511                 :         198 :     case OPT_Wuninit_variable_checking:
     512                 :         198 :       return M2Options_SetUninitVariableChecking (value, "known");
     513                 :         415 :     case OPT_Wuninit_variable_checking_:
     514                 :         415 :       return M2Options_SetUninitVariableChecking (value, arg);
     515                 :           0 :     case OPT_fm2_file_offset_bits_:
     516                 :           0 :       {
     517                 :           0 :         if (arg != NULL)
     518                 :             :           {
     519                 :           0 :             unsigned int bits = atoi (arg);
     520                 :           0 :             if (bits > 0)
     521                 :           0 :               return M2Options_SetFileOffsetBits (value, bits);
     522                 :             :           }
     523                 :             :         return 0;
     524                 :             :       }
     525                 :           0 :     case OPT_fm2_strict_type:
     526                 :           0 :       M2Options_SetStrictTypeChecking (value);
     527                 :           0 :       return 1;
     528                 :           0 :     case OPT_fm2_strict_type_reason:
     529                 :           0 :       M2Options_SetStrictTypeReason (value);
     530                 :           0 :       return 1;
     531                 :           0 :     case OPT_fm2_debug_trace_:
     532                 :           0 :       M2Options_SetM2DebugTraceFilter (value, arg);
     533                 :           0 :       return 1;
     534                 :           0 :     case OPT_fm2_dump_:
     535                 :           0 :       return M2Options_SetM2Dump (value, arg);
     536                 :           0 :     case OPT_fm2_dump_decl_:
     537                 :           0 :       M2Options_SetDumpDeclFilename (value, arg);
     538                 :           0 :       return 1;
     539                 :           0 :     case OPT_fm2_dump_gimple_:
     540                 :           0 :       M2Options_SetDumpGimpleFilename (value, arg);
     541                 :           0 :       return 1;
     542                 :           0 :     case OPT_fm2_dump_quad_:
     543                 :           0 :       M2Options_SetDumpQuadFilename (value, arg);
     544                 :           0 :       return 1;
     545                 :           0 :     case OPT_fm2_dump_filter_:
     546                 :           0 :       M2Options_SetM2DumpFilter (value, arg);
     547                 :           0 :       return 1;
     548                 :           0 :     case OPT_Wall:
     549                 :           0 :       M2Options_SetWall (value);
     550                 :           0 :       return 1;
     551                 :         684 :     case OPT_Wcase_enum:
     552                 :         684 :       M2Options_SetCaseEnumChecking (value);
     553                 :         684 :       return 1;
     554                 :             : #if 0
     555                 :             :     /* Not yet implemented.  */
     556                 :             :     case OPT_fxcode:
     557                 :             :       M2Options_SetXCode (value);
     558                 :             :       return 1;
     559                 :             : #endif
     560                 :           0 :     case OPT_fm2_lower_case:
     561                 :           0 :       M2Options_SetLowerCaseKeywords (value);
     562                 :           0 :       return 1;
     563                 :           0 :     case OPT_fuse_list_:
     564                 :           0 :       M2Options_SetUselist (value, arg);
     565                 :           0 :       return 1;
     566                 :           0 :     case OPT_fruntime_modules_:
     567                 :           0 :       M2Options_SetRuntimeModuleOverride (arg);
     568                 :           0 :       return 1;
     569                 :             :     case OPT_fpthread:
     570                 :             :       /* Handled in the driver.  */
     571                 :             :       return 1;
     572                 :             :     case OPT_fm2_plugin:
     573                 :             :       /* Handled in the driver.  */
     574                 :             :       return 1;
     575                 :       15260 :     case OPT_fscaffold_dynamic:
     576                 :       15260 :       M2Options_SetScaffoldDynamic (value);
     577                 :       15260 :       return 1;
     578                 :          22 :     case OPT_fscaffold_static:
     579                 :          22 :       M2Options_SetScaffoldStatic (value);
     580                 :          22 :       return 1;
     581                 :        2636 :     case OPT_fscaffold_main:
     582                 :        2636 :       M2Options_SetScaffoldMain (value);
     583                 :        2636 :       return 1;
     584                 :         528 :     case OPT_fcpp:
     585                 :         528 :       M2Options_SetCpp (value);
     586                 :         528 :       return 1;
     587                 :             :     case OPT_fpreprocessed:
     588                 :             :       /* Provided for compatibility; ignore for now.  */
     589                 :             :       return 1;
     590                 :         528 :     case OPT_fcpp_begin:
     591                 :         528 :       insideCppArgs = TRUE;
     592                 :         528 :       return 1;
     593                 :         528 :     case OPT_fcpp_end:
     594                 :         528 :       insideCppArgs = FALSE;
     595                 :         528 :       return 1;
     596                 :           0 :     case OPT_fq:
     597                 :           0 :       M2Options_SetQuadDebugging (value);
     598                 :           0 :       return 1;
     599                 :           0 :     case OPT_fsources:
     600                 :           0 :       M2Options_SetSources (value);
     601                 :           0 :       return 1;
     602                 :           0 :     case OPT_funbounded_by_reference:
     603                 :           0 :       M2Options_SetUnboundedByReference (value);
     604                 :           0 :       return 1;
     605                 :           6 :     case OPT_fdef_:
     606                 :           6 :       M2Options_setdefextension (arg);
     607                 :           6 :       return 1;
     608                 :           6 :     case OPT_fmod_:
     609                 :           6 :       M2Options_setmodextension (arg);
     610                 :           6 :       return 1;
     611                 :          22 :     case OPT_fdump_system_exports:
     612                 :          22 :       M2Options_SetDumpSystemExports (value);
     613                 :          22 :       return 1;
     614                 :           0 :     case OPT_fswig:
     615                 :           0 :       M2Options_SetSwig (value);
     616                 :           0 :       return 1;
     617                 :           0 :     case OPT_fshared:
     618                 :           0 :       M2Options_SetShared (value);
     619                 :           0 :       return 1;
     620                 :           0 :     case OPT_fm2_statistics:
     621                 :           0 :       M2Options_SetStatistics (value);
     622                 :           0 :       return 1;
     623                 :         504 :     case OPT_fm2_g:
     624                 :         504 :       M2Options_SetM2g (value);
     625                 :         504 :       return 1;
     626                 :      149506 :       break;
     627                 :      149506 :     case OPT_fm2_pathname_:
     628                 :      149506 :       if (strcmp (arg, "-") == 0)
     629                 :       28258 :         M2Options_SetM2PathName ("");
     630                 :             :       else
     631                 :      121248 :         M2Options_SetM2PathName (arg);
     632                 :             :       return 1;
     633                 :      215686 :       break;
     634                 :      215686 :     case OPT_fm2_pathnameI:
     635                 :      215686 :       push_back_Ipath (arg);
     636                 :      215686 :       return 1;
     637                 :         608 :       break;
     638                 :         608 :     case OPT_fm2_prefix_:
     639                 :         608 :       if (strcmp (arg, "-") == 0)
     640                 :           0 :         M2Options_SetM2Prefix ("");
     641                 :             :       else
     642                 :         608 :         M2Options_SetM2Prefix (arg);
     643                 :             :       return 1;
     644                 :       15260 :       break;
     645                 :       15260 :     case OPT_iprefix:
     646                 :       15260 :       iprefix = arg;
     647                 :       15260 :       return 1;
     648                 :         304 :       break;
     649                 :         304 :     case OPT_imultilib:
     650                 :         304 :       imultilib = arg;
     651                 :         304 :       return 1;
     652                 :       30508 :       break;
     653                 :       30508 :     case OPT_isystem:
     654                 :       30508 :       isystem.push_back (arg);
     655                 :       30508 :       return 1;
     656                 :           0 :       break;
     657                 :           0 :     case OPT_iquote:
     658                 :           0 :       iquote.push_back (arg);
     659                 :           0 :       return 1;
     660                 :             :       break;
     661                 :             :     case OPT_isysroot:
     662                 :             :       /* Otherwise, ignored, at least for now. */
     663                 :             :       return 1;
     664                 :          24 :       break;
     665                 :          24 :     case OPT_fm2_whole_program:
     666                 :          24 :       M2Options_SetWholeProgram (value);
     667                 :          24 :       return 1;
     668                 :             : #ifdef OPT_mabi_ibmlongdouble
     669                 :             :     case OPT_mabi_ibmlongdouble:
     670                 :             :       M2Options_SetIBMLongDouble (value);
     671                 :             :       return 1;
     672                 :             : #endif
     673                 :             : #ifdef OPT_mabi_ieeelongdouble
     674                 :             :     case OPT_mabi_ieeelongdouble:
     675                 :             :       M2Options_SetIEEELongDouble (value);
     676                 :             :       return 1;
     677                 :             : #endif
     678                 :           0 :     case OPT_flocation_:
     679                 :           0 :       if (strcmp (arg, "builtins") == 0)
     680                 :             :         {
     681                 :           0 :           M2Options_SetForcedLocation (BUILTINS_LOCATION);
     682                 :           0 :           return 1;
     683                 :             :         }
     684                 :           0 :       else if (strcmp (arg, "unknown") == 0)
     685                 :             :         {
     686                 :           0 :           M2Options_SetForcedLocation (UNKNOWN_LOCATION);
     687                 :           0 :           return 1;
     688                 :             :         }
     689                 :           0 :       else if ((arg != NULL) && (ISDIGIT (arg[0])))
     690                 :             :         {
     691                 :           0 :           M2Options_SetForcedLocation (atoi (arg));
     692                 :           0 :           return 1;
     693                 :             :         }
     694                 :             :       else
     695                 :             :         return 0;
     696                 :       30113 :     default:
     697                 :       30113 :       if (insideCppArgs)
     698                 :             :         /* Handled in gm2_langhook_init_options ().  */
     699                 :             :         return 1;
     700                 :       28517 :       else if (option->flags & CL_DRIVER)
     701                 :             :         /* Driver options (unless specifically claimed above) should be handled
     702                 :             :            in gm2_langhook_init_options ().  */
     703                 :             :         return 1;
     704                 :         619 :       else if (option->flags & CL_C)
     705                 :             :         /* C options (unless specifically claimed above) should be handled
     706                 :             :            in gm2_langhook_init_options ().  */
     707                 :             :         return 1;
     708                 :             :       break;
     709                 :             :     }
     710                 :             :   return 0;
     711                 :           0 : }
     712                 :             : 
     713                 :             : /* This prefixes LIBNAME with the current compiler prefix (if it has been
     714                 :             :    relocated) or the LIBSUBDIR, if not.  */
     715                 :             : static void
     716                 :        2520 : add_one_import_path (const char *libname)
     717                 :             : {
     718                 :        2520 :   const char *libpath = iprefix ? iprefix : LIBSUBDIR;
     719                 :        2520 :   const char dir_sep[] = {DIR_SEPARATOR, (char)0};
     720                 :        2520 :   size_t dir_sep_size = strlen (dir_sep);
     721                 :        2520 :   unsigned int mlib_len = 0;
     722                 :             : 
     723                 :        2520 :   if (imultilib)
     724                 :             :     {
     725                 :        1216 :       mlib_len = strlen (imultilib);
     726                 :        1216 :       mlib_len += strlen (dir_sep);
     727                 :             :     }
     728                 :             : 
     729                 :        2520 :   char *lib = (char *)alloca (strlen (libpath) + dir_sep_size
     730                 :             :                               + strlen ("m2") + dir_sep_size
     731                 :             :                               + strlen (libname) + 1
     732                 :             :                               + mlib_len + 1);
     733                 :        2520 :   strcpy (lib, libpath);
     734                 :             :   /* iprefix has a trailing dir separator, LIBSUBDIR does not.  */
     735                 :        2520 :   if (!iprefix)
     736                 :           0 :     strcat (lib, dir_sep);
     737                 :             : 
     738                 :        2520 :   if (imultilib)
     739                 :             :     {
     740                 :        1216 :       strcat (lib, imultilib);
     741                 :        1216 :       strcat (lib, dir_sep);
     742                 :             :     }
     743                 :        2520 :   strcat (lib, "m2");
     744                 :        2520 :   strcat (lib, dir_sep);
     745                 :        2520 :   strcat (lib, libname);
     746                 :        2520 :   M2Options_SetM2PathName (libname);
     747                 :        2520 :   M2Options_SetSearchPath (lib);
     748                 :        2520 : }
     749                 :             : 
     750                 :             : /* For each comma-separated standard library name in LIBLIST, add the
     751                 :             :    corresponding include path.  */
     752                 :             : static void
     753                 :         630 : add_m2_import_paths (const char *liblist)
     754                 :             : {
     755                 :        3150 :   while (*liblist != 0 && *liblist != '-')
     756                 :             :     {
     757                 :        2520 :       const char *comma = strstr (liblist, ",");
     758                 :        2520 :       size_t len;
     759                 :        2520 :       if (comma)
     760                 :        1890 :         len = comma - liblist;
     761                 :             :       else
     762                 :         630 :         len = strlen (liblist);
     763                 :        2520 :       char *libname = (char *) alloca (len+1);
     764                 :        2520 :       strncpy (libname, liblist, len);
     765                 :        2520 :       libname[len] = 0;
     766                 :        2520 :       add_one_import_path (libname);
     767                 :        2520 :       liblist += len;
     768                 :        2520 :       if (*liblist == ',')
     769                 :        1890 :         liblist++;
     770                 :             :     }
     771                 :         630 : }
     772                 :             : 
     773                 :             : /* Run after parsing options.  */
     774                 :             : 
     775                 :             : static bool
     776                 :       15260 : gm2_langhook_post_options (const char **pfilename)
     777                 :             : {
     778                 :       15260 :   const char *filename = *pfilename;
     779                 :       15260 :   flag_excess_precision = EXCESS_PRECISION_FAST;
     780                 :       15260 :   M2Options_SetCC1Quiet (quiet_flag);
     781                 :       15260 :   M2Options_FinaliseOptions ();
     782                 :       15260 :   main_input_filename = filename;
     783                 :             : 
     784                 :             :   /* Add the include paths as per the libraries specified.
     785                 :             :      NOTE: This assumes that the driver has validated the input and makes
     786                 :             :      no attempt to be defensive of nonsense input in flibs=.  */
     787                 :       15260 :   if (allow_libraries)
     788                 :             :     {
     789                 :         630 :       if (!flibs)
     790                 :             :         {
     791                 :           0 :           if (iso)
     792                 :           0 :             flibs = "m2iso,m2cor,m2pim,m2log";
     793                 :             :           else
     794                 :           0 :             flibs = "m2pim,m2iso,m2cor,m2log";
     795                 :             :         }
     796                 :             :     }
     797                 :             : 
     798                 :             :   /* Add search paths.
     799                 :             :      We are not handling all of the cases yet (e.g idirafter).
     800                 :             :      This (barring the missing cases) is intended to follow the directory
     801                 :             :      search rules used for c-family.  It would be less confusing if the
     802                 :             :      presence of absence of these search paths was not dependent on the
     803                 :             :      flibs= option. */
     804                 :             : 
     805                 :       15260 :   for (auto *s : iquote)
     806                 :           0 :     M2Options_SetSearchPath (s);
     807                 :       15260 :   iquote.clear();
     808                 :      164738 :   for (auto np : Ipaths)
     809                 :             :     {
     810                 :      149478 :       M2Options_SetM2PathName (np.name);
     811                 :      365164 :       for (auto *s : np.path)
     812                 :      215686 :         M2Options_SetSearchPath (s);
     813                 :      149478 :     }
     814                 :       15260 :   Ipaths.clear();
     815                 :       45768 :   for (auto *s : isystem)
     816                 :       30508 :     M2Options_SetSearchPath (s);
     817                 :       15260 :   isystem.clear();
     818                 :             :   /* FIXME: this is not a good way to suppress the addition of the import
     819                 :             :      paths.  */
     820                 :       15260 :   if (allow_libraries)
     821                 :         630 :     add_m2_import_paths (flibs);
     822                 :             : 
     823                 :             :   /* Returning false means that the backend should be used.  */
     824                 :       15260 :   return M2Options_GetPPOnly ();
     825                 :             : }
     826                 :             : 
     827                 :             : /* Call the compiler for every source filename on the command line.  */
     828                 :             : 
     829                 :             : static void
     830                 :       15260 : gm2_parse_input_files (const char **filenames, unsigned int filename_count)
     831                 :             : {
     832                 :       15260 :   unsigned int i;
     833                 :       15260 :   gcc_assert (filename_count > 0);
     834                 :             : 
     835                 :       29605 :   for (i = 0; i < filename_count; i++)
     836                 :       15788 :     if (!is_cpp_filename (i))
     837                 :             :       {
     838                 :       15260 :         main_input_filename = filenames[i];
     839                 :       15260 :         init_PerCompilationInit (filenames[i]);
     840                 :             :       }
     841                 :       13817 : }
     842                 :             : 
     843                 :             : static void
     844                 :       15260 : gm2_langhook_parse_file (void)
     845                 :             : {
     846                 :       15260 :   gm2_parse_input_files (in_fnames, num_in_fnames);
     847                 :       13817 :   if (!M2Options_GetPPOnly ())
     848                 :       13817 :     write_globals ();
     849                 :       13817 : }
     850                 :             : 
     851                 :             : static tree
     852                 :      225106 : gm2_langhook_type_for_size (unsigned int bits, int unsignedp)
     853                 :             : {
     854                 :      125997 :   return gm2_type_for_size (bits, unsignedp);
     855                 :             : }
     856                 :             : 
     857                 :             : static tree
     858                 :      237738 : gm2_langhook_type_for_mode (machine_mode mode, int unsignedp)
     859                 :             : {
     860                 :      237738 :   tree type;
     861                 :             : 
     862                 :      713164 :   for (int i = 0; i < NUM_INT_N_ENTS; i ++)
     863                 :      237738 :     if (int_n_enabled_p[i]
     864                 :      237738 :         && mode == int_n_data[i].m)
     865                 :          50 :       return (unsignedp ? int_n_trees[i].unsigned_type
     866                 :          50 :               : int_n_trees[i].signed_type);
     867                 :             : 
     868                 :      237688 :   if (VECTOR_MODE_P (mode))
     869                 :             :     {
     870                 :           0 :       tree inner;
     871                 :             : 
     872                 :           0 :       inner = gm2_langhook_type_for_mode (GET_MODE_INNER (mode), unsignedp);
     873                 :           0 :       if (inner != NULL_TREE)
     874                 :           0 :         return build_vector_type_for_mode (inner, mode);
     875                 :             :       return NULL_TREE;
     876                 :             :     }
     877                 :             : 
     878                 :      237688 :   scalar_int_mode imode;
     879                 :      237688 :   if (is_int_mode (mode, &imode))
     880                 :      198218 :     return gm2_langhook_type_for_size (GET_MODE_BITSIZE (imode), unsignedp);
     881                 :             : 
     882                 :      138579 :   if (mode == TYPE_MODE (float_type_node))
     883                 :         342 :     return float_type_node;
     884                 :             : 
     885                 :      138237 :   if (mode == TYPE_MODE (double_type_node))
     886                 :         506 :     return double_type_node;
     887                 :             : 
     888                 :      137731 :   if (mode == TYPE_MODE (long_double_type_node))
     889                 :         205 :     return long_double_type_node;
     890                 :             : 
     891                 :      137526 :   if ((float128_type_node != NULL) && (mode == TYPE_MODE (float128_type_node)))
     892                 :       15260 :     return float128_type_node;
     893                 :             : 
     894                 :      122266 :   if (COMPLEX_MODE_P (mode))
     895                 :             :     {
     896                 :       91746 :       machine_mode inner_mode;
     897                 :       91746 :       tree inner_type;
     898                 :             : 
     899                 :       91746 :       if (mode == TYPE_MODE (complex_float_type_node))
     900                 :       15386 :         return complex_float_type_node;
     901                 :       76360 :       if (mode == TYPE_MODE (complex_double_type_node))
     902                 :       15264 :         return complex_double_type_node;
     903                 :       61096 :       if (mode == TYPE_MODE (complex_long_double_type_node))
     904                 :       15316 :         return complex_long_double_type_node;
     905                 :             : 
     906                 :       45780 :       inner_mode = GET_MODE_INNER (mode);
     907                 :       45780 :       inner_type = gm2_langhook_type_for_mode (inner_mode, unsignedp);
     908                 :       45780 :       if (inner_type != NULL_TREE)
     909                 :       15260 :         return build_complex_type (inner_type);
     910                 :             :     }
     911                 :             : 
     912                 :             : #if HOST_BITS_PER_WIDE_INT >= 64
     913                 :             :   /* The middle-end and some backends rely on TImode being supported
     914                 :             :   for 64-bit HWI.  */
     915                 :       61040 :   if (mode == TImode)
     916                 :             :     {
     917                 :           0 :       type = build_nonstandard_integer_type (GET_MODE_BITSIZE (TImode),
     918                 :             :                                              unsignedp);
     919                 :           0 :       if (type && TYPE_MODE (type) == TImode)
     920                 :             :         return type;
     921                 :             :     }
     922                 :             : #endif
     923                 :             :   return NULL_TREE;
     924                 :             : }
     925                 :             : 
     926                 :             : /* Record a builtin function.  We just ignore builtin functions.  */
     927                 :             : 
     928                 :             : static tree
     929                 :     2380560 : gm2_langhook_builtin_function (tree decl)
     930                 :             : {
     931                 :     2380560 :   return decl;
     932                 :             : }
     933                 :             : 
     934                 :             : /* Return true if we are in the global binding level.  */
     935                 :             : 
     936                 :             : static bool
     937                 :       29892 : gm2_langhook_global_bindings_p (void)
     938                 :             : {
     939                 :       29892 :   return current_function_decl == NULL_TREE;
     940                 :             : }
     941                 :             : 
     942                 :             : /* Unused langhook.  */
     943                 :             : 
     944                 :             : static tree
     945                 :           0 : gm2_langhook_pushdecl (tree decl ATTRIBUTE_UNUSED)
     946                 :             : {
     947                 :           0 :   gcc_unreachable ();
     948                 :             : }
     949                 :             : 
     950                 :             : /* This hook is used to get the current list of declarations as trees.
     951                 :             :    We don't support that; instead we use write_globals.  This can't
     952                 :             :    simply crash because it is called by -gstabs.  */
     953                 :             : 
     954                 :             : static tree
     955                 :           0 : gm2_langhook_getdecls (void)
     956                 :             : {
     957                 :           0 :   return NULL;
     958                 :             : }
     959                 :             : 
     960                 :             : /* m2_write_global_declarations writes out globals creating an array
     961                 :             :    of the declarations and calling wrapup_global_declarations.  */
     962                 :             : 
     963                 :             : static void
     964                 :       13817 : m2_write_global_declarations (tree globals)
     965                 :             : {
     966                 :       13817 :   auto_vec<tree> global_decls;
     967                 :       13817 :   tree decl = globals;
     968                 :       13817 :   int n = 0;
     969                 :             : 
     970                 :     5582362 :   while (decl != NULL)
     971                 :             :     {
     972                 :     5568545 :       global_decls.safe_push (decl);
     973                 :     5568545 :       decl = TREE_CHAIN (decl);
     974                 :     5568545 :       n++;
     975                 :             :     }
     976                 :       27634 :   wrapup_global_declarations (global_decls.address (), n);
     977                 :       13817 : }
     978                 :             : 
     979                 :             : /* Write out globals.  */
     980                 :             : 
     981                 :             : static void
     982                 :       13817 : write_globals (void)
     983                 :             : {
     984                 :       13817 :   tree t;
     985                 :       13817 :   unsigned i;
     986                 :             : 
     987                 :       13817 :   m2block_finishGlobals ();
     988                 :             : 
     989                 :             :   /* Process all file scopes in this compilation, and the
     990                 :             :      external_scope, through wrapup_global_declarations and
     991                 :             :      check_global_declarations.  */
     992                 :       41451 :   FOR_EACH_VEC_ELT (*all_translation_units, i, t)
     993                 :       13817 :   m2_write_global_declarations (BLOCK_VARS (DECL_INITIAL (t)));
     994                 :       13817 : }
     995                 :             : 
     996                 :             : 
     997                 :             : /* Gimplify an EXPR_STMT node.  */
     998                 :             : 
     999                 :             : static void
    1000                 :        2806 : gimplify_expr_stmt (tree *stmt_p)
    1001                 :             : {
    1002                 :        2806 :   gcc_assert (EXPR_STMT_EXPR (*stmt_p) != NULL_TREE);
    1003                 :        2806 :   *stmt_p = EXPR_STMT_EXPR (*stmt_p);
    1004                 :        2806 : }
    1005                 :             : 
    1006                 :             : /* Genericize a TRY_BLOCK.  */
    1007                 :             : 
    1008                 :             : static void
    1009                 :        2806 : genericize_try_block (tree *stmt_p)
    1010                 :             : {
    1011                 :        2806 :   tree body = TRY_STMTS (*stmt_p);
    1012                 :        2806 :   tree cleanup = TRY_HANDLERS (*stmt_p);
    1013                 :             : 
    1014                 :        2806 :   *stmt_p = build2 (TRY_CATCH_EXPR, void_type_node, body, cleanup);
    1015                 :        2806 : }
    1016                 :             : 
    1017                 :             : /* Genericize a HANDLER by converting to a CATCH_EXPR.  */
    1018                 :             : 
    1019                 :             : static void
    1020                 :        2806 : genericize_catch_block (tree *stmt_p)
    1021                 :             : {
    1022                 :        2806 :   tree type = HANDLER_TYPE (*stmt_p);
    1023                 :        2806 :   tree body = HANDLER_BODY (*stmt_p);
    1024                 :             : 
    1025                 :             :   /* FIXME should the caught type go in TREE_TYPE?  */
    1026                 :        2806 :   *stmt_p = build2 (CATCH_EXPR, void_type_node, type, body);
    1027                 :        2806 : }
    1028                 :             : 
    1029                 :             : /* Convert the tree representation of FNDECL from m2 frontend trees
    1030                 :             :    to GENERIC.  */
    1031                 :             : 
    1032                 :             : extern void pf (tree);
    1033                 :             : 
    1034                 :             : void
    1035                 :       99720 : gm2_genericize (tree fndecl)
    1036                 :             : {
    1037                 :       99720 :   tree t;
    1038                 :       99720 :   struct cgraph_node *cgn;
    1039                 :             : 
    1040                 :             : #if 0
    1041                 :             :   pf (fndecl);
    1042                 :             : #endif
    1043                 :             :   /* Fix up the types of parms passed by invisible reference.  */
    1044                 :      265277 :   for (t = DECL_ARGUMENTS (fndecl); t; t = DECL_CHAIN (t))
    1045                 :      165557 :     if (TREE_ADDRESSABLE (TREE_TYPE (t)))
    1046                 :             :       {
    1047                 :             : 
    1048                 :             :         /* If a function's arguments are copied to create a thunk, then
    1049                 :             :            DECL_BY_REFERENCE will be set -- but the type of the argument will be
    1050                 :             :            a pointer type, so we will never get here.  */
    1051                 :           0 :         gcc_assert (!DECL_BY_REFERENCE (t));
    1052                 :           0 :         gcc_assert (DECL_ARG_TYPE (t) != TREE_TYPE (t));
    1053                 :           0 :         TREE_TYPE (t) = DECL_ARG_TYPE (t);
    1054                 :           0 :         DECL_BY_REFERENCE (t) = 1;
    1055                 :           0 :         TREE_ADDRESSABLE (t) = 0;
    1056                 :           0 :         relayout_decl (t);
    1057                 :             :       }
    1058                 :             : 
    1059                 :             :   /* Dump all nested functions now.  */
    1060                 :       99720 :   cgn = cgraph_node::get_create (fndecl);
    1061                 :      100638 :   for (cgn = first_nested_function (cgn);
    1062                 :      100638 :        cgn != NULL; cgn = next_nested_function (cgn))
    1063                 :         918 :     gm2_genericize (cgn->decl);
    1064                 :       99720 : }
    1065                 :             : 
    1066                 :             : /* gm2 gimplify expression, currently just change THROW in the same
    1067                 :             :    way as C++ */
    1068                 :             : 
    1069                 :             : static int
    1070                 :     8612798 : gm2_langhook_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
    1071                 :             :                             gimple_seq *post_p ATTRIBUTE_UNUSED)
    1072                 :             : {
    1073                 :     8612798 :   enum tree_code code = TREE_CODE (*expr_p);
    1074                 :             : 
    1075                 :     8612798 :   switch (code)
    1076                 :             :     {
    1077                 :         322 :     case THROW_EXPR:
    1078                 :             : 
    1079                 :             :       /* FIXME communicate throw type to back end, probably by moving
    1080                 :             :       THROW_EXPR into ../tree.def.  */
    1081                 :         322 :       *expr_p = TREE_OPERAND (*expr_p, 0);
    1082                 :         322 :       return GS_OK;
    1083                 :             : 
    1084                 :        2806 :     case EXPR_STMT:
    1085                 :        2806 :       gimplify_expr_stmt (expr_p);
    1086                 :        2806 :       return GS_OK;
    1087                 :             : 
    1088                 :        2806 :     case TRY_BLOCK:
    1089                 :        2806 :       genericize_try_block (expr_p);
    1090                 :        2806 :       return GS_OK;
    1091                 :             : 
    1092                 :        2806 :     case HANDLER:
    1093                 :        2806 :       genericize_catch_block (expr_p);
    1094                 :        2806 :       return GS_OK;
    1095                 :             : 
    1096                 :             :     default:
    1097                 :             :       return GS_UNHANDLED;
    1098                 :             :     }
    1099                 :             : }
    1100                 :             : 
    1101                 :             : static GTY(()) tree gm2_eh_personality_decl;
    1102                 :             : 
    1103                 :             : static tree
    1104                 :        2841 : gm2_langhook_eh_personality (void)
    1105                 :             : {
    1106                 :        2841 :   if (!gm2_eh_personality_decl)
    1107                 :        2686 :     gm2_eh_personality_decl = build_personality_function ("gxx");
    1108                 :             : 
    1109                 :        2841 :   return gm2_eh_personality_decl;
    1110                 :             : }
    1111                 :             : 
    1112                 :             : /* Functions called directly by the generic backend.  */
    1113                 :             : 
    1114                 :             : tree
    1115                 :     7176030 : convert_loc (location_t location, tree type, tree expr)
    1116                 :             : {
    1117                 :     7176030 :   if (type == error_mark_node || expr == error_mark_node
    1118                 :    14352054 :       || TREE_TYPE (expr) == error_mark_node)
    1119                 :             :     return error_mark_node;
    1120                 :             : 
    1121                 :     7176024 :   if (type == TREE_TYPE (expr))
    1122                 :             :     return expr;
    1123                 :             : 
    1124                 :     3303348 :   gcc_assert (TYPE_MAIN_VARIANT (type) != NULL);
    1125                 :     3303348 :   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (expr)))
    1126                 :           0 :     return fold_convert (type, expr);
    1127                 :             : 
    1128                 :     3303348 :   expr = m2convert_GenericToType (location, type, expr);
    1129                 :     3303348 :   switch (TREE_CODE (type))
    1130                 :             :     {
    1131                 :       85251 :     case VOID_TYPE:
    1132                 :       85251 :     case BOOLEAN_TYPE:
    1133                 :       85251 :       return fold (convert_to_integer (type, expr));
    1134                 :     2669968 :     case INTEGER_TYPE:
    1135                 :     2669968 :       return fold (convert_to_integer (type, expr));
    1136                 :      501113 :     case POINTER_TYPE:
    1137                 :      501113 :       return fold (convert_to_pointer (type, expr));
    1138                 :        3968 :     case REAL_TYPE:
    1139                 :        3968 :       return fold (convert_to_real (type, expr));
    1140                 :         216 :     case COMPLEX_TYPE:
    1141                 :         216 :       return fold (convert_to_complex (type, expr));
    1142                 :       42826 :     case ENUMERAL_TYPE:
    1143                 :       42826 :       return fold (convert_to_integer (type, expr));
    1144                 :           6 :     default:
    1145                 :           6 :       error_at (location, "cannot convert expression, only base types can be converted");
    1146                 :           6 :       break;
    1147                 :             :     }
    1148                 :           6 :   return error_mark_node;
    1149                 :             : }
    1150                 :             : 
    1151                 :             : /* Functions called directly by the generic backend.  */
    1152                 :             : 
    1153                 :             : tree
    1154                 :      636477 : convert (tree type, tree expr)
    1155                 :             : {
    1156                 :      636477 :   return convert_loc (m2linemap_UnknownLocation (), type, expr);
    1157                 :             : }
    1158                 :             : 
    1159                 :             : /* Mark EXP saying that we need to be able to take the address of it;
    1160                 :             :    it should not be allocated in a register.  Returns true if
    1161                 :             :    successful.  */
    1162                 :             : 
    1163                 :             : bool
    1164                 :     2636899 : gm2_mark_addressable (tree exp)
    1165                 :             : {
    1166                 :     2636899 :   tree x = exp;
    1167                 :             : 
    1168                 :     2684741 :   while (TRUE)
    1169                 :     2684741 :     switch (TREE_CODE (x))
    1170                 :             :       {
    1171                 :        6946 :       case COMPONENT_REF:
    1172                 :        6946 :         if (DECL_PACKED (TREE_OPERAND (x, 1)))
    1173                 :             :           return false;
    1174                 :        6946 :         x = TREE_OPERAND (x, 0);
    1175                 :        6946 :         break;
    1176                 :             : 
    1177                 :       40896 :       case ADDR_EXPR:
    1178                 :       40896 :       case ARRAY_REF:
    1179                 :       40896 :       case REALPART_EXPR:
    1180                 :       40896 :       case IMAGPART_EXPR:
    1181                 :       40896 :         x = TREE_OPERAND (x, 0);
    1182                 :       40896 :         break;
    1183                 :             : 
    1184                 :     2630259 :       case COMPOUND_LITERAL_EXPR:
    1185                 :     2630259 :       case CONSTRUCTOR:
    1186                 :     2630259 :       case STRING_CST:
    1187                 :     2630259 :       case VAR_DECL:
    1188                 :     2630259 :       case CONST_DECL:
    1189                 :     2630259 :       case PARM_DECL:
    1190                 :     2630259 :       case RESULT_DECL:
    1191                 :     2630259 :       case FUNCTION_DECL:
    1192                 :     2630259 :         TREE_ADDRESSABLE (x) = 1;
    1193                 :     2630259 :         return true;
    1194                 :             :       default:
    1195                 :             :         return true;
    1196                 :             :       }
    1197                 :             :   /* Never reach here.  */
    1198                 :             :   gcc_unreachable ();
    1199                 :             : }
    1200                 :             : 
    1201                 :             : /* Return an integer type with BITS bits of precision, that is
    1202                 :             :    unsigned if UNSIGNEDP is nonzero, otherwise signed.  */
    1203                 :             : 
    1204                 :             : tree
    1205                 :      240366 : gm2_type_for_size (unsigned int bits, int unsignedp)
    1206                 :             : {
    1207                 :      240366 :   if (unsignedp)
    1208                 :             :     {
    1209                 :       84889 :       if (bits == INT_TYPE_SIZE)
    1210                 :       26286 :         return unsigned_type_node;
    1211                 :       58603 :       else if (bits == CHAR_TYPE_SIZE)
    1212                 :       21554 :         return unsigned_char_type_node;
    1213                 :       37049 :       else if (bits == SHORT_TYPE_SIZE)
    1214                 :         172 :         return short_unsigned_type_node;
    1215                 :       37315 :       else if (bits == LONG_TYPE_SIZE)
    1216                 :       36433 :         return long_unsigned_type_node;
    1217                 :         444 :       else if (bits == LONG_LONG_TYPE_SIZE)
    1218                 :         438 :         return long_long_unsigned_type_node;
    1219                 :             :       else
    1220                 :           6 :         return build_nonstandard_integer_type (bits,
    1221                 :           6 :                                                unsignedp);
    1222                 :             :     }
    1223                 :             :   else
    1224                 :             :     {
    1225                 :      155477 :       if (bits == INT_TYPE_SIZE)
    1226                 :        3039 :         return integer_type_node;
    1227                 :      152438 :       else if (bits == CHAR_TYPE_SIZE)
    1228                 :          24 :         return signed_char_type_node;
    1229                 :      152414 :       else if (bits == SHORT_TYPE_SIZE)
    1230                 :         138 :         return short_integer_type_node;
    1231                 :      152674 :       else if (bits == LONG_TYPE_SIZE)
    1232                 :      136922 :         return long_integer_type_node;
    1233                 :       15354 :       else if (bits == LONG_LONG_TYPE_SIZE)
    1234                 :         398 :         return long_long_integer_type_node;
    1235                 :             :       else
    1236                 :       14956 :         return build_nonstandard_integer_type (bits,
    1237                 :       14956 :                                                unsignedp);
    1238                 :             :     }
    1239                 :             :   /* Never reach here.  */
    1240                 :             :   gcc_unreachable ();
    1241                 :             : }
    1242                 :             : 
    1243                 :             : /* Allow the analyzer to understand Storage ALLOCATE/DEALLOCATE.  */
    1244                 :             : 
    1245                 :             : bool
    1246                 :           0 : gm2_langhook_new_dispose_storage_substitution (void)
    1247                 :             : {
    1248                 :           0 :   return true;
    1249                 :             : }
    1250                 :             : 
    1251                 :             : #undef LANG_HOOKS_NAME
    1252                 :             : #undef LANG_HOOKS_INIT
    1253                 :             : #undef LANG_HOOKS_INIT_OPTIONS
    1254                 :             : #undef LANG_HOOKS_OPTION_LANG_MASK
    1255                 :             : #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
    1256                 :             : #undef LANG_HOOKS_HANDLE_OPTION
    1257                 :             : #undef LANG_HOOKS_POST_OPTIONS
    1258                 :             : #undef LANG_HOOKS_PARSE_FILE
    1259                 :             : #undef LANG_HOOKS_TYPE_FOR_MODE
    1260                 :             : #undef LANG_HOOKS_TYPE_FOR_SIZE
    1261                 :             : #undef LANG_HOOKS_BUILTIN_FUNCTION
    1262                 :             : #undef LANG_HOOKS_GLOBAL_BINDINGS_P
    1263                 :             : #undef LANG_HOOKS_PUSHDECL
    1264                 :             : #undef LANG_HOOKS_GETDECLS
    1265                 :             : #undef LANG_HOOKS_GIMPLIFY_EXPR
    1266                 :             : #undef LANG_HOOKS_EH_PERSONALITY
    1267                 :             : #undef LANG_HOOKS_NEW_DISPOSE_STORAGE_SUBSTITUTION
    1268                 :             : 
    1269                 :             : #define LANG_HOOKS_NAME "GNU Modula-2"
    1270                 :             : #define LANG_HOOKS_INIT gm2_langhook_init
    1271                 :             : #define LANG_HOOKS_INIT_OPTIONS gm2_langhook_init_options
    1272                 :             : #define LANG_HOOKS_OPTION_LANG_MASK gm2_langhook_option_lang_mask
    1273                 :             : #define LANG_HOOKS_INIT_OPTIONS_STRUCT gm2_langhook_init_options_struct
    1274                 :             : #define LANG_HOOKS_HANDLE_OPTION gm2_langhook_handle_option
    1275                 :             : #define LANG_HOOKS_POST_OPTIONS gm2_langhook_post_options
    1276                 :             : #define LANG_HOOKS_PARSE_FILE gm2_langhook_parse_file
    1277                 :             : #define LANG_HOOKS_TYPE_FOR_MODE gm2_langhook_type_for_mode
    1278                 :             : #define LANG_HOOKS_TYPE_FOR_SIZE gm2_langhook_type_for_size
    1279                 :             : #define LANG_HOOKS_BUILTIN_FUNCTION gm2_langhook_builtin_function
    1280                 :             : #define LANG_HOOKS_GLOBAL_BINDINGS_P gm2_langhook_global_bindings_p
    1281                 :             : #define LANG_HOOKS_PUSHDECL gm2_langhook_pushdecl
    1282                 :             : #define LANG_HOOKS_GETDECLS gm2_langhook_getdecls
    1283                 :             : #define LANG_HOOKS_GIMPLIFY_EXPR gm2_langhook_gimplify_expr
    1284                 :             : #define LANG_HOOKS_EH_PERSONALITY gm2_langhook_eh_personality
    1285                 :             : #define LANG_HOOKS_NEW_DISPOSE_STORAGE_SUBSTITUTION \
    1286                 :             :   gm2_langhook_new_dispose_storage_substitution
    1287                 :             : 
    1288                 :             : struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
    1289                 :             : 
    1290                 :             : #include "gt-m2-gm2-lang.h"
    1291                 :             : #include "gtype-m2.h"
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.