LCOV - code coverage report
Current view: top level - gcc/c-family - c-common.c (source / functions) Hit Total Coverage
Test: gcc.info Lines: 3247 3597 90.3 %
Date: 2020-03-28 11:57:23 Functions: 139 148 93.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* Subroutines shared by all languages that are variants of C.
       2                 :            :    Copyright (C) 1992-2020 Free Software Foundation, Inc.
       3                 :            : 
       4                 :            : This file is part of GCC.
       5                 :            : 
       6                 :            : GCC is free software; you can redistribute it and/or modify it under
       7                 :            : the terms of the GNU General Public License as published by the Free
       8                 :            : Software Foundation; either version 3, or (at your option) any later
       9                 :            : version.
      10                 :            : 
      11                 :            : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12                 :            : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13                 :            : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14                 :            : for more details.
      15                 :            : 
      16                 :            : You should have received a copy of the GNU General Public License
      17                 :            : along with GCC; see the file COPYING3.  If not see
      18                 :            : <http://www.gnu.org/licenses/>.  */
      19                 :            : 
      20                 :            : #define GCC_C_COMMON_C
      21                 :            : 
      22                 :            : #include "config.h"
      23                 :            : #include "system.h"
      24                 :            : #include "coretypes.h"
      25                 :            : #include "target.h"
      26                 :            : #include "function.h"
      27                 :            : #include "tree.h"
      28                 :            : #include "memmodel.h"
      29                 :            : #include "c-common.h"
      30                 :            : #include "gimple-expr.h"
      31                 :            : #include "tm_p.h"
      32                 :            : #include "stringpool.h"
      33                 :            : #include "cgraph.h"
      34                 :            : #include "diagnostic.h"
      35                 :            : #include "intl.h"
      36                 :            : #include "stor-layout.h"
      37                 :            : #include "calls.h"
      38                 :            : #include "attribs.h"
      39                 :            : #include "varasm.h"
      40                 :            : #include "trans-mem.h"
      41                 :            : #include "c-objc.h"
      42                 :            : #include "common/common-target.h"
      43                 :            : #include "langhooks.h"
      44                 :            : #include "tree-inline.h"
      45                 :            : #include "toplev.h"
      46                 :            : #include "tree-iterator.h"
      47                 :            : #include "opts.h"
      48                 :            : #include "gimplify.h"
      49                 :            : #include "substring-locations.h"
      50                 :            : #include "spellcheck.h"
      51                 :            : #include "c-spellcheck.h"
      52                 :            : #include "selftest.h"
      53                 :            : 
      54                 :            : cpp_reader *parse_in;           /* Declared in c-pragma.h.  */
      55                 :            : 
      56                 :            : /* Mode used to build pointers (VOIDmode means ptr_mode).  */
      57                 :            : 
      58                 :            : machine_mode c_default_pointer_mode = VOIDmode;
      59                 :            : 
      60                 :            : /* The following symbols are subsumed in the c_global_trees array, and
      61                 :            :    listed here individually for documentation purposes.
      62                 :            : 
      63                 :            :    INTEGER_TYPE and REAL_TYPE nodes for the standard data types.
      64                 :            : 
      65                 :            :         tree short_integer_type_node;
      66                 :            :         tree long_integer_type_node;
      67                 :            :         tree long_long_integer_type_node;
      68                 :            : 
      69                 :            :         tree short_unsigned_type_node;
      70                 :            :         tree long_unsigned_type_node;
      71                 :            :         tree long_long_unsigned_type_node;
      72                 :            : 
      73                 :            :         tree truthvalue_type_node;
      74                 :            :         tree truthvalue_false_node;
      75                 :            :         tree truthvalue_true_node;
      76                 :            : 
      77                 :            :         tree ptrdiff_type_node;
      78                 :            : 
      79                 :            :         tree unsigned_char_type_node;
      80                 :            :         tree signed_char_type_node;
      81                 :            :         tree wchar_type_node;
      82                 :            : 
      83                 :            :         tree char8_type_node;
      84                 :            :         tree char16_type_node;
      85                 :            :         tree char32_type_node;
      86                 :            : 
      87                 :            :         tree float_type_node;
      88                 :            :         tree double_type_node;
      89                 :            :         tree long_double_type_node;
      90                 :            : 
      91                 :            :         tree complex_integer_type_node;
      92                 :            :         tree complex_float_type_node;
      93                 :            :         tree complex_double_type_node;
      94                 :            :         tree complex_long_double_type_node;
      95                 :            : 
      96                 :            :         tree dfloat32_type_node;
      97                 :            :         tree dfloat64_type_node;
      98                 :            :         tree_dfloat128_type_node;
      99                 :            : 
     100                 :            :         tree intQI_type_node;
     101                 :            :         tree intHI_type_node;
     102                 :            :         tree intSI_type_node;
     103                 :            :         tree intDI_type_node;
     104                 :            :         tree intTI_type_node;
     105                 :            : 
     106                 :            :         tree unsigned_intQI_type_node;
     107                 :            :         tree unsigned_intHI_type_node;
     108                 :            :         tree unsigned_intSI_type_node;
     109                 :            :         tree unsigned_intDI_type_node;
     110                 :            :         tree unsigned_intTI_type_node;
     111                 :            : 
     112                 :            :         tree widest_integer_literal_type_node;
     113                 :            :         tree widest_unsigned_literal_type_node;
     114                 :            : 
     115                 :            :    Nodes for types `void *' and `const void *'.
     116                 :            : 
     117                 :            :         tree ptr_type_node, const_ptr_type_node;
     118                 :            : 
     119                 :            :    Nodes for types `char *' and `const char *'.
     120                 :            : 
     121                 :            :         tree string_type_node, const_string_type_node;
     122                 :            : 
     123                 :            :    Type `char[SOMENUMBER]'.
     124                 :            :    Used when an array of char is needed and the size is irrelevant.
     125                 :            : 
     126                 :            :         tree char_array_type_node;
     127                 :            : 
     128                 :            :    Type `wchar_t[SOMENUMBER]' or something like it.
     129                 :            :    Used when a wide string literal is created.
     130                 :            : 
     131                 :            :         tree wchar_array_type_node;
     132                 :            : 
     133                 :            :    Type `char8_t[SOMENUMBER]' or something like it.
     134                 :            :    Used when a UTF-8 string literal is created.
     135                 :            : 
     136                 :            :         tree char8_array_type_node;
     137                 :            : 
     138                 :            :    Type `char16_t[SOMENUMBER]' or something like it.
     139                 :            :    Used when a UTF-16 string literal is created.
     140                 :            : 
     141                 :            :         tree char16_array_type_node;
     142                 :            : 
     143                 :            :    Type `char32_t[SOMENUMBER]' or something like it.
     144                 :            :    Used when a UTF-32 string literal is created.
     145                 :            : 
     146                 :            :         tree char32_array_type_node;
     147                 :            : 
     148                 :            :    Type `int ()' -- used for implicit declaration of functions.
     149                 :            : 
     150                 :            :         tree default_function_type;
     151                 :            : 
     152                 :            :    A VOID_TYPE node, packaged in a TREE_LIST.
     153                 :            : 
     154                 :            :         tree void_list_node;
     155                 :            : 
     156                 :            :   The lazily created VAR_DECLs for __FUNCTION__, __PRETTY_FUNCTION__,
     157                 :            :   and __func__. (C doesn't generate __FUNCTION__ and__PRETTY_FUNCTION__
     158                 :            :   VAR_DECLS, but C++ does.)
     159                 :            : 
     160                 :            :         tree function_name_decl_node;
     161                 :            :         tree pretty_function_name_decl_node;
     162                 :            :         tree c99_function_name_decl_node;
     163                 :            : 
     164                 :            :   Stack of nested function name VAR_DECLs.
     165                 :            : 
     166                 :            :         tree saved_function_name_decls;
     167                 :            : 
     168                 :            : */
     169                 :            : 
     170                 :            : tree c_global_trees[CTI_MAX];
     171                 :            : 
     172                 :            : /* Switches common to the C front ends.  */
     173                 :            : 
     174                 :            : /* Nonzero means don't output line number information.  */
     175                 :            : 
     176                 :            : char flag_no_line_commands;
     177                 :            : 
     178                 :            : /* Nonzero causes -E output not to be done, but directives such as
     179                 :            :    #define that have side effects are still obeyed.  */
     180                 :            : 
     181                 :            : char flag_no_output;
     182                 :            : 
     183                 :            : /* Nonzero means dump macros in some fashion.  */
     184                 :            : 
     185                 :            : char flag_dump_macros;
     186                 :            : 
     187                 :            : /* Nonzero means pass #include lines through to the output.  */
     188                 :            : 
     189                 :            : char flag_dump_includes;
     190                 :            : 
     191                 :            : /* Nonzero means process PCH files while preprocessing.  */
     192                 :            : 
     193                 :            : bool flag_pch_preprocess;
     194                 :            : 
     195                 :            : /* The file name to which we should write a precompiled header, or
     196                 :            :    NULL if no header will be written in this compile.  */
     197                 :            : 
     198                 :            : const char *pch_file;
     199                 :            : 
     200                 :            : /* Nonzero if an ISO standard was selected.  It rejects macros in the
     201                 :            :    user's namespace.  */
     202                 :            : int flag_iso;
     203                 :            : 
     204                 :            : /* C/ObjC language option variables.  */
     205                 :            : 
     206                 :            : 
     207                 :            : /* Nonzero means allow type mismatches in conditional expressions;
     208                 :            :    just make their values `void'.  */
     209                 :            : 
     210                 :            : int flag_cond_mismatch;
     211                 :            : 
     212                 :            : /* Nonzero means enable C89 Amendment 1 features.  */
     213                 :            : 
     214                 :            : int flag_isoc94;
     215                 :            : 
     216                 :            : /* Nonzero means use the ISO C99 (or C11) dialect of C.  */
     217                 :            : 
     218                 :            : int flag_isoc99;
     219                 :            : 
     220                 :            : /* Nonzero means use the ISO C11 dialect of C.  */
     221                 :            : 
     222                 :            : int flag_isoc11;
     223                 :            : 
     224                 :            : /* Nonzero means use the ISO C2X dialect of C.  */
     225                 :            : 
     226                 :            : int flag_isoc2x;
     227                 :            : 
     228                 :            : /* Nonzero means that we have builtin functions, and main is an int.  */
     229                 :            : 
     230                 :            : int flag_hosted = 1;
     231                 :            : 
     232                 :            : 
     233                 :            : /* ObjC language option variables.  */
     234                 :            : 
     235                 :            : 
     236                 :            : /* Tells the compiler that this is a special run.  Do not perform any
     237                 :            :    compiling, instead we are to test some platform dependent features
     238                 :            :    and output a C header file with appropriate definitions.  */
     239                 :            : 
     240                 :            : int print_struct_values;
     241                 :            : 
     242                 :            : /* Tells the compiler what is the constant string class for ObjC.  */
     243                 :            : 
     244                 :            : const char *constant_string_class_name;
     245                 :            : 
     246                 :            : 
     247                 :            : /* C++ language option variables.  */
     248                 :            : 
     249                 :            : /* The reference version of the ABI for -Wabi.  */
     250                 :            : 
     251                 :            : int warn_abi_version = -1;
     252                 :            : 
     253                 :            : /* The C++ dialect being used.  Default set in c_common_post_options.  */
     254                 :            : 
     255                 :            : enum cxx_dialect cxx_dialect = cxx_unset;
     256                 :            : 
     257                 :            : /* Maximum template instantiation depth.  This limit exists to limit the
     258                 :            :    time it takes to notice excessively recursive template instantiations.
     259                 :            : 
     260                 :            :    The default is lower than the 1024 recommended by the C++0x standard
     261                 :            :    because G++ runs out of stack before 1024 with highly recursive template
     262                 :            :    argument deduction substitution (g++.dg/cpp0x/enum11.C).  */
     263                 :            : 
     264                 :            : int max_tinst_depth = 900;
     265                 :            : 
     266                 :            : /* The elements of `ridpointers' are identifier nodes for the reserved
     267                 :            :    type names and storage classes.  It is indexed by a RID_... value.  */
     268                 :            : tree *ridpointers;
     269                 :            : 
     270                 :            : tree (*make_fname_decl) (location_t, tree, int);
     271                 :            : 
     272                 :            : /* Nonzero means don't warn about problems that occur when the code is
     273                 :            :    executed.  */
     274                 :            : int c_inhibit_evaluation_warnings;
     275                 :            : 
     276                 :            : /* Whether we are building a boolean conversion inside
     277                 :            :    convert_for_assignment, or some other late binary operation.  If
     278                 :            :    build_binary_op is called for C (from code shared by C and C++) in
     279                 :            :    this case, then the operands have already been folded and the
     280                 :            :    result will not be folded again, so C_MAYBE_CONST_EXPR should not
     281                 :            :    be generated.  */
     282                 :            : bool in_late_binary_op;
     283                 :            : 
     284                 :            : /* Whether lexing has been completed, so subsequent preprocessor
     285                 :            :    errors should use the compiler's input_location.  */
     286                 :            : bool done_lexing = false;
     287                 :            : 
     288                 :            : /* Information about how a function name is generated.  */
     289                 :            : struct fname_var_t
     290                 :            : {
     291                 :            :   tree *const decl;     /* pointer to the VAR_DECL.  */
     292                 :            :   const unsigned rid;   /* RID number for the identifier.  */
     293                 :            :   const int pretty;     /* How pretty is it? */
     294                 :            : };
     295                 :            : 
     296                 :            : /* The three ways of getting then name of the current function.  */
     297                 :            : 
     298                 :            : const struct fname_var_t fname_vars[] =
     299                 :            : {
     300                 :            :   /* C99 compliant __func__, must be first.  */
     301                 :            :   {&c99_function_name_decl_node, RID_C99_FUNCTION_NAME, 0},
     302                 :            :   /* GCC __FUNCTION__ compliant.  */
     303                 :            :   {&function_name_decl_node, RID_FUNCTION_NAME, 0},
     304                 :            :   /* GCC __PRETTY_FUNCTION__ compliant.  */
     305                 :            :   {&pretty_function_name_decl_node, RID_PRETTY_FUNCTION_NAME, 1},
     306                 :            :   {NULL, 0, 0},
     307                 :            : };
     308                 :            : 
     309                 :            : /* Global visibility options.  */
     310                 :            : struct visibility_flags visibility_options;
     311                 :            : 
     312                 :            : static tree check_case_value (location_t, tree);
     313                 :            : 
     314                 :            : 
     315                 :            : static void check_nonnull_arg (void *, tree, unsigned HOST_WIDE_INT);
     316                 :            : static bool nonnull_check_p (tree, unsigned HOST_WIDE_INT);
     317                 :            : 
     318                 :            : /* Reserved words.  The third field is a mask: keywords are disabled
     319                 :            :    if they match the mask.
     320                 :            : 
     321                 :            :    Masks for languages:
     322                 :            :    C --std=c89: D_C99 | D_CXXONLY | D_OBJC | D_CXX_OBJC
     323                 :            :    C --std=c99: D_CXXONLY | D_OBJC
     324                 :            :    ObjC is like C except that D_OBJC and D_CXX_OBJC are not set
     325                 :            :    C++ --std=c++98: D_CONLY | D_CXX11 | D_CXX20 | D_OBJC
     326                 :            :    C++ --std=c++11: D_CONLY | D_CXX20 | D_OBJC
     327                 :            :    C++ --std=c++2a: D_CONLY | D_OBJC
     328                 :            :    ObjC++ is like C++ except that D_OBJC is not set
     329                 :            : 
     330                 :            :    If -fno-asm is used, D_ASM is added to the mask.  If
     331                 :            :    -fno-gnu-keywords is used, D_EXT is added.  If -fno-asm and C in
     332                 :            :    C89 mode, D_EXT89 is added for both -fno-asm and -fno-gnu-keywords.
     333                 :            :    In C with -Wc++-compat, we warn if D_CXXWARN is set.
     334                 :            : 
     335                 :            :    Note the complication of the D_CXX_OBJC keywords.  These are
     336                 :            :    reserved words such as 'class'.  In C++, 'class' is a reserved
     337                 :            :    word.  In Objective-C++ it is too.  In Objective-C, it is a
     338                 :            :    reserved word too, but only if it follows an '@' sign.
     339                 :            : */
     340                 :            : const struct c_common_resword c_common_reswords[] =
     341                 :            : {
     342                 :            :   { "_Alignas",               RID_ALIGNAS,   D_CONLY },
     343                 :            :   { "_Alignof",               RID_ALIGNOF,   D_CONLY },
     344                 :            :   { "_Atomic",                RID_ATOMIC,    D_CONLY },
     345                 :            :   { "_Bool",          RID_BOOL,      D_CONLY },
     346                 :            :   { "_Complex",               RID_COMPLEX,    0 },
     347                 :            :   { "_Imaginary",     RID_IMAGINARY, D_CONLY },
     348                 :            :   { "_Float16",         RID_FLOAT16,   D_CONLY },
     349                 :            :   { "_Float32",         RID_FLOAT32,   D_CONLY },
     350                 :            :   { "_Float64",         RID_FLOAT64,   D_CONLY },
     351                 :            :   { "_Float128",        RID_FLOAT128,  D_CONLY },
     352                 :            :   { "_Float32x",        RID_FLOAT32X,  D_CONLY },
     353                 :            :   { "_Float64x",        RID_FLOAT64X,  D_CONLY },
     354                 :            :   { "_Float128x",       RID_FLOAT128X, D_CONLY },
     355                 :            :   { "_Decimal32",       RID_DFLOAT32,  D_CONLY },
     356                 :            :   { "_Decimal64",       RID_DFLOAT64,  D_CONLY },
     357                 :            :   { "_Decimal128",      RID_DFLOAT128, D_CONLY },
     358                 :            :   { "_Fract",           RID_FRACT,     D_CONLY | D_EXT },
     359                 :            :   { "_Accum",           RID_ACCUM,     D_CONLY | D_EXT },
     360                 :            :   { "_Sat",             RID_SAT,       D_CONLY | D_EXT },
     361                 :            :   { "_Static_assert",   RID_STATIC_ASSERT, D_CONLY },
     362                 :            :   { "_Noreturn",        RID_NORETURN,  D_CONLY },
     363                 :            :   { "_Generic",         RID_GENERIC,   D_CONLY },
     364                 :            :   { "_Thread_local",    RID_THREAD,    D_CONLY },
     365                 :            :   { "__FUNCTION__",   RID_FUNCTION_NAME, 0 },
     366                 :            :   { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
     367                 :            :   { "__alignof",      RID_ALIGNOF,    0 },
     368                 :            :   { "__alignof__",    RID_ALIGNOF,    0 },
     369                 :            :   { "__asm",          RID_ASM,        0 },
     370                 :            :   { "__asm__",                RID_ASM,        0 },
     371                 :            :   { "__attribute",    RID_ATTRIBUTE,  0 },
     372                 :            :   { "__attribute__",  RID_ATTRIBUTE,  0 },
     373                 :            :   { "__auto_type",    RID_AUTO_TYPE,  D_CONLY },
     374                 :            :   { "__bases",          RID_BASES, D_CXXONLY },
     375                 :            :   { "__builtin_addressof", RID_ADDRESSOF, D_CXXONLY },
     376                 :            :   { "__builtin_call_with_static_chain",
     377                 :            :     RID_BUILTIN_CALL_WITH_STATIC_CHAIN, D_CONLY },
     378                 :            :   { "__builtin_choose_expr", RID_CHOOSE_EXPR, D_CONLY },
     379                 :            :   { "__builtin_complex", RID_BUILTIN_COMPLEX, D_CONLY },
     380                 :            :   { "__builtin_convertvector", RID_BUILTIN_CONVERTVECTOR, 0 },
     381                 :            :   { "__builtin_has_attribute", RID_BUILTIN_HAS_ATTRIBUTE, 0 },
     382                 :            :   { "__builtin_launder", RID_BUILTIN_LAUNDER, D_CXXONLY },
     383                 :            :   { "__builtin_shuffle", RID_BUILTIN_SHUFFLE, 0 },
     384                 :            :   { "__builtin_tgmath", RID_BUILTIN_TGMATH, D_CONLY },
     385                 :            :   { "__builtin_offsetof", RID_OFFSETOF, 0 },
     386                 :            :   { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, D_CONLY },
     387                 :            :   { "__builtin_va_arg",       RID_VA_ARG,     0 },
     388                 :            :   { "__complex",      RID_COMPLEX,    0 },
     389                 :            :   { "__complex__",    RID_COMPLEX,    0 },
     390                 :            :   { "__const",                RID_CONST,      0 },
     391                 :            :   { "__const__",      RID_CONST,      0 },
     392                 :            :   { "__constinit",    RID_CONSTINIT,  D_CXXONLY },
     393                 :            :   { "__decltype",       RID_DECLTYPE,   D_CXXONLY },
     394                 :            :   { "__direct_bases",   RID_DIRECT_BASES, D_CXXONLY },
     395                 :            :   { "__extension__",  RID_EXTENSION,  0 },
     396                 :            :   { "__func__",               RID_C99_FUNCTION_NAME, 0 },
     397                 :            :   { "__has_nothrow_assign", RID_HAS_NOTHROW_ASSIGN, D_CXXONLY },
     398                 :            :   { "__has_nothrow_constructor", RID_HAS_NOTHROW_CONSTRUCTOR, D_CXXONLY },
     399                 :            :   { "__has_nothrow_copy", RID_HAS_NOTHROW_COPY, D_CXXONLY },
     400                 :            :   { "__has_trivial_assign", RID_HAS_TRIVIAL_ASSIGN, D_CXXONLY },
     401                 :            :   { "__has_trivial_constructor", RID_HAS_TRIVIAL_CONSTRUCTOR, D_CXXONLY },
     402                 :            :   { "__has_trivial_copy", RID_HAS_TRIVIAL_COPY, D_CXXONLY },
     403                 :            :   { "__has_trivial_destructor", RID_HAS_TRIVIAL_DESTRUCTOR, D_CXXONLY },
     404                 :            :   { "__has_unique_object_representations", RID_HAS_UNIQUE_OBJ_REPRESENTATIONS,
     405                 :            :                                         D_CXXONLY },
     406                 :            :   { "__has_virtual_destructor", RID_HAS_VIRTUAL_DESTRUCTOR, D_CXXONLY },
     407                 :            :   { "__imag",         RID_IMAGPART,   0 },
     408                 :            :   { "__imag__",               RID_IMAGPART,   0 },
     409                 :            :   { "__inline",               RID_INLINE,     0 },
     410                 :            :   { "__inline__",     RID_INLINE,     0 },
     411                 :            :   { "__is_abstract",  RID_IS_ABSTRACT, D_CXXONLY },
     412                 :            :   { "__is_aggregate", RID_IS_AGGREGATE, D_CXXONLY },
     413                 :            :   { "__is_base_of",   RID_IS_BASE_OF, D_CXXONLY },
     414                 :            :   { "__is_class",     RID_IS_CLASS,   D_CXXONLY },
     415                 :            :   { "__is_empty",     RID_IS_EMPTY,   D_CXXONLY },
     416                 :            :   { "__is_enum",      RID_IS_ENUM,    D_CXXONLY },
     417                 :            :   { "__is_final",     RID_IS_FINAL,   D_CXXONLY },
     418                 :            :   { "__is_literal_type", RID_IS_LITERAL_TYPE, D_CXXONLY },
     419                 :            :   { "__is_pod",               RID_IS_POD,     D_CXXONLY },
     420                 :            :   { "__is_polymorphic",       RID_IS_POLYMORPHIC, D_CXXONLY },
     421                 :            :   { "__is_same",     RID_IS_SAME_AS, D_CXXONLY },
     422                 :            :   { "__is_same_as",     RID_IS_SAME_AS, D_CXXONLY },
     423                 :            :   { "__is_standard_layout", RID_IS_STD_LAYOUT, D_CXXONLY },
     424                 :            :   { "__is_trivial",     RID_IS_TRIVIAL, D_CXXONLY },
     425                 :            :   { "__is_trivially_assignable", RID_IS_TRIVIALLY_ASSIGNABLE, D_CXXONLY },
     426                 :            :   { "__is_trivially_constructible", RID_IS_TRIVIALLY_CONSTRUCTIBLE, D_CXXONLY },
     427                 :            :   { "__is_trivially_copyable", RID_IS_TRIVIALLY_COPYABLE, D_CXXONLY },
     428                 :            :   { "__is_union",     RID_IS_UNION,   D_CXXONLY },
     429                 :            :   { "__label__",      RID_LABEL,      0 },
     430                 :            :   { "__null",         RID_NULL,       0 },
     431                 :            :   { "__real",         RID_REALPART,   0 },
     432                 :            :   { "__real__",               RID_REALPART,   0 },
     433                 :            :   { "__restrict",     RID_RESTRICT,   0 },
     434                 :            :   { "__restrict__",   RID_RESTRICT,   0 },
     435                 :            :   { "__signed",               RID_SIGNED,     0 },
     436                 :            :   { "__signed__",     RID_SIGNED,     0 },
     437                 :            :   { "__thread",               RID_THREAD,     0 },
     438                 :            :   { "__transaction_atomic", RID_TRANSACTION_ATOMIC, 0 },
     439                 :            :   { "__transaction_relaxed", RID_TRANSACTION_RELAXED, 0 },
     440                 :            :   { "__transaction_cancel", RID_TRANSACTION_CANCEL, 0 },
     441                 :            :   { "__typeof",               RID_TYPEOF,     0 },
     442                 :            :   { "__typeof__",     RID_TYPEOF,     0 },
     443                 :            :   { "__underlying_type", RID_UNDERLYING_TYPE, D_CXXONLY },
     444                 :            :   { "__volatile",     RID_VOLATILE,   0 },
     445                 :            :   { "__volatile__",   RID_VOLATILE,   0 },
     446                 :            :   { "__GIMPLE",               RID_GIMPLE,     D_CONLY },
     447                 :            :   { "__PHI",          RID_PHI,        D_CONLY },
     448                 :            :   { "__RTL",          RID_RTL,        D_CONLY },
     449                 :            :   { "alignas",                RID_ALIGNAS,    D_CXXONLY | D_CXX11 | D_CXXWARN },
     450                 :            :   { "alignof",                RID_ALIGNOF,    D_CXXONLY | D_CXX11 | D_CXXWARN },
     451                 :            :   { "asm",            RID_ASM,        D_ASM },
     452                 :            :   { "auto",           RID_AUTO,       0 },
     453                 :            :   { "bool",           RID_BOOL,       D_CXXONLY | D_CXXWARN },
     454                 :            :   { "break",          RID_BREAK,      0 },
     455                 :            :   { "case",           RID_CASE,       0 },
     456                 :            :   { "catch",          RID_CATCH,      D_CXX_OBJC | D_CXXWARN },
     457                 :            :   { "char",           RID_CHAR,       0 },
     458                 :            :   { "char8_t",                RID_CHAR8,      D_CXX_CHAR8_T_FLAGS | D_CXXWARN },
     459                 :            :   { "char16_t",               RID_CHAR16,     D_CXXONLY | D_CXX11 | D_CXXWARN },
     460                 :            :   { "char32_t",               RID_CHAR32,     D_CXXONLY | D_CXX11 | D_CXXWARN },
     461                 :            :   { "class",          RID_CLASS,      D_CXX_OBJC | D_CXXWARN },
     462                 :            :   { "const",          RID_CONST,      0 },
     463                 :            :   { "consteval",      RID_CONSTEVAL,  D_CXXONLY | D_CXX20 | D_CXXWARN },
     464                 :            :   { "constexpr",      RID_CONSTEXPR,  D_CXXONLY | D_CXX11 | D_CXXWARN },
     465                 :            :   { "constinit",      RID_CONSTINIT,  D_CXXONLY | D_CXX20 | D_CXXWARN },
     466                 :            :   { "const_cast",     RID_CONSTCAST,  D_CXXONLY | D_CXXWARN },
     467                 :            :   { "continue",               RID_CONTINUE,   0 },
     468                 :            :   { "decltype",         RID_DECLTYPE,   D_CXXONLY | D_CXX11 | D_CXXWARN },
     469                 :            :   { "default",                RID_DEFAULT,    0 },
     470                 :            :   { "delete",         RID_DELETE,     D_CXXONLY | D_CXXWARN },
     471                 :            :   { "do",             RID_DO,         0 },
     472                 :            :   { "double",         RID_DOUBLE,     0 },
     473                 :            :   { "dynamic_cast",   RID_DYNCAST,    D_CXXONLY | D_CXXWARN },
     474                 :            :   { "else",           RID_ELSE,       0 },
     475                 :            :   { "enum",           RID_ENUM,       0 },
     476                 :            :   { "explicit",               RID_EXPLICIT,   D_CXXONLY | D_CXXWARN },
     477                 :            :   { "export",         RID_EXPORT,     D_CXXONLY | D_CXXWARN },
     478                 :            :   { "extern",         RID_EXTERN,     0 },
     479                 :            :   { "false",          RID_FALSE,      D_CXXONLY | D_CXXWARN },
     480                 :            :   { "float",          RID_FLOAT,      0 },
     481                 :            :   { "for",            RID_FOR,        0 },
     482                 :            :   { "friend",         RID_FRIEND,     D_CXXONLY | D_CXXWARN },
     483                 :            :   { "goto",           RID_GOTO,       0 },
     484                 :            :   { "if",             RID_IF,         0 },
     485                 :            :   { "inline",         RID_INLINE,     D_EXT89 },
     486                 :            :   { "int",            RID_INT,        0 },
     487                 :            :   { "long",           RID_LONG,       0 },
     488                 :            :   { "mutable",                RID_MUTABLE,    D_CXXONLY | D_CXXWARN },
     489                 :            :   { "namespace",      RID_NAMESPACE,  D_CXXONLY | D_CXXWARN },
     490                 :            :   { "new",            RID_NEW,        D_CXXONLY | D_CXXWARN },
     491                 :            :   { "noexcept",               RID_NOEXCEPT,   D_CXXONLY | D_CXX11 | D_CXXWARN },
     492                 :            :   { "nullptr",                RID_NULLPTR,    D_CXXONLY | D_CXX11 | D_CXXWARN },
     493                 :            :   { "operator",               RID_OPERATOR,   D_CXXONLY | D_CXXWARN },
     494                 :            :   { "private",                RID_PRIVATE,    D_CXX_OBJC | D_CXXWARN },
     495                 :            :   { "protected",      RID_PROTECTED,  D_CXX_OBJC | D_CXXWARN },
     496                 :            :   { "public",         RID_PUBLIC,     D_CXX_OBJC | D_CXXWARN },
     497                 :            :   { "register",               RID_REGISTER,   0 },
     498                 :            :   { "reinterpret_cast",       RID_REINTCAST,  D_CXXONLY | D_CXXWARN },
     499                 :            :   { "restrict",               RID_RESTRICT,   D_CONLY | D_C99 },
     500                 :            :   { "return",         RID_RETURN,     0 },
     501                 :            :   { "short",          RID_SHORT,      0 },
     502                 :            :   { "signed",         RID_SIGNED,     0 },
     503                 :            :   { "sizeof",         RID_SIZEOF,     0 },
     504                 :            :   { "static",         RID_STATIC,     0 },
     505                 :            :   { "static_assert",    RID_STATIC_ASSERT, D_CXXONLY | D_CXX11 | D_CXXWARN },
     506                 :            :   { "static_cast",    RID_STATCAST,   D_CXXONLY | D_CXXWARN },
     507                 :            :   { "struct",         RID_STRUCT,     0 },
     508                 :            :   { "switch",         RID_SWITCH,     0 },
     509                 :            :   { "template",               RID_TEMPLATE,   D_CXXONLY | D_CXXWARN },
     510                 :            :   { "this",           RID_THIS,       D_CXXONLY | D_CXXWARN },
     511                 :            :   { "thread_local",   RID_THREAD,     D_CXXONLY | D_CXX11 | D_CXXWARN },
     512                 :            :   { "throw",          RID_THROW,      D_CXX_OBJC | D_CXXWARN },
     513                 :            :   { "true",           RID_TRUE,       D_CXXONLY | D_CXXWARN },
     514                 :            :   { "try",            RID_TRY,        D_CXX_OBJC | D_CXXWARN },
     515                 :            :   { "typedef",                RID_TYPEDEF,    0 },
     516                 :            :   { "typename",               RID_TYPENAME,   D_CXXONLY | D_CXXWARN },
     517                 :            :   { "typeid",         RID_TYPEID,     D_CXXONLY | D_CXXWARN },
     518                 :            :   { "typeof",         RID_TYPEOF,     D_ASM | D_EXT },
     519                 :            :   { "union",          RID_UNION,      0 },
     520                 :            :   { "unsigned",               RID_UNSIGNED,   0 },
     521                 :            :   { "using",          RID_USING,      D_CXXONLY | D_CXXWARN },
     522                 :            :   { "virtual",                RID_VIRTUAL,    D_CXXONLY | D_CXXWARN },
     523                 :            :   { "void",           RID_VOID,       0 },
     524                 :            :   { "volatile",               RID_VOLATILE,   0 },
     525                 :            :   { "wchar_t",                RID_WCHAR,      D_CXXONLY },
     526                 :            :   { "while",          RID_WHILE,      0 },
     527                 :            :   { "__is_assignable", RID_IS_ASSIGNABLE, D_CXXONLY },
     528                 :            :   { "__is_constructible", RID_IS_CONSTRUCTIBLE, D_CXXONLY },
     529                 :            : 
     530                 :            :   /* C++ transactional memory.  */
     531                 :            :   { "synchronized",   RID_SYNCHRONIZED, D_CXX_OBJC | D_TRANSMEM },
     532                 :            :   { "atomic_noexcept",        RID_ATOMIC_NOEXCEPT, D_CXXONLY | D_TRANSMEM },
     533                 :            :   { "atomic_cancel",  RID_ATOMIC_CANCEL, D_CXXONLY | D_TRANSMEM },
     534                 :            :   { "atomic_commit",  RID_TRANSACTION_ATOMIC, D_CXXONLY | D_TRANSMEM },
     535                 :            : 
     536                 :            :   /* Concepts-related keywords */
     537                 :            :   { "concept",                RID_CONCEPT,    D_CXX_CONCEPTS_FLAGS | D_CXXWARN },
     538                 :            :   { "requires",       RID_REQUIRES,   D_CXX_CONCEPTS_FLAGS | D_CXXWARN },
     539                 :            : 
     540                 :            :   /* Coroutines-related keywords */
     541                 :            :   { "co_await",               RID_CO_AWAIT,   D_CXX_COROUTINES_FLAGS | D_CXXWARN },
     542                 :            :   { "co_yield",               RID_CO_YIELD,   D_CXX_COROUTINES_FLAGS | D_CXXWARN },
     543                 :            :   { "co_return",      RID_CO_RETURN,  D_CXX_COROUTINES_FLAGS | D_CXXWARN },
     544                 :            : 
     545                 :            :   /* These Objective-C keywords are recognized only immediately after
     546                 :            :      an '@'.  */
     547                 :            :   { "compatibility_alias", RID_AT_ALIAS,      D_OBJC },
     548                 :            :   { "defs",           RID_AT_DEFS,            D_OBJC },
     549                 :            :   { "encode",         RID_AT_ENCODE,          D_OBJC },
     550                 :            :   { "end",            RID_AT_END,             D_OBJC },
     551                 :            :   { "implementation", RID_AT_IMPLEMENTATION,  D_OBJC },
     552                 :            :   { "interface",      RID_AT_INTERFACE,       D_OBJC },
     553                 :            :   { "protocol",               RID_AT_PROTOCOL,        D_OBJC },
     554                 :            :   { "selector",               RID_AT_SELECTOR,        D_OBJC },
     555                 :            :   { "finally",                RID_AT_FINALLY,         D_OBJC },
     556                 :            :   { "optional",               RID_AT_OPTIONAL,        D_OBJC },
     557                 :            :   { "required",               RID_AT_REQUIRED,        D_OBJC },
     558                 :            :   { "property",               RID_AT_PROPERTY,        D_OBJC },
     559                 :            :   { "package",                RID_AT_PACKAGE,         D_OBJC },
     560                 :            :   { "synthesize",     RID_AT_SYNTHESIZE,      D_OBJC },
     561                 :            :   { "dynamic",                RID_AT_DYNAMIC,         D_OBJC },
     562                 :            :   /* These are recognized only in protocol-qualifier context
     563                 :            :      (see above) */
     564                 :            :   { "bycopy",         RID_BYCOPY,             D_OBJC },
     565                 :            :   { "byref",          RID_BYREF,              D_OBJC },
     566                 :            :   { "in",             RID_IN,                 D_OBJC },
     567                 :            :   { "inout",          RID_INOUT,              D_OBJC },
     568                 :            :   { "oneway",         RID_ONEWAY,             D_OBJC },
     569                 :            :   { "out",            RID_OUT,                D_OBJC },
     570                 :            :   /* These are recognized inside a property attribute list */
     571                 :            :   { "assign",         RID_ASSIGN,             D_OBJC }, 
     572                 :            :   { "copy",           RID_COPY,               D_OBJC }, 
     573                 :            :   { "getter",         RID_GETTER,             D_OBJC }, 
     574                 :            :   { "nonatomic",      RID_NONATOMIC,          D_OBJC }, 
     575                 :            :   { "readonly",               RID_READONLY,           D_OBJC }, 
     576                 :            :   { "readwrite",      RID_READWRITE,          D_OBJC }, 
     577                 :            :   { "retain",         RID_RETAIN,             D_OBJC }, 
     578                 :            :   { "setter",         RID_SETTER,             D_OBJC }, 
     579                 :            : };
     580                 :            : 
     581                 :            : const unsigned int num_c_common_reswords =
     582                 :            :   sizeof c_common_reswords / sizeof (struct c_common_resword);
     583                 :            : 
     584                 :            : /* Return identifier for address space AS.  */
     585                 :            : 
     586                 :            : const char *
     587                 :          0 : c_addr_space_name (addr_space_t as)
     588                 :            : {
     589                 :          0 :   int rid = RID_FIRST_ADDR_SPACE + as;
     590                 :          0 :   gcc_assert (ridpointers [rid]);
     591                 :          0 :   return IDENTIFIER_POINTER (ridpointers [rid]);
     592                 :            : }
     593                 :            : 
     594                 :            : /* Push current bindings for the function name VAR_DECLS.  */
     595                 :            : 
     596                 :            : void
     597                 :   40396400 : start_fname_decls (void)
     598                 :            : {
     599                 :   40396400 :   unsigned ix;
     600                 :   40396400 :   tree saved = NULL_TREE;
     601                 :            : 
     602                 :  161586000 :   for (ix = 0; fname_vars[ix].decl; ix++)
     603                 :            :     {
     604                 :  121189000 :       tree decl = *fname_vars[ix].decl;
     605                 :            : 
     606                 :  121189000 :       if (decl)
     607                 :            :         {
     608                 :      12115 :           saved = tree_cons (decl, build_int_cst (integer_type_node, ix),
     609                 :            :                              saved);
     610                 :      12115 :           *fname_vars[ix].decl = NULL_TREE;
     611                 :            :         }
     612                 :            :     }
     613                 :   40396400 :   if (saved || saved_function_name_decls)
     614                 :            :     /* Normally they'll have been NULL, so only push if we've got a
     615                 :            :        stack, or they are non-NULL.  */
     616                 :      17155 :     saved_function_name_decls = tree_cons (saved, NULL_TREE,
     617                 :            :                                            saved_function_name_decls);
     618                 :   40396400 : }
     619                 :            : 
     620                 :            : /* Finish up the current bindings, adding them into the current function's
     621                 :            :    statement tree.  This must be done _before_ finish_stmt_tree is called.
     622                 :            :    If there is no current function, we must be at file scope and no statements
     623                 :            :    are involved. Pop the previous bindings.  */
     624                 :            : 
     625                 :            : void
     626                 :   40317200 : finish_fname_decls (void)
     627                 :            : {
     628                 :   40317200 :   unsigned ix;
     629                 :   40317200 :   tree stmts = NULL_TREE;
     630                 :   40317200 :   tree stack = saved_function_name_decls;
     631                 :            : 
     632                 :   40395800 :   for (; stack && TREE_VALUE (stack); stack = TREE_CHAIN (stack))
     633                 :      30735 :     append_to_statement_list (TREE_VALUE (stack), &stmts);
     634                 :            : 
     635                 :   40317200 :   if (stmts)
     636                 :            :     {
     637                 :      30627 :       tree *bodyp = &DECL_SAVED_TREE (current_function_decl);
     638                 :            : 
     639                 :      30627 :       if (TREE_CODE (*bodyp) == BIND_EXPR)
     640                 :      29006 :         bodyp = &BIND_EXPR_BODY (*bodyp);
     641                 :            : 
     642                 :      30627 :       append_to_statement_list_force (*bodyp, &stmts);
     643                 :      30627 :       *bodyp = stmts;
     644                 :            :     }
     645                 :            : 
     646                 :  161269000 :   for (ix = 0; fname_vars[ix].decl; ix++)
     647                 :  120951000 :     *fname_vars[ix].decl = NULL_TREE;
     648                 :            : 
     649                 :   40317200 :   if (stack)
     650                 :            :     {
     651                 :            :       /* We had saved values, restore them.  */
     652                 :      17155 :       tree saved;
     653                 :            : 
     654                 :      29270 :       for (saved = TREE_PURPOSE (stack); saved; saved = TREE_CHAIN (saved))
     655                 :            :         {
     656                 :      12115 :           tree decl = TREE_PURPOSE (saved);
     657                 :      12115 :           unsigned ix = TREE_INT_CST_LOW (TREE_VALUE (saved));
     658                 :            : 
     659                 :      12115 :           *fname_vars[ix].decl = decl;
     660                 :            :         }
     661                 :      17155 :       stack = TREE_CHAIN (stack);
     662                 :            :     }
     663                 :   40317200 :   saved_function_name_decls = stack;
     664                 :   40317200 : }
     665                 :            : 
     666                 :            : /* Return the text name of the current function, suitably prettified
     667                 :            :    by PRETTY_P.  Return string must be freed by caller.  */
     668                 :            : 
     669                 :            : const char *
     670                 :       2311 : fname_as_string (int pretty_p)
     671                 :            : {
     672                 :       2311 :   const char *name = "top level";
     673                 :       2311 :   char *namep;
     674                 :       2311 :   int vrb = 2, len;
     675                 :       2311 :   cpp_string cstr = { 0, 0 }, strname;
     676                 :            : 
     677                 :       2311 :   if (!pretty_p)
     678                 :            :     {
     679                 :       1296 :       name = "";
     680                 :       1296 :       vrb = 0;
     681                 :            :     }
     682                 :            : 
     683                 :       2311 :   if (current_function_decl)
     684                 :       2304 :     name = lang_hooks.decl_printable_name (current_function_decl, vrb);
     685                 :            : 
     686                 :       2311 :   len = strlen (name) + 3; /* Two for '"'s.  One for NULL.  */
     687                 :            : 
     688                 :       2311 :   namep = XNEWVEC (char, len);
     689                 :       2311 :   snprintf (namep, len, "\"%s\"", name);
     690                 :       2311 :   strname.text = (unsigned char *) namep;
     691                 :       2311 :   strname.len = len - 1;
     692                 :            : 
     693                 :       2311 :   if (cpp_interpret_string (parse_in, &strname, 1, &cstr, CPP_STRING))
     694                 :            :     {
     695                 :       2311 :       XDELETEVEC (namep);
     696                 :       2311 :       return (const char *) cstr.text;
     697                 :            :     }
     698                 :            : 
     699                 :            :   return namep;
     700                 :            : }
     701                 :            : 
     702                 :            : /* Return the VAR_DECL for a const char array naming the current
     703                 :            :    function. If the VAR_DECL has not yet been created, create it
     704                 :            :    now. RID indicates how it should be formatted and IDENTIFIER_NODE
     705                 :            :    ID is its name (unfortunately C and C++ hold the RID values of
     706                 :            :    keywords in different places, so we can't derive RID from ID in
     707                 :            :    this language independent code. LOC is the location of the
     708                 :            :    function.  */
     709                 :            : 
     710                 :            : tree
     711                 :      81629 : fname_decl (location_t loc, unsigned int rid, tree id)
     712                 :            : {
     713                 :      81629 :   unsigned ix;
     714                 :      81629 :   tree decl = NULL_TREE;
     715                 :            : 
     716                 :     237114 :   for (ix = 0; fname_vars[ix].decl; ix++)
     717                 :     237114 :     if (fname_vars[ix].rid == rid)
     718                 :            :       break;
     719                 :            : 
     720                 :      81629 :   decl = *fname_vars[ix].decl;
     721                 :      81629 :   if (!decl)
     722                 :            :     {
     723                 :            :       /* If a tree is built here, it would normally have the lineno of
     724                 :            :          the current statement.  Later this tree will be moved to the
     725                 :            :          beginning of the function and this line number will be wrong.
     726                 :            :          To avoid this problem set the lineno to 0 here; that prevents
     727                 :            :          it from appearing in the RTL.  */
     728                 :      30735 :       tree stmts;
     729                 :      30735 :       location_t saved_location = input_location;
     730                 :      30735 :       input_location = UNKNOWN_LOCATION;
     731                 :            : 
     732                 :      30735 :       stmts = push_stmt_list ();
     733                 :      30735 :       decl = (*make_fname_decl) (loc, id, fname_vars[ix].pretty);
     734                 :      30735 :       stmts = pop_stmt_list (stmts);
     735                 :      30735 :       if (!IS_EMPTY_STMT (stmts))
     736                 :      30735 :         saved_function_name_decls
     737                 :      30735 :           = tree_cons (decl, stmts, saved_function_name_decls);
     738                 :      30735 :       *fname_vars[ix].decl = decl;
     739                 :      30735 :       input_location = saved_location;
     740                 :            :     }
     741                 :      81629 :   if (!ix && !current_function_decl)
     742                 :          5 :     pedwarn (loc, 0, "%qD is not defined outside of function scope", decl);
     743                 :            : 
     744                 :      81629 :   return decl;
     745                 :            : }
     746                 :            : 
     747                 :            : /* Given a STRING_CST, give it a suitable array-of-chars data type.  */
     748                 :            : 
     749                 :            : tree
     750                 :    4525210 : fix_string_type (tree value)
     751                 :            : {
     752                 :    4525210 :   int length = TREE_STRING_LENGTH (value);
     753                 :    4525210 :   int nchars, charsz;
     754                 :    4525210 :   tree e_type, i_type, a_type;
     755                 :            : 
     756                 :            :   /* Compute the number of elements, for the array type.  */
     757                 :    4525210 :   if (TREE_TYPE (value) == char_array_type_node || !TREE_TYPE (value))
     758                 :            :     {
     759                 :    4501520 :       charsz = 1;
     760                 :    4501520 :       e_type = char_type_node;
     761                 :            :     }
     762                 :      23689 :   else if (flag_char8_t && TREE_TYPE (value) == char8_array_type_node)
     763                 :            :     {
     764                 :        133 :       charsz = TYPE_PRECISION (char8_type_node) / BITS_PER_UNIT;
     765                 :        133 :       e_type = char8_type_node;
     766                 :            :     }
     767                 :      23556 :   else if (TREE_TYPE (value) == char16_array_type_node)
     768                 :            :     {
     769                 :        659 :       charsz = TYPE_PRECISION (char16_type_node) / BITS_PER_UNIT;
     770                 :        659 :       e_type = char16_type_node;
     771                 :            :     }
     772                 :      22897 :   else if (TREE_TYPE (value) == char32_array_type_node)
     773                 :            :     {
     774                 :        645 :       charsz = TYPE_PRECISION (char32_type_node) / BITS_PER_UNIT;
     775                 :        645 :       e_type = char32_type_node;
     776                 :            :     }
     777                 :            :   else
     778                 :            :     {
     779                 :      22252 :       charsz = TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT;
     780                 :      22252 :       e_type = wchar_type_node;
     781                 :            :     }
     782                 :            : 
     783                 :            :   /* This matters only for targets where ssizetype has smaller precision
     784                 :            :      than 32 bits.  */
     785                 :    4525210 :   if (wi::lts_p (wi::to_wide (TYPE_MAX_VALUE (ssizetype)), length))
     786                 :            :     {
     787                 :          0 :       error ("size of string literal is too large");
     788                 :          0 :       length = tree_to_shwi (TYPE_MAX_VALUE (ssizetype)) / charsz * charsz;
     789                 :          0 :       char *str = CONST_CAST (char *, TREE_STRING_POINTER (value));
     790                 :          0 :       memset (str + length, '\0',
     791                 :          0 :               MIN (TREE_STRING_LENGTH (value) - length, charsz));
     792                 :          0 :       TREE_STRING_LENGTH (value) = length;
     793                 :            :     }
     794                 :    4525210 :   nchars = length / charsz;
     795                 :            : 
     796                 :            :   /* C89 2.2.4.1, C99 5.2.4.1 (Translation limits).  The analogous
     797                 :            :      limit in C++98 Annex B is very large (65536) and is not normative,
     798                 :            :      so we do not diagnose it (warn_overlength_strings is forced off
     799                 :            :      in c_common_post_options).  */
     800                 :    4525210 :   if (warn_overlength_strings)
     801                 :            :     {
     802                 :      10520 :       const int nchars_max = flag_isoc99 ? 4095 : 509;
     803                 :      10520 :       const int relevant_std = flag_isoc99 ? 99 : 90;
     804                 :      10520 :       if (nchars - 1 > nchars_max)
     805                 :            :         /* Translators: The %d after 'ISO C' will be 90 or 99.  Do not
     806                 :            :            separate the %d from the 'C'.  'ISO' should not be
     807                 :            :            translated, but it may be moved after 'C%d' in languages
     808                 :            :            where modifiers follow nouns.  */
     809                 :          5 :         pedwarn (input_location, OPT_Woverlength_strings,
     810                 :            :                  "string length %qd is greater than the length %qd "
     811                 :            :                  "ISO C%d compilers are required to support",
     812                 :            :                  nchars - 1, nchars_max, relevant_std);
     813                 :            :     }
     814                 :            : 
     815                 :            :   /* Create the array type for the string constant.  The ISO C++
     816                 :            :      standard says that a string literal has type `const char[N]' or
     817                 :            :      `const wchar_t[N]'.  We use the same logic when invoked as a C
     818                 :            :      front-end with -Wwrite-strings.
     819                 :            :      ??? We should change the type of an expression depending on the
     820                 :            :      state of a warning flag.  We should just be warning -- see how
     821                 :            :      this is handled in the C++ front-end for the deprecated implicit
     822                 :            :      conversion from string literals to `char*' or `wchar_t*'.
     823                 :            : 
     824                 :            :      The C++ front end relies on TYPE_MAIN_VARIANT of a cv-qualified
     825                 :            :      array type being the unqualified version of that type.
     826                 :            :      Therefore, if we are constructing an array of const char, we must
     827                 :            :      construct the matching unqualified array type first.  The C front
     828                 :            :      end does not require this, but it does no harm, so we do it
     829                 :            :      unconditionally.  */
     830                 :    4525210 :   i_type = build_index_type (size_int (nchars - 1));
     831                 :    4525210 :   a_type = build_array_type (e_type, i_type);
     832                 :    4525210 :   if (c_dialect_cxx() || warn_write_strings)
     833                 :    3219880 :     a_type = c_build_qualified_type (a_type, TYPE_QUAL_CONST);
     834                 :            : 
     835                 :    4525210 :   TREE_TYPE (value) = a_type;
     836                 :    4525210 :   TREE_CONSTANT (value) = 1;
     837                 :    4525210 :   TREE_READONLY (value) = 1;
     838                 :    4525210 :   TREE_STATIC (value) = 1;
     839                 :    4525210 :   return value;
     840                 :            : }
     841                 :            : 
     842                 :            : /* Given a string of type STRING_TYPE, determine what kind of string
     843                 :            :    token would give an equivalent execution encoding: CPP_STRING,
     844                 :            :    CPP_STRING16, or CPP_STRING32.  Return CPP_OTHER in case of error.
     845                 :            :    This may not be exactly the string token type that initially created
     846                 :            :    the string, since CPP_WSTRING is indistinguishable from the 16/32 bit
     847                 :            :    string type, and CPP_UTF8STRING is indistinguishable from CPP_STRING
     848                 :            :    at this point.
     849                 :            : 
     850                 :            :    This effectively reverses part of the logic in lex_string and
     851                 :            :    fix_string_type.  */
     852                 :            : 
     853                 :            : static enum cpp_ttype
     854                 :       9593 : get_cpp_ttype_from_string_type (tree string_type)
     855                 :            : {
     856                 :       9593 :   gcc_assert (string_type);
     857                 :       9593 :   if (TREE_CODE (string_type) == POINTER_TYPE)
     858                 :       5391 :     string_type = TREE_TYPE (string_type);
     859                 :            : 
     860                 :       9593 :   if (TREE_CODE (string_type) != ARRAY_TYPE)
     861                 :            :     return CPP_OTHER;
     862                 :            : 
     863                 :       9593 :   tree element_type = TREE_TYPE (string_type);
     864                 :       9593 :   if (TREE_CODE (element_type) != INTEGER_TYPE)
     865                 :            :     return CPP_OTHER;
     866                 :            : 
     867                 :       9593 :   int bits_per_character = TYPE_PRECISION (element_type);
     868                 :       9593 :   switch (bits_per_character)
     869                 :            :     {
     870                 :            :     case 8:
     871                 :            :       return CPP_STRING;  /* It could have also been CPP_UTF8STRING.  */
     872                 :            :     case 16:
     873                 :            :       return CPP_STRING16;
     874                 :            :     case 32:
     875                 :            :       return CPP_STRING32;
     876                 :            :     }
     877                 :            : 
     878                 :            :   return CPP_OTHER;
     879                 :            : }
     880                 :            : 
     881                 :            : /* The global record of string concatentations, for use in
     882                 :            :    extracting locations within string literals.  */
     883                 :            : 
     884                 :            : GTY(()) string_concat_db *g_string_concat_db;
     885                 :            : 
     886                 :            : /* Implementation of LANG_HOOKS_GET_SUBSTRING_LOCATION.  */
     887                 :            : 
     888                 :            : const char *
     889                 :       9593 : c_get_substring_location (const substring_loc &substr_loc,
     890                 :            :                           location_t *out_loc)
     891                 :            : {
     892                 :       9593 :   enum cpp_ttype tok_type
     893                 :       9593 :     = get_cpp_ttype_from_string_type (substr_loc.get_string_type ());
     894                 :       9593 :   if (tok_type == CPP_OTHER)
     895                 :            :     return "unrecognized string type";
     896                 :            : 
     897                 :       9593 :   return get_location_within_string (parse_in, g_string_concat_db,
     898                 :            :                                      substr_loc.get_fmt_string_loc (),
     899                 :            :                                      tok_type,
     900                 :            :                                      substr_loc.get_caret_idx (),
     901                 :            :                                      substr_loc.get_start_idx (),
     902                 :            :                                      substr_loc.get_end_idx (),
     903                 :       9593 :                                      out_loc);
     904                 :            : }
     905                 :            : 
     906                 :            : 
     907                 :            : /* Return true iff T is a boolean promoted to int.  */
     908                 :            : 
     909                 :            : bool
     910                 :      55383 : bool_promoted_to_int_p (tree t)
     911                 :            : {
     912                 :      55383 :   return (CONVERT_EXPR_P (t)
     913                 :      16920 :           && TREE_TYPE (t) == integer_type_node
     914                 :      55508 :           && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == BOOLEAN_TYPE);
     915                 :            : }
     916                 :            : 
     917                 :            : /* vector_targets_convertible_p is used for vector pointer types.  The
     918                 :            :    callers perform various checks that the qualifiers are satisfactory,
     919                 :            :    while OTOH vector_targets_convertible_p ignores the number of elements
     920                 :            :    in the vectors.  That's fine with vector pointers as we can consider,
     921                 :            :    say, a vector of 8 elements as two consecutive vectors of 4 elements,
     922                 :            :    and that does not require and conversion of the pointer values.
     923                 :            :    In contrast, vector_types_convertible_p and
     924                 :            :    vector_types_compatible_elements_p are used for vector value types.  */
     925                 :            : /* True if pointers to distinct types T1 and T2 can be converted to
     926                 :            :    each other without an explicit cast.  Only returns true for opaque
     927                 :            :    vector types.  */
     928                 :            : bool
     929                 :    1319330 : vector_targets_convertible_p (const_tree t1, const_tree t2)
     930                 :            : {
     931                 :     708553 :   if (VECTOR_TYPE_P (t1) && VECTOR_TYPE_P (t2)
     932                 :     708378 :       && (TYPE_VECTOR_OPAQUE (t1) || TYPE_VECTOR_OPAQUE (t2))
     933                 :    1319330 :       && tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)))
     934                 :          0 :     return true;
     935                 :            : 
     936                 :            :   return false;
     937                 :            : }
     938                 :            : 
     939                 :            : /* vector_types_convertible_p is used for vector value types.
     940                 :            :    It could in principle call vector_targets_convertible_p as a subroutine,
     941                 :            :    but then the check for vector type would be duplicated with its callers,
     942                 :            :    and also the purpose of vector_targets_convertible_p would become
     943                 :            :    muddled.
     944                 :            :    Where vector_types_convertible_p returns true, a conversion might still be
     945                 :            :    needed to make the types match.
     946                 :            :    In contrast, vector_targets_convertible_p is used for vector pointer
     947                 :            :    values, and vector_types_compatible_elements_p is used specifically
     948                 :            :    in the context for binary operators, as a check if use is possible without
     949                 :            :    conversion.  */
     950                 :            : /* True if vector types T1 and T2 can be converted to each other
     951                 :            :    without an explicit cast.  If EMIT_LAX_NOTE is true, and T1 and T2
     952                 :            :    can only be converted with -flax-vector-conversions yet that is not
     953                 :            :    in effect, emit a note telling the user about that option if such
     954                 :            :    a note has not previously been emitted.  */
     955                 :            : bool
     956                 :    4390490 : vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note)
     957                 :            : {
     958                 :    4390490 :   static bool emitted_lax_note = false;
     959                 :    4390490 :   bool convertible_lax;
     960                 :            : 
     961                 :    8776800 :   if ((TYPE_VECTOR_OPAQUE (t1) || TYPE_VECTOR_OPAQUE (t2))
     962                 :    4395870 :       && tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2)))
     963                 :            :     return true;
     964                 :            : 
     965                 :    4385120 :   convertible_lax =
     966                 :    4385120 :     (tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2))
     967                 :    4384490 :      && (TREE_CODE (TREE_TYPE (t1)) != REAL_TYPE
     968                 :    1352740 :          || known_eq (TYPE_VECTOR_SUBPARTS (t1),
     969                 :            :                       TYPE_VECTOR_SUBPARTS (t2)))
     970                 :   16169100 :      && (INTEGRAL_TYPE_P (TREE_TYPE (t1))
     971                 :    4376140 :          == INTEGRAL_TYPE_P (TREE_TYPE (t2))));
     972                 :            : 
     973                 :    4385120 :   if (!convertible_lax || flag_lax_vector_conversions)
     974                 :      21901 :     return convertible_lax;
     975                 :            : 
     976                 :    4363220 :   if (known_eq (TYPE_VECTOR_SUBPARTS (t1), TYPE_VECTOR_SUBPARTS (t2))
     977                 :    4363220 :       && lang_hooks.types_compatible_p (TREE_TYPE (t1), TREE_TYPE (t2)))
     978                 :    3387060 :     return true;
     979                 :            : 
     980                 :     976154 :   if (emit_lax_note && !emitted_lax_note)
     981                 :            :     {
     982                 :          7 :       emitted_lax_note = true;
     983                 :          7 :       inform (input_location, "use %<-flax-vector-conversions%> to permit "
     984                 :            :               "conversions between vectors with differing "
     985                 :            :               "element types or numbers of subparts");
     986                 :            :     }
     987                 :            : 
     988                 :            :   return false;
     989                 :            : }
     990                 :            : 
     991                 :            : /* Build a VEC_PERM_EXPR if V0, V1 and MASK are not error_mark_nodes
     992                 :            :    and have vector types, V0 has the same type as V1, and the number of
     993                 :            :    elements of V0, V1, MASK is the same.
     994                 :            : 
     995                 :            :    In case V1 is a NULL_TREE it is assumed that __builtin_shuffle was
     996                 :            :    called with two arguments.  In this case implementation passes the
     997                 :            :    first argument twice in order to share the same tree code.  This fact
     998                 :            :    could enable the mask-values being twice the vector length.  This is
     999                 :            :    an implementation accident and this semantics is not guaranteed to
    1000                 :            :    the user.  */
    1001                 :            : tree
    1002                 :     238389 : c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask,
    1003                 :            :                        bool complain)
    1004                 :            : {
    1005                 :     238389 :   tree ret;
    1006                 :     238389 :   bool wrap = true;
    1007                 :     238389 :   bool maybe_const = false;
    1008                 :     238389 :   bool two_arguments = false;
    1009                 :            : 
    1010                 :     238389 :   if (v1 == NULL_TREE)
    1011                 :            :     {
    1012                 :     211168 :       two_arguments = true;
    1013                 :     211168 :       v1 = v0;
    1014                 :            :     }
    1015                 :            : 
    1016                 :     238389 :   if (v0 == error_mark_node || v1 == error_mark_node
    1017                 :     238389 :       || mask == error_mark_node)
    1018                 :            :     return error_mark_node;
    1019                 :            : 
    1020                 :     238389 :   if (!gnu_vector_type_p (TREE_TYPE (mask))
    1021                 :     238389 :       || !VECTOR_INTEGER_TYPE_P (TREE_TYPE (mask)))
    1022                 :            :     {
    1023                 :          3 :       if (complain)
    1024                 :          0 :         error_at (loc, "%<__builtin_shuffle%> last argument must "
    1025                 :            :                        "be an integer vector");
    1026                 :          3 :       return error_mark_node;
    1027                 :            :     }
    1028                 :            : 
    1029                 :     238386 :   if (!gnu_vector_type_p (TREE_TYPE (v0))
    1030                 :     476772 :       || !gnu_vector_type_p (TREE_TYPE (v1)))
    1031                 :            :     {
    1032                 :          0 :       if (complain)
    1033                 :          0 :         error_at (loc, "%<__builtin_shuffle%> arguments must be vectors");
    1034                 :          0 :       return error_mark_node;
    1035                 :            :     }
    1036                 :            : 
    1037                 :     238386 :   if (TYPE_MAIN_VARIANT (TREE_TYPE (v0)) != TYPE_MAIN_VARIANT (TREE_TYPE (v1)))
    1038                 :            :     {
    1039                 :          0 :       if (complain)
    1040                 :          0 :         error_at (loc, "%<__builtin_shuffle%> argument vectors must be of "
    1041                 :            :                        "the same type");
    1042                 :          0 :       return error_mark_node;
    1043                 :            :     }
    1044                 :            : 
    1045                 :     476772 :   if (maybe_ne (TYPE_VECTOR_SUBPARTS (TREE_TYPE (v0)),
    1046                 :     238386 :                 TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask)))
    1047                 :     238386 :       && maybe_ne (TYPE_VECTOR_SUBPARTS (TREE_TYPE (v1)),
    1048                 :          0 :                    TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask))))
    1049                 :            :     {
    1050                 :          0 :       if (complain)
    1051                 :          0 :         error_at (loc, "%<__builtin_shuffle%> number of elements of the "
    1052                 :            :                        "argument vector(s) and the mask vector should "
    1053                 :            :                        "be the same");
    1054                 :          0 :       return error_mark_node;
    1055                 :            :     }
    1056                 :            : 
    1057                 :     476772 :   if (GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (v0))))
    1058                 :     476772 :       != GET_MODE_BITSIZE (SCALAR_TYPE_MODE (TREE_TYPE (TREE_TYPE (mask)))))
    1059                 :            :     {
    1060                 :          0 :       if (complain)
    1061                 :          0 :         error_at (loc, "%<__builtin_shuffle%> argument vector(s) inner type "
    1062                 :            :                        "must have the same size as inner type of the mask");
    1063                 :          0 :       return error_mark_node;
    1064                 :            :     }
    1065                 :            : 
    1066                 :     238386 :   if (!c_dialect_cxx ())
    1067                 :            :     {
    1068                 :            :       /* Avoid C_MAYBE_CONST_EXPRs inside VEC_PERM_EXPR.  */
    1069                 :     229518 :       v0 = c_fully_fold (v0, false, &maybe_const);
    1070                 :     229518 :       wrap &= maybe_const;
    1071                 :            : 
    1072                 :     229518 :       if (two_arguments)
    1073                 :     203108 :         v1 = v0 = save_expr (v0);
    1074                 :            :       else
    1075                 :            :         {
    1076                 :      26410 :           v1 = c_fully_fold (v1, false, &maybe_const);
    1077                 :      26410 :           wrap &= maybe_const;
    1078                 :            :         }
    1079                 :            : 
    1080                 :     229518 :       mask = c_fully_fold (mask, false, &maybe_const);
    1081                 :     229518 :       wrap &= maybe_const;
    1082                 :            :     }
    1083                 :       8868 :   else if (two_arguments)
    1084                 :       8057 :     v1 = v0 = save_expr (v0);
    1085                 :            : 
    1086                 :     238386 :   ret = build3_loc (loc, VEC_PERM_EXPR, TREE_TYPE (v0), v0, v1, mask);
    1087                 :            : 
    1088                 :     238386 :   if (!c_dialect_cxx () && !wrap)
    1089                 :     229518 :     ret = c_wrap_maybe_const (ret, true);
    1090                 :            : 
    1091                 :            :   return ret;
    1092                 :            : }
    1093                 :            : 
    1094                 :            : /* Build a VEC_CONVERT ifn for __builtin_convertvector builtin.  */
    1095                 :            : 
    1096                 :            : tree
    1097                 :        236 : c_build_vec_convert (location_t loc1, tree expr, location_t loc2, tree type,
    1098                 :            :                      bool complain)
    1099                 :            : {
    1100                 :        472 :   if (error_operand_p (type))
    1101                 :            :     return error_mark_node;
    1102                 :        472 :   if (error_operand_p (expr))
    1103                 :            :     return error_mark_node;
    1104                 :            : 
    1105                 :        236 :   if (!gnu_vector_type_p (TREE_TYPE (expr))
    1106                 :        236 :       || (!VECTOR_INTEGER_TYPE_P (TREE_TYPE (expr))
    1107                 :         78 :           && !VECTOR_FLOAT_TYPE_P (TREE_TYPE (expr))))
    1108                 :            :     {
    1109                 :          5 :       if (complain)
    1110                 :          5 :         error_at (loc1, "%<__builtin_convertvector%> first argument must "
    1111                 :            :                         "be an integer or floating vector");
    1112                 :          5 :       return error_mark_node;
    1113                 :            :     }
    1114                 :            : 
    1115                 :        231 :   if (!gnu_vector_type_p (type)
    1116                 :        566 :       || (!VECTOR_INTEGER_TYPE_P (type) && !VECTOR_FLOAT_TYPE_P (type)))
    1117                 :            :     {
    1118                 :          5 :       if (complain)
    1119                 :          5 :         error_at (loc2, "%<__builtin_convertvector%> second argument must "
    1120                 :            :                         "be an integer or floating vector type");
    1121                 :          5 :       return error_mark_node;
    1122                 :            :     }
    1123                 :            : 
    1124                 :        226 :   if (maybe_ne (TYPE_VECTOR_SUBPARTS (TREE_TYPE (expr)),
    1125                 :        452 :                 TYPE_VECTOR_SUBPARTS (type)))
    1126                 :            :     {
    1127                 :         10 :       if (complain)
    1128                 :         10 :         error_at (loc1, "%<__builtin_convertvector%> number of elements "
    1129                 :            :                         "of the first argument vector and the second argument "
    1130                 :            :                         "vector type should be the same");
    1131                 :         10 :       return error_mark_node;
    1132                 :            :     }
    1133                 :            : 
    1134                 :        216 :   if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (expr)))
    1135                 :        216 :        == TYPE_MAIN_VARIANT (TREE_TYPE (type)))
    1136                 :        216 :       || (VECTOR_INTEGER_TYPE_P (TREE_TYPE (expr))
    1137                 :        133 :           && VECTOR_INTEGER_TYPE_P (type)
    1138                 :         24 :           && (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (expr)))
    1139                 :         24 :               == TYPE_PRECISION (TREE_TYPE (type)))))
    1140                 :         29 :     return build1_loc (loc1, VIEW_CONVERT_EXPR, type, expr);
    1141                 :            : 
    1142                 :        187 :   bool wrap = true;
    1143                 :        187 :   bool maybe_const = false;
    1144                 :        187 :   tree ret;
    1145                 :        187 :   if (!c_dialect_cxx ())
    1146                 :            :     {
    1147                 :            :       /* Avoid C_MAYBE_CONST_EXPRs inside of VEC_CONVERT argument.  */
    1148                 :         61 :       expr = c_fully_fold (expr, false, &maybe_const);
    1149                 :         61 :       wrap &= maybe_const;
    1150                 :            :     }
    1151                 :            : 
    1152                 :        187 :   ret = build_call_expr_internal_loc (loc1, IFN_VEC_CONVERT, type, 1, expr);
    1153                 :            : 
    1154                 :        187 :   if (!wrap)
    1155                 :         61 :     ret = c_wrap_maybe_const (ret, true);
    1156                 :            : 
    1157                 :            :   return ret;
    1158                 :            : }
    1159                 :            : 
    1160                 :            : /* Like tree.c:get_narrower, but retain conversion from C++0x scoped enum
    1161                 :            :    to integral type.  */
    1162                 :            : 
    1163                 :            : tree
    1164                 :   12805400 : c_common_get_narrower (tree op, int *unsignedp_ptr)
    1165                 :            : {
    1166                 :   12805400 :   op = get_narrower (op, unsignedp_ptr);
    1167                 :            : 
    1168                 :   12805400 :   if (TREE_CODE (TREE_TYPE (op)) == ENUMERAL_TYPE
    1169                 :   12805400 :       && ENUM_IS_SCOPED (TREE_TYPE (op)))
    1170                 :            :     {
    1171                 :            :       /* C++0x scoped enumerations don't implicitly convert to integral
    1172                 :            :          type; if we stripped an explicit conversion to a larger type we
    1173                 :            :          need to replace it so common_type will still work.  */
    1174                 :      32445 :       tree type = c_common_type_for_size (TYPE_PRECISION (TREE_TYPE (op)),
    1175                 :      32445 :                                           TYPE_UNSIGNED (TREE_TYPE (op)));
    1176                 :      32445 :       op = fold_convert (type, op);
    1177                 :            :     }
    1178                 :   12805400 :   return op;
    1179                 :            : }
    1180                 :            : 
    1181                 :            : /* This is a helper function of build_binary_op.
    1182                 :            : 
    1183                 :            :    For certain operations if both args were extended from the same
    1184                 :            :    smaller type, do the arithmetic in that type and then extend.
    1185                 :            : 
    1186                 :            :    BITWISE indicates a bitwise operation.
    1187                 :            :    For them, this optimization is safe only if
    1188                 :            :    both args are zero-extended or both are sign-extended.
    1189                 :            :    Otherwise, we might change the result.
    1190                 :            :    Eg, (short)-1 | (unsigned short)-1 is (int)-1
    1191                 :            :    but calculated in (unsigned short) it would be (unsigned short)-1.
    1192                 :            : */
    1193                 :            : tree
    1194                 :    1183340 : shorten_binary_op (tree result_type, tree op0, tree op1, bool bitwise)
    1195                 :            : {
    1196                 :    1183340 :   int unsigned0, unsigned1;
    1197                 :    1183340 :   tree arg0, arg1;
    1198                 :    1183340 :   int uns;
    1199                 :    1183340 :   tree type;
    1200                 :            : 
    1201                 :            :   /* Cast OP0 and OP1 to RESULT_TYPE.  Doing so prevents
    1202                 :            :      excessive narrowing when we call get_narrower below.  For
    1203                 :            :      example, suppose that OP0 is of unsigned int extended
    1204                 :            :      from signed char and that RESULT_TYPE is long long int.
    1205                 :            :      If we explicitly cast OP0 to RESULT_TYPE, OP0 would look
    1206                 :            :      like
    1207                 :            : 
    1208                 :            :      (long long int) (unsigned int) signed_char
    1209                 :            : 
    1210                 :            :      which get_narrower would narrow down to
    1211                 :            : 
    1212                 :            :      (unsigned int) signed char
    1213                 :            : 
    1214                 :            :      If we do not cast OP0 first, get_narrower would return
    1215                 :            :      signed_char, which is inconsistent with the case of the
    1216                 :            :      explicit cast.  */
    1217                 :    1183340 :   op0 = convert (result_type, op0);
    1218                 :    1183340 :   op1 = convert (result_type, op1);
    1219                 :            : 
    1220                 :    1183340 :   arg0 = c_common_get_narrower (op0, &unsigned0);
    1221                 :    1183340 :   arg1 = c_common_get_narrower (op1, &unsigned1);
    1222                 :            : 
    1223                 :            :   /* UNS is 1 if the operation to be done is an unsigned one.  */
    1224                 :    1183340 :   uns = TYPE_UNSIGNED (result_type);
    1225                 :            : 
    1226                 :            :   /* Handle the case that OP0 (or OP1) does not *contain* a conversion
    1227                 :            :      but it *requires* conversion to FINAL_TYPE.  */
    1228                 :            : 
    1229                 :    1183340 :   if ((TYPE_PRECISION (TREE_TYPE (op0))
    1230                 :    1183340 :        == TYPE_PRECISION (TREE_TYPE (arg0)))
    1231                 :    1183340 :       && TREE_TYPE (op0) != result_type)
    1232                 :        235 :     unsigned0 = TYPE_UNSIGNED (TREE_TYPE (op0));
    1233                 :    1183340 :   if ((TYPE_PRECISION (TREE_TYPE (op1))
    1234                 :    1183340 :        == TYPE_PRECISION (TREE_TYPE (arg1)))
    1235                 :    1183340 :       && TREE_TYPE (op1) != result_type)
    1236                 :      21961 :     unsigned1 = TYPE_UNSIGNED (TREE_TYPE (op1));
    1237                 :            : 
    1238                 :            :   /* Now UNSIGNED0 is 1 if ARG0 zero-extends to FINAL_TYPE.  */
    1239                 :            : 
    1240                 :            :   /* For bitwise operations, signedness of nominal type
    1241                 :            :      does not matter.  Consider only how operands were extended.  */
    1242                 :    1183340 :   if (bitwise)
    1243                 :     796851 :     uns = unsigned0;
    1244                 :            : 
    1245                 :            :   /* Note that in all three cases below we refrain from optimizing
    1246                 :            :      an unsigned operation on sign-extended args.
    1247                 :            :      That would not be valid.  */
    1248                 :            : 
    1249                 :            :   /* Both args variable: if both extended in same way
    1250                 :            :      from same width, do it in that width.
    1251                 :            :      Do it unsigned if args were zero-extended.  */
    1252                 :    1183340 :   if ((TYPE_PRECISION (TREE_TYPE (arg0))
    1253                 :    1183340 :        < TYPE_PRECISION (result_type))
    1254                 :      26648 :       && (TYPE_PRECISION (TREE_TYPE (arg1))
    1255                 :      26648 :           == TYPE_PRECISION (TREE_TYPE (arg0)))
    1256                 :       7650 :       && unsigned0 == unsigned1
    1257                 :    1190920 :       && (unsigned0 || !uns))
    1258                 :       7578 :     return c_common_signed_or_unsigned_type
    1259                 :       7578 :       (unsigned0, common_type (TREE_TYPE (arg0), TREE_TYPE (arg1)));
    1260                 :            : 
    1261                 :    1175760 :   else if (TREE_CODE (arg0) == INTEGER_CST
    1262                 :     337378 :            && (unsigned1 || !uns)
    1263                 :     229214 :            && (TYPE_PRECISION (TREE_TYPE (arg1))
    1264                 :     229214 :                < TYPE_PRECISION (result_type))
    1265                 :        229 :            && (type
    1266                 :        229 :                = c_common_signed_or_unsigned_type (unsigned1,
    1267                 :        229 :                                                    TREE_TYPE (arg1)))
    1268                 :        229 :            && !POINTER_TYPE_P (type)
    1269                 :    1175990 :            && int_fits_type_p (arg0, type))
    1270                 :            :     return type;
    1271                 :            : 
    1272                 :    1175580 :   else if (TREE_CODE (arg1) == INTEGER_CST
    1273                 :     760953 :            && (unsigned0 || !uns)
    1274                 :     529762 :            && (TYPE_PRECISION (TREE_TYPE (arg0))
    1275                 :     529762 :                < TYPE_PRECISION (result_type))
    1276                 :      12995 :            && (type
    1277                 :      12995 :                = c_common_signed_or_unsigned_type (unsigned0,
    1278                 :      12995 :                                                    TREE_TYPE (arg0)))
    1279                 :      12995 :            && !POINTER_TYPE_P (type)
    1280                 :    1188570 :            && int_fits_type_p (arg1, type))
    1281                 :      12525 :     return type;
    1282                 :            : 
    1283                 :            :   return result_type;
    1284                 :            : }
    1285                 :            : 
    1286                 :            : /* Returns true iff any integer value of type FROM_TYPE can be represented as
    1287                 :            :    real of type TO_TYPE.  This is a helper function for unsafe_conversion_p.  */
    1288                 :            : 
    1289                 :            : static bool
    1290                 :        121 : int_safely_convertible_to_real_p (const_tree from_type, const_tree to_type)
    1291                 :            : {
    1292                 :        121 :   tree type_low_bound = TYPE_MIN_VALUE (from_type);
    1293                 :        121 :   tree type_high_bound = TYPE_MAX_VALUE (from_type);
    1294                 :        121 :   REAL_VALUE_TYPE real_low_bound =
    1295                 :        121 :           real_value_from_int_cst (0, type_low_bound);
    1296                 :        121 :   REAL_VALUE_TYPE real_high_bound =
    1297                 :        121 :           real_value_from_int_cst (0, type_high_bound);
    1298                 :            : 
    1299                 :        121 :   return exact_real_truncate (TYPE_MODE (to_type), &real_low_bound)
    1300                 :        242 :          && exact_real_truncate (TYPE_MODE (to_type), &real_high_bound);
    1301                 :            : }
    1302                 :            : 
    1303                 :            : /* Checks if expression EXPR of complex/real/integer type cannot be converted
    1304                 :            :    to the complex/real/integer type TYPE.  Function returns non-zero when:
    1305                 :            :         * EXPR is a constant which cannot be exactly converted to TYPE.
    1306                 :            :         * EXPR is not a constant and size of EXPR's type > than size of TYPE,
    1307                 :            :           for EXPR type and TYPE being both integers or both real, or both
    1308                 :            :           complex.
    1309                 :            :         * EXPR is not a constant of complex type and TYPE is a real or
    1310                 :            :           an integer.
    1311                 :            :         * EXPR is not a constant of real type and TYPE is an integer.
    1312                 :            :         * EXPR is not a constant of integer type which cannot be
    1313                 :            :           exactly converted to real type.
    1314                 :            : 
    1315                 :            :    Function allows conversions between types of different signedness if
    1316                 :            :    CHECK_SIGN is false and can return SAFE_CONVERSION (zero) in that
    1317                 :            :    case.  Function can return UNSAFE_SIGN if CHECK_SIGN is true.
    1318                 :            : 
    1319                 :            :    RESULT, when non-null is the result of the conversion.  When constant
    1320                 :            :    it is included in the text of diagnostics.
    1321                 :            : 
    1322                 :            :    Function allows conversions from complex constants to non-complex types,
    1323                 :            :    provided that imaginary part is zero and real part can be safely converted
    1324                 :            :    to TYPE.  */
    1325                 :            : 
    1326                 :            : enum conversion_safety
    1327                 :       6030 : unsafe_conversion_p (tree type, tree expr, tree result, bool check_sign)
    1328                 :            : {
    1329                 :       6030 :   enum conversion_safety give_warning = SAFE_CONVERSION; /* is 0 or false */
    1330                 :       6030 :   tree expr_type = TREE_TYPE (expr);
    1331                 :            : 
    1332                 :       6030 :   expr = fold_for_warn (expr);
    1333                 :            : 
    1334                 :       6030 :   if (TREE_CODE (expr) == REAL_CST || TREE_CODE (expr) == INTEGER_CST)
    1335                 :            :     {
    1336                 :            :       /* If type is complex, we are interested in compatibility with
    1337                 :            :          underlying type.  */
    1338                 :       3512 :       if (TREE_CODE (type) == COMPLEX_TYPE)
    1339                 :        114 :           type = TREE_TYPE (type);
    1340                 :            : 
    1341                 :            :       /* Warn for real constant that is not an exact integer converted
    1342                 :            :          to integer type.  */
    1343                 :       3512 :       if (TREE_CODE (expr_type) == REAL_TYPE
    1344                 :        640 :           && TREE_CODE (type) == INTEGER_TYPE)
    1345                 :            :         {
    1346                 :        358 :           if (!real_isinteger (TREE_REAL_CST_PTR (expr), TYPE_MODE (expr_type)))
    1347                 :        242 :             give_warning = UNSAFE_REAL;
    1348                 :            :         }
    1349                 :            :       /* Warn for an integer constant that does not fit into integer type.  */
    1350                 :       3154 :       else if (TREE_CODE (expr_type) == INTEGER_TYPE
    1351                 :       2859 :                && TREE_CODE (type) == INTEGER_TYPE
    1352                 :       2188 :                && !int_fits_type_p (expr, type))
    1353                 :            :         {
    1354                 :        816 :           if (TYPE_UNSIGNED (type) && !TYPE_UNSIGNED (expr_type)
    1355                 :        776 :               && tree_int_cst_sgn (expr) < 0)
    1356                 :            :             {
    1357                 :        287 :               if (check_sign)
    1358                 :        275 :                 give_warning = UNSAFE_SIGN;
    1359                 :            :             }
    1360                 :        361 :           else if (!TYPE_UNSIGNED (type) && TYPE_UNSIGNED (expr_type))
    1361                 :            :             {
    1362                 :         83 :               if (check_sign)
    1363                 :         83 :                 give_warning = UNSAFE_SIGN;
    1364                 :            :             }
    1365                 :            :           else
    1366                 :            :             give_warning = UNSAFE_OTHER;
    1367                 :            :         }
    1368                 :       2666 :       else if (TREE_CODE (type) == REAL_TYPE)
    1369                 :            :         {
    1370                 :            :           /* Warn for an integer constant that does not fit into real type.  */
    1371                 :        846 :           if (TREE_CODE (expr_type) == INTEGER_TYPE)
    1372                 :            :             {
    1373                 :        564 :               REAL_VALUE_TYPE a = real_value_from_int_cst (0, expr);
    1374                 :        564 :               if (!exact_real_truncate (TYPE_MODE (type), &a))
    1375                 :         63 :                 give_warning = UNSAFE_REAL;
    1376                 :            :             }
    1377                 :            :           /* Warn for a real constant that does not fit into a smaller
    1378                 :            :              real type.  */
    1379                 :        282 :           else if (TREE_CODE (expr_type) == REAL_TYPE
    1380                 :        564 :                    && TYPE_PRECISION (type) < TYPE_PRECISION (expr_type))
    1381                 :            :             {
    1382                 :        176 :               REAL_VALUE_TYPE a = TREE_REAL_CST (expr);
    1383                 :        176 :               if (!exact_real_truncate (TYPE_MODE (type), &a))
    1384                 :         72 :                 give_warning = UNSAFE_REAL;
    1385                 :            :             }
    1386                 :            :         }
    1387                 :            :     }
    1388                 :            : 
    1389                 :       2518 :   else if (TREE_CODE (expr) == COMPLEX_CST)
    1390                 :            :     {
    1391                 :         69 :       tree imag_part = TREE_IMAGPART (expr);
    1392                 :            :       /* Conversion from complex constant with zero imaginary part,
    1393                 :            :          perform check for conversion of real part.  */
    1394                 :         69 :       if ((TREE_CODE (imag_part) == REAL_CST
    1395                 :         29 :            && real_zerop (imag_part))
    1396                 :         80 :           || (TREE_CODE (imag_part) == INTEGER_CST
    1397                 :         40 :               && integer_zerop (imag_part)))
    1398                 :            :         /* Note: in this branch we use recursive call to unsafe_conversion_p
    1399                 :            :            with different type of EXPR, but it is still safe, because when EXPR
    1400                 :            :            is a constant, it's type is not used in text of generated warnings
    1401                 :            :            (otherwise they could sound misleading).  */
    1402                 :         30 :         return unsafe_conversion_p (type, TREE_REALPART (expr), result,
    1403                 :         30 :                                     check_sign);
    1404                 :            :       /* Conversion from complex constant with non-zero imaginary part.  */
    1405                 :            :       else
    1406                 :            :         {
    1407                 :            :           /* Conversion to complex type.
    1408                 :            :              Perform checks for both real and imaginary parts.  */
    1409                 :         39 :           if (TREE_CODE (type) == COMPLEX_TYPE)
    1410                 :            :             {
    1411                 :         33 :               enum conversion_safety re_safety =
    1412                 :         33 :                 unsafe_conversion_p (type, TREE_REALPART (expr),
    1413                 :            :                                      result, check_sign);
    1414                 :         33 :               enum conversion_safety im_safety =
    1415                 :         33 :                 unsafe_conversion_p (type, imag_part, result, check_sign);
    1416                 :            : 
    1417                 :            :               /* Merge the results into appropriate single warning.  */
    1418                 :            : 
    1419                 :            :               /* Note: this case includes SAFE_CONVERSION, i.e. success.  */
    1420                 :         33 :               if (re_safety == im_safety)
    1421                 :            :                 give_warning = re_safety;
    1422                 :          9 :               else if (!re_safety && im_safety)
    1423                 :            :                 give_warning = im_safety;
    1424                 :          4 :               else if (re_safety && !im_safety)
    1425                 :            :                 give_warning = re_safety;
    1426                 :            :               else
    1427                 :          0 :                 give_warning = UNSAFE_OTHER;
    1428                 :            :             }
    1429                 :            :           /* Warn about conversion from complex to real or integer type.  */
    1430                 :            :           else
    1431                 :            :             give_warning = UNSAFE_IMAGINARY;
    1432                 :            :         }
    1433                 :            :     }
    1434                 :            : 
    1435                 :            :   /* Checks for remaining case: EXPR is not constant.  */
    1436                 :            :   else
    1437                 :            :     {
    1438                 :            :       /* Warn for real types converted to integer types.  */
    1439                 :       2449 :       if (TREE_CODE (expr_type) == REAL_TYPE
    1440                 :        203 :           && TREE_CODE (type) == INTEGER_TYPE)
    1441                 :            :         give_warning = UNSAFE_REAL;
    1442                 :            : 
    1443                 :       2413 :       else if (TREE_CODE (expr_type) == INTEGER_TYPE
    1444                 :       2202 :                && TREE_CODE (type) == INTEGER_TYPE)
    1445                 :            :         {
    1446                 :            :           /* Don't warn about unsigned char y = 0xff, x = (int) y;  */
    1447                 :       1937 :           expr = get_unwidened (expr, 0);
    1448                 :       1937 :           expr_type = TREE_TYPE (expr);
    1449                 :            : 
    1450                 :            :           /* Don't warn for short y; short x = ((int)y & 0xff);  */
    1451                 :       1937 :           if (TREE_CODE (expr) == BIT_AND_EXPR
    1452                 :       1873 :               || TREE_CODE (expr) == BIT_IOR_EXPR
    1453                 :       1825 :               || TREE_CODE (expr) == BIT_XOR_EXPR)
    1454                 :            :             {
    1455                 :            :               /* If both args were extended from a shortest type,
    1456                 :            :                  use that type if that is safe.  */
    1457                 :        118 :               expr_type = shorten_binary_op (expr_type,
    1458                 :        118 :                                              TREE_OPERAND (expr, 0),
    1459                 :        118 :                                              TREE_OPERAND (expr, 1),
    1460                 :            :                                              /* bitwise */1);
    1461                 :            : 
    1462                 :        118 :               if (TREE_CODE (expr) == BIT_AND_EXPR)
    1463                 :            :                 {
    1464                 :         64 :                   tree op0 = TREE_OPERAND (expr, 0);
    1465                 :         64 :                   tree op1 = TREE_OPERAND (expr, 1);
    1466                 :         64 :                   bool unsigned0 = TYPE_UNSIGNED (TREE_TYPE (op0));
    1467                 :         64 :                   bool unsigned1 = TYPE_UNSIGNED (TREE_TYPE (op1));
    1468                 :            : 
    1469                 :            :                   /* If one of the operands is a non-negative constant
    1470                 :            :                      that fits in the target type, then the type of the
    1471                 :            :                      other operand does not matter. */
    1472                 :         64 :                   if ((TREE_CODE (op0) == INTEGER_CST
    1473                 :          0 :                        && int_fits_type_p (op0, c_common_signed_type (type))
    1474                 :          0 :                        && int_fits_type_p (op0, c_common_unsigned_type (type)))
    1475                 :         64 :                       || (TREE_CODE (op1) == INTEGER_CST
    1476                 :         53 :                           && int_fits_type_p (op1, c_common_signed_type (type))
    1477                 :         30 :                           && int_fits_type_p (op1,
    1478                 :         30 :                                               c_common_unsigned_type (type))))
    1479                 :         30 :                     return SAFE_CONVERSION;
    1480                 :            :                   /* If constant is unsigned and fits in the target
    1481                 :            :                      type, then the result will also fit.  */
    1482                 :         34 :                   else if ((TREE_CODE (op0) == INTEGER_CST
    1483                 :          0 :                             && unsigned0
    1484                 :          0 :                             && int_fits_type_p (op0, type))
    1485                 :         34 :                            || (TREE_CODE (op1) == INTEGER_CST
    1486                 :         23 :                                && unsigned1
    1487                 :         13 :                                && int_fits_type_p (op1, type)))
    1488                 :            :                     return SAFE_CONVERSION;
    1489                 :            :                 }
    1490                 :            :             }
    1491                 :            :           /* Warn for integer types converted to smaller integer types.  */
    1492                 :       1899 :           if (TYPE_PRECISION (type) < TYPE_PRECISION (expr_type))
    1493                 :            :             give_warning = UNSAFE_OTHER;
    1494                 :            : 
    1495                 :            :           /* When they are the same width but different signedness,
    1496                 :            :              then the value may change.  */
    1497                 :       1302 :           else if (((TYPE_PRECISION (type) == TYPE_PRECISION (expr_type)
    1498                 :       1040 :                      && TYPE_UNSIGNED (expr_type) != TYPE_UNSIGNED (type))
    1499                 :            :                     /* Even when converted to a bigger type, if the type is
    1500                 :            :                        unsigned but expr is signed, then negative values
    1501                 :            :                        will be changed.  */
    1502                 :       1128 :                     || (TYPE_UNSIGNED (type) && !TYPE_UNSIGNED (expr_type)))
    1503                 :       1511 :                    && check_sign)
    1504                 :            :             give_warning = UNSAFE_SIGN;
    1505                 :            :         }
    1506                 :            : 
    1507                 :            :       /* Warn for integer types converted to real types if and only if
    1508                 :            :          all the range of values of the integer type cannot be
    1509                 :            :          represented by the real type.  */
    1510                 :        476 :       else if (TREE_CODE (expr_type) == INTEGER_TYPE
    1511                 :        265 :                && TREE_CODE (type) == REAL_TYPE)
    1512                 :            :         {
    1513                 :            :           /* Don't warn about char y = 0xff; float x = (int) y;  */
    1514                 :        121 :           expr = get_unwidened (expr, 0);
    1515                 :        121 :           expr_type = TREE_TYPE (expr);
    1516                 :            : 
    1517                 :        121 :           if (!int_safely_convertible_to_real_p (expr_type, type))
    1518                 :         41 :             give_warning = UNSAFE_OTHER;
    1519                 :            :         }
    1520                 :            : 
    1521                 :            :       /* Warn for real types converted to smaller real types.  */
    1522                 :        355 :       else if (TREE_CODE (expr_type) == REAL_TYPE
    1523                 :        167 :                && TREE_CODE (type) == REAL_TYPE
    1524                 :        522 :                && TYPE_PRECISION (type) < TYPE_PRECISION (expr_type))
    1525                 :            :         give_warning = UNSAFE_REAL;
    1526                 :            : 
    1527                 :            :       /* Check conversion between two complex types.  */
    1528                 :        290 :       else if (TREE_CODE (expr_type) == COMPLEX_TYPE
    1529                 :         32 :                && TREE_CODE (type) == COMPLEX_TYPE)
    1530                 :            :         {
    1531                 :            :           /* Extract underlying types (i.e., type of real and imaginary
    1532                 :            :              parts) of expr_type and type.  */
    1533                 :         10 :           tree from_type = TREE_TYPE (expr_type);
    1534                 :         10 :           tree to_type = TREE_TYPE (type);
    1535                 :            : 
    1536                 :            :           /* Warn for real types converted to integer types.  */
    1537                 :         10 :           if (TREE_CODE (from_type) == REAL_TYPE
    1538                 :          8 :               && TREE_CODE (to_type) == INTEGER_TYPE)
    1539                 :            :             give_warning = UNSAFE_REAL;
    1540                 :            : 
    1541                 :            :           /* Warn for real types converted to smaller real types.  */
    1542                 :          6 :           else if (TREE_CODE (from_type) == REAL_TYPE
    1543                 :          4 :                    && TREE_CODE (to_type) == REAL_TYPE
    1544                 :         10 :                    && TYPE_PRECISION (to_type) < TYPE_PRECISION (from_type))
    1545                 :            :             give_warning = UNSAFE_REAL;
    1546                 :            : 
    1547                 :            :           /* Check conversion for complex integer types.  Here implementation
    1548                 :            :              is simpler than for real-domain integers because it does not
    1549                 :            :              involve sophisticated cases, such as bitmasks, casts, etc.  */
    1550                 :          4 :           else if (TREE_CODE (from_type) == INTEGER_TYPE
    1551                 :          2 :                    && TREE_CODE (to_type) == INTEGER_TYPE)
    1552                 :            :             {
    1553                 :            :               /* Warn for integer types converted to smaller integer types.  */
    1554                 :          2 :               if (TYPE_PRECISION (to_type) < TYPE_PRECISION (from_type))
    1555                 :            :                 give_warning = UNSAFE_OTHER;
    1556                 :            : 
    1557                 :            :               /* Check for different signedness, see case for real-domain
    1558                 :            :                  integers (above) for a more detailed comment.  */
    1559                 :          0 :               else if (((TYPE_PRECISION (to_type) == TYPE_PRECISION (from_type)
    1560                 :          0 :                          && TYPE_UNSIGNED (to_type) != TYPE_UNSIGNED (from_type))
    1561                 :          0 :                         || (TYPE_UNSIGNED (to_type) && !TYPE_UNSIGNED (from_type)))
    1562                 :          0 :                        && check_sign)
    1563                 :            :                 give_warning = UNSAFE_SIGN;
    1564                 :            :             }
    1565                 :          2 :           else if (TREE_CODE (from_type) == INTEGER_TYPE
    1566                 :          0 :                    && TREE_CODE (to_type) == REAL_TYPE
    1567                 :          2 :                    && !int_safely_convertible_to_real_p (from_type, to_type))
    1568                 :            :             give_warning = UNSAFE_OTHER;
    1569                 :            :         }
    1570                 :            : 
    1571                 :            :       /* Warn for complex types converted to real or integer types.  */
    1572                 :        280 :       else if (TREE_CODE (expr_type) == COMPLEX_TYPE
    1573                 :         22 :                && TREE_CODE (type) != COMPLEX_TYPE)
    1574                 :         22 :         give_warning = UNSAFE_IMAGINARY;
    1575                 :            :     }
    1576                 :            : 
    1577                 :            :   return give_warning;
    1578                 :            : }
    1579                 :            : 
    1580                 :            : 
    1581                 :            : /* Convert EXPR to TYPE, warning about conversion problems with constants.
    1582                 :            :    Invoke this function on every expression that is converted implicitly,
    1583                 :            :    i.e. because of language rules and not because of an explicit cast.  */
    1584                 :            : 
    1585                 :            : tree
    1586                 :    6755590 : convert_and_check (location_t loc, tree type, tree expr)
    1587                 :            : {
    1588                 :    6755590 :   tree result;
    1589                 :    6755590 :   tree expr_for_warning;
    1590                 :            : 
    1591                 :            :   /* Convert from a value with possible excess precision rather than
    1592                 :            :      via the semantic type, but do not warn about values not fitting
    1593                 :            :      exactly in the semantic type.  */
    1594                 :    6755590 :   if (TREE_CODE (expr) == EXCESS_PRECISION_EXPR)
    1595                 :            :     {
    1596                 :         65 :       tree orig_type = TREE_TYPE (expr);
    1597                 :         65 :       expr = TREE_OPERAND (expr, 0);
    1598                 :         65 :       expr_for_warning = convert (orig_type, expr);
    1599                 :         65 :       if (orig_type == type)
    1600                 :            :         return expr_for_warning;
    1601                 :            :     }
    1602                 :            :   else
    1603                 :            :     expr_for_warning = expr;
    1604                 :            : 
    1605                 :    6755570 :   if (TREE_TYPE (expr) == type)
    1606                 :            :     return expr;
    1607                 :            : 
    1608                 :    6535050 :   result = convert (type, expr);
    1609                 :            : 
    1610                 :    6535050 :   if (c_inhibit_evaluation_warnings == 0
    1611                 :    6288690 :       && !TREE_OVERFLOW_P (expr)
    1612                 :   12823700 :       && result != error_mark_node)
    1613                 :    6288500 :     warnings_for_convert_and_check (loc, type, expr_for_warning, result);
    1614                 :            : 
    1615                 :            :   return result;
    1616                 :            : }
    1617                 :            : 
    1618                 :            : /* A node in a list that describes references to variables (EXPR), which are
    1619                 :            :    either read accesses if WRITER is zero, or write accesses, in which case
    1620                 :            :    WRITER is the parent of EXPR.  */
    1621                 :            : struct tlist
    1622                 :            : {
    1623                 :            :   struct tlist *next;
    1624                 :            :   tree expr, writer;
    1625                 :            : };
    1626                 :            : 
    1627                 :            : /* Used to implement a cache the results of a call to verify_tree.  We only
    1628                 :            :    use this for SAVE_EXPRs.  */
    1629                 :            : struct tlist_cache
    1630                 :            : {
    1631                 :            :   struct tlist_cache *next;
    1632                 :            :   struct tlist *cache_before_sp;
    1633                 :            :   struct tlist *cache_after_sp;
    1634                 :            :   tree expr;
    1635                 :            : };
    1636                 :            : 
    1637                 :            : /* Obstack to use when allocating tlist structures, and corresponding
    1638                 :            :    firstobj.  */
    1639                 :            : static struct obstack tlist_obstack;
    1640                 :            : static char *tlist_firstobj = 0;
    1641                 :            : 
    1642                 :            : /* Keep track of the identifiers we've warned about, so we can avoid duplicate
    1643                 :            :    warnings.  */
    1644                 :            : static struct tlist *warned_ids;
    1645                 :            : /* SAVE_EXPRs need special treatment.  We process them only once and then
    1646                 :            :    cache the results.  */
    1647                 :            : static struct tlist_cache *save_expr_cache;
    1648                 :            : 
    1649                 :            : static void add_tlist (struct tlist **, struct tlist *, tree, int);
    1650                 :            : static void merge_tlist (struct tlist **, struct tlist *, int);
    1651                 :            : static void verify_tree (tree, struct tlist **, struct tlist **, tree);
    1652                 :            : static bool warning_candidate_p (tree);
    1653                 :            : static bool candidate_equal_p (const_tree, const_tree);
    1654                 :            : static void warn_for_collisions (struct tlist *);
    1655                 :            : static void warn_for_collisions_1 (tree, tree, struct tlist *, int);
    1656                 :            : static struct tlist *new_tlist (struct tlist *, tree, tree);
    1657                 :            : 
    1658                 :            : /* Create a new struct tlist and fill in its fields.  */
    1659                 :            : static struct tlist *
    1660                 :   14752900 : new_tlist (struct tlist *next, tree t, tree writer)
    1661                 :            : {
    1662                 :   14752900 :   struct tlist *l;
    1663                 :   14752900 :   l = XOBNEW (&tlist_obstack, struct tlist);
    1664                 :   14752900 :   l->next = next;
    1665                 :   14752900 :   l->expr = t;
    1666                 :   14752900 :   l->writer = writer;
    1667                 :   14752900 :   return l;
    1668                 :            : }
    1669                 :            : 
    1670                 :            : /* Add duplicates of the nodes found in ADD to the list *TO.  If EXCLUDE_WRITER
    1671                 :            :    is nonnull, we ignore any node we find which has a writer equal to it.  */
    1672                 :            : 
    1673                 :            : static void
    1674                 :    3867600 : add_tlist (struct tlist **to, struct tlist *add, tree exclude_writer, int copy)
    1675                 :            : {
    1676                 :   54955600 :   while (add)
    1677                 :            :     {
    1678                 :   30536700 :       struct tlist *next = add->next;
    1679                 :    5856820 :       if (!copy)
    1680                 :    1402860 :         add->next = *to;
    1681                 :    5856820 :       if (!exclude_writer || !candidate_equal_p (add->writer, exclude_writer))
    1682                 :   29057200 :         *to = copy ? new_tlist (*to, add->expr, add->writer) : add;
    1683                 :            :       add = next;
    1684                 :            :     }
    1685                 :    3867600 : }
    1686                 :            : 
    1687                 :            : /* Merge the nodes of ADD into TO.  This merging process is done so that for
    1688                 :            :    each variable that already exists in TO, no new node is added; however if
    1689                 :            :    there is a write access recorded in ADD, and an occurrence on TO is only
    1690                 :            :    a read access, then the occurrence in TO will be modified to record the
    1691                 :            :    write.  */
    1692                 :            : 
    1693                 :            : static void
    1694                 :   19145500 : merge_tlist (struct tlist **to, struct tlist *add, int copy)
    1695                 :            : {
    1696                 :   19145500 :   struct tlist **end = to;
    1697                 :            : 
    1698                 :   37185400 :   while (*end)
    1699                 :   18039800 :     end = &(*end)->next;
    1700                 :            : 
    1701                 :   26443700 :   while (add)
    1702                 :            :     {
    1703                 :    7298140 :       int found = 0;
    1704                 :    7298140 :       struct tlist *tmp2;
    1705                 :    7298140 :       struct tlist *next = add->next;
    1706                 :            : 
    1707                 :   34069100 :       for (tmp2 = *to; tmp2; tmp2 = tmp2->next)
    1708                 :   26770900 :         if (candidate_equal_p (tmp2->expr, add->expr))
    1709                 :            :           {
    1710                 :    1868050 :             found = 1;
    1711                 :    1868050 :             if (!tmp2->writer)
    1712                 :    1864240 :               tmp2->writer = add->writer;
    1713                 :            :           }
    1714                 :    7298140 :       if (!found)
    1715                 :            :         {
    1716                 :    5444360 :           *end = copy ? new_tlist (NULL, add->expr, add->writer) : add;
    1717                 :    5444360 :           end = &(*end)->next;
    1718                 :    5444360 :           *end = 0;
    1719                 :            :         }
    1720                 :            :       add = next;
    1721                 :            :     }
    1722                 :   19145500 : }
    1723                 :            : 
    1724                 :            : /* WRITTEN is a variable, WRITER is its parent.  Warn if any of the variable
    1725                 :            :    references in list LIST conflict with it, excluding reads if ONLY writers
    1726                 :            :    is nonzero.  */
    1727                 :            : 
    1728                 :            : static void
    1729                 :    2151500 : warn_for_collisions_1 (tree written, tree writer, struct tlist *list,
    1730                 :            :                        int only_writes)
    1731                 :            : {
    1732                 :    2151500 :   struct tlist *tmp;
    1733                 :            : 
    1734                 :            :   /* Avoid duplicate warnings.  */
    1735                 :    2151710 :   for (tmp = warned_ids; tmp; tmp = tmp->next)
    1736                 :        786 :     if (candidate_equal_p (tmp->expr, written))
    1737                 :            :       return;
    1738                 :            : 
    1739                 :    7933060 :   while (list)
    1740                 :            :     {
    1741                 :    5782140 :       if (candidate_equal_p (list->expr, written)
    1742                 :     992719 :           && !candidate_equal_p (list->writer, writer)
    1743                 :    5869020 :           && (!only_writes || list->writer))
    1744                 :            :         {
    1745                 :        716 :           warned_ids = new_tlist (warned_ids, written, NULL_TREE);
    1746                 :        716 :           warning_at (EXPR_LOC_OR_LOC (writer, input_location),
    1747                 :            :                       OPT_Wsequence_point, "operation on %qE may be undefined",
    1748                 :            :                       list->expr);
    1749                 :            :         }
    1750                 :    5782140 :       list = list->next;
    1751                 :            :     }
    1752                 :            : }
    1753                 :            : 
    1754                 :            : /* Given a list LIST of references to variables, find whether any of these
    1755                 :            :    can cause conflicts due to missing sequence points.  */
    1756                 :            : 
    1757                 :            : static void
    1758                 :    7917240 : warn_for_collisions (struct tlist *list)
    1759                 :            : {
    1760                 :    7917240 :   struct tlist *tmp;
    1761                 :            : 
    1762                 :   22622300 :   for (tmp = list; tmp; tmp = tmp->next)
    1763                 :            :     {
    1764                 :   14705000 :       if (tmp->writer)
    1765                 :     873061 :         warn_for_collisions_1 (tmp->expr, tmp->writer, list, 0);
    1766                 :            :     }
    1767                 :    7917240 : }
    1768                 :            : 
    1769                 :            : /* Return nonzero if X is a tree that can be verified by the sequence point
    1770                 :            :    warnings.  */
    1771                 :            : 
    1772                 :            : static bool
    1773                 :   31597100 : warning_candidate_p (tree x)
    1774                 :            : {
    1775                 :   41063600 :   if (DECL_P (x) && DECL_ARTIFICIAL (x))
    1776                 :            :     return false;
    1777                 :            : 
    1778                 :   29250900 :   if (TREE_CODE (x) == BLOCK)
    1779                 :            :     return false;
    1780                 :            : 
    1781                 :            :   /* VOID_TYPE_P (TREE_TYPE (x)) is workaround for cp/tree.c
    1782                 :            :      (lvalue_p) crash on TRY/CATCH. */
    1783                 :   29250200 :   if (TREE_TYPE (x) == NULL_TREE || VOID_TYPE_P (TREE_TYPE (x)))
    1784                 :            :     return false;
    1785                 :            : 
    1786                 :   28701300 :   if (!lvalue_p (x))
    1787                 :            :     return false;
    1788                 :            : 
    1789                 :            :   /* No point to track non-const calls, they will never satisfy
    1790                 :            :      operand_equal_p.  */
    1791                 :   11237500 :   if (TREE_CODE (x) == CALL_EXPR && (call_expr_flags (x) & ECF_CONST) == 0)
    1792                 :            :     return false;
    1793                 :            : 
    1794                 :   11196100 :   if (TREE_CODE (x) == STRING_CST)
    1795                 :     164438 :     return false;
    1796                 :            : 
    1797                 :            :   return true;
    1798                 :            : }
    1799                 :            : 
    1800                 :            : /* Return nonzero if X and Y appear to be the same candidate (or NULL) */
    1801                 :            : static bool
    1802                 :   36428800 : candidate_equal_p (const_tree x, const_tree y)
    1803                 :            : {
    1804                 :   36428800 :   return (x == y) || (x && y && operand_equal_p (x, y, 0));
    1805                 :            : }
    1806                 :            : 
    1807                 :            : /* Walk the tree X, and record accesses to variables.  If X is written by the
    1808                 :            :    parent tree, WRITER is the parent.
    1809                 :            :    We store accesses in one of the two lists: PBEFORE_SP, and PNO_SP.  If this
    1810                 :            :    expression or its only operand forces a sequence point, then everything up
    1811                 :            :    to the sequence point is stored in PBEFORE_SP.  Everything else gets stored
    1812                 :            :    in PNO_SP.
    1813                 :            :    Once we return, we will have emitted warnings if any subexpression before
    1814                 :            :    such a sequence point could be undefined.  On a higher level, however, the
    1815                 :            :    sequence point may not be relevant, and we'll merge the two lists.
    1816                 :            : 
    1817                 :            :    Example: (b++, a) + b;
    1818                 :            :    The call that processes the COMPOUND_EXPR will store the increment of B
    1819                 :            :    in PBEFORE_SP, and the use of A in PNO_SP.  The higher-level call that
    1820                 :            :    processes the PLUS_EXPR will need to merge the two lists so that
    1821                 :            :    eventually, all accesses end up on the same list (and we'll warn about the
    1822                 :            :    unordered subexpressions b++ and b.
    1823                 :            : 
    1824                 :            :    A note on merging.  If we modify the former example so that our expression
    1825                 :            :    becomes
    1826                 :            :      (b++, b) + a
    1827                 :            :    care must be taken not simply to add all three expressions into the final
    1828                 :            :    PNO_SP list.  The function merge_tlist takes care of that by merging the
    1829                 :            :    before-SP list of the COMPOUND_EXPR into its after-SP list in a special
    1830                 :            :    way, so that no more than one access to B is recorded.  */
    1831                 :            : 
    1832                 :            : static void
    1833                 :   25488600 : verify_tree (tree x, struct tlist **pbefore_sp, struct tlist **pno_sp,
    1834                 :            :              tree writer)
    1835                 :            : {
    1836                 :   25488600 :   struct tlist *tmp_before, *tmp_nosp, *tmp_list2, *tmp_list3;
    1837                 :   25488600 :   enum tree_code code;
    1838                 :   25488600 :   enum tree_code_class cl;
    1839                 :            : 
    1840                 :            :   /* X may be NULL if it is the operand of an empty statement expression
    1841                 :            :      ({ }).  */
    1842                 :   25488600 :   if (x == NULL)
    1843                 :            :     return;
    1844                 :            : 
    1845                 :   23855100 :  restart:
    1846                 :   30318700 :   code = TREE_CODE (x);
    1847                 :   30318700 :   cl = TREE_CODE_CLASS (code);
    1848                 :            : 
    1849                 :   30318700 :   if (warning_candidate_p (x))
    1850                 :   10332000 :     *pno_sp = new_tlist (*pno_sp, x, writer);
    1851                 :            : 
    1852                 :   30318700 :   switch (code)
    1853                 :            :     {
    1854                 :            :     case CONSTRUCTOR:
    1855                 :            :     case SIZEOF_EXPR:
    1856                 :            :       return;
    1857                 :            : 
    1858                 :     167452 :     case COMPOUND_EXPR:
    1859                 :     167452 :     case TRUTH_ANDIF_EXPR:
    1860                 :     167452 :     case TRUTH_ORIF_EXPR:
    1861                 :     167452 :     sequenced_binary:
    1862                 :     167452 :       tmp_before = tmp_nosp = tmp_list2 = tmp_list3 = 0;
    1863                 :     167452 :       verify_tree (TREE_OPERAND (x, 0), &tmp_before, &tmp_nosp, NULL_TREE);
    1864                 :     167452 :       warn_for_collisions (tmp_nosp);
    1865                 :     167452 :       merge_tlist (pbefore_sp, tmp_before, 0);
    1866                 :     167452 :       merge_tlist (pbefore_sp, tmp_nosp, 0);
    1867                 :     167452 :       verify_tree (TREE_OPERAND (x, 1), &tmp_list3, &tmp_list2, NULL_TREE);
    1868                 :     167452 :       warn_for_collisions (tmp_list2);
    1869                 :     167452 :       merge_tlist (pbefore_sp, tmp_list3, 0);
    1870                 :     167452 :       merge_tlist (pno_sp, tmp_list2, 0);
    1871                 :     167452 :       return;
    1872                 :            : 
    1873                 :      48843 :     case COND_EXPR:
    1874                 :      48843 :       tmp_before = tmp_list2 = 0;
    1875                 :      48843 :       verify_tree (TREE_OPERAND (x, 0), &tmp_before, &tmp_list2, NULL_TREE);
    1876                 :      48843 :       warn_for_collisions (tmp_list2);
    1877                 :      48843 :       merge_tlist (pbefore_sp, tmp_before, 0);
    1878                 :      48843 :       merge_tlist (pbefore_sp, tmp_list2, 0);
    1879                 :            : 
    1880                 :      48843 :       tmp_list3 = tmp_nosp = 0;
    1881                 :      48843 :       verify_tree (TREE_OPERAND (x, 1), &tmp_list3, &tmp_nosp, NULL_TREE);
    1882                 :      48843 :       warn_for_collisions (tmp_nosp);
    1883                 :      48843 :       merge_tlist (pbefore_sp, tmp_list3, 0);
    1884                 :            : 
    1885                 :      48843 :       tmp_list3 = tmp_list2 = 0;
    1886                 :      48843 :       verify_tree (TREE_OPERAND (x, 2), &tmp_list3, &tmp_list2, NULL_TREE);
    1887                 :      48843 :       warn_for_collisions (tmp_list2);
    1888                 :      48843 :       merge_tlist (pbefore_sp, tmp_list3, 0);
    1889                 :            :       /* Rather than add both tmp_nosp and tmp_list2, we have to merge the
    1890                 :            :          two first, to avoid warning for (a ? b++ : b++).  */
    1891                 :      48843 :       merge_tlist (&tmp_nosp, tmp_list2, 0);
    1892                 :      48843 :       add_tlist (pno_sp, tmp_nosp, NULL_TREE, 0);
    1893                 :            :       return;
    1894                 :            : 
    1895                 :      85676 :     case PREDECREMENT_EXPR:
    1896                 :      85676 :     case PREINCREMENT_EXPR:
    1897                 :      85676 :     case POSTDECREMENT_EXPR:
    1898                 :      85676 :     case POSTINCREMENT_EXPR:
    1899                 :      85676 :       verify_tree (TREE_OPERAND (x, 0), pno_sp, pno_sp, x);
    1900                 :      85676 :       return;
    1901                 :            : 
    1902                 :    1278440 :     case MODIFY_EXPR:
    1903                 :    1278440 :       tmp_before = tmp_nosp = tmp_list3 = 0;
    1904                 :    1278440 :       verify_tree (TREE_OPERAND (x, 1), &tmp_before, &tmp_nosp, NULL_TREE);
    1905                 :    1278440 :       verify_tree (TREE_OPERAND (x, 0), &tmp_list3, &tmp_list3, x);
    1906                 :            :       /* Expressions inside the LHS are not ordered wrt. the sequence points
    1907                 :            :          in the RHS.  Example:
    1908                 :            :            *a = (a++, 2)
    1909                 :            :          Despite the fact that the modification of "a" is in the before_sp
    1910                 :            :          list (tmp_before), it conflicts with the use of "a" in the LHS.
    1911                 :            :          We can handle this by adding the contents of tmp_list3
    1912                 :            :          to those of tmp_before, and redoing the collision warnings for that
    1913                 :            :          list.  */
    1914                 :    1278440 :       add_tlist (&tmp_before, tmp_list3, x, 1);
    1915                 :    1278440 :       warn_for_collisions (tmp_before);
    1916                 :            :       /* Exclude the LHS itself here; we first have to merge it into the
    1917                 :            :          tmp_nosp list.  This is done to avoid warning for "a = a"; if we
    1918                 :            :          didn't exclude the LHS, we'd get it twice, once as a read and once
    1919                 :            :          as a write.  */
    1920                 :    1278440 :       add_tlist (pno_sp, tmp_list3, x, 0);
    1921                 :    1278440 :       warn_for_collisions_1 (TREE_OPERAND (x, 0), x, tmp_nosp, 1);
    1922                 :            : 
    1923                 :    1278440 :       merge_tlist (pbefore_sp, tmp_before, 0);
    1924                 :    1278440 :       if (warning_candidate_p (TREE_OPERAND (x, 0)))
    1925                 :     699609 :         merge_tlist (&tmp_nosp, new_tlist (NULL, TREE_OPERAND (x, 0), x), 0);
    1926                 :    1278440 :       add_tlist (pno_sp, tmp_nosp, NULL_TREE, 1);
    1927                 :    1278440 :       return;
    1928                 :            : 
    1929                 :    2147570 :     case CALL_EXPR:
    1930                 :            :       /* We need to warn about conflicts among arguments and conflicts between
    1931                 :            :          args and the function address.  Side effects of the function address,
    1932                 :            :          however, are not ordered by the sequence point of the call.  */
    1933                 :    2147570 :       {
    1934                 :    2147570 :         call_expr_arg_iterator iter;
    1935                 :    2147570 :         tree arg;
    1936                 :    2147570 :         tmp_before = tmp_nosp = 0;
    1937                 :    2147570 :         verify_tree (CALL_EXPR_FN (x), &tmp_before, &tmp_nosp, NULL_TREE);
    1938                 :    7041270 :         FOR_EACH_CALL_EXPR_ARG (arg, iter, x)
    1939                 :            :           {
    1940                 :    4893700 :             tmp_list2 = tmp_list3 = 0;
    1941                 :    4893700 :             verify_tree (arg, &tmp_list2, &tmp_list3, NULL_TREE);
    1942                 :    4893700 :             merge_tlist (&tmp_list3, tmp_list2, 0);
    1943                 :    9787400 :             add_tlist (&tmp_before, tmp_list3, NULL_TREE, 0);
    1944                 :            :           }
    1945                 :    2147570 :         add_tlist (&tmp_before, tmp_nosp, NULL_TREE, 0);
    1946                 :    2147570 :         warn_for_collisions (tmp_before);
    1947                 :    2147570 :         add_tlist (pbefore_sp, tmp_before, NULL_TREE, 0);
    1948                 :    2147570 :         return;
    1949                 :            :       }
    1950                 :            : 
    1951                 :          0 :     case TREE_LIST:
    1952                 :            :       /* Scan all the list, e.g. indices of multi dimensional array.  */
    1953                 :          0 :       while (x)
    1954                 :            :         {
    1955                 :          0 :           tmp_before = tmp_nosp = 0;
    1956                 :          0 :           verify_tree (TREE_VALUE (x), &tmp_before, &tmp_nosp, NULL_TREE);
    1957                 :          0 :           merge_tlist (&tmp_nosp, tmp_before, 0);
    1958                 :          0 :           add_tlist (pno_sp, tmp_nosp, NULL_TREE, 0);
    1959                 :          0 :           x = TREE_CHAIN (x);
    1960                 :            :         }
    1961                 :            :       return;
    1962                 :            : 
    1963                 :      32266 :     case SAVE_EXPR:
    1964                 :      32266 :       {
    1965                 :      32266 :         struct tlist_cache *t;
    1966                 :      90362 :         for (t = save_expr_cache; t; t = t->next)
    1967                 :      76464 :           if (candidate_equal_p (t->expr, x))
    1968                 :            :             break;
    1969                 :            : 
    1970                 :      32266 :         if (!t)
    1971                 :            :           {
    1972                 :      13898 :             t = XOBNEW (&tlist_obstack, struct tlist_cache);
    1973                 :      13898 :             t->next = save_expr_cache;
    1974                 :      13898 :             t->expr = x;
    1975                 :      13898 :             save_expr_cache = t;
    1976                 :            : 
    1977                 :      13898 :             tmp_before = tmp_nosp = 0;
    1978                 :      13898 :             verify_tree (TREE_OPERAND (x, 0), &tmp_before, &tmp_nosp, NULL_TREE);
    1979                 :      13898 :             warn_for_collisions (tmp_nosp);
    1980                 :            : 
    1981                 :      13898 :             tmp_list3 = 0;
    1982                 :      13898 :             merge_tlist (&tmp_list3, tmp_nosp, 0);
    1983                 :      13898 :             t->cache_before_sp = tmp_before;
    1984                 :      13898 :             t->cache_after_sp = tmp_list3;
    1985                 :            :           }
    1986                 :      32266 :         merge_tlist (pbefore_sp, t->cache_before_sp, 1);
    1987                 :      32266 :         add_tlist (pno_sp, t->cache_after_sp, NULL_TREE, 1);
    1988                 :      32266 :         return;
    1989                 :            :       }
    1990                 :            : 
    1991                 :    2639390 :     case ADDR_EXPR:
    1992                 :    2639390 :       x = TREE_OPERAND (x, 0);
    1993                 :    2639390 :       if (DECL_P (x))
    1994                 :            :         return;
    1995                 :     289906 :       writer = 0;
    1996                 :     289906 :       goto restart;
    1997                 :            : 
    1998                 :    3815770 :     case VIEW_CONVERT_EXPR:
    1999                 :    3815770 :       if (location_wrapper_p (x))
    2000                 :            :         {
    2001                 :    2056740 :           x = TREE_OPERAND (x, 0);
    2002                 :    2056740 :           goto restart;
    2003                 :            :         }
    2004                 :    1759030 :       goto do_default;
    2005                 :            : 
    2006                 :    1301920 :     case LSHIFT_EXPR:
    2007                 :    1301920 :     case RSHIFT_EXPR:
    2008                 :    1301920 :     case COMPONENT_REF:
    2009                 :    1301920 :     case ARRAY_REF:
    2010                 :    1301920 :       if (cxx_dialect >= cxx17)
    2011                 :      61935 :         goto sequenced_binary;
    2012                 :    1239990 :       goto do_default;
    2013                 :            : 
    2014                 :   21484300 :     default:
    2015                 :   21484300 :     do_default:
    2016                 :            :       /* For other expressions, simply recurse on their operands.
    2017                 :            :          Manual tail recursion for unary expressions.
    2018                 :            :          Other non-expressions need not be processed.  */
    2019                 :   21484300 :       if (cl == tcc_unary)
    2020                 :            :         {
    2021                 :    4116980 :           x = TREE_OPERAND (x, 0);
    2022                 :    4116980 :           writer = 0;
    2023                 :    4116980 :           goto restart;
    2024                 :            :         }
    2025                 :   17367300 :       else if (IS_EXPR_CODE_CLASS (cl))
    2026                 :            :         {
    2027                 :    6086450 :           int lp;
    2028                 :    6086450 :           int max = TREE_OPERAND_LENGTH (x);
    2029                 :   17400000 :           for (lp = 0; lp < max; lp++)
    2030                 :            :             {
    2031                 :   11313600 :               tmp_before = tmp_nosp = 0;
    2032                 :   11313600 :               verify_tree (TREE_OPERAND (x, lp), &tmp_before, &tmp_nosp, 0);
    2033                 :   11313600 :               merge_tlist (&tmp_nosp, tmp_before, 0);
    2034                 :   22627200 :               add_tlist (pno_sp, tmp_nosp, NULL_TREE, 0);
    2035                 :            :             }
    2036                 :            :         }
    2037                 :            :       return;
    2038                 :            :     }
    2039                 :            : }
    2040                 :            : 
    2041                 :            : /* Try to warn for undefined behavior in EXPR due to missing sequence
    2042                 :            :    points.  */
    2043                 :            : 
    2044                 :            : DEBUG_FUNCTION void
    2045                 :    3995900 : verify_sequence_points (tree expr)
    2046                 :            : {
    2047                 :    3995900 :   struct tlist *before_sp = 0, *after_sp = 0;
    2048                 :            : 
    2049                 :    3995900 :   warned_ids = 0;
    2050                 :    3995900 :   save_expr_cache = 0;
    2051                 :    3995900 :   if (tlist_firstobj == 0)
    2052                 :            :     {
    2053                 :       7617 :       gcc_obstack_init (&tlist_obstack);
    2054                 :       7617 :       tlist_firstobj = (char *) obstack_alloc (&tlist_obstack, 0);
    2055                 :            :     }
    2056                 :            : 
    2057                 :    3995900 :   verify_tree (expr, &before_sp, &after_sp, 0);
    2058                 :    3995900 :   warn_for_collisions (after_sp);
    2059                 :    3995900 :   obstack_free (&tlist_obstack, tlist_firstobj);
    2060                 :    3995900 : }
    2061                 :            : 
    2062                 :            : /* Validate the expression after `case' and apply default promotions.  */
    2063                 :            : 
    2064                 :            : static tree
    2065                 :    1081820 : check_case_value (location_t loc, tree value)
    2066                 :            : {
    2067                 :    1081820 :   if (value == NULL_TREE)
    2068                 :            :     return value;
    2069                 :            : 
    2070                 :    1081820 :   if (TREE_CODE (value) == INTEGER_CST)
    2071                 :            :     /* Promote char or short to int.  */
    2072                 :    1081640 :     value = perform_integral_promotions (value);
    2073                 :        183 :   else if (value != error_mark_node)
    2074                 :            :     {
    2075                 :         50 :       error_at (loc, "case label does not reduce to an integer constant");
    2076                 :         50 :       value = error_mark_node;
    2077                 :            :     }
    2078                 :            : 
    2079                 :    1081820 :   constant_expression_warning (value);
    2080                 :            : 
    2081                 :    1081820 :   return value;
    2082                 :            : }
    2083                 :            : 
    2084                 :            : /* Return an integer type with BITS bits of precision,
    2085                 :            :    that is unsigned if UNSIGNEDP is nonzero, otherwise signed.  */
    2086                 :            : 
    2087                 :            : tree
    2088                 :   11141100 : c_common_type_for_size (unsigned int bits, int unsignedp)
    2089                 :            : {
    2090                 :   11141100 :   int i;
    2091                 :            : 
    2092                 :   11141100 :   if (bits == TYPE_PRECISION (integer_type_node))
    2093                 :    7454050 :     return unsignedp ? unsigned_type_node : integer_type_node;
    2094                 :            : 
    2095                 :    3687090 :   if (bits == TYPE_PRECISION (signed_char_type_node))
    2096                 :     348818 :     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
    2097                 :            : 
    2098                 :    3338270 :   if (bits == TYPE_PRECISION (short_integer_type_node))
    2099                 :     219256 :     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
    2100                 :            : 
    2101                 :    3119020 :   if (bits == TYPE_PRECISION (long_integer_type_node))
    2102                 :    2897760 :     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
    2103                 :            : 
    2104                 :     221252 :   if (bits == TYPE_PRECISION (long_long_integer_type_node))
    2105                 :       9038 :     return (unsignedp ? long_long_unsigned_type_node
    2106                 :       9038 :             : long_long_integer_type_node);
    2107                 :            : 
    2108                 :     263440 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    2109                 :     212214 :     if (int_n_enabled_p[i]
    2110                 :     207332 :         && bits == int_n_data[i].bitsize)
    2111                 :     160988 :       return (unsignedp ? int_n_trees[i].unsigned_type
    2112                 :     160988 :               : int_n_trees[i].signed_type);
    2113                 :            : 
    2114                 :      51226 :   if (bits == TYPE_PRECISION (widest_integer_literal_type_node))
    2115                 :          0 :     return (unsignedp ? widest_unsigned_literal_type_node
    2116                 :          0 :             : widest_integer_literal_type_node);
    2117                 :            : 
    2118                 :      51226 :   if (bits <= TYPE_PRECISION (intQI_type_node))
    2119                 :      12437 :     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
    2120                 :            : 
    2121                 :      38789 :   if (bits <= TYPE_PRECISION (intHI_type_node))
    2122                 :       9769 :     return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
    2123                 :            : 
    2124                 :      29020 :   if (bits <= TYPE_PRECISION (intSI_type_node))
    2125                 :      12561 :     return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
    2126                 :            : 
    2127                 :      16459 :   if (bits <= TYPE_PRECISION (intDI_type_node))
    2128                 :      11197 :     return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
    2129                 :            : 
    2130                 :            :   return NULL_TREE;
    2131                 :            : }
    2132                 :            : 
    2133                 :            : /* Return a fixed-point type that has at least IBIT ibits and FBIT fbits
    2134                 :            :    that is unsigned if UNSIGNEDP is nonzero, otherwise signed;
    2135                 :            :    and saturating if SATP is nonzero, otherwise not saturating.  */
    2136                 :            : 
    2137                 :            : tree
    2138                 :          0 : c_common_fixed_point_type_for_size (unsigned int ibit, unsigned int fbit,
    2139                 :            :                                     int unsignedp, int satp)
    2140                 :            : {
    2141                 :          0 :   enum mode_class mclass;
    2142                 :          0 :   if (ibit == 0)
    2143                 :          0 :     mclass = unsignedp ? MODE_UFRACT : MODE_FRACT;
    2144                 :            :   else
    2145                 :          0 :     mclass = unsignedp ? MODE_UACCUM : MODE_ACCUM;
    2146                 :            : 
    2147                 :          0 :   opt_scalar_mode opt_mode;
    2148                 :          0 :   scalar_mode mode;
    2149                 :          0 :   FOR_EACH_MODE_IN_CLASS (opt_mode, mclass)
    2150                 :            :     {
    2151                 :          0 :       mode = opt_mode.require ();
    2152                 :          0 :       if (GET_MODE_IBIT (mode) >= ibit && GET_MODE_FBIT (mode) >= fbit)
    2153                 :            :         break;
    2154                 :            :     }
    2155                 :            : 
    2156                 :          0 :   if (!opt_mode.exists (&mode) || !targetm.scalar_mode_supported_p (mode))
    2157                 :            :     {
    2158                 :          0 :       sorry ("GCC cannot support operators with integer types and "
    2159                 :            :              "fixed-point types that have too many integral and "
    2160                 :            :              "fractional bits together");
    2161                 :          0 :       return NULL_TREE;
    2162                 :            :     }
    2163                 :            : 
    2164                 :          0 :   return c_common_type_for_mode (mode, satp);
    2165                 :            : }
    2166                 :            : 
    2167                 :            : /* Used for communication between c_common_type_for_mode and
    2168                 :            :    c_register_builtin_type.  */
    2169                 :            : tree registered_builtin_types;
    2170                 :            : 
    2171                 :            : /* Return a data type that has machine mode MODE.
    2172                 :            :    If the mode is an integer,
    2173                 :            :    then UNSIGNEDP selects between signed and unsigned types.
    2174                 :            :    If the mode is a fixed-point mode,
    2175                 :            :    then UNSIGNEDP selects between saturating and nonsaturating types.  */
    2176                 :            : 
    2177                 :            : tree
    2178                 :    2497250 : c_common_type_for_mode (machine_mode mode, int unsignedp)
    2179                 :            : {
    2180                 :    2497250 :   tree t;
    2181                 :    2497250 :   int i;
    2182                 :            : 
    2183                 :    2497250 :   if (mode == TYPE_MODE (integer_type_node))
    2184                 :     346558 :     return unsignedp ? unsigned_type_node : integer_type_node;
    2185                 :            : 
    2186                 :    2150700 :   if (mode == TYPE_MODE (signed_char_type_node))
    2187                 :      61367 :     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
    2188                 :            : 
    2189                 :    2089330 :   if (mode == TYPE_MODE (short_integer_type_node))
    2190                 :      39055 :     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
    2191                 :            : 
    2192                 :    2050270 :   if (mode == TYPE_MODE (long_integer_type_node))
    2193                 :     786534 :     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
    2194                 :            : 
    2195                 :    1263740 :   if (mode == TYPE_MODE (long_long_integer_type_node))
    2196                 :      36948 :     return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node;
    2197                 :            : 
    2198                 :    2061800 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    2199                 :    1226790 :     if (int_n_enabled_p[i]
    2200                 :    1226790 :         && mode == int_n_data[i].m)
    2201                 :     391787 :       return (unsignedp ? int_n_trees[i].unsigned_type
    2202                 :     391787 :               : int_n_trees[i].signed_type);
    2203                 :            : 
    2204                 :     835004 :   if (mode == QImode)
    2205                 :          0 :     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
    2206                 :            : 
    2207                 :     835004 :   if (mode == HImode)
    2208                 :          0 :     return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
    2209                 :            : 
    2210                 :     835004 :   if (mode == SImode)
    2211                 :          0 :     return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
    2212                 :            : 
    2213                 :     835004 :   if (mode == DImode)
    2214                 :          0 :     return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
    2215                 :            : 
    2216                 :            : #if HOST_BITS_PER_WIDE_INT >= 64
    2217                 :     835004 :   if (mode == TYPE_MODE (intTI_type_node))
    2218                 :          0 :     return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
    2219                 :            : #endif
    2220                 :            : 
    2221                 :     835004 :   if (mode == TYPE_MODE (float_type_node))
    2222                 :      21283 :     return float_type_node;
    2223                 :            : 
    2224                 :     813721 :   if (mode == TYPE_MODE (double_type_node))
    2225                 :      52869 :     return double_type_node;
    2226                 :            : 
    2227                 :     760852 :   if (mode == TYPE_MODE (long_double_type_node))
    2228                 :      15485 :     return long_double_type_node;
    2229                 :            : 
    2230                 :    5602540 :   for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    2231                 :    4947280 :     if (FLOATN_NX_TYPE_NODE (i) != NULL_TREE
    2232                 :    4947280 :         && mode == TYPE_MODE (FLOATN_NX_TYPE_NODE (i)))
    2233                 :      90098 :       return FLOATN_NX_TYPE_NODE (i);
    2234                 :            : 
    2235                 :     655269 :   if (mode == TYPE_MODE (void_type_node))
    2236                 :          0 :     return void_type_node;
    2237                 :            : 
    2238                 :     655269 :   if (mode == TYPE_MODE (build_pointer_type (char_type_node))
    2239                 :     655269 :       || mode == TYPE_MODE (build_pointer_type (integer_type_node)))
    2240                 :            :     {
    2241                 :          0 :       unsigned int precision
    2242                 :          0 :         = GET_MODE_PRECISION (as_a <scalar_int_mode> (mode));
    2243                 :          0 :       return (unsignedp
    2244                 :          0 :               ? make_unsigned_type (precision)
    2245                 :          0 :               : make_signed_type (precision));
    2246                 :            :     }
    2247                 :            : 
    2248                 :     655269 :   if (COMPLEX_MODE_P (mode))
    2249                 :            :     {
    2250                 :     639142 :       machine_mode inner_mode;
    2251                 :     639142 :       tree inner_type;
    2252                 :            : 
    2253                 :     639142 :       if (mode == TYPE_MODE (complex_float_type_node))
    2254                 :     157950 :         return complex_float_type_node;
    2255                 :     481192 :       if (mode == TYPE_MODE (complex_double_type_node))
    2256                 :     157139 :         return complex_double_type_node;
    2257                 :     324053 :       if (mode == TYPE_MODE (complex_long_double_type_node))
    2258                 :     157133 :         return complex_long_double_type_node;
    2259                 :            : 
    2260                 :     667800 :       for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    2261                 :     667770 :         if (COMPLEX_FLOATN_NX_TYPE_NODE (i) != NULL_TREE
    2262                 :     667770 :             && mode == TYPE_MODE (COMPLEX_FLOATN_NX_TYPE_NODE (i)))
    2263                 :     166890 :           return COMPLEX_FLOATN_NX_TYPE_NODE (i);
    2264                 :            : 
    2265                 :         30 :       if (mode == TYPE_MODE (complex_integer_type_node) && !unsignedp)
    2266                 :         11 :         return complex_integer_type_node;
    2267                 :            : 
    2268                 :         38 :       inner_mode = GET_MODE_INNER (mode);
    2269                 :         19 :       inner_type = c_common_type_for_mode (inner_mode, unsignedp);
    2270                 :         19 :       if (inner_type != NULL_TREE)
    2271                 :         19 :         return build_complex_type (inner_type);
    2272                 :            :     }
    2273                 :      16127 :   else if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL
    2274                 :      16127 :            && valid_vector_subparts_p (GET_MODE_NUNITS (mode)))
    2275                 :            :     {
    2276                 :          0 :       unsigned int elem_bits = vector_element_size (GET_MODE_BITSIZE (mode),
    2277                 :            :                                                     GET_MODE_NUNITS (mode));
    2278                 :          0 :       tree bool_type = build_nonstandard_boolean_type (elem_bits);
    2279                 :          0 :       return build_vector_type_for_mode (bool_type, mode);
    2280                 :            :     }
    2281                 :       9802 :   else if (VECTOR_MODE_P (mode)
    2282                 :      32254 :            && valid_vector_subparts_p (GET_MODE_NUNITS (mode)))
    2283                 :            :     {
    2284                 :      13404 :       machine_mode inner_mode = GET_MODE_INNER (mode);
    2285                 :       6702 :       tree inner_type = c_common_type_for_mode (inner_mode, unsignedp);
    2286                 :       6702 :       if (inner_type != NULL_TREE)
    2287                 :       6702 :         return build_vector_type_for_mode (inner_type, mode);
    2288                 :            :     }
    2289                 :            : 
    2290                 :       9425 :   if (dfloat32_type_node != NULL_TREE
    2291                 :       9425 :       && mode == TYPE_MODE (dfloat32_type_node))
    2292                 :       2836 :     return dfloat32_type_node;
    2293                 :       6589 :   if (dfloat64_type_node != NULL_TREE
    2294                 :       6589 :       && mode == TYPE_MODE (dfloat64_type_node))
    2295                 :       2972 :     return dfloat64_type_node;
    2296                 :       3617 :   if (dfloat128_type_node != NULL_TREE
    2297                 :       3617 :       && mode == TYPE_MODE (dfloat128_type_node))
    2298                 :       2674 :     return dfloat128_type_node;
    2299                 :            : 
    2300                 :        943 :   if (ALL_SCALAR_FIXED_POINT_MODE_P (mode))
    2301                 :            :     {
    2302                 :          0 :       if (mode == TYPE_MODE (short_fract_type_node))
    2303                 :          0 :         return unsignedp ? sat_short_fract_type_node : short_fract_type_node;
    2304                 :          0 :       if (mode == TYPE_MODE (fract_type_node))
    2305                 :          0 :         return unsignedp ? sat_fract_type_node : fract_type_node;
    2306                 :          0 :       if (mode == TYPE_MODE (long_fract_type_node))
    2307                 :          0 :         return unsignedp ? sat_long_fract_type_node : long_fract_type_node;
    2308                 :          0 :       if (mode == TYPE_MODE (long_long_fract_type_node))
    2309                 :          0 :         return unsignedp ? sat_long_long_fract_type_node
    2310                 :          0 :                          : long_long_fract_type_node;
    2311                 :            : 
    2312                 :          0 :       if (mode == TYPE_MODE (unsigned_short_fract_type_node))
    2313                 :          0 :         return unsignedp ? sat_unsigned_short_fract_type_node
    2314                 :          0 :                          : unsigned_short_fract_type_node;
    2315                 :          0 :       if (mode == TYPE_MODE (unsigned_fract_type_node))
    2316                 :          0 :         return unsignedp ? sat_unsigned_fract_type_node
    2317                 :          0 :                          : unsigned_fract_type_node;
    2318                 :          0 :       if (mode == TYPE_MODE (unsigned_long_fract_type_node))
    2319                 :          0 :         return unsignedp ? sat_unsigned_long_fract_type_node
    2320                 :          0 :                          : unsigned_long_fract_type_node;
    2321                 :          0 :       if (mode == TYPE_MODE (unsigned_long_long_fract_type_node))
    2322                 :          0 :         return unsignedp ? sat_unsigned_long_long_fract_type_node
    2323                 :          0 :                          : unsigned_long_long_fract_type_node;
    2324                 :            : 
    2325                 :          0 :       if (mode == TYPE_MODE (short_accum_type_node))
    2326                 :          0 :         return unsignedp ? sat_short_accum_type_node : short_accum_type_node;
    2327                 :          0 :       if (mode == TYPE_MODE (accum_type_node))
    2328                 :          0 :         return unsignedp ? sat_accum_type_node : accum_type_node;
    2329                 :          0 :       if (mode == TYPE_MODE (long_accum_type_node))
    2330                 :          0 :         return unsignedp ? sat_long_accum_type_node : long_accum_type_node;
    2331                 :          0 :       if (mode == TYPE_MODE (long_long_accum_type_node))
    2332                 :          0 :         return unsignedp ? sat_long_long_accum_type_node
    2333                 :          0 :                          : long_long_accum_type_node;
    2334                 :            : 
    2335                 :          0 :       if (mode == TYPE_MODE (unsigned_short_accum_type_node))
    2336                 :          0 :         return unsignedp ? sat_unsigned_short_accum_type_node
    2337                 :          0 :                          : unsigned_short_accum_type_node;
    2338                 :          0 :       if (mode == TYPE_MODE (unsigned_accum_type_node))
    2339                 :          0 :         return unsignedp ? sat_unsigned_accum_type_node
    2340                 :          0 :                          : unsigned_accum_type_node;
    2341                 :          0 :       if (mode == TYPE_MODE (unsigned_long_accum_type_node))
    2342                 :          0 :         return unsignedp ? sat_unsigned_long_accum_type_node
    2343                 :          0 :                          : unsigned_long_accum_type_node;
    2344                 :          0 :       if (mode == TYPE_MODE (unsigned_long_long_accum_type_node))
    2345                 :          0 :         return unsignedp ? sat_unsigned_long_long_accum_type_node
    2346                 :          0 :                          : unsigned_long_long_accum_type_node;
    2347                 :            : 
    2348                 :          0 :       if (mode == QQmode)
    2349                 :          0 :         return unsignedp ? sat_qq_type_node : qq_type_node;
    2350                 :          0 :       if (mode == HQmode)
    2351                 :          0 :         return unsignedp ? sat_hq_type_node : hq_type_node;
    2352                 :          0 :       if (mode == SQmode)
    2353                 :          0 :         return unsignedp ? sat_sq_type_node : sq_type_node;
    2354                 :          0 :       if (mode == DQmode)
    2355                 :          0 :         return unsignedp ? sat_dq_type_node : dq_type_node;
    2356                 :          0 :       if (mode == TQmode)
    2357                 :          0 :         return unsignedp ? sat_tq_type_node : tq_type_node;
    2358                 :            : 
    2359                 :          0 :       if (mode == UQQmode)
    2360                 :          0 :         return unsignedp ? sat_uqq_type_node : uqq_type_node;
    2361                 :          0 :       if (mode == UHQmode)
    2362                 :          0 :         return unsignedp ? sat_uhq_type_node : uhq_type_node;
    2363                 :          0 :       if (mode == USQmode)
    2364                 :          0 :         return unsignedp ? sat_usq_type_node : usq_type_node;
    2365                 :          0 :       if (mode == UDQmode)
    2366                 :          0 :         return unsignedp ? sat_udq_type_node : udq_type_node;
    2367                 :          0 :       if (mode == UTQmode)
    2368                 :          0 :         return unsignedp ? sat_utq_type_node : utq_type_node;
    2369                 :            : 
    2370                 :          0 :       if (mode == HAmode)
    2371                 :          0 :         return unsignedp ? sat_ha_type_node : ha_type_node;
    2372                 :          0 :       if (mode == SAmode)
    2373                 :          0 :         return unsignedp ? sat_sa_type_node : sa_type_node;
    2374                 :          0 :       if (mode == DAmode)
    2375                 :          0 :         return unsignedp ? sat_da_type_node : da_type_node;
    2376                 :          0 :       if (mode == TAmode)
    2377                 :          0 :         return unsignedp ? sat_ta_type_node : ta_type_node;
    2378                 :            : 
    2379                 :          0 :       if (mode == UHAmode)
    2380                 :          0 :         return unsignedp ? sat_uha_type_node : uha_type_node;
    2381                 :          0 :       if (mode == USAmode)
    2382                 :          0 :         return unsignedp ? sat_usa_type_node : usa_type_node;
    2383                 :          0 :       if (mode == UDAmode)
    2384                 :          0 :         return unsignedp ? sat_uda_type_node : uda_type_node;
    2385                 :          0 :       if (mode == UTAmode)
    2386                 :          0 :         return unsignedp ? sat_uta_type_node : uta_type_node;
    2387                 :            :     }
    2388                 :            : 
    2389                 :       2810 :   for (t = registered_builtin_types; t; t = TREE_CHAIN (t))
    2390                 :            :     {
    2391                 :       1886 :       tree type = TREE_VALUE (t);
    2392                 :       1886 :       if (TYPE_MODE (type) == mode
    2393                 :         38 :           && VECTOR_TYPE_P (type) == VECTOR_MODE_P (mode)
    2394                 :       1905 :           && !!unsignedp == !!TYPE_UNSIGNED (type))
    2395                 :         19 :         return type;
    2396                 :            :     }
    2397                 :            :   return NULL_TREE;
    2398                 :            : }
    2399                 :            : 
    2400                 :            : tree
    2401                 :     783940 : c_common_unsigned_type (tree type)
    2402                 :            : {
    2403                 :     783940 :   return c_common_signed_or_unsigned_type (1, type);
    2404                 :            : }
    2405                 :            : 
    2406                 :            : /* Return a signed type the same as TYPE in other respects.  */
    2407                 :            : 
    2408                 :            : tree
    2409                 :   19991400 : c_common_signed_type (tree type)
    2410                 :            : {
    2411                 :   19991400 :   return c_common_signed_or_unsigned_type (0, type);
    2412                 :            : }
    2413                 :            : 
    2414                 :            : /* Return a type the same as TYPE except unsigned or
    2415                 :            :    signed according to UNSIGNEDP.  */
    2416                 :            : 
    2417                 :            : tree
    2418                 :   21514700 : c_common_signed_or_unsigned_type (int unsignedp, tree type)
    2419                 :            : {
    2420                 :   21514700 :   tree type1;
    2421                 :   21514700 :   int i;
    2422                 :            : 
    2423                 :            :   /* This block of code emulates the behavior of the old
    2424                 :            :      c_common_unsigned_type. In particular, it returns
    2425                 :            :      long_unsigned_type_node if passed a long, even when a int would
    2426                 :            :      have the same size. This is necessary for warnings to work
    2427                 :            :      correctly in archs where sizeof(int) == sizeof(long) */
    2428                 :            : 
    2429                 :   21514700 :   type1 = TYPE_MAIN_VARIANT (type);
    2430                 :   21514700 :   if (type1 == signed_char_type_node || type1 == char_type_node || type1 == unsigned_char_type_node)
    2431                 :     731001 :     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
    2432                 :   20783700 :   if (type1 == integer_type_node || type1 == unsigned_type_node)
    2433                 :    7356560 :     return unsignedp ? unsigned_type_node : integer_type_node;
    2434                 :   13427200 :   if (type1 == short_integer_type_node || type1 == short_unsigned_type_node)
    2435                 :    1467870 :     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
    2436                 :   11959300 :   if (type1 == long_integer_type_node || type1 == long_unsigned_type_node)
    2437                 :    9116870 :     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
    2438                 :    2842440 :   if (type1 == long_long_integer_type_node || type1 == long_long_unsigned_type_node)
    2439                 :     999344 :     return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node;
    2440                 :            : 
    2441                 :    3628630 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    2442                 :    1843090 :     if (int_n_enabled_p[i]
    2443                 :    1674940 :         && (type1 == int_n_trees[i].unsigned_type
    2444                 :    1617710 :             || type1 == int_n_trees[i].signed_type))
    2445                 :      57556 :       return (unsignedp ? int_n_trees[i].unsigned_type
    2446                 :      57556 :               : int_n_trees[i].signed_type);
    2447                 :            : 
    2448                 :            : #if HOST_BITS_PER_WIDE_INT >= 64
    2449                 :    1785540 :   if (type1 == intTI_type_node || type1 == unsigned_intTI_type_node)
    2450                 :          0 :     return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
    2451                 :            : #endif
    2452                 :    1785540 :   if (type1 == intDI_type_node || type1 == unsigned_intDI_type_node)
    2453                 :          0 :     return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
    2454                 :    1785540 :   if (type1 == intSI_type_node || type1 == unsigned_intSI_type_node)
    2455                 :          0 :     return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
    2456                 :    1785540 :   if (type1 == intHI_type_node || type1 == unsigned_intHI_type_node)
    2457                 :          0 :     return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
    2458                 :    1785540 :   if (type1 == intQI_type_node || type1 == unsigned_intQI_type_node)
    2459                 :          0 :     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
    2460                 :            : 
    2461                 :            : #define C_COMMON_FIXED_TYPES(NAME)          \
    2462                 :            :   if (type1 == short_ ## NAME ## _type_node \
    2463                 :            :       || type1 == unsigned_short_ ## NAME ## _type_node) \
    2464                 :            :     return unsignedp ? unsigned_short_ ## NAME ## _type_node \
    2465                 :            :                      : short_ ## NAME ## _type_node; \
    2466                 :            :   if (type1 == NAME ## _type_node \
    2467                 :            :       || type1 == unsigned_ ## NAME ## _type_node) \
    2468                 :            :     return unsignedp ? unsigned_ ## NAME ## _type_node \
    2469                 :            :                      : NAME ## _type_node; \
    2470                 :            :   if (type1 == long_ ## NAME ## _type_node \
    2471                 :            :       || type1 == unsigned_long_ ## NAME ## _type_node) \
    2472                 :            :     return unsignedp ? unsigned_long_ ## NAME ## _type_node \
    2473                 :            :                      : long_ ## NAME ## _type_node; \
    2474                 :            :   if (type1 == long_long_ ## NAME ## _type_node \
    2475                 :            :       || type1 == unsigned_long_long_ ## NAME ## _type_node) \
    2476                 :            :     return unsignedp ? unsigned_long_long_ ## NAME ## _type_node \
    2477                 :            :                      : long_long_ ## NAME ## _type_node;
    2478                 :            : 
    2479                 :            : #define C_COMMON_FIXED_MODE_TYPES(NAME) \
    2480                 :            :   if (type1 == NAME ## _type_node \
    2481                 :            :       || type1 == u ## NAME ## _type_node) \
    2482                 :            :     return unsignedp ? u ## NAME ## _type_node \
    2483                 :            :                      : NAME ## _type_node;
    2484                 :            : 
    2485                 :            : #define C_COMMON_FIXED_TYPES_SAT(NAME) \
    2486                 :            :   if (type1 == sat_ ## short_ ## NAME ## _type_node \
    2487                 :            :       || type1 == sat_ ## unsigned_short_ ## NAME ## _type_node) \
    2488                 :            :     return unsignedp ? sat_ ## unsigned_short_ ## NAME ## _type_node \
    2489                 :            :                      : sat_ ## short_ ## NAME ## _type_node; \
    2490                 :            :   if (type1 == sat_ ## NAME ## _type_node \
    2491                 :            :       || type1 == sat_ ## unsigned_ ## NAME ## _type_node) \
    2492                 :            :     return unsignedp ? sat_ ## unsigned_ ## NAME ## _type_node \
    2493                 :            :                      : sat_ ## NAME ## _type_node; \
    2494                 :            :   if (type1 == sat_ ## long_ ## NAME ## _type_node \
    2495                 :            :       || type1 == sat_ ## unsigned_long_ ## NAME ## _type_node) \
    2496                 :            :     return unsignedp ? sat_ ## unsigned_long_ ## NAME ## _type_node \
    2497                 :            :                      : sat_ ## long_ ## NAME ## _type_node; \
    2498                 :            :   if (type1 == sat_ ## long_long_ ## NAME ## _type_node \
    2499                 :            :       || type1 == sat_ ## unsigned_long_long_ ## NAME ## _type_node) \
    2500                 :            :     return unsignedp ? sat_ ## unsigned_long_long_ ## NAME ## _type_node \
    2501                 :            :                      : sat_ ## long_long_ ## NAME ## _type_node;
    2502                 :            : 
    2503                 :            : #define C_COMMON_FIXED_MODE_TYPES_SAT(NAME)     \
    2504                 :            :   if (type1 == sat_ ## NAME ## _type_node \
    2505                 :            :       || type1 == sat_ ## u ## NAME ## _type_node) \
    2506                 :            :     return unsignedp ? sat_ ## u ## NAME ## _type_node \
    2507                 :            :                      : sat_ ## NAME ## _type_node;
    2508                 :            : 
    2509                 :    1785540 :   C_COMMON_FIXED_TYPES (fract);
    2510                 :    1785540 :   C_COMMON_FIXED_TYPES_SAT (fract);
    2511                 :    1785540 :   C_COMMON_FIXED_TYPES (accum);
    2512                 :    1785540 :   C_COMMON_FIXED_TYPES_SAT (accum);
    2513                 :            : 
    2514                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES (qq);
    2515                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES (hq);
    2516                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES (sq);
    2517                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES (dq);
    2518                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES (tq);
    2519                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES_SAT (qq);
    2520                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES_SAT (hq);
    2521                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES_SAT (sq);
    2522                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES_SAT (dq);
    2523                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES_SAT (tq);
    2524                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES (ha);
    2525                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES (sa);
    2526                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES (da);
    2527                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES (ta);
    2528                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES_SAT (ha);
    2529                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES_SAT (sa);
    2530                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES_SAT (da);
    2531                 :    1785540 :   C_COMMON_FIXED_MODE_TYPES_SAT (ta);
    2532                 :            : 
    2533                 :            :   /* For ENUMERAL_TYPEs in C++, must check the mode of the types, not
    2534                 :            :      the precision; they have precision set to match their range, but
    2535                 :            :      may use a wider mode to match an ABI.  If we change modes, we may
    2536                 :            :      wind up with bad conversions.  For INTEGER_TYPEs in C, must check
    2537                 :            :      the precision as well, so as to yield correct results for
    2538                 :            :      bit-field types.  C++ does not have these separate bit-field
    2539                 :            :      types, and producing a signed or unsigned variant of an
    2540                 :            :      ENUMERAL_TYPE may cause other problems as well.  */
    2541                 :            : 
    2542                 :    1785540 :   if (!INTEGRAL_TYPE_P (type)
    2543                 :    1785540 :       || TYPE_UNSIGNED (type) == unsignedp)
    2544                 :            :     return type;
    2545                 :            : 
    2546                 :            : #define TYPE_OK(node)                                                       \
    2547                 :            :   (TYPE_MODE (type) == TYPE_MODE (node)                                     \
    2548                 :            :    && TYPE_PRECISION (type) == TYPE_PRECISION (node))
    2549                 :    1402810 :   if (TYPE_OK (signed_char_type_node))
    2550                 :      11541 :     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
    2551                 :    1643730 :   if (TYPE_OK (integer_type_node))
    2552                 :     277105 :     return unsignedp ? unsigned_type_node : integer_type_node;
    2553                 :    1146740 :   if (TYPE_OK (short_integer_type_node))
    2554                 :      61672 :     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
    2555                 :    1974920 :   if (TYPE_OK (long_integer_type_node))
    2556                 :     955598 :     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
    2557                 :      70544 :   if (TYPE_OK (long_long_integer_type_node))
    2558                 :      10056 :     return (unsignedp ? long_long_unsigned_type_node
    2559                 :      10056 :             : long_long_integer_type_node);
    2560                 :            : 
    2561                 :      97688 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    2562                 :      49779 :     if (int_n_enabled_p[i]
    2563                 :      40177 :         && TYPE_MODE (type) == int_n_data[i].m
    2564                 :      51697 :         && TYPE_PRECISION (type) == int_n_data[i].bitsize)
    2565                 :       1870 :       return (unsignedp ? int_n_trees[i].unsigned_type
    2566                 :       1870 :               : int_n_trees[i].signed_type);
    2567                 :            : 
    2568                 :            : #if HOST_BITS_PER_WIDE_INT >= 64
    2569                 :      49267 :   if (TYPE_OK (intTI_type_node))
    2570                 :       1310 :     return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
    2571                 :            : #endif
    2572                 :      47252 :   if (TYPE_OK (intDI_type_node))
    2573                 :          0 :     return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
    2574                 :      59012 :   if (TYPE_OK (intSI_type_node))
    2575                 :          0 :     return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
    2576                 :      54563 :   if (TYPE_OK (intHI_type_node))
    2577                 :          0 :     return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
    2578                 :      72120 :   if (TYPE_OK (intQI_type_node))
    2579                 :          0 :     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
    2580                 :            : #undef TYPE_OK
    2581                 :            : 
    2582                 :      46599 :   return build_nonstandard_integer_type (TYPE_PRECISION (type), unsignedp);
    2583                 :            : }
    2584                 :            : 
    2585                 :            : /* Build a bit-field integer type for the given WIDTH and UNSIGNEDP.  */
    2586                 :            : 
    2587                 :            : tree
    2588                 :      34434 : c_build_bitfield_integer_type (unsigned HOST_WIDE_INT width, int unsignedp)
    2589                 :            : {
    2590                 :      34434 :   int i;
    2591                 :            : 
    2592                 :            :   /* Extended integer types of the same width as a standard type have
    2593                 :            :      lesser rank, so those of the same width as int promote to int or
    2594                 :            :      unsigned int and are valid for printf formats expecting int or
    2595                 :            :      unsigned int.  To avoid such special cases, avoid creating
    2596                 :            :      extended integer types for bit-fields if a standard integer type
    2597                 :            :      is available.  */
    2598                 :      34434 :   if (width == TYPE_PRECISION (integer_type_node))
    2599                 :        128 :     return unsignedp ? unsigned_type_node : integer_type_node;
    2600                 :      34306 :   if (width == TYPE_PRECISION (signed_char_type_node))
    2601                 :       1453 :     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
    2602                 :      32853 :   if (width == TYPE_PRECISION (short_integer_type_node))
    2603                 :       1232 :     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
    2604                 :      31621 :   if (width == TYPE_PRECISION (long_integer_type_node))
    2605                 :          0 :     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
    2606                 :      31621 :   if (width == TYPE_PRECISION (long_long_integer_type_node))
    2607                 :          0 :     return (unsignedp ? long_long_unsigned_type_node
    2608                 :          0 :             : long_long_integer_type_node);
    2609                 :      63242 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    2610                 :      31621 :     if (int_n_enabled_p[i]
    2611                 :      28221 :         && width == int_n_data[i].bitsize)
    2612                 :          0 :       return (unsignedp ? int_n_trees[i].unsigned_type
    2613                 :          0 :               : int_n_trees[i].signed_type);
    2614                 :      31621 :   return build_nonstandard_integer_type (width, unsignedp);
    2615                 :            : }
    2616                 :            : 
    2617                 :            : /* The C version of the register_builtin_type langhook.  */
    2618                 :            : 
    2619                 :            : void
    2620                 :     313672 : c_register_builtin_type (tree type, const char* name)
    2621                 :            : {
    2622                 :     313672 :   tree decl;
    2623                 :            : 
    2624                 :     313672 :   decl = build_decl (UNKNOWN_LOCATION,
    2625                 :            :                      TYPE_DECL, get_identifier (name), type);
    2626                 :     313672 :   DECL_ARTIFICIAL (decl) = 1;
    2627                 :     313672 :   if (!TYPE_NAME (type))
    2628                 :      78252 :     TYPE_NAME (type) = decl;
    2629                 :     313672 :   lang_hooks.decls.pushdecl (decl);
    2630                 :            : 
    2631                 :     313672 :   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
    2632                 :     313672 : }
    2633                 :            : 
    2634                 :            : /* Print an error message for invalid operands to arith operation
    2635                 :            :    CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
    2636                 :            :    RICHLOC is a rich location for the message, containing either
    2637                 :            :    three separate locations for each of the operator and operands
    2638                 :            : 
    2639                 :            :       lhs op rhs
    2640                 :            :       ~~~ ^~ ~~~
    2641                 :            : 
    2642                 :            :    (C FE), or one location ranging over all over them
    2643                 :            : 
    2644                 :            :       lhs op rhs
    2645                 :            :       ~~~~^~~~~~
    2646                 :            : 
    2647                 :            :    (C++ FE).  */
    2648                 :            : 
    2649                 :            : void
    2650                 :        969 : binary_op_error (rich_location *richloc, enum tree_code code,
    2651                 :            :                  tree type0, tree type1)
    2652                 :            : {
    2653                 :        969 :   const char *opname;
    2654                 :            : 
    2655                 :        969 :   switch (code)
    2656                 :            :     {
    2657                 :            :     case PLUS_EXPR:
    2658                 :            :       opname = "+"; break;
    2659                 :          7 :     case MINUS_EXPR:
    2660                 :          7 :       opname = "-"; break;
    2661                 :        805 :     case MULT_EXPR:
    2662                 :        805 :       opname = "*"; break;
    2663                 :          0 :     case MAX_EXPR:
    2664                 :          0 :       opname = "max"; break;
    2665                 :          0 :     case MIN_EXPR:
    2666                 :          0 :       opname = "min"; break;
    2667                 :          0 :     case EQ_EXPR:
    2668                 :          0 :       opname = "=="; break;
    2669                 :          0 :     case NE_EXPR:
    2670                 :          0 :       opname = "!="; break;
    2671                 :          0 :     case LE_EXPR:
    2672                 :          0 :       opname = "<="; break;
    2673                 :          0 :     case GE_EXPR:
    2674                 :          0 :       opname = ">="; break;
    2675                 :          0 :     case LT_EXPR:
    2676                 :          0 :       opname = "<"; break;
    2677                 :          0 :     case GT_EXPR:
    2678                 :          0 :       opname = ">"; break;
    2679                 :         23 :     case LSHIFT_EXPR:
    2680                 :         23 :       opname = "<<"; break;
    2681                 :         18 :     case RSHIFT_EXPR:
    2682                 :         18 :       opname = ">>"; break;
    2683                 :          3 :     case TRUNC_MOD_EXPR:
    2684                 :          3 :     case FLOOR_MOD_EXPR:
    2685                 :          3 :       opname = "%"; break;
    2686                 :          6 :     case TRUNC_DIV_EXPR:
    2687                 :          6 :     case FLOOR_DIV_EXPR:
    2688                 :          6 :       opname = "/"; break;
    2689                 :         40 :     case BIT_AND_EXPR:
    2690                 :         40 :       opname = "&"; break;
    2691                 :         21 :     case BIT_IOR_EXPR:
    2692                 :         21 :       opname = "|"; break;
    2693                 :          0 :     case TRUTH_ANDIF_EXPR:
    2694                 :          0 :       opname = "&&"; break;
    2695                 :          0 :     case TRUTH_ORIF_EXPR:
    2696                 :          0 :       opname = "||"; break;
    2697                 :         21 :     case BIT_XOR_EXPR:
    2698                 :         21 :       opname = "^"; break;
    2699                 :          0 :     default:
    2700                 :          0 :       gcc_unreachable ();
    2701                 :            :     }
    2702                 :        969 :   error_at (richloc,
    2703                 :            :             "invalid operands to binary %s (have %qT and %qT)",
    2704                 :            :             opname, type0, type1);
    2705                 :        969 : }
    2706                 :            : 
    2707                 :            : /* Given an expression as a tree, return its original type.  Do this
    2708                 :            :    by stripping any conversion that preserves the sign and precision.  */
    2709                 :            : static tree
    2710                 :      35767 : expr_original_type (tree expr)
    2711                 :            : {
    2712                 :      35767 :   STRIP_SIGN_NOPS (expr);
    2713                 :      35767 :   return TREE_TYPE (expr);
    2714                 :            : }
    2715                 :            : 
    2716                 :            : /* Subroutine of build_binary_op, used for comparison operations.
    2717                 :            :    See if the operands have both been converted from subword integer types
    2718                 :            :    and, if so, perhaps change them both back to their original type.
    2719                 :            :    This function is also responsible for converting the two operands
    2720                 :            :    to the proper common type for comparison.
    2721                 :            : 
    2722                 :            :    The arguments of this function are all pointers to local variables
    2723                 :            :    of build_binary_op: OP0_PTR is &OP0, OP1_PTR is &OP1,
    2724                 :            :    RESTYPE_PTR is &RESULT_TYPE and RESCODE_PTR is &RESULTCODE.
    2725                 :            : 
    2726                 :            :    LOC is the location of the comparison.
    2727                 :            : 
    2728                 :            :    If this function returns non-NULL_TREE, it means that the comparison has
    2729                 :            :    a constant value.  What this function returns is an expression for
    2730                 :            :    that value.  */
    2731                 :            : 
    2732                 :            : tree
    2733                 :    4769990 : shorten_compare (location_t loc, tree *op0_ptr, tree *op1_ptr,
    2734                 :            :                  tree *restype_ptr, enum tree_code *rescode_ptr)
    2735                 :            : {
    2736                 :    4769990 :   tree type;
    2737                 :    4769990 :   tree op0 = *op0_ptr;
    2738                 :    4769990 :   tree op1 = *op1_ptr;
    2739                 :    4769990 :   int unsignedp0, unsignedp1;
    2740                 :    4769990 :   int real1, real2;
    2741                 :    4769990 :   tree primop0, primop1;
    2742                 :    4769990 :   enum tree_code code = *rescode_ptr;
    2743                 :            : 
    2744                 :            :   /* Throw away any conversions to wider types
    2745                 :            :      already present in the operands.  */
    2746                 :            : 
    2747                 :    4769990 :   primop0 = c_common_get_narrower (op0, &unsignedp0);
    2748                 :    4769990 :   primop1 = c_common_get_narrower (op1, &unsignedp1);
    2749                 :            : 
    2750                 :            :   /* If primopN is first sign-extended from primopN's precision to opN's
    2751                 :            :      precision, then zero-extended from opN's precision to
    2752                 :            :      *restype_ptr precision, shortenings might be invalid.  */
    2753                 :    4769990 :   if (TYPE_PRECISION (TREE_TYPE (primop0)) < TYPE_PRECISION (TREE_TYPE (op0))
    2754                 :     290711 :       && TYPE_PRECISION (TREE_TYPE (op0)) < TYPE_PRECISION (*restype_ptr)
    2755                 :        540 :       && !unsignedp0
    2756                 :    4770300 :       && TYPE_UNSIGNED (TREE_TYPE (op0)))
    2757                 :            :     primop0 = op0;
    2758                 :    4769990 :   if (TYPE_PRECISION (TREE_TYPE (primop1)) < TYPE_PRECISION (TREE_TYPE (op1))
    2759                 :     355464 :       && TYPE_PRECISION (TREE_TYPE (op1)) < TYPE_PRECISION (*restype_ptr)
    2760                 :       1307 :       && !unsignedp1
    2761                 :    4771200 :       && TYPE_UNSIGNED (TREE_TYPE (op1)))
    2762                 :            :     primop1 = op1;
    2763                 :            : 
    2764                 :            :   /* Handle the case that OP0 does not *contain* a conversion
    2765                 :            :      but it *requires* conversion to FINAL_TYPE.  */
    2766                 :            : 
    2767                 :    4769990 :   if (op0 == primop0 && TREE_TYPE (op0) != *restype_ptr)
    2768                 :     436099 :     unsignedp0 = TYPE_UNSIGNED (TREE_TYPE (op0));
    2769                 :    4769990 :   if (op1 == primop1 && TREE_TYPE (op1) != *restype_ptr)
    2770                 :    1135170 :     unsignedp1 = TYPE_UNSIGNED (TREE_TYPE (op1));
    2771                 :            : 
    2772                 :            :   /* If one of the operands must be floated, we cannot optimize.  */
    2773                 :    4769990 :   real1 = TREE_CODE (TREE_TYPE (primop0)) == REAL_TYPE;
    2774                 :    4769990 :   real2 = TREE_CODE (TREE_TYPE (primop1)) == REAL_TYPE;
    2775                 :            : 
    2776                 :            :   /* If first arg is constant, swap the args (changing operation
    2777                 :            :      so value is preserved), for canonicalization.  Don't do this if
    2778                 :            :      the second arg is 0.  */
    2779                 :            : 
    2780                 :    4769990 :   if (TREE_CONSTANT (primop0)
    2781                 :     830000 :       && !integer_zerop (primop1) && !real_zerop (primop1)
    2782                 :    5349710 :       && !fixed_zerop (primop1))
    2783                 :            :     {
    2784                 :     579723 :       std::swap (primop0, primop1);
    2785                 :     579723 :       std::swap (op0, op1);
    2786                 :     579723 :       *op0_ptr = op0;
    2787                 :     579723 :       *op1_ptr = op1;
    2788                 :     579723 :       std::swap (unsignedp0, unsignedp1);
    2789                 :     579723 :       std::swap (real1, real2);
    2790                 :            : 
    2791                 :     579723 :       switch (code)
    2792                 :            :         {
    2793                 :            :         case LT_EXPR:
    2794                 :            :           code = GT_EXPR;
    2795                 :            :           break;
    2796                 :            :         case GT_EXPR:
    2797                 :            :           code = LT_EXPR;
    2798                 :            :           break;
    2799                 :            :         case LE_EXPR:
    2800                 :            :           code = GE_EXPR;
    2801                 :            :           break;
    2802                 :            :         case GE_EXPR:
    2803                 :            :           code = LE_EXPR;
    2804                 :            :           break;
    2805                 :            :         default:
    2806                 :            :           break;
    2807                 :            :         }
    2808                 :     579723 :       *rescode_ptr = code;
    2809                 :            :     }
    2810                 :            : 
    2811                 :            :   /* If comparing an integer against a constant more bits wide,
    2812                 :            :      maybe we can deduce a value of 1 or 0 independent of the data.
    2813                 :            :      Or else truncate the constant now
    2814                 :            :      rather than extend the variable at run time.
    2815                 :            : 
    2816                 :            :      This is only interesting if the constant is the wider arg.
    2817                 :            :      Also, it is not safe if the constant is unsigned and the
    2818                 :            :      variable arg is signed, since in this case the variable
    2819                 :            :      would be sign-extended and then regarded as unsigned.
    2820                 :            :      Our technique fails in this case because the lowest/highest
    2821                 :            :      possible unsigned results don't follow naturally from the
    2822                 :            :      lowest/highest possible values of the variable operand.
    2823                 :            :      For just EQ_EXPR and NE_EXPR there is another technique that
    2824                 :            :      could be used: see if the constant can be faithfully represented
    2825                 :            :      in the other operand's type, by truncating it and reextending it
    2826                 :            :      and see if that preserves the constant's value.  */
    2827                 :            : 
    2828                 :    4180610 :   if (!real1 && !real2
    2829                 :    4175880 :       && TREE_CODE (TREE_TYPE (primop0)) != FIXED_POINT_TYPE
    2830                 :    4175880 :       && TREE_CODE (primop1) == INTEGER_CST
    2831                 :    7594880 :       && TYPE_PRECISION (TREE_TYPE (primop0)) < TYPE_PRECISION (*restype_ptr))
    2832                 :            :     {
    2833                 :     326483 :       int min_gt, max_gt, min_lt, max_lt;
    2834                 :     326483 :       tree maxval, minval;
    2835                 :            :       /* 1 if comparison is nominally unsigned.  */
    2836                 :     326483 :       int unsignedp = TYPE_UNSIGNED (*restype_ptr);
    2837                 :     326483 :       tree val;
    2838                 :            : 
    2839                 :     652966 :       type = c_common_signed_or_unsigned_type (unsignedp0,
    2840                 :     326483 :                                                TREE_TYPE (primop0));
    2841                 :            : 
    2842                 :     326483 :       maxval = TYPE_MAX_VALUE (type);
    2843                 :     326483 :       minval = TYPE_MIN_VALUE (type);
    2844                 :            : 
    2845                 :     326483 :       if (unsignedp && !unsignedp0)
    2846                 :     119956 :         *restype_ptr = c_common_signed_type (*restype_ptr);
    2847                 :            : 
    2848                 :     326483 :       if (TREE_TYPE (primop1) != *restype_ptr)
    2849                 :            :         {
    2850                 :            :           /* Convert primop1 to target type, but do not introduce
    2851                 :            :              additional overflow.  We know primop1 is an int_cst.  */
    2852                 :     120075 :           primop1 = force_fit_type (*restype_ptr,
    2853                 :            :                                     wi::to_wide
    2854                 :     120075 :                                      (primop1,
    2855                 :     120075 :                                       TYPE_PRECISION (*restype_ptr)),
    2856                 :     120075 :                                     0, TREE_OVERFLOW (primop1));
    2857                 :            :         }
    2858                 :     326483 :       if (type != *restype_ptr)
    2859                 :            :         {
    2860                 :     326483 :           minval = convert (*restype_ptr, minval);
    2861                 :     326483 :           maxval = convert (*restype_ptr, maxval);
    2862                 :            :         }
    2863                 :            : 
    2864                 :     326483 :       min_gt = tree_int_cst_lt (primop1, minval);
    2865                 :     326483 :       max_gt = tree_int_cst_lt (primop1, maxval);
    2866                 :     326483 :       min_lt = tree_int_cst_lt (minval, primop1);
    2867                 :     326483 :       max_lt = tree_int_cst_lt (maxval, primop1);
    2868                 :            : 
    2869                 :     326483 :       val = 0;
    2870                 :            :       /* This used to be a switch, but Genix compiler can't handle that.  */
    2871                 :     326483 :       if (code == NE_EXPR)
    2872                 :            :         {
    2873                 :     106510 :           if (max_lt || min_gt)
    2874                 :         12 :             val = truthvalue_true_node;
    2875                 :            :         }
    2876                 :     219973 :       else if (code == EQ_EXPR)
    2877                 :            :         {
    2878                 :      94340 :           if (max_lt || min_gt)
    2879                 :         16 :             val = truthvalue_false_node;
    2880                 :            :         }
    2881                 :     125633 :       else if (code == LT_EXPR)
    2882                 :            :         {
    2883                 :      89610 :           if (max_lt)
    2884                 :         19 :             val = truthvalue_true_node;
    2885                 :      89610 :           if (!min_lt)
    2886                 :        114 :             val = truthvalue_false_node;
    2887                 :            :         }
    2888                 :      36023 :       else if (code == GT_EXPR)
    2889                 :            :         {
    2890                 :       6523 :           if (min_gt)
    2891                 :          8 :             val = truthvalue_true_node;
    2892                 :       6523 :           if (!max_gt)
    2893                 :          6 :             val = truthvalue_false_node;
    2894                 :            :         }
    2895                 :      29500 :       else if (code == LE_EXPR)
    2896                 :            :         {
    2897                 :      15133 :           if (!max_gt)
    2898                 :         92 :             val = truthvalue_true_node;
    2899                 :      15133 :           if (min_gt)
    2900                 :          7 :             val = truthvalue_false_node;
    2901                 :            :         }
    2902                 :      14367 :       else if (code == GE_EXPR)
    2903                 :            :         {
    2904                 :      14366 :           if (!min_lt)
    2905                 :        144 :             val = truthvalue_true_node;
    2906                 :      14366 :           if (max_lt)
    2907                 :       8486 :             val = truthvalue_false_node;
    2908                 :            :         }
    2909                 :            : 
    2910                 :            :       /* If primop0 was sign-extended and unsigned comparison specd,
    2911                 :            :          we did a signed comparison above using the signed type bounds.
    2912                 :            :          But the comparison we output must be unsigned.
    2913                 :            : 
    2914                 :            :          Also, for inequalities, VAL is no good; but if the signed
    2915                 :            :          comparison had *any* fixed result, it follows that the
    2916                 :            :          unsigned comparison just tests the sign in reverse
    2917                 :            :          (positive values are LE, negative ones GE).
    2918                 :            :          So we can generate an unsigned comparison
    2919                 :            :          against an extreme value of the signed type.  */
    2920                 :            : 
    2921                 :     326483 :       if (unsignedp && !unsignedp0)
    2922                 :            :         {
    2923                 :     119956 :           if (val != 0)
    2924                 :         76 :             switch (code)
    2925                 :            :               {
    2926                 :         45 :               case LT_EXPR:
    2927                 :         45 :               case GE_EXPR:
    2928                 :         45 :                 primop1 = TYPE_MIN_VALUE (type);
    2929                 :         45 :                 val = 0;
    2930                 :         45 :                 break;
    2931                 :            : 
    2932                 :         30 :               case LE_EXPR:
    2933                 :         30 :               case GT_EXPR:
    2934                 :         30 :                 primop1 = TYPE_MAX_VALUE (type);
    2935                 :         30 :                 val = 0;
    2936                 :         30 :                 break;
    2937                 :            : 
    2938                 :            :               default:
    2939                 :            :                 break;
    2940                 :            :               }
    2941                 :     119956 :           type = c_common_unsigned_type (type);
    2942                 :            :         }
    2943                 :            : 
    2944                 :     326483 :       if (TREE_CODE (primop0) != INTEGER_CST
    2945                 :            :           /* Don't warn if it's from a (non-system) macro.  */
    2946                 :     326483 :           && !(from_macro_expansion_at
    2947                 :     240223 :                (expansion_point_location_if_in_system_header
    2948                 :     240223 :                 (EXPR_LOCATION (primop0)))))
    2949                 :            :         {
    2950                 :     207084 :           if (val == truthvalue_false_node)
    2951                 :        127 :             warning_at (loc, OPT_Wtype_limits,
    2952                 :            :                         "comparison is always false due to limited range of data type");
    2953                 :     207084 :           if (val == truthvalue_true_node)
    2954                 :        192 :             warning_at (loc, OPT_Wtype_limits,
    2955                 :            :                         "comparison is always true due to limited range of data type");
    2956                 :            :         }
    2957                 :            : 
    2958                 :     326483 :       if (val != 0)
    2959                 :            :         {
    2960                 :            :           /* Don't forget to evaluate PRIMOP0 if it has side effects.  */
    2961                 :       8829 :           if (TREE_SIDE_EFFECTS (primop0))
    2962                 :          2 :             return build2 (COMPOUND_EXPR, TREE_TYPE (val), primop0, val);
    2963                 :            :           return val;
    2964                 :            :         }
    2965                 :            : 
    2966                 :            :       /* Value is not predetermined, but do the comparison
    2967                 :            :          in the type of the operand that is not constant.
    2968                 :            :          TYPE is already properly set.  */
    2969                 :            :     }
    2970                 :            : 
    2971                 :            :   /* If either arg is decimal float and the other is float, find the
    2972                 :            :      proper common type to use for comparison.  */
    2973                 :     589378 :   else if (real1 && real2
    2974                 :     564354 :            && DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (primop0)))
    2975                 :    4461880 :            && DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (primop1))))
    2976                 :      18378 :     type = common_type (TREE_TYPE (primop0), TREE_TYPE (primop1));
    2977                 :            : 
    2978                 :            :   /* If either arg is decimal float and the other is float, fail.  */
    2979                 :     571000 :   else if (real1 && real2
    2980                 :    4971100 :            && (DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (primop0)))
    2981                 :     545976 :                || DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (primop1)))))
    2982                 :          0 :     return NULL_TREE;
    2983                 :            : 
    2984                 :     571000 :   else if (real1 && real2
    2985                 :    4971100 :            && (TYPE_PRECISION (TREE_TYPE (primop0))
    2986                 :     545976 :                == TYPE_PRECISION (TREE_TYPE (primop1))))
    2987                 :    4725390 :     type = TREE_TYPE (primop0);
    2988                 :            : 
    2989                 :            :   /* If args' natural types are both narrower than nominal type
    2990                 :            :      and both extend in the same manner, compare them
    2991                 :            :      in the type of the wider arg.
    2992                 :            :      Otherwise must actually extend both to the nominal
    2993                 :            :      common type lest different ways of extending
    2994                 :            :      alter the result.
    2995                 :            :      (eg, (short)-1 == (unsigned short)-1  should be 0.)  */
    2996                 :            : 
    2997                 :    3637730 :   else if (unsignedp0 == unsignedp1 && real1 == real2
    2998                 :    3611240 :            && TYPE_PRECISION (TREE_TYPE (primop0)) < TYPE_PRECISION (*restype_ptr)
    2999                 :    4148850 :            && TYPE_PRECISION (TREE_TYPE (primop1)) < TYPE_PRECISION (*restype_ptr))
    3000                 :            :     {
    3001                 :     130069 :       type = common_type (TREE_TYPE (primop0), TREE_TYPE (primop1));
    3002                 :     130069 :       type = c_common_signed_or_unsigned_type (unsignedp0
    3003                 :     130069 :                                                || TYPE_UNSIGNED (*restype_ptr),
    3004                 :            :                                                type);
    3005                 :            :       /* Make sure shorter operand is extended the right way
    3006                 :            :          to match the longer operand.  */
    3007                 :     130069 :       primop0
    3008                 :     130069 :         = convert (c_common_signed_or_unsigned_type (unsignedp0,
    3009                 :     130069 :                                                      TREE_TYPE (primop0)),
    3010                 :            :                    primop0);
    3011                 :     130069 :       primop1
    3012                 :     130069 :         = convert (c_common_signed_or_unsigned_type (unsignedp1,
    3013                 :     130069 :                                                      TREE_TYPE (primop1)),
    3014                 :            :                    primop1);
    3015                 :            :     }
    3016                 :            :   else
    3017                 :            :     {
    3018                 :            :       /* Here we must do the comparison on the nominal type
    3019                 :            :          using the args exactly as we received them.  */
    3020                 :    3825660 :       type = *restype_ptr;
    3021                 :    3825660 :       primop0 = op0;
    3022                 :    3825660 :       primop1 = op1;
    3023                 :            : 
    3024                 :            :       /* We want to fold unsigned comparisons of >= and < against zero.
    3025                 :            :          For these, we may also issue a warning if we have a non-constant
    3026                 :            :          compared against zero, where the zero was spelled as "0" (rather
    3027                 :            :          than merely folding to it).
    3028                 :            :          If we have at least one constant, then op1 is constant
    3029                 :            :          and we may have a non-constant expression as op0.  */
    3030                 :    3724060 :       if (!real1 && !real2 && integer_zerop (primop1)
    3031                 :    5270710 :           && TYPE_UNSIGNED (*restype_ptr))
    3032                 :            :         {
    3033                 :     353676 :           tree value = NULL_TREE;
    3034                 :            :           /* All unsigned values are >= 0, so we warn.  However,
    3035                 :            :              if OP0 is a constant that is >= 0, the signedness of
    3036                 :            :              the comparison isn't an issue, so suppress the
    3037                 :            :              warning.  */
    3038                 :     353676 :           tree folded_op0 = fold_for_warn (op0);
    3039                 :     353676 :           bool warn = 
    3040                 :      49558 :             warn_type_limits && !in_system_header_at (loc)
    3041                 :      43123 :             && !(TREE_CODE (folded_op0) == INTEGER_CST
    3042                 :       7356 :                  && !TREE_OVERFLOW (convert (c_common_signed_type (type),
    3043                 :            :                                              folded_op0)))
    3044                 :            :             /* Do not warn for enumeration types.  */
    3045                 :     389443 :             && (TREE_CODE (expr_original_type (folded_op0)) != ENUMERAL_TYPE);
    3046                 :            :           
    3047                 :     353676 :           switch (code)
    3048                 :            :             {
    3049                 :       2213 :             case GE_EXPR:
    3050                 :       2213 :               if (warn)
    3051                 :         68 :                 warning_at (loc, OPT_Wtype_limits,
    3052                 :            :                             "comparison of unsigned expression in %<>= 0%> "
    3053                 :            :                             "is always true");
    3054                 :       2213 :               value = truthvalue_true_node;
    3055                 :       2213 :               break;
    3056                 :            : 
    3057                 :      33557 :             case LT_EXPR:
    3058                 :      33557 :               if (warn)
    3059                 :         67 :                 warning_at (loc, OPT_Wtype_limits,
    3060                 :            :                             "comparison of unsigned expression in %<< 0%> "
    3061                 :            :                             "is always false");
    3062                 :      33557 :               value = truthvalue_false_node;
    3063                 :      33557 :               break;
    3064                 :            : 
    3065                 :            :             default:
    3066                 :            :               break;
    3067                 :            :             }
    3068                 :            : 
    3069                 :      35770 :           if (value != NULL_TREE)
    3070                 :            :             {
    3071                 :            :               /* Don't forget to evaluate PRIMOP0 if it has side effects.  */
    3072                 :      35770 :               if (TREE_SIDE_EFFECTS (primop0))
    3073                 :         19 :                 return build2 (COMPOUND_EXPR, TREE_TYPE (value),
    3074                 :         19 :                                primop0, value);
    3075                 :            :               return value;
    3076                 :            :             }
    3077                 :            :         }
    3078                 :            :     }
    3079                 :            : 
    3080                 :    4725390 :   *op0_ptr = convert (type, primop0);
    3081                 :    4725390 :   *op1_ptr = convert (type, primop1);
    3082                 :            : 
    3083                 :    4725390 :   *restype_ptr = truthvalue_type_node;
    3084                 :            : 
    3085                 :    4725390 :   return NULL_TREE;
    3086                 :            : }
    3087                 :            : 
    3088                 :            : /* Return a tree for the sum or difference (RESULTCODE says which)
    3089                 :            :    of pointer PTROP and integer INTOP.  */
    3090                 :            : 
    3091                 :            : tree
    3092                 :    1612640 : pointer_int_sum (location_t loc, enum tree_code resultcode,
    3093                 :            :                  tree ptrop, tree intop, bool complain)
    3094                 :            : {
    3095                 :    1612640 :   tree size_exp, ret;
    3096                 :            : 
    3097                 :            :   /* The result is a pointer of the same type that is being added.  */
    3098                 :    1612640 :   tree result_type = TREE_TYPE (ptrop);
    3099                 :            : 
    3100                 :    1612640 :   if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)
    3101                 :            :     {
    3102                 :       1055 :       if (complain && warn_pointer_arith)
    3103                 :         66 :         pedwarn (loc, OPT_Wpointer_arith,
    3104                 :            :                  "pointer of type %<void *%> used in arithmetic");
    3105                 :        989 :       else if (!complain)
    3106                 :          6 :         return error_mark_node;
    3107                 :       1049 :       size_exp = integer_one_node;
    3108                 :            :     }
    3109                 :    1611590 :   else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE)
    3110                 :            :     {
    3111                 :        124 :       if (complain && warn_pointer_arith)
    3112                 :         50 :         pedwarn (loc, OPT_Wpointer_arith,
    3113                 :            :                  "pointer to a function used in arithmetic");
    3114                 :         74 :       else if (!complain)
    3115                 :          0 :         return error_mark_node;
    3116                 :        124 :       size_exp = integer_one_node;
    3117                 :            :     }
    3118                 :    1611460 :   else if (!verify_type_context (loc, TCTX_POINTER_ARITH,
    3119                 :    1611460 :                                  TREE_TYPE (result_type)))
    3120                 :          0 :     size_exp = integer_one_node;
    3121                 :            :   else
    3122                 :    1611460 :     size_exp = size_in_bytes_loc (loc, TREE_TYPE (result_type));
    3123                 :            : 
    3124                 :            :   /* We are manipulating pointer values, so we don't need to warn
    3125                 :            :      about relying on undefined signed overflow.  We disable the
    3126                 :            :      warning here because we use integer types so fold won't know that
    3127                 :            :      they are really pointers.  */
    3128                 :    1612640 :   fold_defer_overflow_warnings ();
    3129                 :            : 
    3130                 :            :   /* If what we are about to multiply by the size of the elements
    3131                 :            :      contains a constant term, apply distributive law
    3132                 :            :      and multiply that constant term separately.
    3133                 :            :      This helps produce common subexpressions.  */
    3134                 :    1612640 :   if ((TREE_CODE (intop) == PLUS_EXPR || TREE_CODE (intop) == MINUS_EXPR)
    3135                 :      71979 :       && !TREE_CONSTANT (intop)
    3136                 :      71883 :       && TREE_CONSTANT (TREE_OPERAND (intop, 1))
    3137                 :      41600 :       && TREE_CONSTANT (size_exp)
    3138                 :            :       /* If the constant comes from pointer subtraction,
    3139                 :            :          skip this optimization--it would cause an error.  */
    3140                 :      41600 :       && TREE_CODE (TREE_TYPE (TREE_OPERAND (intop, 0))) == INTEGER_TYPE
    3141                 :            :       /* If the constant is unsigned, and smaller than the pointer size,
    3142                 :            :          then we must skip this optimization.  This is because it could cause
    3143                 :            :          an overflow error if the constant is negative but INTOP is not.  */
    3144                 :    1654240 :       && (!TYPE_UNSIGNED (TREE_TYPE (intop))
    3145                 :      27500 :           || (TYPE_PRECISION (TREE_TYPE (intop))
    3146                 :      27500 :               == TYPE_PRECISION (TREE_TYPE (ptrop)))))
    3147                 :            :     {
    3148                 :      17141 :       enum tree_code subcode = resultcode;
    3149                 :      17141 :       tree int_type = TREE_TYPE (intop);
    3150                 :      17141 :       if (TREE_CODE (intop) == MINUS_EXPR)
    3151                 :      12317 :         subcode = (subcode == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR);
    3152                 :            :       /* Convert both subexpression types to the type of intop,
    3153                 :            :          because weird cases involving pointer arithmetic
    3154                 :            :          can result in a sum or difference with different type args.  */
    3155                 :      17141 :       ptrop = build_binary_op (EXPR_LOCATION (TREE_OPERAND (intop, 1)),
    3156                 :            :                                subcode, ptrop,
    3157                 :      17141 :                                convert (int_type, TREE_OPERAND (intop, 1)),
    3158                 :            :                                true);
    3159                 :      17141 :       intop = convert (int_type, TREE_OPERAND (intop, 0));
    3160                 :            :     }
    3161                 :            : 
    3162                 :            :   /* Convert the integer argument to a type the same size as sizetype
    3163                 :            :      so the multiply won't overflow spuriously.  */
    3164                 :    1612640 :   if (TYPE_PRECISION (TREE_TYPE (intop)) != TYPE_PRECISION (sizetype)
    3165                 :    1612640 :       || TYPE_UNSIGNED (TREE_TYPE (intop)) != TYPE_UNSIGNED (sizetype))
    3166                 :    1348450 :     intop = convert (c_common_type_for_size (TYPE_PRECISION (sizetype),
    3167                 :    1348450 :                                              TYPE_UNSIGNED (sizetype)), intop);
    3168                 :            : 
    3169                 :            :   /* Replace the integer argument with a suitable product by the object size.
    3170                 :            :      Do this multiplication as signed, then convert to the appropriate type
    3171                 :            :      for the pointer operation and disregard an overflow that occurred only
    3172                 :            :      because of the sign-extension change in the latter conversion.  */
    3173                 :    1612640 :   {
    3174                 :    3225270 :     tree t = fold_build2_loc (loc, MULT_EXPR, TREE_TYPE (intop), intop,
    3175                 :    1612640 :                               convert (TREE_TYPE (intop), size_exp));
    3176                 :    1612640 :     intop = convert (sizetype, t);
    3177                 :    1612640 :     if (TREE_OVERFLOW_P (intop) && !TREE_OVERFLOW (t))
    3178                 :          0 :       intop = wide_int_to_tree (TREE_TYPE (intop), wi::to_wide (intop));
    3179                 :            :   }
    3180                 :            : 
    3181                 :            :   /* Create the sum or difference.  */
    3182                 :    1612640 :   if (resultcode == MINUS_EXPR)
    3183                 :      43305 :     intop = fold_build1_loc (loc, NEGATE_EXPR, sizetype, intop);
    3184                 :            : 
    3185                 :    1612640 :   ret = fold_build_pointer_plus_loc (loc, ptrop, intop);
    3186                 :            : 
    3187                 :    1612640 :   fold_undefer_and_ignore_overflow_warnings ();
    3188                 :            : 
    3189                 :    1612640 :   return ret;
    3190                 :            : }
    3191                 :            : 
    3192                 :            : /* Wrap a C_MAYBE_CONST_EXPR around an expression that is fully folded
    3193                 :            :    and if NON_CONST is known not to be permitted in an evaluated part
    3194                 :            :    of a constant expression.  */
    3195                 :            : 
    3196                 :            : tree
    3197                 :    2514140 : c_wrap_maybe_const (tree expr, bool non_const)
    3198                 :            : {
    3199                 :    2514140 :   bool nowarning = TREE_NO_WARNING (expr);
    3200                 :    2514140 :   location_t loc = EXPR_LOCATION (expr);
    3201                 :            : 
    3202                 :            :   /* This should never be called for C++.  */
    3203                 :    2514140 :   if (c_dialect_cxx ())
    3204                 :          0 :     gcc_unreachable ();
    3205                 :            : 
    3206                 :            :   /* The result of folding may have a NOP_EXPR to set TREE_NO_WARNING.  */
    3207                 :    3025450 :   STRIP_TYPE_NOPS (expr);
    3208                 :    2514140 :   expr = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (expr), NULL, expr);
    3209                 :    2514140 :   C_MAYBE_CONST_EXPR_NON_CONST (expr) = non_const;
    3210                 :    2514140 :   if (nowarning)
    3211                 :       7917 :     TREE_NO_WARNING (expr) = 1;
    3212                 :    2514140 :   protected_set_expr_location (expr, loc);
    3213                 :            : 
    3214                 :    2514140 :   return expr;
    3215                 :            : }
    3216                 :            : 
    3217                 :            : /* Return whether EXPR is a declaration whose address can never be
    3218                 :            :    NULL.  */
    3219                 :            : 
    3220                 :            : bool
    3221                 :       1331 : decl_with_nonnull_addr_p (const_tree expr)
    3222                 :            : {
    3223                 :       1331 :   return (DECL_P (expr)
    3224                 :       1331 :           && (TREE_CODE (expr) == PARM_DECL
    3225                 :        948 :               || TREE_CODE (expr) == LABEL_DECL
    3226                 :        874 :               || !DECL_WEAK (expr)));
    3227                 :            : }
    3228                 :            : 
    3229                 :            : /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
    3230                 :            :    or for an `if' or `while' statement or ?..: exp.  It should already
    3231                 :            :    have been validated to be of suitable type; otherwise, a bad
    3232                 :            :    diagnostic may result.
    3233                 :            : 
    3234                 :            :    The EXPR is located at LOCATION.
    3235                 :            : 
    3236                 :            :    This preparation consists of taking the ordinary
    3237                 :            :    representation of an expression expr and producing a valid tree
    3238                 :            :    boolean expression describing whether expr is nonzero.  We could
    3239                 :            :    simply always do build_binary_op (NE_EXPR, expr, truthvalue_false_node, 1),
    3240                 :            :    but we optimize comparisons, &&, ||, and !.
    3241                 :            : 
    3242                 :            :    The resulting type should always be `truthvalue_type_node'.  */
    3243                 :            : 
    3244                 :            : tree
    3245                 :    3994680 : c_common_truthvalue_conversion (location_t location, tree expr)
    3246                 :            : {
    3247                 :    4073840 :   STRIP_ANY_LOCATION_WRAPPER (expr);
    3248                 :    4073840 :   switch (TREE_CODE (expr))
    3249                 :            :     {
    3250                 :    1589500 :     case EQ_EXPR:   case NE_EXPR:   case UNEQ_EXPR: case LTGT_EXPR:
    3251                 :    1589500 :     case LE_EXPR:   case GE_EXPR:   case LT_EXPR:   case GT_EXPR:
    3252                 :    1589500 :     case UNLE_EXPR: case UNGE_EXPR: case UNLT_EXPR: case UNGT_EXPR:
    3253                 :    1589500 :     case ORDERED_EXPR: case UNORDERED_EXPR:
    3254                 :    1589500 :       if (TREE_TYPE (expr) == truthvalue_type_node)
    3255                 :            :         return expr;
    3256                 :      10922 :       expr = build2 (TREE_CODE (expr), truthvalue_type_node,
    3257                 :      10922 :                      TREE_OPERAND (expr, 0), TREE_OPERAND (expr, 1));
    3258                 :      10922 :       goto ret;
    3259                 :            : 
    3260                 :     464439 :     case TRUTH_ANDIF_EXPR:
    3261                 :     464439 :     case TRUTH_ORIF_EXPR:
    3262                 :     464439 :     case TRUTH_AND_EXPR:
    3263                 :     464439 :     case TRUTH_OR_EXPR:
    3264                 :     464439 :     case TRUTH_XOR_EXPR:
    3265                 :     464439 :       if (TREE_TYPE (expr) == truthvalue_type_node)
    3266                 :            :         return expr;
    3267                 :         46 :       expr = build2 (TREE_CODE (expr), truthvalue_type_node,
    3268                 :            :                      c_common_truthvalue_conversion (location,
    3269                 :         23 :                                                      TREE_OPERAND (expr, 0)),
    3270                 :            :                      c_common_truthvalue_conversion (location,
    3271                 :         23 :                                                      TREE_OPERAND (expr, 1)));
    3272                 :         23 :       goto ret;
    3273                 :            : 
    3274                 :       8947 :     case TRUTH_NOT_EXPR:
    3275                 :       8947 :       if (TREE_TYPE (expr) == truthvalue_type_node)
    3276                 :            :         return expr;
    3277                 :       6319 :       expr = build1 (TREE_CODE (expr), truthvalue_type_node,
    3278                 :            :                      c_common_truthvalue_conversion (location,
    3279                 :       6319 :                                                      TREE_OPERAND (expr, 0)));
    3280                 :       6319 :       goto ret;
    3281                 :            : 
    3282                 :            :     case ERROR_MARK:
    3283                 :            :       return expr;
    3284                 :            : 
    3285                 :    1146680 :     case INTEGER_CST:
    3286                 :    1146680 :       if (TREE_CODE (TREE_TYPE (expr)) == ENUMERAL_TYPE
    3287                 :     271551 :           && !integer_zerop (expr)
    3288                 :    1186630 :           && !integer_onep (expr))
    3289                 :         97 :         warning_at (location, OPT_Wint_in_bool_context,
    3290                 :            :                     "enum constant in boolean context");
    3291                 :    1146680 :       return integer_zerop (expr) ? truthvalue_false_node
    3292                 :            :                                   : truthvalue_true_node;
    3293                 :            : 
    3294                 :       1281 :     case REAL_CST:
    3295                 :       1281 :       return real_compare (NE_EXPR, &TREE_REAL_CST (expr), &dconst0)
    3296                 :       1281 :              ? truthvalue_true_node
    3297                 :            :              : truthvalue_false_node;
    3298                 :            : 
    3299                 :          0 :     case FIXED_CST:
    3300                 :          0 :       return fixed_compare (NE_EXPR, &TREE_FIXED_CST (expr),
    3301                 :          0 :                             &FCONST0 (TYPE_MODE (TREE_TYPE (expr))))
    3302                 :          0 :              ? truthvalue_true_node
    3303                 :            :              : truthvalue_false_node;
    3304                 :            : 
    3305                 :          0 :     case FUNCTION_DECL:
    3306                 :          0 :       expr = build_unary_op (location, ADDR_EXPR, expr, false);
    3307                 :            :       /* Fall through.  */
    3308                 :            : 
    3309                 :        493 :     case ADDR_EXPR:
    3310                 :        493 :       {
    3311                 :        493 :         tree inner = TREE_OPERAND (expr, 0);
    3312                 :        493 :         if (decl_with_nonnull_addr_p (inner))
    3313                 :            :           {
    3314                 :            :             /* Common Ada programmer's mistake.  */
    3315                 :         74 :             warning_at (location,
    3316                 :            :                         OPT_Waddress,
    3317                 :            :                         "the address of %qD will always evaluate as %<true%>",
    3318                 :            :                         inner);
    3319                 :         74 :             return truthvalue_true_node;
    3320                 :            :           }
    3321                 :            :         break;
    3322                 :            :       }
    3323                 :            : 
    3324                 :        578 :     case COMPLEX_EXPR:
    3325                 :       1734 :       expr = build_binary_op (EXPR_LOCATION (expr),
    3326                 :        578 :                               (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1))
    3327                 :        578 :                                ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
    3328                 :            :                 c_common_truthvalue_conversion (location,
    3329                 :        578 :                                                 TREE_OPERAND (expr, 0)),
    3330                 :            :                 c_common_truthvalue_conversion (location,
    3331                 :        578 :                                                 TREE_OPERAND (expr, 1)),
    3332                 :            :                               false);
    3333                 :        578 :       goto ret;
    3334                 :            : 
    3335                 :         74 :     case NEGATE_EXPR:
    3336                 :         74 :     case ABS_EXPR:
    3337                 :         74 :     case ABSU_EXPR:
    3338                 :         74 :     case FLOAT_EXPR:
    3339                 :         74 :     case EXCESS_PRECISION_EXPR:
    3340                 :            :       /* These don't change whether an object is nonzero or zero.  */
    3341                 :         74 :       return c_common_truthvalue_conversion (location, TREE_OPERAND (expr, 0));
    3342                 :            : 
    3343                 :          0 :     case LROTATE_EXPR:
    3344                 :          0 :     case RROTATE_EXPR:
    3345                 :            :       /* These don't change whether an object is zero or nonzero, but
    3346                 :            :          we can't ignore them if their second arg has side-effects.  */
    3347                 :          0 :       if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
    3348                 :            :         {
    3349                 :          0 :           expr = build2 (COMPOUND_EXPR, truthvalue_type_node,
    3350                 :          0 :                          TREE_OPERAND (expr, 1),
    3351                 :            :                          c_common_truthvalue_conversion
    3352                 :          0 :                          (location, TREE_OPERAND (expr, 0)));
    3353                 :          0 :           goto ret;
    3354                 :            :         }
    3355                 :            :       else
    3356                 :          0 :         return c_common_truthvalue_conversion (location,
    3357                 :          0 :                                                TREE_OPERAND (expr, 0));
    3358                 :            : 
    3359                 :        556 :     case MULT_EXPR:
    3360                 :        556 :       warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
    3361                 :            :                   "%<*%> in boolean context, suggest %<&&%> instead");
    3362                 :        556 :       break;
    3363                 :            : 
    3364                 :        160 :     case LSHIFT_EXPR:
    3365                 :            :       /* We will only warn on signed shifts here, because the majority of
    3366                 :            :          false positive warnings happen in code where unsigned arithmetic
    3367                 :            :          was used in anticipation of a possible overflow.
    3368                 :            :          Furthermore, if we see an unsigned type here we know that the
    3369                 :            :          result of the shift is not subject to integer promotion rules.  */
    3370                 :        160 :       if (TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
    3371                 :        160 :           && !TYPE_UNSIGNED (TREE_TYPE (expr)))
    3372                 :        142 :         warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
    3373                 :            :                     "%<<<%> in boolean context, did you mean %<<%>?");
    3374                 :            :       break;
    3375                 :            : 
    3376                 :       2654 :     case COND_EXPR:
    3377                 :       2654 :       if (warn_int_in_bool_context
    3378                 :       3775 :           && !from_macro_definition_at (EXPR_LOCATION (expr)))
    3379                 :            :         {
    3380                 :        597 :           tree val1 = fold_for_warn (TREE_OPERAND (expr, 1));
    3381                 :        597 :           tree val2 = fold_for_warn (TREE_OPERAND (expr, 2));
    3382                 :        597 :           if (TREE_CODE (val1) == INTEGER_CST
    3383                 :         48 :               && TREE_CODE (val2) == INTEGER_CST
    3384                 :         48 :               && !integer_zerop (val1)
    3385                 :         38 :               && !integer_zerop (val2)
    3386                 :        617 :               && (!integer_onep (val1)
    3387                 :         15 :                   || !integer_onep (val2)))
    3388                 :         15 :             warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
    3389                 :            :                         "%<?:%> using integer constants in boolean context, "
    3390                 :            :                         "the expression will always evaluate to %<true%>");
    3391                 :        582 :           else if ((TREE_CODE (val1) == INTEGER_CST
    3392                 :         33 :                     && !integer_zerop (val1)
    3393                 :         23 :                     && !integer_onep (val1))
    3394                 :        615 :                    || (TREE_CODE (val2) == INTEGER_CST
    3395                 :        199 :                        && !integer_zerop (val2)
    3396                 :        174 :                        && !integer_onep (val2)))
    3397                 :          5 :             warning_at (EXPR_LOCATION (expr), OPT_Wint_in_bool_context,
    3398                 :            :                         "%<?:%> using integer constants in boolean context");
    3399                 :            :         }
    3400                 :            :       /* Distribute the conversion into the arms of a COND_EXPR.  */
    3401                 :       2654 :       if (c_dialect_cxx ())
    3402                 :            :         /* Avoid premature folding.  */
    3403                 :            :         break;
    3404                 :            :       else
    3405                 :            :         {
    3406                 :       1583 :           int w = warn_int_in_bool_context;
    3407                 :       1583 :           warn_int_in_bool_context = 0;
    3408                 :            :           /* Folding will happen later for C.  */
    3409                 :       4749 :           expr = build3 (COND_EXPR, truthvalue_type_node,
    3410                 :       1583 :                          TREE_OPERAND (expr, 0),
    3411                 :            :                          c_common_truthvalue_conversion (location,
    3412                 :       1583 :                                                          TREE_OPERAND (expr, 1)),
    3413                 :            :                          c_common_truthvalue_conversion (location,
    3414                 :       1583 :                                                          TREE_OPERAND (expr, 2)));
    3415                 :       1583 :           warn_int_in_bool_context = w;
    3416                 :       1583 :           goto ret;
    3417                 :            :         }
    3418                 :            : 
    3419                 :      95887 :     CASE_CONVERT:
    3420                 :      95887 :       {
    3421                 :      95887 :         tree totype = TREE_TYPE (expr);
    3422                 :      95887 :         tree fromtype = TREE_TYPE (TREE_OPERAND (expr, 0));
    3423                 :            : 
    3424                 :      95887 :         if (POINTER_TYPE_P (totype)
    3425                 :        197 :             && !c_inhibit_evaluation_warnings
    3426                 :        197 :             && TREE_CODE (fromtype) == REFERENCE_TYPE)
    3427                 :            :           {
    3428                 :          0 :             tree inner = expr;
    3429                 :          0 :             STRIP_NOPS (inner);
    3430                 :            : 
    3431                 :          0 :             if (DECL_P (inner))
    3432                 :          0 :               warning_at (location,
    3433                 :            :                           OPT_Waddress,
    3434                 :            :                           "the compiler can assume that the address of "
    3435                 :            :                           "%qD will always evaluate to %<true%>",
    3436                 :            :                           inner);
    3437                 :            :           }
    3438                 :            : 
    3439                 :            :         /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
    3440                 :            :            since that affects how `default_conversion' will behave.  */
    3441                 :      95887 :         if (TREE_CODE (totype) == REFERENCE_TYPE
    3442                 :      95887 :             || TREE_CODE (fromtype) == REFERENCE_TYPE)
    3443                 :            :           break;
    3444                 :            :         /* Don't strip a conversion from C++0x scoped enum, since they
    3445                 :            :            don't implicitly convert to other types.  */
    3446                 :      95887 :         if (TREE_CODE (fromtype) == ENUMERAL_TYPE
    3447                 :      95887 :             && ENUM_IS_SCOPED (fromtype))
    3448                 :            :           break;
    3449                 :            :         /* If this isn't narrowing the argument, we can ignore it.  */
    3450                 :      95881 :         if (TYPE_PRECISION (totype) >= TYPE_PRECISION (fromtype))
    3451                 :     157952 :           return c_common_truthvalue_conversion (location,
    3452                 :      78976 :                                                  TREE_OPERAND (expr, 0));
    3453                 :            :       }
    3454                 :            :       break;
    3455                 :            : 
    3456                 :       7987 :     case MODIFY_EXPR:
    3457                 :       7987 :       if (!TREE_NO_WARNING (expr)
    3458                 :       3504 :           && warn_parentheses
    3459                 :       8001 :           && warning_at (location, OPT_Wparentheses,
    3460                 :            :                          "suggest parentheses around assignment used as "
    3461                 :            :                          "truth value"))
    3462                 :         14 :         TREE_NO_WARNING (expr) = 1;
    3463                 :            :       break;
    3464                 :            : 
    3465                 :        112 :     case CONST_DECL:
    3466                 :        112 :       {
    3467                 :        112 :         tree folded_expr = fold_for_warn (expr);
    3468                 :        112 :         if (folded_expr != expr)
    3469                 :            :           return c_common_truthvalue_conversion (location, folded_expr);
    3470                 :            :       }
    3471                 :            :       break;
    3472                 :            : 
    3473                 :            :     default:
    3474                 :            :       break;
    3475                 :            :     }
    3476                 :            : 
    3477                 :     781383 :   if (TREE_CODE (TREE_TYPE (expr)) == COMPLEX_TYPE)
    3478                 :            :     {
    3479                 :        130 :       tree t = save_expr (expr);
    3480                 :        130 :       expr = (build_binary_op
    3481                 :        260 :               (EXPR_LOCATION (expr),
    3482                 :        130 :                (TREE_SIDE_EFFECTS (expr)
    3483                 :        130 :                 ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
    3484                 :            :         c_common_truthvalue_conversion
    3485                 :            :                (location,
    3486                 :            :                 build_unary_op (location, REALPART_EXPR, t, false)),
    3487                 :            :         c_common_truthvalue_conversion
    3488                 :            :                (location,
    3489                 :            :                 build_unary_op (location, IMAGPART_EXPR, t, false)),
    3490                 :            :                false));
    3491                 :        130 :       goto ret;
    3492                 :            :     }
    3493                 :            : 
    3494                 :     781253 :   if (TREE_CODE (TREE_TYPE (expr)) == FIXED_POINT_TYPE)
    3495                 :            :     {
    3496                 :          0 :       tree fixed_zero_node = build_fixed (TREE_TYPE (expr),
    3497                 :          0 :                                           FCONST0 (TYPE_MODE
    3498                 :            :                                                    (TREE_TYPE (expr))));
    3499                 :          0 :       return build_binary_op (location, NE_EXPR, expr, fixed_zero_node, true);
    3500                 :            :     }
    3501                 :            :   else
    3502                 :     781253 :     return build_binary_op (location, NE_EXPR, expr, integer_zero_node, true);
    3503                 :            : 
    3504                 :      19555 :  ret:
    3505                 :      19555 :   protected_set_expr_location (expr, location);
    3506                 :      19555 :   return expr;
    3507                 :            : }
    3508                 :            : 
    3509                 :            : static void def_builtin_1  (enum built_in_function fncode,
    3510                 :            :                             const char *name,
    3511                 :            :                             enum built_in_class fnclass,
    3512                 :            :                             tree fntype, tree libtype,
    3513                 :            :                             bool both_p, bool fallback_p, bool nonansi_p,
    3514                 :            :                             tree fnattrs, bool implicit_p);
    3515                 :            : 
    3516                 :            : 
    3517                 :            : /* Apply the TYPE_QUALS to the new DECL.  */
    3518                 :            : 
    3519                 :            : void
    3520                 :  197527000 : c_apply_type_quals_to_decl (int type_quals, tree decl)
    3521                 :            : {
    3522                 :  197527000 :   tree type = TREE_TYPE (decl);
    3523                 :            : 
    3524                 :  197527000 :   if (type == error_mark_node)
    3525                 :            :     return;
    3526                 :            : 
    3527                 :  197527000 :   if ((type_quals & TYPE_QUAL_CONST)
    3528                 :  171776000 :       || (type && TREE_CODE (type) == REFERENCE_TYPE))
    3529                 :            :     /* We used to check TYPE_NEEDS_CONSTRUCTING here, but now a constexpr
    3530                 :            :        constructor can produce constant init, so rely on cp_finish_decl to
    3531                 :            :        clear TREE_READONLY if the variable has non-constant init.  */
    3532                 :   36640000 :     TREE_READONLY (decl) = 1;
    3533                 :  197527000 :   if (type_quals & TYPE_QUAL_VOLATILE)
    3534                 :            :     {
    3535                 :     126696 :       TREE_SIDE_EFFECTS (decl) = 1;
    3536                 :     126696 :       TREE_THIS_VOLATILE (decl) = 1;
    3537                 :            :     }
    3538                 :  197527000 :   if (type_quals & TYPE_QUAL_RESTRICT)
    3539                 :            :     {
    3540                 :    3777860 :       while (type && TREE_CODE (type) == ARRAY_TYPE)
    3541                 :            :         /* Allow 'restrict' on arrays of pointers.
    3542                 :            :            FIXME currently we just ignore it.  */
    3543                 :          8 :         type = TREE_TYPE (type);
    3544                 :    3777850 :       if (!type
    3545                 :    3777850 :           || !POINTER_TYPE_P (type)
    3546                 :    7555690 :           || !C_TYPE_OBJECT_OR_INCOMPLETE_P (TREE_TYPE (type)))
    3547                 :          3 :         error ("invalid use of %<restrict%>");
    3548                 :            :     }
    3549                 :            : }
    3550                 :            : 
    3551                 :            : /* Return the typed-based alias set for T, which may be an expression
    3552                 :            :    or a type.  Return -1 if we don't do anything special.  */
    3553                 :            : 
    3554                 :            : alias_set_type
    3555                 :  303372000 : c_common_get_alias_set (tree t)
    3556                 :            : {
    3557                 :            :   /* For VLAs, use the alias set of the element type rather than the
    3558                 :            :      default of alias set 0 for types compared structurally.  */
    3559                 :  303372000 :   if (TYPE_P (t) && TYPE_STRUCTURAL_EQUALITY_P (t))
    3560                 :            :     {
    3561                 :     411887 :       if (TREE_CODE (t) == ARRAY_TYPE)
    3562                 :     324833 :         return get_alias_set (TREE_TYPE (t));
    3563                 :            :       return -1;
    3564                 :            :     }
    3565                 :            : 
    3566                 :            :   /* That's all the expressions we handle specially.  */
    3567                 :  302960000 :   if (!TYPE_P (t))
    3568                 :            :     return -1;
    3569                 :            : 
    3570                 :            :   /* Unlike char, char8_t doesn't alias. */
    3571                 :   36019900 :   if (flag_char8_t && t == char8_type_node)
    3572                 :            :     return -1;
    3573                 :            : 
    3574                 :            :   /* The C standard guarantees that any object may be accessed via an
    3575                 :            :      lvalue that has narrow character type (except char8_t).  */
    3576                 :   36019900 :   if (t == char_type_node
    3577                 :   26526100 :       || t == signed_char_type_node
    3578                 :   20733600 :       || t == unsigned_char_type_node)
    3579                 :            :     return 0;
    3580                 :            : 
    3581                 :            :   /* The C standard specifically allows aliasing between signed and
    3582                 :            :      unsigned variants of the same type.  We treat the signed
    3583                 :            :      variant as canonical.  */
    3584                 :   18756600 :   if (TREE_CODE (t) == INTEGER_TYPE && TYPE_UNSIGNED (t))
    3585                 :            :     {
    3586                 :   17638900 :       tree t1 = c_common_signed_type (t);
    3587                 :            : 
    3588                 :            :       /* t1 == t can happen for boolean nodes which are always unsigned.  */
    3589                 :   17638900 :       if (t1 != t)
    3590                 :   17638900 :         return get_alias_set (t1);
    3591                 :            :     }
    3592                 :            : 
    3593                 :            :   return -1;
    3594                 :            : }
    3595                 :            : 
    3596                 :            : /* Compute the value of 'sizeof (TYPE)' or '__alignof__ (TYPE)', where
    3597                 :            :    the IS_SIZEOF parameter indicates which operator is being applied.
    3598                 :            :    The COMPLAIN flag controls whether we should diagnose possibly
    3599                 :            :    ill-formed constructs or not.  LOC is the location of the SIZEOF or
    3600                 :            :    TYPEOF operator.  If MIN_ALIGNOF, the least alignment required for
    3601                 :            :    a type in any context should be returned, rather than the normal
    3602                 :            :    alignment for that type.  */
    3603                 :            : 
    3604                 :            : tree
    3605                 :    4403450 : c_sizeof_or_alignof_type (location_t loc,
    3606                 :            :                           tree type, bool is_sizeof, bool min_alignof,
    3607                 :            :                           int complain)
    3608                 :            : {
    3609                 :    4403450 :   const char *op_name;
    3610                 :    4403450 :   tree value = NULL;
    3611                 :    4403450 :   enum tree_code type_code = TREE_CODE (type);
    3612                 :            : 
    3613                 :    4403450 :   op_name = is_sizeof ? "sizeof" : "__alignof__";
    3614                 :            : 
    3615                 :    4403450 :   if (type_code == FUNCTION_TYPE)
    3616                 :            :     {
    3617                 :        243 :       if (is_sizeof)
    3618                 :            :         {
    3619                 :        238 :           if (complain && warn_pointer_arith)
    3620                 :         27 :             pedwarn (loc, OPT_Wpointer_arith,
    3621                 :            :                      "invalid application of %<sizeof%> to a function type");
    3622                 :        211 :           else if (!complain)
    3623                 :        200 :             return error_mark_node;
    3624                 :         38 :           value = size_one_node;
    3625                 :            :         }
    3626                 :            :       else
    3627                 :            :         {
    3628                 :          5 :           if (complain)
    3629                 :            :             {
    3630                 :          5 :               if (c_dialect_cxx ())
    3631                 :          3 :                 pedwarn (loc, OPT_Wpedantic, "ISO C++ does not permit "
    3632                 :            :                          "%<alignof%> applied to a function type");
    3633                 :            :               else
    3634                 :          2 :                 pedwarn (loc, OPT_Wpedantic, "ISO C does not permit "
    3635                 :            :                          "%<_Alignof%> applied to a function type");
    3636                 :            :             }
    3637                 :          5 :           value = size_int (FUNCTION_BOUNDARY / BITS_PER_UNIT);
    3638                 :            :         }
    3639                 :            :     }
    3640                 :    4403200 :   else if (type_code == VOID_TYPE || type_code == ERROR_MARK)
    3641                 :            :     {
    3642                 :        148 :       if (type_code == VOID_TYPE
    3643                 :        148 :           && complain && warn_pointer_arith)
    3644                 :         15 :         pedwarn (loc, OPT_Wpointer_arith,
    3645                 :            :                  "invalid application of %qs to a void type", op_name);
    3646                 :        133 :       else if (!complain)
    3647                 :        110 :         return error_mark_node;
    3648                 :         38 :       value = size_one_node;
    3649                 :            :     }
    3650                 :    4403060 :   else if (!COMPLETE_TYPE_P (type)
    3651                 :    4403060 :            && (!c_dialect_cxx () || is_sizeof || type_code != ARRAY_TYPE))
    3652                 :            :     {
    3653                 :        582 :       if (complain)
    3654                 :        191 :         error_at (loc, "invalid application of %qs to incomplete type %qT",
    3655                 :            :                   op_name, type);
    3656                 :        582 :       return error_mark_node;
    3657                 :            :     }
    3658                 :    3858060 :   else if (c_dialect_cxx () && type_code == ARRAY_TYPE
    3659                 :    4441030 :            && !COMPLETE_TYPE_P (TREE_TYPE (type)))
    3660                 :            :     {
    3661                 :          0 :       if (complain)
    3662                 :          0 :         error_at (loc, "invalid application of %qs to array type %qT of "
    3663                 :            :                   "incomplete element type", op_name, type);
    3664                 :          0 :       return error_mark_node;
    3665                 :            :     }
    3666                 :    4546500 :   else if (!verify_type_context (loc, is_sizeof ? TCTX_SIZEOF : TCTX_ALIGNOF,
    3667                 :            :                                  type, !complain))
    3668                 :            :     {
    3669                 :          0 :       if (!complain)
    3670                 :          0 :         return error_mark_node;
    3671                 :          0 :       value = size_one_node;
    3672                 :            :     }
    3673                 :            :   else
    3674                 :            :     {
    3675                 :    4402470 :       if (is_sizeof)
    3676                 :            :         /* Convert in case a char is more than one unit.  */
    3677                 :    4258450 :         value = size_binop_loc (loc, CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
    3678                 :    4258450 :                                 size_int (TYPE_PRECISION (char_type_node)
    3679                 :            :                                           / BITS_PER_UNIT));
    3680                 :     144024 :       else if (min_alignof)
    3681                 :      27457 :         value = size_int (min_align_of_type (type));
    3682                 :            :       else
    3683                 :     116567 :         value = size_int (TYPE_ALIGN_UNIT (type));
    3684                 :            :     }
    3685                 :            : 
    3686                 :            :   /* VALUE will have the middle-end integer type sizetype.
    3687                 :            :      However, we should really return a value of type `size_t',
    3688                 :            :      which is just a typedef for an ordinary integer type.  */
    3689                 :    4402550 :   value = fold_convert_loc (loc, size_type_node, value);
    3690                 :            : 
    3691                 :    4402550 :   return value;
    3692                 :            : }
    3693                 :            : 
    3694                 :            : /* Implement the __alignof keyword: Return the minimum required
    3695                 :            :    alignment of EXPR, measured in bytes.  For VAR_DECLs,
    3696                 :            :    FUNCTION_DECLs and FIELD_DECLs return DECL_ALIGN (which can be set
    3697                 :            :    from an "aligned" __attribute__ specification).  LOC is the
    3698                 :            :    location of the ALIGNOF operator.  */
    3699                 :            : 
    3700                 :            : tree
    3701                 :      40030 : c_alignof_expr (location_t loc, tree expr)
    3702                 :            : {
    3703                 :      40030 :   tree t;
    3704                 :            : 
    3705                 :      40030 :   if (!verify_type_context (loc, TCTX_ALIGNOF, TREE_TYPE (expr)))
    3706                 :          0 :     t = size_one_node;
    3707                 :            : 
    3708                 :      40030 :   else if (VAR_OR_FUNCTION_DECL_P (expr))
    3709                 :       6888 :     t = size_int (DECL_ALIGN_UNIT (expr));
    3710                 :            : 
    3711                 :      33142 :   else if (TREE_CODE (expr) == COMPONENT_REF
    3712                 :      33142 :            && DECL_C_BIT_FIELD (TREE_OPERAND (expr, 1)))
    3713                 :            :     {
    3714                 :          1 :       error_at (loc, "%<__alignof%> applied to a bit-field");
    3715                 :          1 :       t = size_one_node;
    3716                 :            :     }
    3717                 :      33141 :   else if (TREE_CODE (expr) == COMPONENT_REF
    3718                 :      33141 :            && TREE_CODE (TREE_OPERAND (expr, 1)) == FIELD_DECL)
    3719                 :      17508 :     t = size_int (DECL_ALIGN_UNIT (TREE_OPERAND (expr, 1)));
    3720                 :            : 
    3721                 :      15633 :   else if (INDIRECT_REF_P (expr))
    3722                 :            :     {
    3723                 :         55 :       tree t = TREE_OPERAND (expr, 0);
    3724                 :         55 :       tree best = t;
    3725                 :         55 :       int bestalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
    3726                 :            : 
    3727                 :         55 :       while (CONVERT_EXPR_P (t)
    3728                 :         55 :              && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == POINTER_TYPE)
    3729                 :            :         {
    3730                 :          0 :           int thisalign;
    3731                 :            : 
    3732                 :          0 :           t = TREE_OPERAND (t, 0);
    3733                 :          0 :           thisalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
    3734                 :          0 :           if (thisalign > bestalign)
    3735                 :          0 :             best = t, bestalign = thisalign;
    3736                 :            :         }
    3737                 :         55 :       return c_alignof (loc, TREE_TYPE (TREE_TYPE (best)));
    3738                 :            :     }
    3739                 :            :   else
    3740                 :      15578 :     return c_alignof (loc, TREE_TYPE (expr));
    3741                 :            : 
    3742                 :      24397 :   return fold_convert_loc (loc, size_type_node, t);
    3743                 :            : }
    3744                 :            : 
    3745                 :            : /* Handle C and C++ default attributes.  */
    3746                 :            : 
    3747                 :            : enum built_in_attribute
    3748                 :            : {
    3749                 :            : #define DEF_ATTR_NULL_TREE(ENUM) ENUM,
    3750                 :            : #define DEF_ATTR_INT(ENUM, VALUE) ENUM,
    3751                 :            : #define DEF_ATTR_STRING(ENUM, VALUE) ENUM,
    3752                 :            : #define DEF_ATTR_IDENT(ENUM, STRING) ENUM,
    3753                 :            : #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM,
    3754                 :            : #include "builtin-attrs.def"
    3755                 :            : #undef DEF_ATTR_NULL_TREE
    3756                 :            : #undef DEF_ATTR_INT
    3757                 :            : #undef DEF_ATTR_STRING
    3758                 :            : #undef DEF_ATTR_IDENT
    3759                 :            : #undef DEF_ATTR_TREE_LIST
    3760                 :            :   ATTR_LAST
    3761                 :            : };
    3762                 :            : 
    3763                 :            : static GTY(()) tree built_in_attributes[(int) ATTR_LAST];
    3764                 :            : 
    3765                 :            : static void c_init_attributes (void);
    3766                 :            : 
    3767                 :            : enum c_builtin_type
    3768                 :            : {
    3769                 :            : #define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME,
    3770                 :            : #define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME,
    3771                 :            : #define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME,
    3772                 :            : #define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME,
    3773                 :            : #define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
    3774                 :            : #define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
    3775                 :            : #define DEF_FUNCTION_TYPE_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) NAME,
    3776                 :            : #define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3777                 :            :                             ARG6) NAME,
    3778                 :            : #define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3779                 :            :                             ARG6, ARG7) NAME,
    3780                 :            : #define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3781                 :            :                             ARG6, ARG7, ARG8) NAME,
    3782                 :            : #define DEF_FUNCTION_TYPE_9(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3783                 :            :                             ARG6, ARG7, ARG8, ARG9) NAME,
    3784                 :            : #define DEF_FUNCTION_TYPE_10(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3785                 :            :                              ARG6, ARG7, ARG8, ARG9, ARG10) NAME,
    3786                 :            : #define DEF_FUNCTION_TYPE_11(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3787                 :            :                              ARG6, ARG7, ARG8, ARG9, ARG10, ARG11) NAME,
    3788                 :            : #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
    3789                 :            : #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
    3790                 :            : #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
    3791                 :            : #define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
    3792                 :            : #define DEF_FUNCTION_TYPE_VAR_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
    3793                 :            : #define DEF_FUNCTION_TYPE_VAR_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
    3794                 :            :                                 NAME,
    3795                 :            : #define DEF_FUNCTION_TYPE_VAR_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3796                 :            :                                 ARG6) NAME,
    3797                 :            : #define DEF_FUNCTION_TYPE_VAR_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3798                 :            :                                 ARG6, ARG7) NAME,
    3799                 :            : #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
    3800                 :            : #include "builtin-types.def"
    3801                 :            : #undef DEF_PRIMITIVE_TYPE
    3802                 :            : #undef DEF_FUNCTION_TYPE_0
    3803                 :            : #undef DEF_FUNCTION_TYPE_1
    3804                 :            : #undef DEF_FUNCTION_TYPE_2
    3805                 :            : #undef DEF_FUNCTION_TYPE_3
    3806                 :            : #undef DEF_FUNCTION_TYPE_4
    3807                 :            : #undef DEF_FUNCTION_TYPE_5
    3808                 :            : #undef DEF_FUNCTION_TYPE_6
    3809                 :            : #undef DEF_FUNCTION_TYPE_7
    3810                 :            : #undef DEF_FUNCTION_TYPE_8
    3811                 :            : #undef DEF_FUNCTION_TYPE_9
    3812                 :            : #undef DEF_FUNCTION_TYPE_10
    3813                 :            : #undef DEF_FUNCTION_TYPE_11
    3814                 :            : #undef DEF_FUNCTION_TYPE_VAR_0
    3815                 :            : #undef DEF_FUNCTION_TYPE_VAR_1
    3816                 :            : #undef DEF_FUNCTION_TYPE_VAR_2
    3817                 :            : #undef DEF_FUNCTION_TYPE_VAR_3
    3818                 :            : #undef DEF_FUNCTION_TYPE_VAR_4
    3819                 :            : #undef DEF_FUNCTION_TYPE_VAR_5
    3820                 :            : #undef DEF_FUNCTION_TYPE_VAR_6
    3821                 :            : #undef DEF_FUNCTION_TYPE_VAR_7
    3822                 :            : #undef DEF_POINTER_TYPE
    3823                 :            :   BT_LAST
    3824                 :            : };
    3825                 :            : 
    3826                 :            : typedef enum c_builtin_type builtin_type;
    3827                 :            : 
    3828                 :            : /* A temporary array for c_common_nodes_and_builtins.  Used in
    3829                 :            :    communication with def_fn_type.  */
    3830                 :            : static tree builtin_types[(int) BT_LAST + 1];
    3831                 :            : 
    3832                 :            : /* A helper function for c_common_nodes_and_builtins.  Build function type
    3833                 :            :    for DEF with return type RET and N arguments.  If VAR is true, then the
    3834                 :            :    function should be variadic after those N arguments.
    3835                 :            : 
    3836                 :            :    Takes special care not to ICE if any of the types involved are
    3837                 :            :    error_mark_node, which indicates that said type is not in fact available
    3838                 :            :    (see builtin_type_for_size).  In which case the function type as a whole
    3839                 :            :    should be error_mark_node.  */
    3840                 :            : 
    3841                 :            : static void
    3842                 :   62420700 : def_fn_type (builtin_type def, builtin_type ret, bool var, int n, ...)
    3843                 :            : {
    3844                 :   62420700 :   tree t;
    3845                 :   62420700 :   tree *args = XALLOCAVEC (tree, n);
    3846                 :   62420700 :   va_list list;
    3847                 :   62420700 :   int i;
    3848                 :            : 
    3849                 :   62420700 :   va_start (list, n);
    3850                 :  203028000 :   for (i = 0; i < n; ++i)
    3851                 :            :     {
    3852                 :  141583000 :       builtin_type a = (builtin_type) va_arg (list, int);
    3853                 :  141583000 :       t = builtin_types[a];
    3854                 :  141583000 :       if (t == error_mark_node)
    3855                 :     976256 :         goto egress;
    3856                 :  140607000 :       args[i] = t;
    3857                 :            :     }
    3858                 :            : 
    3859                 :   61444500 :   t = builtin_types[ret];
    3860                 :   61444500 :   if (t == error_mark_node)
    3861                 :     631749 :     goto egress;
    3862                 :   60812700 :   if (var)
    3863                 :    4700680 :     t = build_varargs_function_type_array (t, n, args);
    3864                 :            :   else
    3865                 :   56112000 :     t = build_function_type_array (t, n, args);
    3866                 :            : 
    3867                 :   62420700 :  egress:
    3868                 :   62420700 :   builtin_types[def] = t;
    3869                 :   62420700 :   va_end (list);
    3870                 :   62420700 : }
    3871                 :            : 
    3872                 :            : /* Build builtin functions common to both C and C++ language
    3873                 :            :    frontends.  */
    3874                 :            : 
    3875                 :            : static void
    3876                 :     156836 : c_define_builtins (tree va_list_ref_type_node, tree va_list_arg_type_node)
    3877                 :            : {
    3878                 :            : #define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \
    3879                 :            :   builtin_types[ENUM] = VALUE;
    3880                 :            : #define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \
    3881                 :            :   def_fn_type (ENUM, RETURN, 0, 0);
    3882                 :            : #define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \
    3883                 :            :   def_fn_type (ENUM, RETURN, 0, 1, ARG1);
    3884                 :            : #define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \
    3885                 :            :   def_fn_type (ENUM, RETURN, 0, 2, ARG1, ARG2);
    3886                 :            : #define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
    3887                 :            :   def_fn_type (ENUM, RETURN, 0, 3, ARG1, ARG2, ARG3);
    3888                 :            : #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
    3889                 :            :   def_fn_type (ENUM, RETURN, 0, 4, ARG1, ARG2, ARG3, ARG4);
    3890                 :            : #define DEF_FUNCTION_TYPE_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
    3891                 :            :   def_fn_type (ENUM, RETURN, 0, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
    3892                 :            : #define DEF_FUNCTION_TYPE_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3893                 :            :                             ARG6)                                       \
    3894                 :            :   def_fn_type (ENUM, RETURN, 0, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
    3895                 :            : #define DEF_FUNCTION_TYPE_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3896                 :            :                             ARG6, ARG7)                                 \
    3897                 :            :   def_fn_type (ENUM, RETURN, 0, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7);
    3898                 :            : #define DEF_FUNCTION_TYPE_8(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3899                 :            :                             ARG6, ARG7, ARG8)                           \
    3900                 :            :   def_fn_type (ENUM, RETURN, 0, 8, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6,  \
    3901                 :            :                ARG7, ARG8);
    3902                 :            : #define DEF_FUNCTION_TYPE_9(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3903                 :            :                             ARG6, ARG7, ARG8, ARG9)                     \
    3904                 :            :   def_fn_type (ENUM, RETURN, 0, 9, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6,  \
    3905                 :            :                ARG7, ARG8, ARG9);
    3906                 :            : #define DEF_FUNCTION_TYPE_10(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3907                 :            :                              ARG6, ARG7, ARG8, ARG9, ARG10)              \
    3908                 :            :   def_fn_type (ENUM, RETURN, 0, 10, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6,  \
    3909                 :            :                ARG7, ARG8, ARG9, ARG10);
    3910                 :            : #define DEF_FUNCTION_TYPE_11(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3911                 :            :                              ARG6, ARG7, ARG8, ARG9, ARG10, ARG11)       \
    3912                 :            :   def_fn_type (ENUM, RETURN, 0, 11, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6,  \
    3913                 :            :                ARG7, ARG8, ARG9, ARG10, ARG11);
    3914                 :            : #define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \
    3915                 :            :   def_fn_type (ENUM, RETURN, 1, 0);
    3916                 :            : #define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \
    3917                 :            :   def_fn_type (ENUM, RETURN, 1, 1, ARG1);
    3918                 :            : #define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \
    3919                 :            :   def_fn_type (ENUM, RETURN, 1, 2, ARG1, ARG2);
    3920                 :            : #define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
    3921                 :            :   def_fn_type (ENUM, RETURN, 1, 3, ARG1, ARG2, ARG3);
    3922                 :            : #define DEF_FUNCTION_TYPE_VAR_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
    3923                 :            :   def_fn_type (ENUM, RETURN, 1, 4, ARG1, ARG2, ARG3, ARG4);
    3924                 :            : #define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
    3925                 :            :   def_fn_type (ENUM, RETURN, 1, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
    3926                 :            : #define DEF_FUNCTION_TYPE_VAR_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3927                 :            :                                 ARG6) \
    3928                 :            :   def_fn_type (ENUM, RETURN, 1, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
    3929                 :            : #define DEF_FUNCTION_TYPE_VAR_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
    3930                 :            :                                 ARG6, ARG7)                             \
    3931                 :            :   def_fn_type (ENUM, RETURN, 1, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7);
    3932                 :            : #define DEF_POINTER_TYPE(ENUM, TYPE) \
    3933                 :            :   builtin_types[(int) ENUM] = build_pointer_type (builtin_types[(int) TYPE]);
    3934                 :            : 
    3935                 :            : #include "builtin-types.def"
    3936                 :            : 
    3937                 :            : #undef DEF_PRIMITIVE_TYPE
    3938                 :            : #undef DEF_FUNCTION_TYPE_0
    3939                 :            : #undef DEF_FUNCTION_TYPE_1
    3940                 :            : #undef DEF_FUNCTION_TYPE_2
    3941                 :            : #undef DEF_FUNCTION_TYPE_3
    3942                 :            : #undef DEF_FUNCTION_TYPE_4
    3943                 :            : #undef DEF_FUNCTION_TYPE_5
    3944                 :            : #undef DEF_FUNCTION_TYPE_6
    3945                 :            : #undef DEF_FUNCTION_TYPE_7
    3946                 :            : #undef DEF_FUNCTION_TYPE_8
    3947                 :            : #undef DEF_FUNCTION_TYPE_9
    3948                 :            : #undef DEF_FUNCTION_TYPE_10
    3949                 :            : #undef DEF_FUNCTION_TYPE_11
    3950                 :            : #undef DEF_FUNCTION_TYPE_VAR_0
    3951                 :            : #undef DEF_FUNCTION_TYPE_VAR_1
    3952                 :            : #undef DEF_FUNCTION_TYPE_VAR_2
    3953                 :            : #undef DEF_FUNCTION_TYPE_VAR_3
    3954                 :            : #undef DEF_FUNCTION_TYPE_VAR_4
    3955                 :            : #undef DEF_FUNCTION_TYPE_VAR_5
    3956                 :            : #undef DEF_FUNCTION_TYPE_VAR_6
    3957                 :            : #undef DEF_FUNCTION_TYPE_VAR_7
    3958                 :            : #undef DEF_POINTER_TYPE
    3959                 :     156836 :   builtin_types[(int) BT_LAST] = NULL_TREE;
    3960                 :            : 
    3961                 :     156836 :   c_init_attributes ();
    3962                 :            : 
    3963                 :            : #define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, \
    3964                 :            :                     NONANSI_P, ATTRS, IMPLICIT, COND)                   \
    3965                 :            :   if (NAME && COND)                                                     \
    3966                 :            :     def_builtin_1 (ENUM, NAME, CLASS,                                   \
    3967                 :            :                    builtin_types[(int) TYPE],                           \
    3968                 :            :                    builtin_types[(int) LIBTYPE],                        \
    3969                 :            :                    BOTH_P, FALLBACK_P, NONANSI_P,                       \
    3970                 :            :                    built_in_attributes[(int) ATTRS], IMPLICIT);
    3971                 :            : #include "builtins.def"
    3972                 :            : 
    3973                 :     156836 :   targetm.init_builtins ();
    3974                 :            : 
    3975                 :     156836 :   build_common_builtin_nodes ();
    3976                 :     156836 : }
    3977                 :            : 
    3978                 :            : /* Like get_identifier, but avoid warnings about null arguments when
    3979                 :            :    the argument may be NULL for targets where GCC lacks stdint.h type
    3980                 :            :    information.  */
    3981                 :            : 
    3982                 :            : static inline tree
    3983                 :    4234570 : c_get_ident (const char *id)
    3984                 :            : {
    3985                 :    1882030 :   return get_identifier (id);
    3986                 :            : }
    3987                 :            : 
    3988                 :            : /* Build tree nodes and builtin functions common to both C and C++ language
    3989                 :            :    frontends.  */
    3990                 :            : 
    3991                 :            : void
    3992                 :     156836 : c_common_nodes_and_builtins (void)
    3993                 :            : {
    3994                 :     156836 :   int char8_type_size;
    3995                 :     156836 :   int char16_type_size;
    3996                 :     156836 :   int char32_type_size;
    3997                 :     156836 :   int wchar_type_size;
    3998                 :     156836 :   tree array_domain_type;
    3999                 :     156836 :   tree va_list_ref_type_node;
    4000                 :     156836 :   tree va_list_arg_type_node;
    4001                 :     156836 :   int i;
    4002                 :            : 
    4003                 :     156836 :   build_common_tree_nodes (flag_signed_char);
    4004                 :            : 
    4005                 :            :   /* Define `int' and `char' first so that dbx will output them first.  */
    4006                 :     156836 :   record_builtin_type (RID_INT, NULL, integer_type_node);
    4007                 :     156836 :   record_builtin_type (RID_CHAR, "char", char_type_node);
    4008                 :            : 
    4009                 :            :   /* `signed' is the same as `int'.  FIXME: the declarations of "signed",
    4010                 :            :      "unsigned long", "long long unsigned" and "unsigned short" were in C++
    4011                 :            :      but not C.  Are the conditionals here needed?  */
    4012                 :     156836 :   if (c_dialect_cxx ())
    4013                 :      78233 :     record_builtin_type (RID_SIGNED, NULL, integer_type_node);
    4014                 :     156836 :   record_builtin_type (RID_LONG, "long int", long_integer_type_node);
    4015                 :     156836 :   record_builtin_type (RID_UNSIGNED, "unsigned int", unsigned_type_node);
    4016                 :     156836 :   record_builtin_type (RID_MAX, "long unsigned int",
    4017                 :            :                        long_unsigned_type_node);
    4018                 :            : 
    4019                 :     313672 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
    4020                 :            :     {
    4021                 :     156836 :       char name[25];
    4022                 :            : 
    4023                 :     156836 :       sprintf (name, "__int%d", int_n_data[i].bitsize);
    4024                 :     156836 :       record_builtin_type ((enum rid)(RID_FIRST_INT_N + i), name,
    4025                 :            :                            int_n_trees[i].signed_type);
    4026                 :     156836 :       sprintf (name, "__int%d__", int_n_data[i].bitsize);
    4027                 :     156836 :       record_builtin_type ((enum rid)(RID_FIRST_INT_N + i), name,
    4028                 :            :                            int_n_trees[i].signed_type);
    4029                 :            : 
    4030                 :     156836 :       sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
    4031                 :     156836 :       record_builtin_type (RID_MAX, name, int_n_trees[i].unsigned_type);
    4032                 :     156836 :       sprintf (name, "__int%d__ unsigned", int_n_data[i].bitsize);
    4033                 :     156836 :       record_builtin_type (RID_MAX, name, int_n_trees[i].unsigned_type);
    4034                 :            :     }
    4035                 :            : 
    4036                 :     156836 :   if (c_dialect_cxx ())
    4037                 :      78233 :     record_builtin_type (RID_MAX, "unsigned long", long_unsigned_type_node);
    4038                 :     156836 :   record_builtin_type (RID_MAX, "long long int",
    4039                 :            :                        long_long_integer_type_node);
    4040                 :     156836 :   record_builtin_type (RID_MAX, "long long unsigned int",
    4041                 :            :                        long_long_unsigned_type_node);
    4042                 :     156836 :   if (c_dialect_cxx ())
    4043                 :      78233 :     record_builtin_type (RID_MAX, "long long unsigned",
    4044                 :            :                          long_long_unsigned_type_node);
    4045                 :     156836 :   record_builtin_type (RID_SHORT, "short int", short_integer_type_node);
    4046                 :     156836 :   record_builtin_type (RID_MAX, "short unsigned int",
    4047                 :            :                        short_unsigned_type_node);
    4048                 :     156836 :   if (c_dialect_cxx ())
    4049                 :      78233 :     record_builtin_type (RID_MAX, "unsigned short",
    4050                 :            :                          short_unsigned_type_node);
    4051                 :            : 
    4052                 :            :   /* Define both `signed char' and `unsigned char'.  */
    4053                 :     156836 :   record_builtin_type (RID_MAX, "signed char", signed_char_type_node);
    4054                 :     156836 :   record_builtin_type (RID_MAX, "unsigned char", unsigned_char_type_node);
    4055                 :            : 
    4056                 :            :   /* These are types that c_common_type_for_size and
    4057                 :            :      c_common_type_for_mode use.  */
    4058                 :     156836 :   lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4059                 :            :                                          TYPE_DECL, NULL_TREE,
    4060                 :            :                                          intQI_type_node));
    4061                 :     156836 :   lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4062                 :            :                                          TYPE_DECL, NULL_TREE,
    4063                 :            :                                          intHI_type_node));
    4064                 :     156836 :   lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4065                 :            :                                          TYPE_DECL, NULL_TREE,
    4066                 :            :                                          intSI_type_node));
    4067                 :     156836 :   lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4068                 :            :                                          TYPE_DECL, NULL_TREE,
    4069                 :            :                                          intDI_type_node));
    4070                 :            : #if HOST_BITS_PER_WIDE_INT >= 64
    4071                 :            :   /* Note that this is different than the __int128 type that's part of
    4072                 :            :      the generic __intN support.  */
    4073                 :     156836 :   if (targetm.scalar_mode_supported_p (TImode))
    4074                 :     152431 :     lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4075                 :            :                                            TYPE_DECL,
    4076                 :            :                                            get_identifier ("__int128_t"),
    4077                 :            :                                            intTI_type_node));
    4078                 :            : #endif
    4079                 :     156836 :   lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4080                 :            :                                          TYPE_DECL, NULL_TREE,
    4081                 :            :                                          unsigned_intQI_type_node));
    4082                 :     156836 :   lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4083                 :            :                                          TYPE_DECL, NULL_TREE,
    4084                 :            :                                          unsigned_intHI_type_node));
    4085                 :     156836 :   lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4086                 :            :                                          TYPE_DECL, NULL_TREE,
    4087                 :            :                                          unsigned_intSI_type_node));
    4088                 :     156836 :   lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4089                 :            :                                          TYPE_DECL, NULL_TREE,
    4090                 :            :                                          unsigned_intDI_type_node));
    4091                 :            : #if HOST_BITS_PER_WIDE_INT >= 64
    4092                 :     156836 :   if (targetm.scalar_mode_supported_p (TImode))
    4093                 :     152431 :     lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4094                 :            :                                            TYPE_DECL,
    4095                 :            :                                            get_identifier ("__uint128_t"),
    4096                 :            :                                            unsigned_intTI_type_node));
    4097                 :            : #endif
    4098                 :            : 
    4099                 :            :   /* Create the widest literal types.  */
    4100                 :     156836 :   if (targetm.scalar_mode_supported_p (TImode))
    4101                 :            :     {
    4102                 :     152431 :       widest_integer_literal_type_node = intTI_type_node;
    4103                 :     152431 :       widest_unsigned_literal_type_node = unsigned_intTI_type_node;
    4104                 :            :     }
    4105                 :            :   else
    4106                 :            :     {
    4107                 :       4405 :       widest_integer_literal_type_node = intDI_type_node;
    4108                 :       4405 :       widest_unsigned_literal_type_node = unsigned_intDI_type_node;
    4109                 :            :     }
    4110                 :            : 
    4111                 :     156836 :   signed_size_type_node = c_common_signed_type (size_type_node);
    4112                 :            : 
    4113                 :     313672 :   pid_type_node =
    4114                 :     156836 :     TREE_TYPE (identifier_global_value (get_identifier (PID_TYPE)));
    4115                 :            : 
    4116                 :     156836 :   record_builtin_type (RID_FLOAT, NULL, float_type_node);
    4117                 :     156836 :   record_builtin_type (RID_DOUBLE, NULL, double_type_node);
    4118                 :     156836 :   record_builtin_type (RID_MAX, "long double", long_double_type_node);
    4119                 :            : 
    4120                 :     156836 :   if (!c_dialect_cxx ())
    4121                 :     628824 :     for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    4122                 :     550221 :       if (FLOATN_NX_TYPE_NODE (i) != NULL_TREE)
    4123                 :     393015 :         record_builtin_type ((enum rid) (RID_FLOATN_NX_FIRST + i), NULL,
    4124                 :            :                              FLOATN_NX_TYPE_NODE (i));
    4125                 :            : 
    4126                 :            :   /* Only supported decimal floating point extension if the target
    4127                 :            :      actually supports underlying modes. */
    4128                 :     156836 :   if (targetm.scalar_mode_supported_p (SDmode)
    4129                 :     156836 :       && targetm.scalar_mode_supported_p (DDmode)
    4130                 :     313672 :       && targetm.scalar_mode_supported_p (TDmode))
    4131                 :            :     {
    4132                 :     156836 :       record_builtin_type (RID_DFLOAT32, NULL, dfloat32_type_node);
    4133                 :     156836 :       record_builtin_type (RID_DFLOAT64, NULL, dfloat64_type_node);
    4134                 :     156836 :       record_builtin_type (RID_DFLOAT128, NULL, dfloat128_type_node);
    4135                 :            :     }
    4136                 :            : 
    4137                 :     156836 :   if (targetm.fixed_point_supported_p ())
    4138                 :            :     {
    4139                 :          0 :       record_builtin_type (RID_MAX, "short _Fract", short_fract_type_node);
    4140                 :          0 :       record_builtin_type (RID_FRACT, NULL, fract_type_node);
    4141                 :          0 :       record_builtin_type (RID_MAX, "long _Fract", long_fract_type_node);
    4142                 :          0 :       record_builtin_type (RID_MAX, "long long _Fract",
    4143                 :            :                            long_long_fract_type_node);
    4144                 :          0 :       record_builtin_type (RID_MAX, "unsigned short _Fract",
    4145                 :            :                            unsigned_short_fract_type_node);
    4146                 :          0 :       record_builtin_type (RID_MAX, "unsigned _Fract",
    4147                 :            :                            unsigned_fract_type_node);
    4148                 :          0 :       record_builtin_type (RID_MAX, "unsigned long _Fract",
    4149                 :            :                            unsigned_long_fract_type_node);
    4150                 :          0 :       record_builtin_type (RID_MAX, "unsigned long long _Fract",
    4151                 :            :                            unsigned_long_long_fract_type_node);
    4152                 :          0 :       record_builtin_type (RID_MAX, "_Sat short _Fract",
    4153                 :            :                            sat_short_fract_type_node);
    4154                 :          0 :       record_builtin_type (RID_MAX, "_Sat _Fract", sat_fract_type_node);
    4155                 :          0 :       record_builtin_type (RID_MAX, "_Sat long _Fract",
    4156                 :            :                            sat_long_fract_type_node);
    4157                 :          0 :       record_builtin_type (RID_MAX, "_Sat long long _Fract",
    4158                 :            :                            sat_long_long_fract_type_node);
    4159                 :          0 :       record_builtin_type (RID_MAX, "_Sat unsigned short _Fract",
    4160                 :            :                            sat_unsigned_short_fract_type_node);
    4161                 :          0 :       record_builtin_type (RID_MAX, "_Sat unsigned _Fract",
    4162                 :            :                            sat_unsigned_fract_type_node);
    4163                 :          0 :       record_builtin_type (RID_MAX, "_Sat unsigned long _Fract",
    4164                 :            :                            sat_unsigned_long_fract_type_node);
    4165                 :          0 :       record_builtin_type (RID_MAX, "_Sat unsigned long long _Fract",
    4166                 :            :                            sat_unsigned_long_long_fract_type_node);
    4167                 :          0 :       record_builtin_type (RID_MAX, "short _Accum", short_accum_type_node);
    4168                 :          0 :       record_builtin_type (RID_ACCUM, NULL, accum_type_node);
    4169                 :          0 :       record_builtin_type (RID_MAX, "long _Accum", long_accum_type_node);
    4170                 :          0 :       record_builtin_type (RID_MAX, "long long _Accum",
    4171                 :            :                            long_long_accum_type_node);
    4172                 :          0 :       record_builtin_type (RID_MAX, "unsigned short _Accum",
    4173                 :            :                            unsigned_short_accum_type_node);
    4174                 :          0 :       record_builtin_type (RID_MAX, "unsigned _Accum",
    4175                 :            :                            unsigned_accum_type_node);
    4176                 :          0 :       record_builtin_type (RID_MAX, "unsigned long _Accum",
    4177                 :            :                            unsigned_long_accum_type_node);
    4178                 :          0 :       record_builtin_type (RID_MAX, "unsigned long long _Accum",
    4179                 :            :                            unsigned_long_long_accum_type_node);
    4180                 :          0 :       record_builtin_type (RID_MAX, "_Sat short _Accum",
    4181                 :            :                            sat_short_accum_type_node);
    4182                 :          0 :       record_builtin_type (RID_MAX, "_Sat _Accum", sat_accum_type_node);
    4183                 :          0 :       record_builtin_type (RID_MAX, "_Sat long _Accum",
    4184                 :            :                            sat_long_accum_type_node);
    4185                 :          0 :       record_builtin_type (RID_MAX, "_Sat long long _Accum",
    4186                 :            :                           sat_long_long_accum_type_node);
    4187                 :          0 :       record_builtin_type (RID_MAX, "_Sat unsigned short _Accum",
    4188                 :            :                            sat_unsigned_short_accum_type_node);
    4189                 :          0 :       record_builtin_type (RID_MAX, "_Sat unsigned _Accum",
    4190                 :            :                            sat_unsigned_accum_type_node);
    4191                 :          0 :       record_builtin_type (RID_MAX, "_Sat unsigned long _Accum",
    4192                 :            :                            sat_unsigned_long_accum_type_node);
    4193                 :          0 :       record_builtin_type (RID_MAX, "_Sat unsigned long long _Accum",
    4194                 :            :                            sat_unsigned_long_long_accum_type_node);
    4195                 :            : 
    4196                 :            :     }
    4197                 :            : 
    4198                 :     156836 :   lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4199                 :            :                                          TYPE_DECL,
    4200                 :            :                                          get_identifier ("complex int"),
    4201                 :            :                                          complex_integer_type_node));
    4202                 :     156836 :   lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4203                 :            :                                          TYPE_DECL,
    4204                 :            :                                          get_identifier ("complex float"),
    4205                 :            :                                          complex_float_type_node));
    4206                 :     156836 :   lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
    4207                 :            :                                          TYPE_DECL,
    4208                 :            :                                          get_identifier ("complex double"),
    4209                 :            :                                          complex_double_type_node));
    4210                 :     156836 :   lang_hooks.decls.pushdecl
    4211                 :     156836 :     (build_decl (UNKNOWN_LOCATION,
    4212                 :            :                  TYPE_DECL, get_identifier ("complex long double"),
    4213                 :            :                  complex_long_double_type_node));
    4214                 :            : 
    4215                 :     156836 :   if (!c_dialect_cxx ())
    4216                 :     628824 :     for (i = 0; i < NUM_FLOATN_NX_TYPES; i++)
    4217                 :     550221 :       if (COMPLEX_FLOATN_NX_TYPE_NODE (i) != NULL_TREE)
    4218                 :            :         {
    4219                 :     393015 :           char buf[30];
    4220                 :     786030 :           sprintf (buf, "complex _Float%d%s", floatn_nx_types[i].n,
    4221                 :     393015 :                    floatn_nx_types[i].extended ? "x" : "");
    4222                 :     393015 :           lang_hooks.decls.pushdecl
    4223                 :     393015 :             (build_decl (UNKNOWN_LOCATION,
    4224                 :            :                          TYPE_DECL,
    4225                 :            :                          get_identifier (buf),
    4226                 :            :                          COMPLEX_FLOATN_NX_TYPE_NODE (i)));
    4227                 :            :         }
    4228                 :            : 
    4229                 :            :   /* Make fileptr_type_node a distinct void * type until
    4230                 :            :      FILE type is defined.  Likewise for const struct tm*.  */
    4231                 :     941016 :   for (unsigned i = 0;
    4232                 :    1097850 :        i < sizeof (builtin_structptr_types) / sizeof (builtin_structptr_type);
    4233                 :            :        ++i)
    4234                 :     941016 :     builtin_structptr_types[i].node
    4235                 :     941016 :       = build_variant_type_copy (builtin_structptr_types[i].base);
    4236                 :            : 
    4237                 :     156836 :   record_builtin_type (RID_VOID, NULL, void_type_node);
    4238                 :            : 
    4239                 :            :   /* Set the TYPE_NAME for any variants that were built before
    4240                 :            :      record_builtin_type gave names to the built-in types. */
    4241                 :     156836 :   {
    4242                 :     156836 :     tree void_name = TYPE_NAME (void_type_node);
    4243                 :     156836 :     TYPE_NAME (void_type_node) = NULL_TREE;
    4244                 :     156836 :     TYPE_NAME (build_qualified_type (void_type_node, TYPE_QUAL_CONST))
    4245                 :     156836 :       = void_name;
    4246                 :     156836 :     TYPE_NAME (void_type_node) = void_name;
    4247                 :            :   }
    4248                 :            : 
    4249                 :     156836 :   void_list_node = build_void_list_node ();
    4250                 :            : 
    4251                 :            :   /* Make a type to be the domain of a few array types
    4252                 :            :      whose domains don't really matter.
    4253                 :            :      200 is small enough that it always fits in size_t
    4254                 :            :      and large enough that it can hold most function names for the
    4255                 :            :      initializations of __FUNCTION__ and __PRETTY_FUNCTION__.  */
    4256                 :     156836 :   array_domain_type = build_index_type (size_int (200));
    4257                 :            : 
    4258                 :            :   /* Make a type for arrays of characters.
    4259                 :            :      With luck nothing will ever really depend on the length of this
    4260                 :            :      array type.  */
    4261                 :     156836 :   char_array_type_node
    4262                 :     156836 :     = build_array_type (char_type_node, array_domain_type);
    4263                 :            : 
    4264                 :     156836 :   string_type_node = build_pointer_type (char_type_node);
    4265                 :     156836 :   const_string_type_node
    4266                 :     156836 :     = build_pointer_type (build_qualified_type
    4267                 :            :                           (char_type_node, TYPE_QUAL_CONST));
    4268                 :            : 
    4269                 :            :   /* This is special for C++ so functions can be overloaded.  */
    4270                 :     161309 :   wchar_type_node = get_identifier (MODIFIED_WCHAR_TYPE);
    4271                 :     156836 :   wchar_type_node = TREE_TYPE (identifier_global_value (wchar_type_node));
    4272                 :     156836 :   wchar_type_size = TYPE_PRECISION (wchar_type_node);
    4273                 :     156836 :   underlying_wchar_type_node = wchar_type_node;
    4274                 :     156836 :   if (c_dialect_cxx ())
    4275                 :            :     {
    4276                 :      78233 :       if (TYPE_UNSIGNED (wchar_type_node))
    4277                 :          3 :         wchar_type_node = make_unsigned_type (wchar_type_size);
    4278                 :            :       else
    4279                 :      78230 :         wchar_type_node = make_signed_type (wchar_type_size);
    4280                 :      78233 :       record_builtin_type (RID_WCHAR, "wchar_t", wchar_type_node);
    4281                 :            :     }
    4282                 :            : 
    4283                 :            :   /* This is for wide string constants.  */
    4284                 :     156836 :   wchar_array_type_node
    4285                 :     156836 :     = build_array_type (wchar_type_node, array_domain_type);
    4286                 :            : 
    4287                 :            :   /* Define 'char8_t'.  */
    4288                 :     156836 :   char8_type_node = get_identifier (CHAR8_TYPE);
    4289                 :     156836 :   char8_type_node = TREE_TYPE (identifier_global_value (char8_type_node));
    4290                 :     156836 :   char8_type_size = TYPE_PRECISION (char8_type_node);
    4291                 :     156836 :   if (c_dialect_cxx ())
    4292                 :            :     {
    4293                 :      78233 :       char8_type_node = make_unsigned_type (char8_type_size);
    4294                 :            : 
    4295                 :      78233 :       if (flag_char8_t)
    4296                 :      15872 :         record_builtin_type (RID_CHAR8, "char8_t", char8_type_node);
    4297                 :            :     }
    4298                 :            : 
    4299                 :            :   /* This is for UTF-8 string constants.  */
    4300                 :     156836 :   char8_array_type_node
    4301                 :     156836 :     = build_array_type (char8_type_node, array_domain_type);
    4302                 :            : 
    4303                 :            :   /* Define 'char16_t'.  */
    4304                 :     156836 :   char16_type_node = get_identifier (CHAR16_TYPE);
    4305                 :     156836 :   char16_type_node = TREE_TYPE (identifier_global_value (char16_type_node));
    4306                 :     156836 :   char16_type_size = TYPE_PRECISION (char16_type_node);
    4307                 :     156836 :   if (c_dialect_cxx ())
    4308                 :            :     {
    4309                 :      78233 :       char16_type_node = make_unsigned_type (char16_type_size);
    4310                 :            : 
    4311                 :      78233 :       if (cxx_dialect >= cxx11)
    4312                 :      67097 :         record_builtin_type (RID_CHAR16, "char16_t", char16_type_node);
    4313                 :            :     }
    4314                 :            : 
    4315                 :            :   /* This is for UTF-16 string constants.  */
    4316                 :     156836 :   char16_array_type_node
    4317                 :     156836 :     = build_array_type (char16_type_node, array_domain_type);
    4318                 :            : 
    4319                 :            :   /* Define 'char32_t'.  */
    4320                 :     156836 :   char32_type_node = get_identifier (CHAR32_TYPE);
    4321                 :     156836 :   char32_type_node = TREE_TYPE (identifier_global_value (char32_type_node));
    4322                 :     156836 :   char32_type_size = TYPE_PRECISION (char32_type_node);
    4323                 :     156836 :   if (c_dialect_cxx ())
    4324                 :            :     {
    4325                 :      78233 :       char32_type_node = make_unsigned_type (char32_type_size);
    4326                 :            : 
    4327                 :      78233 :       if (cxx_dialect >= cxx11)
    4328                 :      67097 :         record_builtin_type (RID_CHAR32, "char32_t", char32_type_node);
    4329                 :            :     }
    4330                 :            : 
    4331                 :            :   /* This is for UTF-32 string constants.  */
    4332                 :     156836 :   char32_array_type_node
    4333                 :     156836 :     = build_array_type (char32_type_node, array_domain_type);
    4334                 :            : 
    4335                 :     313672 :   wint_type_node =
    4336                 :     156836 :     TREE_TYPE (identifier_global_value (get_identifier (WINT_TYPE)));
    4337                 :            : 
    4338                 :     313672 :   intmax_type_node =
    4339                 :     309199 :     TREE_TYPE (identifier_global_value (get_identifier (INTMAX_TYPE)));
    4340                 :     313672 :   uintmax_type_node =
    4341                 :     309199 :     TREE_TYPE (identifier_global_value (get_identifier (UINTMAX_TYPE)));
    4342                 :            : 
    4343                 :     156836 :   if (SIG_ATOMIC_TYPE)
    4344                 :     156836 :     sig_atomic_type_node =
    4345                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (SIG_ATOMIC_TYPE)));
    4346                 :     156836 :   if (INT8_TYPE)
    4347                 :     156836 :     int8_type_node =
    4348                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (INT8_TYPE)));
    4349                 :     156836 :   if (INT16_TYPE)
    4350                 :     156836 :     int16_type_node =
    4351                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (INT16_TYPE)));
    4352                 :     156836 :   if (INT32_TYPE)
    4353                 :     156836 :     int32_type_node =
    4354                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (INT32_TYPE)));
    4355                 :     156836 :   if (INT64_TYPE)
    4356                 :     313672 :     int64_type_node =
    4357                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (INT64_TYPE)));
    4358                 :     156836 :   if (UINT8_TYPE)
    4359                 :     156836 :     uint8_type_node =
    4360                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT8_TYPE)));
    4361                 :     156836 :   if (UINT16_TYPE)
    4362                 :     156836 :     c_uint16_type_node = uint16_type_node =
    4363                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT16_TYPE)));
    4364                 :     156836 :   if (UINT32_TYPE)
    4365                 :     156836 :     c_uint32_type_node = uint32_type_node =
    4366                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT32_TYPE)));
    4367                 :     156836 :   if (UINT64_TYPE)
    4368                 :     313672 :     c_uint64_type_node = uint64_type_node =
    4369                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT64_TYPE)));
    4370                 :     156836 :   if (INT_LEAST8_TYPE)
    4371                 :     156836 :     int_least8_type_node =
    4372                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (INT_LEAST8_TYPE)));
    4373                 :     156836 :   if (INT_LEAST16_TYPE)
    4374                 :     156836 :     int_least16_type_node =
    4375                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (INT_LEAST16_TYPE)));
    4376                 :     156836 :   if (INT_LEAST32_TYPE)
    4377                 :     156836 :     int_least32_type_node =
    4378                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (INT_LEAST32_TYPE)));
    4379                 :     156836 :   if (INT_LEAST64_TYPE)
    4380                 :     313672 :     int_least64_type_node =
    4381                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (INT_LEAST64_TYPE)));
    4382                 :     156836 :   if (UINT_LEAST8_TYPE)
    4383                 :     156836 :     uint_least8_type_node =
    4384                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT_LEAST8_TYPE)));
    4385                 :     156836 :   if (UINT_LEAST16_TYPE)
    4386                 :     156836 :     uint_least16_type_node =
    4387                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT_LEAST16_TYPE)));
    4388                 :     156836 :   if (UINT_LEAST32_TYPE)
    4389                 :     156836 :     uint_least32_type_node =
    4390                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT_LEAST32_TYPE)));
    4391                 :     156836 :   if (UINT_LEAST64_TYPE)
    4392                 :     313672 :     uint_least64_type_node =
    4393                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT_LEAST64_TYPE)));
    4394                 :     156836 :   if (INT_FAST8_TYPE)
    4395                 :     156836 :     int_fast8_type_node =
    4396                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (INT_FAST8_TYPE)));
    4397                 :     156836 :   if (INT_FAST16_TYPE)
    4398                 :     313672 :     int_fast16_type_node =
    4399                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (INT_FAST16_TYPE)));
    4400                 :     156836 :   if (INT_FAST32_TYPE)
    4401                 :     313672 :     int_fast32_type_node =
    4402                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (INT_FAST32_TYPE)));
    4403                 :     156836 :   if (INT_FAST64_TYPE)
    4404                 :     313672 :     int_fast64_type_node =
    4405                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (INT_FAST64_TYPE)));
    4406                 :     156836 :   if (UINT_FAST8_TYPE)
    4407                 :     156836 :     uint_fast8_type_node =
    4408                 :     156836 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT_FAST8_TYPE)));
    4409                 :     156836 :   if (UINT_FAST16_TYPE)
    4410                 :     313672 :     uint_fast16_type_node =
    4411                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT_FAST16_TYPE)));
    4412                 :     156836 :   if (UINT_FAST32_TYPE)
    4413                 :     313672 :     uint_fast32_type_node =
    4414                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT_FAST32_TYPE)));
    4415                 :     156836 :   if (UINT_FAST64_TYPE)
    4416                 :     313672 :     uint_fast64_type_node =
    4417                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (UINT_FAST64_TYPE)));
    4418                 :     156836 :   if (INTPTR_TYPE)
    4419                 :     313672 :     intptr_type_node =
    4420                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (INTPTR_TYPE)));
    4421                 :     156836 :   if (UINTPTR_TYPE)
    4422                 :     313672 :     uintptr_type_node =
    4423                 :     313672 :       TREE_TYPE (identifier_global_value (c_get_ident (UINTPTR_TYPE)));
    4424                 :            : 
    4425                 :     156836 :   default_function_type
    4426                 :     156836 :     = build_varargs_function_type_list (integer_type_node, NULL_TREE);
    4427                 :     156836 :   unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node);
    4428                 :            : 
    4429                 :     156836 :   lang_hooks.decls.pushdecl
    4430                 :     156836 :     (build_decl (UNKNOWN_LOCATION,
    4431                 :            :                  TYPE_DECL, get_identifier ("__builtin_va_list"),
    4432                 :            :                  va_list_type_node));
    4433                 :     156836 :   if (targetm.enum_va_list_p)
    4434                 :            :     {
    4435                 :            :       int l;
    4436                 :            :       const char *pname;
    4437                 :            :       tree ptype;
    4438                 :            : 
    4439                 :     461698 :       for (l = 0; targetm.enum_va_list_p (l, &pname, &ptype); ++l)
    4440                 :            :         {
    4441                 :     304862 :           lang_hooks.decls.pushdecl
    4442                 :     304862 :             (build_decl (UNKNOWN_LOCATION,
    4443                 :            :                          TYPE_DECL, get_identifier (pname),
    4444                 :            :                          ptype));
    4445                 :            : 
    4446                 :            :         }
    4447                 :            :     }
    4448                 :            : 
    4449                 :     156836 :   if (TREE_CODE (va_list_type_node) == ARRAY_TYPE)
    4450                 :            :     {
    4451                 :     304802 :       va_list_arg_type_node = va_list_ref_type_node =
    4452                 :     152401 :         build_pointer_type (TREE_TYPE (va_list_type_node));
    4453                 :            :     }
    4454                 :            :   else
    4455                 :            :     {
    4456                 :       4435 :       va_list_arg_type_node = va_list_type_node;
    4457                 :       4435 :       va_list_ref_type_node = build_reference_type (va_list_type_node);
    4458                 :            :     }
    4459                 :            : 
    4460                 :     156836 :   c_define_builtins (va_list_ref_type_node, va_list_arg_type_node);
    4461                 :            : 
    4462                 :     156836 :   main_identifier_node = get_identifier ("main");
    4463                 :            : 
    4464                 :            :   /* Create the built-in __null node.  It is important that this is
    4465                 :            :      not shared.  */
    4466                 :     156836 :   null_node = make_int_cst (1, 1);
    4467                 :     161241 :   TREE_TYPE (null_node) = c_common_type_for_size (POINTER_SIZE, 0);
    4468                 :            : 
    4469                 :            :   /* Since builtin_types isn't gc'ed, don't export these nodes.  */
    4470                 :     156836 :   memset (builtin_types, 0, sizeof (builtin_types));
    4471                 :     156836 : }
    4472                 :            : 
    4473                 :            : /* The number of named compound-literals generated thus far.  */
    4474                 :            : static GTY(()) int compound_literal_number;
    4475                 :            : 
    4476                 :            : /* Set DECL_NAME for DECL, a VAR_DECL for a compound-literal.  */
    4477                 :            : 
    4478                 :            : void
    4479                 :        212 : set_compound_literal_name (tree decl)
    4480                 :            : {
    4481                 :        212 :   char *name;
    4482                 :        212 :   ASM_FORMAT_PRIVATE_NAME (name, "__compound_literal",
    4483                 :            :                            compound_literal_number);
    4484                 :        212 :   compound_literal_number++;
    4485                 :        212 :   DECL_NAME (decl) = get_identifier (name);
    4486                 :        212 : }
    4487                 :            : 
    4488                 :            : /* build_va_arg helper function.  Return a VA_ARG_EXPR with location LOC, type
    4489                 :            :    TYPE and operand OP.  */
    4490                 :            : 
    4491                 :            : static tree
    4492                 :      34962 : build_va_arg_1 (location_t loc, tree type, tree op)
    4493                 :            : {
    4494                 :      34962 :   tree expr = build1 (VA_ARG_EXPR, type, op);
    4495                 :      34962 :   SET_EXPR_LOCATION (expr, loc);
    4496                 :      34962 :   return expr;
    4497                 :            : }
    4498                 :            : 
    4499                 :            : /* Return a VA_ARG_EXPR corresponding to a source-level expression
    4500                 :            :    va_arg (EXPR, TYPE) at source location LOC.  */
    4501                 :            : 
    4502                 :            : tree
    4503                 :      34962 : build_va_arg (location_t loc, tree expr, tree type)
    4504                 :            : {
    4505                 :      34962 :   tree va_type = TREE_TYPE (expr);
    4506                 :      34962 :   tree canon_va_type = (va_type == error_mark_node
    4507                 :      34962 :                         ? error_mark_node
    4508                 :      34951 :                         : targetm.canonical_va_list_type (va_type));
    4509                 :            : 
    4510                 :      34962 :   if (va_type == error_mark_node
    4511                 :      34951 :       || canon_va_type == NULL_TREE)
    4512                 :            :     {
    4513                 :         25 :       if (canon_va_type == NULL_TREE)
    4514                 :         14 :         error_at (loc, "first argument to %<va_arg%> not of type %<va_list%>");
    4515                 :            : 
    4516                 :            :       /* Let's handle things neutrallly, if expr:
    4517                 :            :          - has undeclared type, or
    4518                 :            :          - is not an va_list type.  */
    4519                 :         25 :       return build_va_arg_1 (loc, type, error_mark_node);
    4520                 :            :     }
    4521                 :            : 
    4522                 :      34937 :   if (TREE_CODE (canon_va_type) != ARRAY_TYPE)
    4523                 :            :     {
    4524                 :            :       /* Case 1: Not an array type.  */
    4525                 :            : 
    4526                 :            :       /* Take the address, to get '&ap'.  Note that &ap is not a va_list
    4527                 :            :          type.  */
    4528                 :        215 :       mark_addressable (expr);
    4529                 :        215 :       expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (expr)), expr);
    4530                 :            : 
    4531                 :        215 :       return build_va_arg_1 (loc, type, expr);
    4532                 :            :     }
    4533                 :            : 
    4534                 :            :   /* Case 2: Array type.
    4535                 :            : 
    4536                 :            :      Background:
    4537                 :            : 
    4538                 :            :      For contrast, let's start with the simple case (case 1).  If
    4539                 :            :      canon_va_type is not an array type, but say a char *, then when
    4540                 :            :      passing-by-value a va_list, the type of the va_list param decl is
    4541                 :            :      the same as for another va_list decl (all ap's are char *):
    4542                 :            : 
    4543                 :            :      f2_1 (char * ap)
    4544                 :            :        D.1815 = VA_ARG (&ap, 0B, 1);
    4545                 :            :        return D.1815;
    4546                 :            : 
    4547                 :            :      f2 (int i)
    4548                 :            :        char * ap.0;
    4549                 :            :        char * ap;
    4550                 :            :        __builtin_va_start (&ap, 0);
    4551                 :            :        ap.0 = ap;
    4552                 :            :        res = f2_1 (ap.0);
    4553                 :            :        __builtin_va_end (&ap);
    4554                 :            :        D.1812 = res;
    4555                 :            :        return D.1812;
    4556                 :            : 
    4557                 :            :      However, if canon_va_type is ARRAY_TYPE, then when passing-by-value a
    4558                 :            :      va_list the type of the va_list param decl (case 2b, struct * ap) is not
    4559                 :            :      the same as for another va_list decl (case 2a, struct ap[1]).
    4560                 :            : 
    4561                 :            :      f2_1 (struct  * ap)
    4562                 :            :        D.1844 = VA_ARG (ap, 0B, 0);
    4563                 :            :        return D.1844;
    4564                 :            : 
    4565                 :            :      f2 (int i)
    4566                 :            :        struct  ap[1];
    4567                 :            :        __builtin_va_start (&ap, 0);
    4568                 :            :        res = f2_1 (&ap);
    4569                 :            :        __builtin_va_end (&ap);
    4570                 :            :        D.1841 = res;
    4571                 :            :        return D.1841;
    4572                 :            : 
    4573                 :            :      Case 2b is different because:
    4574                 :            :      - on the callee side, the parm decl has declared type va_list, but
    4575                 :            :        grokdeclarator changes the type of the parm decl to a pointer to the
    4576                 :            :        array elem type.
    4577                 :            :      - on the caller side, the pass-by-value uses &ap.
    4578                 :            : 
    4579                 :            :      We unify these two cases (case 2a: va_list is array type,
    4580                 :            :      case 2b: va_list is pointer to array elem type), by adding '&' for the
    4581                 :            :      array type case, such that we have a pointer to array elem in both
    4582                 :            :      cases.  */
    4583                 :            : 
    4584                 :      34722 :   if (TREE_CODE (va_type) == ARRAY_TYPE)
    4585                 :            :     {
    4586                 :            :       /* Case 2a: va_list is array type.  */
    4587                 :            : 
    4588                 :            :       /* Take the address, to get '&ap'.  Make sure it's a pointer to array
    4589                 :            :          elem type.  */
    4590                 :      34061 :       mark_addressable (expr);
    4591                 :      34061 :       expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (canon_va_type)),
    4592                 :            :                      expr);
    4593                 :            : 
    4594                 :            :       /* Verify that &ap is still recognized as having va_list type.  */
    4595                 :      34061 :       tree canon_expr_type
    4596                 :      34061 :         = targetm.canonical_va_list_type (TREE_TYPE (expr));
    4597                 :      34061 :       gcc_assert (canon_expr_type != NULL_TREE);
    4598                 :            :     }
    4599                 :            :   else
    4600                 :            :     {
    4601                 :            :       /* Case 2b: va_list is pointer to array elem type.  */
    4602                 :        661 :       gcc_assert (POINTER_TYPE_P (va_type));
    4603                 :            : 
    4604                 :            :       /* Comparison as in std_canonical_va_list_type.  */
    4605                 :        661 :       gcc_assert (TYPE_MAIN_VARIANT (TREE_TYPE (va_type))
    4606                 :            :                   == TYPE_MAIN_VARIANT (TREE_TYPE (canon_va_type)));
    4607                 :            : 
    4608                 :            :       /* Don't take the address.  We've already got '&ap'.  */
    4609                 :      34722 :       ;
    4610                 :            :     }
    4611                 :            : 
    4612                 :      34722 :   return build_va_arg_1 (loc, type, expr);
    4613                 :            : }
    4614                 :            : 
    4615                 :            : 
    4616                 :            : /* Linked list of disabled built-in functions.  */
    4617                 :            : 
    4618                 :            : struct disabled_builtin
    4619                 :            : {
    4620                 :            :   const char *name;
    4621                 :            :   struct disabled_builtin *next;
    4622                 :            : };
    4623                 :            : static disabled_builtin *disabled_builtins = NULL;
    4624                 :            : 
    4625                 :            : static bool builtin_function_disabled_p (const char *);
    4626                 :            : 
    4627                 :            : /* Disable a built-in function specified by -fno-builtin-NAME.  If NAME
    4628                 :            :    begins with "__builtin_", give an error.  */
    4629                 :            : 
    4630                 :            : void
    4631                 :        275 : disable_builtin_function (const char *name)
    4632                 :            : {
    4633                 :        275 :   if (strncmp (name, "__builtin_", strlen ("__builtin_")) == 0)
    4634                 :          0 :     error ("cannot disable built-in function %qs", name);
    4635                 :            :   else
    4636                 :            :     {
    4637                 :        275 :       disabled_builtin *new_disabled_builtin = XNEW (disabled_builtin);
    4638                 :        275 :       new_disabled_builtin->name = name;
    4639                 :        275 :       new_disabled_builtin->next = disabled_builtins;
    4640                 :        275 :       disabled_builtins = new_disabled_builtin;
    4641                 :            :     }
    4642                 :        275 : }
    4643                 :            : 
    4644                 :            : 
    4645                 :            : /* Return true if the built-in function NAME has been disabled, false
    4646                 :            :    otherwise.  */
    4647                 :            : 
    4648                 :            : static bool
    4649                 :   79598600 : builtin_function_disabled_p (const char *name)
    4650                 :            : {
    4651                 :   79598600 :   disabled_builtin *p;
    4652                 :   79778000 :   for (p = disabled_builtins; p != NULL; p = p->next)
    4653                 :            :     {
    4654                 :     179691 :       if (strcmp (name, p->name) == 0)
    4655                 :            :         return true;
    4656                 :            :     }
    4657                 :            :   return false;
    4658                 :            : }
    4659                 :            : 
    4660                 :            : 
    4661                 :            : /* Worker for DEF_BUILTIN.
    4662                 :            :    Possibly define a builtin function with one or two names.
    4663                 :            :    Does not declare a non-__builtin_ function if flag_no_builtin, or if
    4664                 :            :    nonansi_p and flag_no_nonansi_builtin.  */
    4665                 :            : 
    4666                 :            : static void
    4667                 :  148939000 : def_builtin_1 (enum built_in_function fncode,
    4668                 :            :                const char *name,
    4669                 :            :                enum built_in_class fnclass,
    4670                 :            :                tree fntype, tree libtype,
    4671                 :            :                bool both_p, bool fallback_p, bool nonansi_p,
    4672                 :            :                tree fnattrs, bool implicit_p)
    4673                 :            : {
    4674                 :  148939000 :   tree decl;
    4675                 :  148939000 :   const char *libname;
    4676                 :            : 
    4677                 :  148939000 :   if (fntype == error_mark_node)
    4678                 :            :     return;
    4679                 :            : 
    4680                 :  143465000 :   gcc_assert ((!both_p && !fallback_p)
    4681                 :            :               || !strncmp (name, "__builtin_",
    4682                 :            :                            strlen ("__builtin_")));
    4683                 :            : 
    4684                 :  143465000 :   libname = name + strlen ("__builtin_");
    4685                 :  200729000 :   decl = add_builtin_function (name, fntype, fncode, fnclass,
    4686                 :            :                                (fallback_p ? libname : NULL),
    4687                 :            :                                fnattrs);
    4688                 :            : 
    4689                 :  143465000 :   set_builtin_decl (fncode, decl, implicit_p);
    4690                 :            : 
    4691                 :  143465000 :   if (both_p
    4692                 :   79917700 :       && !flag_no_builtin && !builtin_function_disabled_p (libname)
    4693                 :  223064000 :       && !(nonansi_p && flag_no_nonansi_builtin))
    4694                 :   71490100 :     add_builtin_function (libname, libtype, fncode, fnclass,
    4695                 :            :                           NULL, fnattrs);
    4696                 :            : }
    4697                 :            : 
    4698                 :            : /* Nonzero if the type T promotes to int.  This is (nearly) the
    4699                 :            :    integral promotions defined in ISO C99 6.3.1.1/2.  */
    4700                 :            : 
    4701                 :            : bool
    4702                 :  176307000 : c_promoting_integer_type_p (const_tree t)
    4703                 :            : {
    4704                 :  176307000 :   switch (TREE_CODE (t))
    4705                 :            :     {
    4706                 :  125538000 :     case INTEGER_TYPE:
    4707                 :  125538000 :       return (TYPE_MAIN_VARIANT (t) == char_type_node
    4708                 :  122215000 :               || TYPE_MAIN_VARIANT (t) == signed_char_type_node
    4709                 :  122074000 :               || TYPE_MAIN_VARIANT (t) == unsigned_char_type_node
    4710                 :   98793400 :               || TYPE_MAIN_VARIANT (t) == short_integer_type_node
    4711                 :   96912700 :               || TYPE_MAIN_VARIANT (t) == short_unsigned_type_node
    4712                 :  214885000 :               || TYPE_PRECISION (t) < TYPE_PRECISION (integer_type_node));
    4713                 :            : 
    4714                 :     300165 :     case ENUMERAL_TYPE:
    4715                 :            :       /* ??? Technically all enumerations not larger than an int
    4716                 :            :          promote to an int.  But this is used along code paths
    4717                 :            :          that only want to notice a size change.  */
    4718                 :     300165 :       return TYPE_PRECISION (t) < TYPE_PRECISION (integer_type_node);
    4719                 :            : 
    4720                 :            :     case BOOLEAN_TYPE:
    4721                 :            :       return true;
    4722                 :            : 
    4723                 :   50362800 :     default:
    4724                 :   50362800 :       return false;
    4725                 :            :     }
    4726                 :            : }
    4727                 :            : 
    4728                 :            : /* Return 1 if PARMS specifies a fixed number of parameters
    4729                 :            :    and none of their types is affected by default promotions.  */
    4730                 :            : 
    4731                 :            : bool
    4732                 :      18721 : self_promoting_args_p (const_tree parms)
    4733                 :            : {
    4734                 :      18721 :   const_tree t;
    4735                 :      53898 :   for (t = parms; t; t = TREE_CHAIN (t))
    4736                 :            :     {
    4737                 :      35910 :       tree type = TREE_VALUE (t);
    4738                 :            : 
    4739                 :      35910 :       if (type == error_mark_node)
    4740                 :          1 :         continue;
    4741                 :            : 
    4742                 :      35909 :       if (TREE_CHAIN (t) == NULL_TREE && type != void_type_node)
    4743                 :            :         return false;
    4744                 :            : 
    4745                 :      35230 :       if (type == NULL_TREE)
    4746                 :            :         return false;
    4747                 :            : 
    4748                 :      35230 :       if (TYPE_MAIN_VARIANT (type) == float_type_node)
    4749                 :            :         return false;
    4750                 :            : 
    4751                 :      35178 :       if (c_promoting_integer_type_p (type))
    4752                 :            :         return false;
    4753                 :            :     }
    4754                 :            :   return true;
    4755                 :            : }
    4756                 :            : 
    4757                 :            : /* Recursively remove any '*' or '&' operator from TYPE.  */
    4758                 :            : tree
    4759                 :   12337500 : strip_pointer_operator (tree t)
    4760                 :            : {
    4761                 :   13701900 :   while (POINTER_TYPE_P (t))
    4762                 :    1364430 :     t = TREE_TYPE (t);
    4763                 :   12337500 :   return t;
    4764                 :            : }
    4765                 :            : 
    4766                 :            : /* Recursively remove pointer or array type from TYPE. */
    4767                 :            : tree
    4768                 :     375987 : strip_pointer_or_array_types (tree t)
    4769                 :            : {
    4770                 :     487992 :   while (TREE_CODE (t) == ARRAY_TYPE || POINTER_TYPE_P (t))
    4771                 :     112005 :     t = TREE_TYPE (t);
    4772                 :     375987 :   return t;
    4773                 :            : }
    4774                 :            : 
    4775                 :            : /* Used to compare case labels.  K1 and K2 are actually tree nodes
    4776                 :            :    representing case labels, or NULL_TREE for a `default' label.
    4777                 :            :    Returns -1 if K1 is ordered before K2, -1 if K1 is ordered after
    4778                 :            :    K2, and 0 if K1 and K2 are equal.  */
    4779                 :            : 
    4780                 :            : int
    4781                 :   10847400 : case_compare (splay_tree_key k1, splay_tree_key k2)
    4782                 :            : {
    4783                 :            :   /* Consider a NULL key (such as arises with a `default' label) to be
    4784                 :            :      smaller than anything else.  */
    4785                 :   10847400 :   if (!k1)
    4786                 :    1351600 :     return k2 ? -1 : 0;
    4787                 :    9638760 :   else if (!k2)
    4788                 :            :     return k1 ? 1 : 0;
    4789                 :            : 
    4790                 :    9483660 :   return tree_int_cst_compare ((tree) k1, (tree) k2);
    4791                 :            : }
    4792                 :            : 
    4793                 :            : /* Process a case label, located at LOC, for the range LOW_VALUE
    4794                 :            :    ... HIGH_VALUE.  If LOW_VALUE and HIGH_VALUE are both NULL_TREE
    4795                 :            :    then this case label is actually a `default' label.  If only
    4796                 :            :    HIGH_VALUE is NULL_TREE, then case label was declared using the
    4797                 :            :    usual C/C++ syntax, rather than the GNU case range extension.
    4798                 :            :    CASES is a tree containing all the case ranges processed so far;
    4799                 :            :    COND is the condition for the switch-statement itself.
    4800                 :            :    Returns the CASE_LABEL_EXPR created, or ERROR_MARK_NODE if no
    4801                 :            :    CASE_LABEL_EXPR is created.  */
    4802                 :            : 
    4803                 :            : tree
    4804                 :    1127760 : c_add_case_label (location_t loc, splay_tree cases, tree cond,
    4805                 :            :                   tree low_value, tree high_value)
    4806                 :            : {
    4807                 :    1127760 :   tree type;
    4808                 :    1127760 :   tree label;
    4809                 :    1127760 :   tree case_label;
    4810                 :    1127760 :   splay_tree_node node;
    4811                 :            : 
    4812                 :            :   /* Create the LABEL_DECL itself.  */
    4813                 :    1127760 :   label = create_artificial_label (loc);
    4814                 :            : 
    4815                 :            :   /* If there was an error processing the switch condition, bail now
    4816                 :            :      before we get more confused.  */
    4817                 :    1127760 :   if (!cond || cond == error_mark_node)
    4818                 :          0 :     goto error_out;
    4819                 :            : 
    4820                 :    1081530 :   if ((low_value && TREE_TYPE (low_value)
    4821                 :    1081530 :        && POINTER_TYPE_P (TREE_TYPE (low_value)))
    4822                 :    2209580 :       || (high_value && TREE_TYPE (high_value)
    4823                 :        291 :           && POINTER_TYPE_P (TREE_TYPE (high_value))))
    4824                 :            :     {
    4825                 :          1 :       error_at (loc, "pointers are not permitted as case values");
    4826                 :          1 :       goto error_out;
    4827                 :            :     }
    4828                 :            : 
    4829                 :            :   /* Case ranges are a GNU extension.  */
    4830                 :    1127760 :   if (high_value)
    4831                 :        291 :     pedwarn (loc, OPT_Wpedantic,
    4832                 :            :              "range expressions in switch statements are non-standard");
    4833                 :            : 
    4834                 :    1127760 :   type = TREE_TYPE (cond);
    4835                 :    1127760 :   if (low_value)
    4836                 :            :     {
    4837                 :    1081530 :       low_value = check_case_value (loc, low_value);
    4838                 :    1081530 :       low_value = convert_and_check (loc, type, low_value);
    4839                 :    1081530 :       low_value = fold (low_value);
    4840                 :    1081530 :       if (low_value == error_mark_node)
    4841                 :        180 :         goto error_out;
    4842                 :            :     }
    4843                 :    1127580 :   if (high_value)
    4844                 :            :     {
    4845                 :        291 :       high_value = check_case_value (loc, high_value);
    4846                 :        291 :       high_value = convert_and_check (loc, type, high_value);
    4847                 :        291 :       high_value = fold (high_value);
    4848                 :        291 :       if (high_value == error_mark_node)
    4849                 :          3 :         goto error_out;
    4850                 :            :     }
    4851                 :            : 
    4852                 :    1127580 :   if (low_value && high_value)
    4853                 :            :     {
    4854                 :            :       /* If the LOW_VALUE and HIGH_VALUE are the same, then this isn't
    4855                 :            :          really a case range, even though it was written that way.
    4856                 :            :          Remove the HIGH_VALUE to simplify later processing.  */
    4857                 :        288 :       if (tree_int_cst_equal (low_value, high_value))
    4858                 :            :         high_value = NULL_TREE;
    4859                 :        285 :       else if (!tree_int_cst_lt (low_value, high_value))
    4860                 :          3 :         warning_at (loc, 0, "empty range specified");
    4861                 :            :     }
    4862                 :            : 
    4863                 :            :   /* Look up the LOW_VALUE in the table of case labels we already
    4864                 :            :      have.  */
    4865                 :    1127580 :   node = splay_tree_lookup (cases, (splay_tree_key) low_value);
    4866                 :            :   /* If there was not an exact match, check for overlapping ranges.
    4867                 :            :      There's no need to do this if there's no LOW_VALUE or HIGH_VALUE;
    4868                 :            :      that's a `default' label and the only overlap is an exact match.  */
    4869                 :    1127580 :   if (!node && (low_value || high_value))
    4870                 :            :     {
    4871                 :    1081320 :       splay_tree_node low_bound;
    4872                 :    1081320 :       splay_tree_node high_bound;
    4873                 :            : 
    4874                 :            :       /* Even though there wasn't an exact match, there might be an
    4875                 :            :          overlap between this case range and another case range.
    4876                 :            :          Since we've (inductively) not allowed any overlapping case
    4877                 :            :          ranges, we simply need to find the greatest low case label
    4878                 :            :          that is smaller that LOW_VALUE, and the smallest low case
    4879                 :            :          label that is greater than LOW_VALUE.  If there is an overlap
    4880                 :            :          it will occur in one of these two ranges.  */
    4881                 :    1081320 :       low_bound = splay_tree_predecessor (cases,
    4882                 :            :                                           (splay_tree_key) low_value);
    4883                 :    1081320 :       high_bound = splay_tree_successor (cases,
    4884                 :            :                                          (splay_tree_key) low_value);
    4885                 :            : 
    4886                 :            :       /* Check to see if the LOW_BOUND overlaps.  It is smaller than
    4887                 :            :          the LOW_VALUE, so there is no need to check unless the
    4888                 :            :          LOW_BOUND is in fact itself a case range.  */
    4889                 :    1081320 :       if (low_bound
    4890                 :    1009760 :           && CASE_HIGH ((tree) low_bound->value)
    4891                 :    1081400 :           && tree_int_cst_compare (CASE_HIGH ((tree) low_bound->value),
    4892                 :            :                                     low_value) >= 0)
    4893                 :            :         node = low_bound;
    4894                 :            :       /* Check to see if the HIGH_BOUND overlaps.  The low end of that
    4895                 :            :          range is bigger than the low end of the current range, so we
    4896                 :            :          are only interested if the current range is a real range, and
    4897                 :            :          not an ordinary case label.  */
    4898                 :    1081310 :       else if (high_bound
    4899                 :    1081310 :                && high_value
    4900                 :    1081310 :                && (tree_int_cst_compare ((tree) high_bound->key,
    4901                 :            :                                          high_value)
    4902                 :            :                    <= 0))
    4903                 :            :         node = high_bound;
    4904                 :            :     }
    4905                 :            :   /* If there was an overlap, issue an error.  */
    4906                 :    1127580 :   if (node)
    4907                 :            :     {
    4908                 :         33 :       tree duplicate = CASE_LABEL ((tree) node->value);
    4909                 :            : 
    4910                 :         33 :       if (high_value)
    4911                 :            :         {
    4912                 :          6 :           error_at (loc, "duplicate (or overlapping) case value");
    4913                 :          6 :           inform (DECL_SOURCE_LOCATION (duplicate),
    4914                 :            :                   "this is the first entry overlapping that value");
    4915                 :            :         }
    4916                 :         27 :       else if (low_value)
    4917                 :            :         {
    4918                 :         26 :           error_at (loc, "duplicate case value") ;
    4919                 :         26 :           inform (DECL_SOURCE_LOCATION (duplicate), "previously used here");
    4920                 :            :         }
    4921                 :            :       else
    4922                 :            :         {
    4923                 :          1 :           error_at (loc, "multiple default labels in one switch");
    4924                 :          1 :           inform (DECL_SOURCE_LOCATION (duplicate),
    4925                 :            :                   "this is the first default label");
    4926                 :            :         }
    4927                 :         33 :       goto error_out;
    4928                 :            :     }
    4929                 :            : 
    4930                 :            :   /* Add a CASE_LABEL to the statement-tree.  */
    4931                 :    1127540 :   case_label = add_stmt (build_case_label (low_value, high_value, label));
    4932                 :            :   /* Register this case label in the splay tree.  */
    4933                 :    1127540 :   splay_tree_insert (cases,
    4934                 :            :                      (splay_tree_key) low_value,
    4935                 :            :                      (splay_tree_value) case_label);
    4936                 :            : 
    4937                 :    1127540 :   return case_label;
    4938                 :            : 
    4939                 :        217 :  error_out:
    4940                 :            :   /* Add a label so that the back-end doesn't think that the beginning of
    4941                 :            :      the switch is unreachable.  Note that we do not add a case label, as
    4942                 :            :      that just leads to duplicates and thence to failure later on.  */
    4943                 :        217 :   if (!cases->root)
    4944                 :            :     {
    4945                 :        177 :       tree t = create_artificial_label (loc);
    4946                 :        177 :       add_stmt (build_stmt (loc, LABEL_EXPR, t));
    4947                 :            :     }
    4948                 :        217 :   return error_mark_node;
    4949                 :            : }
    4950                 :            : 
    4951                 :            : /* Subroutine of c_switch_covers_all_cases_p, called via
    4952                 :            :    splay_tree_foreach.  Return 1 if it doesn't cover all the cases.
    4953                 :            :    ARGS[0] is initially NULL and after the first iteration is the
    4954                 :            :    so far highest case label.  ARGS[1] is the minimum of SWITCH_COND's
    4955                 :            :    type.  */
    4956                 :            : 
    4957                 :            : static int
    4958                 :      71300 : c_switch_covers_all_cases_p_1 (splay_tree_node node, void *data)
    4959                 :            : {
    4960                 :      71300 :   tree label = (tree) node->value;
    4961                 :      71300 :   tree *args = (tree *) data;
    4962                 :            : 
    4963                 :            :   /* If there is a default case, we shouldn't have called this.  */
    4964                 :      71300 :   gcc_assert (CASE_LOW (label));
    4965                 :            : 
    4966                 :      71300 :   if (args[0] == NULL_TREE)
    4967                 :            :     {
    4968                 :      20484 :       if (wi::to_widest (args[1]) < wi::to_widest (CASE_LOW (label)))
    4969                 :            :         return 1;
    4970                 :            :     }
    4971                 :     101632 :   else if (wi::add (wi::to_widest (args[0]), 1)
    4972                 :     101632 :            != wi::to_widest (CASE_LOW (label)))
    4973                 :            :     return 1;
    4974                 :      66859 :   if (CASE_HIGH (label))
    4975                 :        117 :     args[0] = CASE_HIGH (label);
    4976                 :            :   else
    4977                 :      66742 :     args[0] = CASE_LOW (label);
    4978                 :            :   return 0;
    4979                 :            : }
    4980                 :            : 
    4981                 :            : /* Return true if switch with CASES and switch condition with type
    4982                 :            :    covers all possible values in the case labels.  */
    4983                 :            : 
    4984                 :            : bool
    4985                 :      49978 : c_switch_covers_all_cases_p (splay_tree cases, tree type)
    4986                 :            : {
    4987                 :            :   /* If there is default:, this is always the case.  */
    4988                 :      49978 :   splay_tree_node default_node
    4989                 :      49978 :     = splay_tree_lookup (cases, (splay_tree_key) NULL);
    4990                 :      49978 :   if (default_node)
    4991                 :            :     return true;
    4992                 :            : 
    4993                 :      24783 :   if (!INTEGRAL_TYPE_P (type))
    4994                 :            :     return false;
    4995                 :            : 
    4996                 :      24754 :   tree args[2] = { NULL_TREE, TYPE_MIN_VALUE (type) };
    4997                 :      24754 :   if (splay_tree_foreach (cases, c_switch_covers_all_cases_p_1, args))
    4998                 :            :     return false;
    4999                 :            : 
    5000                 :            :   /* If there are no cases at all, or if the highest case label
    5001                 :            :      is smaller than TYPE_MAX_VALUE, return false.  */
    5002                 :      20313 :   if (args[0] == NULL_TREE
    5003                 :      20313 :       || wi::to_widest (args[0]) < wi::to_widest (TYPE_MAX_VALUE (type)))
    5004                 :      20265 :     return false;
    5005                 :            : 
    5006                 :            :   return true;
    5007                 :            : }
    5008                 :            : 
    5009                 :            : /* Finish an expression taking the address of LABEL (an
    5010                 :            :    IDENTIFIER_NODE).  Returns an expression for the address.
    5011                 :            : 
    5012                 :            :    LOC is the location for the expression returned.  */
    5013                 :            : 
    5014                 :            : tree
    5015                 :       1962 : finish_label_address_expr (tree label, location_t loc)
    5016                 :            : {
    5017                 :       1962 :   tree result;
    5018                 :            : 
    5019                 :       1962 :   pedwarn (input_location, OPT_Wpedantic, "taking the address of a label is non-standard");
    5020                 :            : 
    5021                 :       1962 :   if (label == error_mark_node)
    5022                 :            :     return error_mark_node;
    5023                 :            : 
    5024                 :       1954 :   label = lookup_label (label);
    5025                 :       1954 :   if (label == NULL_TREE)
    5026                 :          6 :     result = null_pointer_node;
    5027                 :            :   else
    5028                 :            :     {
    5029                 :       1948 :       TREE_USED (label) = 1;
    5030                 :       1948 :       result = build1 (ADDR_EXPR, ptr_type_node, label);
    5031                 :            :       /* The current function is not necessarily uninlinable.
    5032                 :            :          Computed gotos are incompatible with inlining, but the value
    5033                 :            :          here could be used only in a diagnostic, for example.  */
    5034                 :       1948 :       protected_set_expr_location (result, loc);
    5035                 :            :     }
    5036                 :            : 
    5037                 :            :   return result;
    5038                 :            : }
    5039                 :            : 
    5040                 :            : 
    5041                 :            : /* Given a boolean expression ARG, return a tree representing an increment
    5042                 :            :    or decrement (as indicated by CODE) of ARG.  The front end must check for
    5043                 :            :    invalid cases (e.g., decrement in C++).  */
    5044                 :            : tree
    5045                 :         80 : boolean_increment (enum tree_code code, tree arg)
    5046                 :            : {
    5047                 :         80 :   tree val;
    5048                 :         80 :   tree true_res = build_int_cst (TREE_TYPE (arg), 1);
    5049                 :            : 
    5050                 :         80 :   arg = stabilize_reference (arg);
    5051                 :         80 :   switch (code)
    5052                 :            :     {
    5053                 :         26 :     case PREINCREMENT_EXPR:
    5054                 :         26 :       val = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg, true_res);
    5055                 :         26 :       break;
    5056                 :         36 :     case POSTINCREMENT_EXPR:
    5057                 :         36 :       val = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg, true_res);
    5058                 :         36 :       arg = save_expr (arg);
    5059                 :         36 :       val = build2 (COMPOUND_EXPR, TREE_TYPE (arg), val, arg);
    5060                 :         36 :       val = build2 (COMPOUND_EXPR, TREE_TYPE (arg), arg, val);
    5061                 :         36 :       break;
    5062                 :          9 :     case PREDECREMENT_EXPR:
    5063                 :          9 :       val = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg,
    5064                 :            :                     invert_truthvalue_loc (input_location, arg));
    5065                 :          9 :       break;
    5066                 :          9 :     case POSTDECREMENT_EXPR:
    5067                 :          9 :       val = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg,
    5068                 :            :                     invert_truthvalue_loc (input_location, arg));
    5069                 :          9 :       arg = save_expr (arg);
    5070                 :          9 :       val = build2 (COMPOUND_EXPR, TREE_TYPE (arg), val, arg);
    5071                 :          9 :       val = build2 (COMPOUND_EXPR, TREE_TYPE (arg), arg, val);
    5072                 :          9 :       break;
    5073                 :          0 :     default:
    5074                 :          0 :       gcc_unreachable ();
    5075                 :            :     }
    5076                 :         80 :   TREE_SIDE_EFFECTS (val) = 1;
    5077                 :         80 :   return val;
    5078                 :            : }
    5079                 :            : 
    5080                 :            : /* Built-in macros for stddef.h and stdint.h, that require macros
    5081                 :            :    defined in this file.  */
    5082                 :            : void
    5083                 :     156687 : c_stddef_cpp_builtins(void)
    5084                 :            : {
    5085                 :     161160 :   builtin_define_with_value ("__SIZE_TYPE__", SIZE_TYPE, 0);
    5086                 :     161160 :   builtin_define_with_value ("__PTRDIFF_TYPE__", PTRDIFF_TYPE, 0);
    5087                 :     161160 :   builtin_define_with_value ("__WCHAR_TYPE__", MODIFIED_WCHAR_TYPE, 0);
    5088                 :     156687 :   builtin_define_with_value ("__WINT_TYPE__", WINT_TYPE, 0);
    5089                 :     161092 :   builtin_define_with_value ("__INTMAX_TYPE__", INTMAX_TYPE, 0);
    5090                 :     308901 :   builtin_define_with_value ("__UINTMAX_TYPE__", UINTMAX_TYPE, 0);
    5091                 :     156687 :   if (flag_char8_t)
    5092                 :      15858 :     builtin_define_with_value ("__CHAR8_TYPE__", CHAR8_TYPE, 0);
    5093                 :     156687 :   builtin_define_with_value ("__CHAR16_TYPE__", CHAR16_TYPE, 0);
    5094                 :     156687 :   builtin_define_with_value ("__CHAR32_TYPE__", CHAR32_TYPE, 0);
    5095                 :     156687 :   if (SIG_ATOMIC_TYPE)
    5096                 :     156687 :     builtin_define_with_value ("__SIG_ATOMIC_TYPE__", SIG_ATOMIC_TYPE, 0);
    5097                 :     156687 :   if (INT8_TYPE)
    5098                 :     156687 :     builtin_define_with_value ("__INT8_TYPE__", INT8_TYPE, 0);
    5099                 :     156687 :   if (INT16_TYPE)
    5100                 :     156687 :     builtin_define_with_value ("__INT16_TYPE__", INT16_TYPE, 0);
    5101                 :     156687 :   if (INT32_TYPE)
    5102                 :     156687 :     builtin_define_with_value ("__INT32_TYPE__", INT32_TYPE, 0);
    5103                 :     156687 :   if (INT64_TYPE)
    5104                 :     308901 :     builtin_define_with_value ("__INT64_TYPE__", INT64_TYPE, 0);
    5105                 :     156687 :   if (UINT8_TYPE)
    5106                 :     156687 :     builtin_define_with_value ("__UINT8_TYPE__", UINT8_TYPE, 0);
    5107                 :     156687 :   if (UINT16_TYPE)
    5108                 :     156687 :     builtin_define_with_value ("__UINT16_TYPE__", UINT16_TYPE, 0);
    5109                 :     156687 :   if (UINT32_TYPE)
    5110                 :     156687 :     builtin_define_with_value ("__UINT32_TYPE__", UINT32_TYPE, 0);
    5111                 :     156687 :   if (UINT64_TYPE)
    5112                 :     308901 :     builtin_define_with_value ("__UINT64_TYPE__", UINT64_TYPE, 0);
    5113                 :     156687 :   if (INT_LEAST8_TYPE)
    5114                 :     156687 :     builtin_define_with_value ("__INT_LEAST8_TYPE__", INT_LEAST8_TYPE, 0);
    5115                 :     156687 :   if (INT_LEAST16_TYPE)
    5116                 :     156687 :     builtin_define_with_value ("__INT_LEAST16_TYPE__", INT_LEAST16_TYPE, 0);
    5117                 :     156687 :   if (INT_LEAST32_TYPE)
    5118                 :     156687 :     builtin_define_with_value ("__INT_LEAST32_TYPE__", INT_LEAST32_TYPE, 0);
    5119                 :     156687 :   if (INT_LEAST64_TYPE)
    5120                 :     308901 :     builtin_define_with_value ("__INT_LEAST64_TYPE__", INT_LEAST64_TYPE, 0);
    5121                 :     156687 :   if (UINT_LEAST8_TYPE)
    5122                 :     156687 :     builtin_define_with_value ("__UINT_LEAST8_TYPE__", UINT_LEAST8_TYPE, 0);
    5123                 :     156687 :   if (UINT_LEAST16_TYPE)
    5124                 :     156687 :     builtin_define_with_value ("__UINT_LEAST16_TYPE__", UINT_LEAST16_TYPE, 0);
    5125                 :     156687 :   if (UINT_LEAST32_TYPE)
    5126                 :     156687 :     builtin_define_with_value ("__UINT_LEAST32_TYPE__", UINT_LEAST32_TYPE, 0);
    5127                 :     156687 :   if (UINT_LEAST64_TYPE)
    5128                 :     308901 :     builtin_define_with_value ("__UINT_LEAST64_TYPE__", UINT_LEAST64_TYPE, 0);
    5129                 :     156687 :   if (INT_FAST8_TYPE)
    5130                 :     156687 :     builtin_define_with_value ("__INT_FAST8_TYPE__", INT_FAST8_TYPE, 0);
    5131                 :     156687 :   if (INT_FAST16_TYPE)
    5132                 :     161160 :     builtin_define_with_value ("__INT_FAST16_TYPE__", INT_FAST16_TYPE, 0);
    5133                 :     156687 :   if (INT_FAST32_TYPE)
    5134                 :     161160 :     builtin_define_with_value ("__INT_FAST32_TYPE__", INT_FAST32_TYPE, 0);
    5135                 :     156687 :   if (INT_FAST64_TYPE)
    5136                 :     308901 :     builtin_define_with_value ("__INT_FAST64_TYPE__", INT_FAST64_TYPE, 0);
    5137                 :     156687 :   if (UINT_FAST8_TYPE)
    5138                 :     156687 :     builtin_define_with_value ("__UINT_FAST8_TYPE__", UINT_FAST8_TYPE, 0);
    5139                 :     156687 :   if (UINT_FAST16_TYPE)
    5140                 :     161160 :     builtin_define_with_value ("__UINT_FAST16_TYPE__", UINT_FAST16_TYPE, 0);
    5141                 :     156687 :   if (UINT_FAST32_TYPE)
    5142                 :     161160 :     builtin_define_with_value ("__UINT_FAST32_TYPE__", UINT_FAST32_TYPE, 0);
    5143                 :     156687 :   if (UINT_FAST64_TYPE)
    5144                 :     308901 :     builtin_define_with_value ("__UINT_FAST64_TYPE__", UINT_FAST64_TYPE, 0);
    5145                 :     156687 :   if (INTPTR_TYPE)
    5146                 :     308901 :     builtin_define_with_value ("__INTPTR_TYPE__", INTPTR_TYPE, 0);
    5147                 :     156687 :   if (UINTPTR_TYPE)
    5148                 :     308901 :     builtin_define_with_value ("__UINTPTR_TYPE__", UINTPTR_TYPE, 0);
    5149                 :            :   /* GIMPLE FE testcases need access to the GCC internal 'sizetype'.
    5150                 :            :      Expose it as __SIZETYPE__.  */
    5151                 :     156687 :   if (flag_gimple)
    5152                 :        129 :     builtin_define_with_value ("__SIZETYPE__", SIZETYPE, 0);
    5153                 :     156687 : }
    5154                 :            : 
    5155                 :            : static void
    5156                 :     156836 : c_init_attributes (void)
    5157                 :            : {
    5158                 :            :   /* Fill in the built_in_attributes array.  */
    5159                 :            : #define DEF_ATTR_NULL_TREE(ENUM)                                \
    5160                 :            :   built_in_attributes[(int) ENUM] = NULL_TREE;
    5161                 :            : #define DEF_ATTR_INT(ENUM, VALUE)                               \
    5162                 :            :   built_in_attributes[(int) ENUM] = build_int_cst (integer_type_node, VALUE);
    5163                 :            : #define DEF_ATTR_STRING(ENUM, VALUE)                            \
    5164                 :            :   built_in_attributes[(int) ENUM] = build_string (strlen (VALUE), VALUE);
    5165                 :            : #define DEF_ATTR_IDENT(ENUM, STRING)                            \
    5166                 :            :   built_in_attributes[(int) ENUM] = get_identifier (STRING);
    5167                 :            : #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) \
    5168                 :            :   built_in_attributes[(int) ENUM]                       \
    5169                 :            :     = tree_cons (built_in_attributes[(int) PURPOSE],    \
    5170                 :            :                  built_in_attributes[(int) VALUE],      \
    5171                 :            :                  built_in_attributes[(int) CHAIN]);
    5172                 :            : #include "builtin-attrs.def"
    5173                 :            : #undef DEF_ATTR_NULL_TREE
    5174                 :            : #undef DEF_ATTR_INT
    5175                 :            : #undef DEF_ATTR_IDENT
    5176                 :            : #undef DEF_ATTR_TREE_LIST
    5177                 :     156836 : }
    5178                 :            : 
    5179                 :            : /* Check whether the byte alignment ALIGN is a valid user-specified
    5180                 :            :    alignment less than the supported maximum.  If so, return ALIGN's
    5181                 :            :    base-2 log; if not, output an error and return -1.  If OBJFILE
    5182                 :            :    then reject alignments greater than MAX_OFILE_ALIGNMENT when
    5183                 :            :    converted to bits.  Otherwise, consider valid only alignments
    5184                 :            :    that are less than HOST_BITS_PER_INT - LOG2_BITS_PER_UNIT.
    5185                 :            :    Zero is not considered a valid argument (and results in -1 on
    5186                 :            :    return) but it only triggers a warning when WARN_ZERO is set.  */
    5187                 :            : 
    5188                 :            : int
    5189                 :     147198 : check_user_alignment (const_tree align, bool objfile, bool warn_zero)
    5190                 :            : {
    5191                 :     294381 :   if (error_operand_p (align))
    5192                 :            :     return -1;
    5193                 :            : 
    5194                 :     147183 :   if (TREE_CODE (align) != INTEGER_CST
    5195                 :     294338 :       || !INTEGRAL_TYPE_P (TREE_TYPE (align)))
    5196                 :            :     {
    5197                 :         29 :       error ("requested alignment is not an integer constant");
    5198                 :         29 :       return -1;
    5199                 :            :     }
    5200                 :            : 
    5201                 :     147154 :   if (integer_zerop (align))
    5202                 :            :     {
    5203                 :         80 :       if (warn_zero)
    5204                 :         70 :         warning (OPT_Wattributes,
    5205                 :            :                  "requested alignment %qE is not a positive power of 2",
    5206                 :            :                  align);
    5207                 :         80 :       return -1;
    5208                 :            :     }
    5209                 :            : 
    5210                 :            :   /* Log2 of the byte alignment ALIGN.  */
    5211                 :     147074 :   int log2align;
    5212                 :     147074 :   if (tree_int_cst_sgn (align) == -1
    5213                 :     147074 :       || (log2align = tree_log2 (align)) == -1)
    5214                 :            :     {
    5215                 :         37 :       error ("requested alignment %qE is not a positive power of 2",
    5216                 :            :              align);
    5217                 :         37 :       return -1;
    5218                 :            :     }
    5219                 :            : 
    5220                 :     147037 :   if (objfile)
    5221                 :            :     {
    5222                 :       2460 :       unsigned maxalign = MAX_OFILE_ALIGNMENT / BITS_PER_UNIT;
    5223                 :       2460 :       if (!tree_fits_uhwi_p (align) || tree_to_uhwi (align) > maxalign)
    5224                 :            :         {
    5225                 :         10 :           error ("requested alignment %qE exceeds object file maximum %u",
    5226                 :            :                  align, maxalign);
    5227                 :         10 :           return -1;
    5228                 :            :         }
    5229                 :            :     }
    5230                 :            : 
    5231                 :     147027 :   if (log2align >= HOST_BITS_PER_INT - LOG2_BITS_PER_UNIT)
    5232                 :            :     {
    5233                 :         19 :       error ("requested alignment %qE exceeds maximum %u",
    5234                 :            :              align, 1U << (HOST_BITS_PER_INT - LOG2_BITS_PER_UNIT - 1));
    5235                 :         19 :       return -1;
    5236                 :            :     }
    5237                 :            : 
    5238                 :            :   return log2align;
    5239                 :            : }
    5240                 :            : 
    5241                 :            : /* Determine the ELF symbol visibility for DECL, which is either a
    5242                 :            :    variable or a function.  It is an error to use this function if a
    5243                 :            :    definition of DECL is not available in this translation unit.
    5244                 :            :    Returns true if the final visibility has been determined by this
    5245                 :            :    function; false if the caller is free to make additional
    5246                 :            :    modifications.  */
    5247                 :            : 
    5248                 :            : bool
    5249                 :   31374200 : c_determine_visibility (tree decl)
    5250                 :            : {
    5251                 :   31374200 :   gcc_assert (VAR_OR_FUNCTION_DECL_P (decl));
    5252                 :            : 
    5253                 :            :   /* If the user explicitly specified the visibility with an
    5254                 :            :      attribute, honor that.  DECL_VISIBILITY will have been set during
    5255                 :            :      the processing of the attribute.  We check for an explicit
    5256                 :            :      attribute, rather than just checking DECL_VISIBILITY_SPECIFIED,
    5257                 :            :      to distinguish the use of an attribute from the use of a "#pragma
    5258                 :            :      GCC visibility push(...)"; in the latter case we still want other
    5259                 :            :      considerations to be able to overrule the #pragma.  */
    5260                 :   31374200 :   if (lookup_attribute ("visibility", DECL_ATTRIBUTES (decl))
    5261                 :            :       || (TARGET_DLLIMPORT_DECL_ATTRIBUTES
    5262                 :            :           && (lookup_attribute ("dllimport", DECL_ATTRIBUTES (decl))
    5263                 :            :               || lookup_attribute ("dllexport", DECL_ATTRIBUTES (decl)))))
    5264                 :            :     return true;
    5265                 :            : 
    5266                 :            :   /* Set default visibility to whatever the user supplied with
    5267                 :            :      visibility_specified depending on #pragma GCC visibility.  */
    5268                 :   30871300 :   if (!DECL_VISIBILITY_SPECIFIED (decl))
    5269                 :            :     {
    5270                 :   30870300 :       if (visibility_options.inpragma
    5271                 :   30870300 :           || DECL_VISIBILITY (decl) != default_visibility)
    5272                 :            :         {
    5273                 :     189838 :           DECL_VISIBILITY (decl) = default_visibility;
    5274                 :     189838 :           DECL_VISIBILITY_SPECIFIED (decl) = visibility_options.inpragma;
    5275                 :            :           /* If visibility changed and DECL already has DECL_RTL, ensure
    5276                 :            :              symbol flags are updated.  */
    5277                 :     189838 :           if (((VAR_P (decl) && TREE_STATIC (decl))
    5278                 :     189822 :                || TREE_CODE (decl) == FUNCTION_DECL)
    5279                 :     366828 :               && DECL_RTL_SET_P (decl))
    5280                 :          0 :             make_decl_rtl (decl);
    5281                 :            :         }
    5282                 :            :     }
    5283                 :            :   return false;
    5284                 :            : }
    5285                 :            : 
    5286                 :            : /* Data to communicate through check_function_arguments_recurse between
    5287                 :            :    check_function_nonnull and check_nonnull_arg.  */
    5288                 :            : 
    5289                 :            : struct nonnull_arg_ctx
    5290                 :            : {
    5291                 :            :   location_t loc;
    5292                 :            :   bool warned_p;
    5293                 :            : };
    5294                 :            : 
    5295                 :            : /* Check the argument list of a function call for null in argument slots
    5296                 :            :    that are marked as requiring a non-null pointer argument.  The NARGS
    5297                 :            :    arguments are passed in the array ARGARRAY.  Return true if we have
    5298                 :            :    warned.  */
    5299                 :            : 
    5300                 :            : static bool
    5301                 :    2278600 : check_function_nonnull (location_t loc, tree attrs, int nargs, tree *argarray)
    5302                 :            : {
    5303                 :    2278600 :   tree a;
    5304                 :    2278600 :   int i;
    5305                 :            : 
    5306                 :    2278600 :   attrs = lookup_attribute ("nonnull", attrs);
    5307                 :    2278600 :   if (attrs == NULL_TREE)
    5308                 :            :     return false;
    5309                 :            : 
    5310                 :      88389 :   a = attrs;
    5311                 :            :   /* See if any of the nonnull attributes has no arguments.  If so,
    5312                 :            :      then every pointer argument is checked (in which case the check
    5313                 :            :      for pointer type is done in check_nonnull_arg).  */
    5314                 :      88389 :   if (TREE_VALUE (a) != NULL_TREE)
    5315                 :      54325 :     do
    5316                 :      54325 :       a = lookup_attribute ("nonnull", TREE_CHAIN (a));
    5317                 :      59701 :     while (a != NULL_TREE && TREE_VALUE (a) != NULL_TREE);
    5318                 :            : 
    5319                 :      88389 :   struct nonnull_arg_ctx ctx = { loc, false };
    5320                 :      88389 :   if (a != NULL_TREE)
    5321                 :     135520 :     for (i = 0; i < nargs; i++)
    5322                 :      96080 :       check_function_arguments_recurse (check_nonnull_arg, &ctx, argarray[i],
    5323                 :      96080 :                                         i + 1);
    5324                 :            :   else
    5325                 :            :     {
    5326                 :            :       /* Walk the argument list.  If we encounter an argument number we
    5327                 :            :          should check for non-null, do it.  */
    5328                 :     193415 :       for (i = 0; i < nargs; i++)
    5329                 :            :         {
    5330                 :      80707 :           for (a = attrs; ; a = TREE_CHAIN (a))
    5331                 :            :             {
    5332                 :     225173 :               a = lookup_attribute ("nonnull", a);
    5333                 :     225173 :               if (a == NULL_TREE || nonnull_check_p (TREE_VALUE (a), i + 1))
    5334                 :            :                 break;
    5335                 :            :             }
    5336                 :            : 
    5337                 :     144466 :           if (a != NULL_TREE)
    5338                 :      63835 :             check_function_arguments_recurse (check_nonnull_arg, &ctx,
    5339                 :      63835 :                                               argarray[i], i + 1);
    5340                 :            :         }
    5341                 :            :     }
    5342                 :      88389 :   return ctx.warned_p;
    5343                 :            : }
    5344                 :            : 
    5345                 :            : /* Check that the Nth argument of a function call (counting backwards
    5346                 :            :    from the end) is a (pointer)0.  The NARGS arguments are passed in the
    5347                 :            :    array ARGARRAY.  */
    5348                 :            : 
    5349                 :            : static void
    5350                 :    2277090 : check_function_sentinel (const_tree fntype, int nargs, tree *argarray)
    5351                 :            : {
    5352                 :    2277090 :   tree attr = lookup_attribute ("sentinel", TYPE_ATTRIBUTES (fntype));
    5353                 :            : 
    5354                 :    2277090 :   if (attr)
    5355                 :            :     {
    5356                 :        101 :       int len = 0;
    5357                 :        101 :       int pos = 0;
    5358                 :        101 :       tree sentinel;
    5359                 :        101 :       function_args_iterator iter;
    5360                 :        101 :       tree t;
    5361                 :            : 
    5362                 :            :       /* Skip over the named arguments.  */
    5363                 :        224 :       FOREACH_FUNCTION_ARGS (fntype, t, iter)
    5364                 :            :         {
    5365                 :        123 :           if (len == nargs)
    5366                 :            :             break;
    5367                 :        123 :           len++;
    5368                 :            :         }
    5369                 :            : 
    5370                 :        101 :       if (TREE_VALUE (attr))
    5371                 :            :         {
    5372                 :         63 :           tree p = TREE_VALUE (TREE_VALUE (attr));
    5373                 :         63 :           pos = TREE_INT_CST_LOW (p);
    5374                 :            :         }
    5375                 :            : 
    5376                 :            :       /* The sentinel must be one of the varargs, i.e.
    5377                 :            :          in position >= the number of fixed arguments.  */
    5378                 :        101 :       if ((nargs - 1 - pos) < len)
    5379                 :            :         {
    5380                 :         22 :           warning (OPT_Wformat_,
    5381                 :            :                    "not enough variable arguments to fit a sentinel");
    5382                 :         22 :           return;
    5383                 :            :         }
    5384                 :            : 
    5385                 :            :       /* Validate the sentinel.  */
    5386                 :         79 :       sentinel = fold_for_warn (argarray[nargs - 1 - pos]);
    5387                 :        118 :       if ((!POINTER_TYPE_P (TREE_TYPE (sentinel))
    5388                 :         40 :            || !integer_zerop (sentinel))
    5389                 :            :           /* Although __null (in C++) is only an integer we allow it
    5390                 :            :              nevertheless, as we are guaranteed that it's exactly
    5391                 :            :              as wide as a pointer, and we don't want to force
    5392                 :            :              users to cast the NULL they have written there.
    5393                 :            :              We warn with -Wstrict-null-sentinel, though.  */
    5394                 :        126 :           && (warn_strict_null_sentinel || null_node != sentinel))
    5395                 :         43 :         warning (OPT_Wformat_, "missing sentinel in function call");
    5396                 :            :     }
    5397                 :            : }
    5398                 :            : 
    5399                 :            : /* Check that the same argument isn't passed to two or more
    5400                 :            :    restrict-qualified formal and issue a -Wrestrict warning
    5401                 :            :    if it is.  Return true if a warning has been issued.  */
    5402                 :            : 
    5403                 :            : static bool
    5404                 :   30337500 : check_function_restrict (const_tree fndecl, const_tree fntype,
    5405                 :            :                          int nargs, tree *unfolded_argarray)
    5406                 :            : {
    5407                 :   30337500 :   int i;
    5408                 :   30337500 :   tree parms = TYPE_ARG_TYPES (fntype);
    5409                 :            : 
    5410                 :            :   /* Call fold_for_warn on all of the arguments.  */
    5411                 :   30337500 :   auto_vec<tree> argarray (nargs);
    5412                 :  103615000 :   for (i = 0; i < nargs; i++)
    5413                 :   73277500 :     argarray.quick_push (fold_for_warn (unfolded_argarray[i]));
    5414                 :            : 
    5415                 :   30337500 :   if (fndecl
    5416                 :   29004300 :       && TREE_CODE (fndecl) == FUNCTION_DECL)
    5417                 :            :     {
    5418                 :            :       /* Avoid diagnosing calls built-ins with a zero size/bound
    5419                 :            :          here.  They are checked in more detail elsewhere.  */
    5420                 :   29004300 :       if (fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
    5421                 :    1127480 :           && nargs == 3
    5422                 :     217535 :           && TREE_CODE (argarray[2]) == INTEGER_CST
    5423                 :   29121300 :           && integer_zerop (argarray[2]))
    5424                 :            :         return false;
    5425                 :            : 
    5426                 :   28980800 :       if (DECL_ARGUMENTS (fndecl))
    5427                 :    3355950 :         parms = DECL_ARGUMENTS (fndecl);
    5428                 :            :     }
    5429                 :            : 
    5430                 :  103521000 :   for (i = 0; i < nargs; i++)
    5431                 :   73206800 :     TREE_VISITED (argarray[i]) = 0;
    5432                 :            : 
    5433                 :            :   bool warned = false;
    5434                 :            : 
    5435                 :  103182000 :   for (i = 0; i < nargs && parms && parms != void_list_node; i++)
    5436                 :            :     {
    5437                 :   72868400 :       tree type;
    5438                 :   72868400 :       if (TREE_CODE (parms) == PARM_DECL)
    5439                 :            :         {
    5440                 :    7406430 :           type = TREE_TYPE (parms);
    5441                 :    7406430 :           parms = DECL_CHAIN (parms);
    5442                 :            :         }
    5443                 :            :       else
    5444                 :            :         {
    5445                 :   65462000 :           type = TREE_VALUE (parms);
    5446                 :   65462000 :           parms = TREE_CHAIN (parms);
    5447                 :            :         }
    5448                 :   72868400 :       if (POINTER_TYPE_P (type)
    5449                 :    4327340 :           && TYPE_RESTRICT (type)
    5450                 :   73043700 :           && !TYPE_READONLY (TREE_TYPE (type)))
    5451                 :     178334 :         warned |= warn_for_restrict (i, argarray.address (), nargs);
    5452                 :            :     }
    5453                 :            : 
    5454                 :  103521000 :   for (i = 0; i < nargs; i++)
    5455                 :   73206800 :     TREE_VISITED (argarray[i]) = 0;
    5456                 :            : 
    5457                 :            :   return warned;
    5458                 :            : }
    5459                 :            : 
    5460                 :            : /* Helper for check_function_nonnull; given a list of operands which
    5461                 :            :    must be non-null in ARGS, determine if operand PARAM_NUM should be
    5462                 :            :    checked.  */
    5463                 :            : 
    5464                 :            : static bool
    5465                 :     144542 : nonnull_check_p (tree args, unsigned HOST_WIDE_INT param_num)
    5466                 :            : {
    5467                 :     144542 :   unsigned HOST_WIDE_INT arg_num = 0;
    5468                 :            : 
    5469                 :     257810 :   for (; args; args = TREE_CHAIN (args))
    5470                 :            :     {
    5471                 :     177103 :       bool found = get_attribute_operand (TREE_VALUE (args), &arg_num);
    5472                 :            : 
    5473                 :     177103 :       gcc_assert (found);
    5474                 :            : 
    5475                 :     177103 :       if (arg_num == param_num)
    5476                 :            :         return true;
    5477                 :            :     }
    5478                 :            :   return false;
    5479                 :            : }
    5480                 :            : 
    5481                 :            : /* Check that the function argument PARAM (which is operand number
    5482                 :            :    PARAM_NUM) is non-null.  This is called by check_function_nonnull
    5483                 :            :    via check_function_arguments_recurse.  */
    5484                 :            : 
    5485                 :            : static void
    5486                 :     160288 : check_nonnull_arg (void *ctx, tree param, unsigned HOST_WIDE_INT param_num)
    5487                 :            : {
    5488                 :     160288 :   struct nonnull_arg_ctx *pctx = (struct nonnull_arg_ctx *) ctx;
    5489                 :            : 
    5490                 :            :   /* Just skip checking the argument if it's not a pointer.  This can
    5491                 :            :      happen if the "nonnull" attribute was given without an operand
    5492                 :            :      list (which means to check every pointer argument).  */
    5493                 :            : 
    5494                 :     160288 :   if (TREE_CODE (TREE_TYPE (param)) != POINTER_TYPE)
    5495                 :            :     return;
    5496                 :            : 
    5497                 :            :   /* Diagnose the simple cases of null arguments.  */
    5498                 :     124973 :   if (integer_zerop (fold_for_warn (param)))
    5499                 :            :     {
    5500                 :        370 :       warning_at (pctx->loc, OPT_Wnonnull, "null argument where non-null "
    5501                 :            :                   "required (argument %lu)", (unsigned long) param_num);
    5502                 :        370 :       pctx->warned_p = true;
    5503                 :            :     }
    5504                 :            : }
    5505                 :            : 
    5506                 :            : /* Helper for attribute handling; fetch the operand number from
    5507                 :            :    the attribute argument list.  */
    5508                 :            : 
    5509                 :            : bool
    5510                 :     177103 : get_attribute_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp)
    5511                 :            : {
    5512                 :            :   /* Verify the arg number is a small constant.  */
    5513                 :     177103 :   if (tree_fits_uhwi_p (arg_num_expr))
    5514                 :            :     {
    5515                 :     177103 :       *valp = tree_to_uhwi (arg_num_expr);
    5516                 :     177103 :       return true;
    5517                 :            :     }
    5518                 :            :   else
    5519                 :            :     return false;
    5520                 :            : }
    5521                 :            : 
    5522                 :            : /* Arguments being collected for optimization.  */
    5523                 :            : typedef const char *const_char_p;               /* For DEF_VEC_P.  */
    5524                 :            : static GTY(()) vec<const_char_p, va_gc> *optimize_args;
    5525                 :            : 
    5526                 :            : 
    5527                 :            : /* Inner function to convert a TREE_LIST to argv string to parse the optimize
    5528                 :            :    options in ARGS.  ATTR_P is true if this is for attribute(optimize), and
    5529                 :            :    false for #pragma GCC optimize.  */
    5530                 :            : 
    5531                 :            : bool
    5532                 :       4327 : parse_optimize_options (tree args, bool attr_p)
    5533                 :            : {
    5534                 :       4327 :   bool ret = true;
    5535                 :       4327 :   unsigned opt_argc;
    5536                 :       4327 :   unsigned i;
    5537                 :       4327 :   const char **opt_argv;
    5538                 :       4327 :   struct cl_decoded_option *decoded_options;
    5539                 :       4327 :   unsigned int decoded_options_count;
    5540                 :       4327 :   tree ap;
    5541                 :            : 
    5542                 :            :   /* Build up argv vector.  Just in case the string is stored away, use garbage
    5543                 :            :      collected strings.  */
    5544                 :       4327 :   vec_safe_truncate (optimize_args, 0);
    5545                 :       4327 :   vec_safe_push (optimize_args, (const char *) NULL);
    5546                 :            : 
    5547                 :       8675 :   for (ap = args; ap != NULL_TREE; ap = TREE_CHAIN (ap))
    5548                 :            :     {
    5549                 :       4348 :       tree value = TREE_VALUE (ap);
    5550                 :            : 
    5551                 :       4348 :       if (TREE_CODE (value) == INTEGER_CST)
    5552                 :            :         {
    5553                 :         94 :           char buffer[20];
    5554                 :         94 :           sprintf (buffer, "-O%ld", (long) TREE_INT_CST_LOW (value));
    5555                 :         94 :           vec_safe_push (optimize_args, ggc_strdup (buffer));
    5556                 :            :         }
    5557                 :            : 
    5558                 :       4254 :       else if (TREE_CODE (value) == STRING_CST)
    5559                 :            :         {
    5560                 :            :           /* Split string into multiple substrings.  */
    5561                 :       4254 :           size_t len = TREE_STRING_LENGTH (value);
    5562                 :       4254 :           char *p = ASTRDUP (TREE_STRING_POINTER (value));
    5563                 :       4254 :           char *end = p + len;
    5564                 :       4254 :           char *comma;
    5565                 :       4254 :           char *next_p = p;
    5566                 :            : 
    5567                 :       8525 :           while (next_p != NULL)
    5568                 :            :             {
    5569                 :       4271 :               size_t len2;
    5570                 :       4271 :               char *q, *r;
    5571                 :            : 
    5572                 :       4271 :               p = next_p;
    5573                 :       4271 :               comma = strchr (p, ',');
    5574                 :       4271 :               if (comma)
    5575                 :            :                 {
    5576                 :         17 :                   len2 = comma - p;
    5577                 :         17 :                   *comma = '\0';
    5578                 :         17 :                   next_p = comma+1;
    5579                 :            :                 }
    5580                 :            :               else
    5581                 :            :                 {
    5582                 :       4254 :                   len2 = end - p;
    5583                 :       4254 :                   next_p = NULL;
    5584                 :            :                 }
    5585                 :            : 
    5586                 :            :               /* If the user supplied -Oxxx or -fxxx, only allow -Oxxx or -fxxx
    5587                 :            :                  options.  */
    5588                 :       4271 :               if (*p == '-' && p[1] != 'O' && p[1] != 'f')
    5589                 :            :                 {
    5590                 :          0 :                   ret = false;
    5591                 :          0 :                   if (attr_p)
    5592                 :          0 :                     warning (OPT_Wattributes,
    5593                 :            :                              "bad option %qs to attribute %<optimize%>", p);
    5594                 :            :                   else
    5595                 :          0 :                     warning (OPT_Wpragmas,
    5596                 :            :                              "bad option %qs to pragma %<optimize%>", p);
    5597                 :          0 :                   continue;
    5598                 :            :                 }
    5599                 :            : 
    5600                 :            :               /* Can't use GC memory here, see PR88007.  */
    5601                 :       4271 :               r = q = XOBNEWVEC (&opts_obstack, char, len2 + 3);
    5602                 :            : 
    5603                 :       4271 :               if (*p != '-')
    5604                 :            :                 {
    5605                 :       4138 :                   *r++ = '-';
    5606                 :            : 
    5607                 :            :                   /* Assume that Ox is -Ox, a numeric value is -Ox, a s by
    5608                 :            :                      itself is -Os, and any other switch begins with a -f.  */
    5609                 :       4138 :                   if ((*p >= '0' && *p <= '9')
    5610                 :       4110 :                       || (p[0] == 's' && p[1] == '\0'))
    5611                 :         28 :                     *r++ = 'O';
    5612                 :       4110 :                   else if (*p != 'O')
    5613                 :       3976 :                     *r++ = 'f';
    5614                 :            :                 }
    5615                 :            : 
    5616                 :       4271 :               memcpy (r, p, len2);
    5617                 :       4271 :               r[len2] = '\0';
    5618                 :       4271 :               vec_safe_push (optimize_args, (const char *) q);
    5619                 :            :             }
    5620                 :            : 
    5621                 :            :         }
    5622                 :            :     }
    5623                 :            : 
    5624                 :       4327 :   opt_argc = optimize_args->length ();
    5625                 :       4327 :   opt_argv = (const char **) alloca (sizeof (char *) * (opt_argc + 1));
    5626                 :            : 
    5627                 :       8692 :   for (i = 1; i < opt_argc; i++)
    5628                 :       4365 :     opt_argv[i] = (*optimize_args)[i];
    5629                 :            : 
    5630                 :            :   /* Now parse the options.  */
    5631                 :       4327 :   decode_cmdline_options_to_array_default_mask (opt_argc, opt_argv,
    5632                 :            :                                                 &decoded_options,
    5633                 :            :                                                 &decoded_options_count);
    5634                 :            :   /* Drop non-Optimization options.  */
    5635                 :       4327 :   unsigned j = 1;
    5636                 :       8692 :   for (i = 1; i < decoded_options_count; ++i)
    5637                 :            :     {
    5638                 :       4365 :       if (! (cl_options[decoded_options[i].opt_index].flags & CL_OPTIMIZATION))
    5639                 :            :         {
    5640                 :          3 :           ret = false;
    5641                 :          3 :           if (attr_p)
    5642                 :          2 :             warning (OPT_Wattributes,
    5643                 :            :                      "bad option %qs to attribute %<optimize%>",
    5644                 :            :                      decoded_options[i].orig_option_with_args_text);
    5645                 :            :           else
    5646                 :          1 :             warning (OPT_Wpragmas,
    5647                 :            :                      "bad option %qs to pragma %<optimize%>",
    5648                 :            :                      decoded_options[i].orig_option_with_args_text);
    5649                 :          3 :           continue;
    5650                 :            :         }
    5651                 :       4362 :       if (i != j)
    5652                 :          0 :         decoded_options[j] = decoded_options[i];
    5653                 :       4362 :       j++;
    5654                 :            :     }
    5655                 :       4327 :   decoded_options_count = j;
    5656                 :            :   /* And apply them.  */
    5657                 :       4327 :   decode_options (&global_options, &global_options_set,
    5658                 :            :                   decoded_options, decoded_options_count,
    5659                 :            :                   input_location, global_dc, NULL);
    5660                 :            : 
    5661                 :       4327 :   targetm.override_options_after_change();
    5662                 :            : 
    5663                 :       4327 :   optimize_args->truncate (0);
    5664                 :       4327 :   return ret;
    5665                 :            : }
    5666                 :            : 
    5667                 :            : /* Check whether ATTR is a valid attribute fallthrough.  */
    5668                 :            : 
    5669                 :            : bool
    5670                 :   51564400 : attribute_fallthrough_p (tree attr)
    5671                 :            : {
    5672                 :   51564400 :   if (attr == error_mark_node)
    5673                 :            :    return false;
    5674                 :   51564400 :   tree t = lookup_attribute ("fallthrough", attr);
    5675                 :   51564400 :   if (t == NULL_TREE)
    5676                 :            :     return false;
    5677                 :            :   /* This attribute shall appear at most once in each attribute-list.  */
    5678                 :       1680 :   if (lookup_attribute ("fallthrough", TREE_CHAIN (t)))
    5679                 :          9 :     warning (OPT_Wattributes, "%<fallthrough%> attribute specified multiple "
    5680                 :            :              "times");
    5681                 :            :   /* No attribute-argument-clause shall be present.  */
    5682                 :       1671 :   else if (TREE_VALUE (t) != NULL_TREE)
    5683                 :          5 :     warning (OPT_Wattributes, "%<fallthrough%> attribute specified with "
    5684                 :            :              "a parameter");
    5685                 :            :   /* Warn if other attributes are found.  */
    5686                 :       3382 :   for (t = attr; t != NULL_TREE; t = TREE_CHAIN (t))
    5687                 :            :     {
    5688                 :       1702 :       tree name = get_attribute_name (t);
    5689                 :       1702 :       if (!is_attribute_p ("fallthrough", name))
    5690                 :            :         {
    5691                 :         13 :           if (!c_dialect_cxx () && get_attribute_namespace (t) == NULL_TREE)
    5692                 :            :             /* The specifications of standard attributes in C mean
    5693                 :            :                this is a constraint violation.  */
    5694                 :          3 :             pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored",
    5695                 :            :                      get_attribute_name (t));
    5696                 :            :           else
    5697                 :         10 :             warning (OPT_Wattributes, "%qE attribute ignored", name);
    5698                 :            :         }
    5699                 :            :     }
    5700                 :            :   return true;
    5701                 :            : }
    5702                 :            : 
    5703                 :            : 
    5704                 :            : /* Check for valid arguments being passed to a function with FNTYPE.
    5705                 :            :    There are NARGS arguments in the array ARGARRAY.  LOC should be used
    5706                 :            :    for diagnostics.  Return true if either -Wnonnull or -Wrestrict has
    5707                 :            :    been issued.
    5708                 :            : 
    5709                 :            :    The arguments in ARGARRAY may not have been folded yet (e.g. for C++,
    5710                 :            :    to preserve location wrappers); checks that require folded arguments
    5711                 :            :    should call fold_for_warn on them.  */
    5712                 :            : 
    5713                 :            : bool
    5714                 :   30341200 : check_function_arguments (location_t loc, const_tree fndecl, const_tree fntype,
    5715                 :            :                           int nargs, tree *argarray, vec<location_t> *arglocs)
    5716                 :            : {
    5717                 :   30341200 :   bool warned_p = false;
    5718                 :            : 
    5719                 :            :   /* Check for null being passed in a pointer argument that must be
    5720                 :            :      non-null.  We also need to do this if format checking is enabled.  */
    5721                 :            : 
    5722                 :   30341200 :   if (warn_nonnull)
    5723                 :    2278600 :     warned_p = check_function_nonnull (loc, TYPE_ATTRIBUTES (fntype),
    5724                 :            :                                        nargs, argarray);
    5725                 :            : 
    5726                 :            :   /* Check for errors in format strings.  */
    5727                 :            : 
    5728                 :   30341200 :   if (warn_format || warn_suggest_attribute_format)
    5729                 :    2277250 :     check_function_format (fntype, TYPE_ATTRIBUTES (fntype), nargs, argarray,
    5730                 :            :                            arglocs);
    5731                 :            : 
    5732                 :   30341200 :   if (warn_format)
    5733                 :    2277090 :     check_function_sentinel (fntype, nargs, argarray);
    5734                 :            : 
    5735                 :   30341200 :   if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL))
    5736                 :            :     {
    5737                 :    1131260 :       switch (DECL_FUNCTION_CODE (fndecl))
    5738                 :            :         {
    5739                 :            :         case BUILT_IN_SPRINTF:
    5740                 :            :         case BUILT_IN_SPRINTF_CHK:
    5741                 :            :         case BUILT_IN_SNPRINTF:
    5742                 :            :         case BUILT_IN_SNPRINTF_CHK:
    5743                 :            :           /* Let the sprintf pass handle these.  */
    5744                 :            :           return warned_p;
    5745                 :            : 
    5746                 :            :         default:
    5747                 :            :           break;
    5748                 :            :         }
    5749                 :            :     }
    5750                 :            : 
    5751                 :            :   /* check_function_restrict sets the DECL_READ_P for arguments
    5752                 :            :      so it must be called unconditionally.  */
    5753                 :   30337500 :   warned_p |= check_function_restrict (fndecl, fntype, nargs, argarray);
    5754                 :            : 
    5755                 :   30337500 :   return warned_p;
    5756                 :            : }
    5757                 :            : 
    5758                 :            : /* Generic argument checking recursion routine.  PARAM is the argument to
    5759                 :            :    be checked.  PARAM_NUM is the number of the argument.  CALLBACK is invoked
    5760                 :            :    once the argument is resolved.  CTX is context for the callback.  */
    5761                 :            : void
    5762                 :     284797 : check_function_arguments_recurse (void (*callback)
    5763                 :            :                                   (void *, tree, unsigned HOST_WIDE_INT),
    5764                 :            :                                   void *ctx, tree param,
    5765                 :            :                                   unsigned HOST_WIDE_INT param_num)
    5766                 :            : {
    5767                 :     191561 :   if (CONVERT_EXPR_P (param)
    5768                 :     378650 :       && (TYPE_PRECISION (TREE_TYPE (param))
    5769                 :      93853 :           == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (param, 0)))))
    5770                 :            :     {
    5771                 :            :       /* Strip coercion.  */
    5772                 :     184466 :       check_function_arguments_recurse (callback, ctx,
    5773                 :      92233 :                                         TREE_OPERAND (param, 0), param_num);
    5774                 :      92233 :       return;
    5775                 :            :     }
    5776                 :            : 
    5777                 :     192564 :   if (TREE_CODE (param) == CALL_EXPR)
    5778                 :            :     {
    5779                 :       3169 :       tree type = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (param)));
    5780                 :       3169 :       tree attrs;
    5781                 :       3169 :       bool found_format_arg = false;
    5782                 :            : 
    5783                 :            :       /* See if this is a call to a known internationalization function
    5784                 :            :          that modifies a format arg.  Such a function may have multiple
    5785                 :            :          format_arg attributes (for example, ngettext).  */
    5786                 :            : 
    5787                 :       3791 :       for (attrs = TYPE_ATTRIBUTES (type);
    5788                 :       3791 :            attrs;
    5789                 :        622 :            attrs = TREE_CHAIN (attrs))
    5790                 :        622 :         if (is_attribute_p ("format_arg", get_attribute_name (attrs)))
    5791                 :            :           {
    5792                 :        182 :             tree inner_arg;
    5793                 :        182 :             tree format_num_expr;
    5794                 :        182 :             int format_num;
    5795                 :        182 :             int i;
    5796                 :        182 :             call_expr_arg_iterator iter;
    5797                 :            : 
    5798                 :            :             /* Extract the argument number, which was previously checked
    5799                 :            :                to be valid.  */
    5800                 :        182 :             format_num_expr = TREE_VALUE (TREE_VALUE (attrs));
    5801                 :            : 
    5802                 :        182 :             format_num = tree_to_uhwi (format_num_expr);
    5803                 :            : 
    5804                 :        182 :             for (inner_arg = first_call_expr_arg (param, &iter), i = 1;
    5805                 :        252 :                  inner_arg != NULL_TREE;
    5806                 :         70 :                  inner_arg = next_call_expr_arg (&iter), i++)
    5807                 :        252 :               if (i == format_num)
    5808                 :            :                 {
    5809                 :        182 :                   check_function_arguments_recurse (callback, ctx,
    5810                 :            :                                                     inner_arg, param_num);
    5811                 :        182 :                   found_format_arg = true;
    5812                 :        182 :                   break;
    5813                 :            :                 }
    5814                 :            :           }
    5815                 :            : 
    5816                 :            :       /* If we found a format_arg attribute and did a recursive check,
    5817                 :            :          we are done with checking this argument.  Otherwise, we continue
    5818                 :            :          and this will be considered a non-literal.  */
    5819                 :       3169 :       if (found_format_arg)
    5820                 :            :         return;
    5821                 :            :     }
    5822                 :            : 
    5823                 :     192430 :   if (TREE_CODE (param) == COND_EXPR)
    5824                 :            :     {
    5825                 :            :       /* Simplify to avoid warning for an impossible case.  */
    5826                 :        403 :       param = fold_for_warn (param);
    5827                 :        403 :       if (TREE_CODE (param) == COND_EXPR)
    5828                 :            :         {
    5829                 :            :           /* Check both halves of the conditional expression.  */
    5830                 :        395 :           check_function_arguments_recurse (callback, ctx,
    5831                 :        395 :                                             TREE_OPERAND (param, 1),
    5832                 :            :                                             param_num);
    5833                 :        790 :           check_function_arguments_recurse (callback, ctx,
    5834                 :        395 :                                             TREE_OPERAND (param, 2),
    5835                 :            :                                             param_num);
    5836                 :        395 :           return;
    5837                 :            :         }
    5838                 :            :     }
    5839                 :            : 
    5840                 :     192035 :   (*callback) (ctx, param, param_num);
    5841                 :            : }
    5842                 :            : 
    5843                 :            : /* Checks for a builtin function FNDECL that the number of arguments
    5844                 :            :    NARGS against the required number REQUIRED and issues an error if
    5845                 :            :    there is a mismatch.  Returns true if the number of arguments is
    5846                 :            :    correct, otherwise false.  LOC is the location of FNDECL.  */
    5847                 :            : 
    5848                 :            : static bool
    5849                 :     131186 : builtin_function_validate_nargs (location_t loc, tree fndecl, int nargs,
    5850                 :            :                                  int required)
    5851                 :            : {
    5852                 :     131186 :   if (nargs < required)
    5853                 :            :     {
    5854                 :        139 :       error_at (loc, "too few arguments to function %qE", fndecl);
    5855                 :        139 :       return false;
    5856                 :            :     }
    5857                 :     131047 :   else if (nargs > required)
    5858                 :            :     {
    5859                 :         71 :       error_at (loc, "too many arguments to function %qE", fndecl);
    5860                 :         71 :       return false;
    5861                 :            :     }
    5862                 :            :   return true;
    5863                 :            : }
    5864                 :            : 
    5865                 :            : /* Helper macro for check_builtin_function_arguments.  */
    5866                 :            : #define ARG_LOCATION(N)                                 \
    5867                 :            :   (arg_loc.is_empty ()                                  \
    5868                 :            :    ? EXPR_LOC_OR_LOC (args[(N)], input_location)        \
    5869                 :            :    : expansion_point_location (arg_loc[(N)]))
    5870                 :            : 
    5871                 :            : /* Verifies the NARGS arguments ARGS to the builtin function FNDECL.
    5872                 :            :    Returns false if there was an error, otherwise true.  LOC is the
    5873                 :            :    location of the function; ARG_LOC is a vector of locations of the
    5874                 :            :    arguments.  If FNDECL is the result of resolving an overloaded
    5875                 :            :    target built-in, ORIG_FNDECL is the original function decl,
    5876                 :            :    otherwise it is null.  */
    5877                 :            : 
    5878                 :            : bool
    5879                 :   20494200 : check_builtin_function_arguments (location_t loc, vec<location_t> arg_loc,
    5880                 :            :                                   tree fndecl, tree orig_fndecl,
    5881                 :            :                                   int nargs, tree *args)
    5882                 :            : {
    5883                 :   20494200 :   if (!fndecl_built_in_p (fndecl))
    5884                 :            :     return true;
    5885                 :            : 
    5886                 :   20494200 :   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
    5887                 :   18725700 :     return (!targetm.check_builtin_call
    5888                 :   18725700 :             || targetm.check_builtin_call (loc, arg_loc, fndecl,
    5889                 :            :                                            orig_fndecl, nargs, args));
    5890                 :            : 
    5891                 :    1768500 :   if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_FRONTEND)
    5892                 :            :     return true;
    5893                 :            : 
    5894                 :    1756920 :   gcc_assert (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL);
    5895                 :    1756920 :   switch (DECL_FUNCTION_CODE (fndecl))
    5896                 :            :     {
    5897                 :          2 :     case BUILT_IN_ALLOCA_WITH_ALIGN_AND_MAX:
    5898                 :          2 :       if (!tree_fits_uhwi_p (args[2]))
    5899                 :            :         {
    5900                 :          0 :           error_at (ARG_LOCATION (2),
    5901                 :            :                     "third argument to function %qE must be a constant integer",
    5902                 :            :                     fndecl);
    5903                 :          0 :           return false;
    5904                 :            :         }
    5905                 :            :       /* fall through */
    5906                 :            : 
    5907                 :        327 :     case BUILT_IN_ALLOCA_WITH_ALIGN:
    5908                 :        327 :       {
    5909                 :            :         /* Get the requested alignment (in bits) if it's a constant
    5910                 :            :            integer expression.  */
    5911                 :        654 :         unsigned HOST_WIDE_INT align
    5912                 :        327 :           = tree_fits_uhwi_p (args[1]) ? tree_to_uhwi (args[1]) : 0;
    5913                 :            : 
    5914                 :            :         /* Determine if the requested alignment is a power of 2.  */
    5915                 :        327 :         if ((align & (align - 1)))
    5916                 :            :           align = 0;
    5917                 :            : 
    5918                 :            :         /* The maximum alignment in bits corresponding to the same
    5919                 :            :            maximum in bytes enforced in check_user_alignment().  */
    5920                 :        391 :         unsigned maxalign = (UINT_MAX >> 1) + 1;
    5921                 :            : 
    5922                 :            :         /* Reject invalid alignments.  */
    5923                 :        224 :         if (align < BITS_PER_UNIT || maxalign < align)
    5924                 :            :           {
    5925                 :        202 :             error_at (ARG_LOCATION (1),
    5926                 :            :                       "second argument to function %qE must be a constant "
    5927                 :            :                       "integer power of 2 between %qi and %qu bits",
    5928                 :            :                       fndecl, BITS_PER_UNIT, maxalign);
    5929                 :        167 :             return false;
    5930                 :            :           }
    5931                 :            :         return true;
    5932                 :            :       }
    5933                 :            : 
    5934                 :      29885 :     case BUILT_IN_CONSTANT_P:
    5935                 :      29885 :       return builtin_function_validate_nargs (loc, fndecl, nargs, 1);
    5936                 :            : 
    5937                 :       8593 :     case BUILT_IN_ISFINITE:
    5938                 :       8593 :     case BUILT_IN_ISINF:
    5939                 :       8593 :     case BUILT_IN_ISINF_SIGN:
    5940                 :       8593 :     case BUILT_IN_ISNAN:
    5941                 :       8593 :     case BUILT_IN_ISNORMAL:
    5942                 :       8593 :     case BUILT_IN_SIGNBIT:
    5943                 :       8593 :       if (builtin_function_validate_nargs (loc, fndecl, nargs, 1))
    5944                 :            :         {
    5945                 :       8579 :           if (TREE_CODE (TREE_TYPE (args[0])) != REAL_TYPE)
    5946                 :            :             {
    5947                 :         28 :               error_at (ARG_LOCATION (0), "non-floating-point argument in "
    5948                 :            :                         "call to function %qE", fndecl);
    5949                 :         16 :               return false;
    5950                 :            :             }
    5951                 :            :           return true;
    5952                 :            :         }
    5953                 :            :       return false;
    5954                 :            : 
    5955                 :       8643 :     case BUILT_IN_ISGREATER:
    5956                 :       8643 :     case BUILT_IN_ISGREATEREQUAL:
    5957                 :       8643 :     case BUILT_IN_ISLESS:
    5958                 :       8643 :     case BUILT_IN_ISLESSEQUAL:
    5959                 :       8643 :     case BUILT_IN_ISLESSGREATER:
    5960                 :       8643 :     case BUILT_IN_ISUNORDERED:
    5961                 :       8643 :       if (builtin_function_validate_nargs (loc, fndecl, nargs, 2))
    5962                 :            :         {
    5963                 :       8629 :           enum tree_code code0, code1;
    5964                 :       8629 :           code0 = TREE_CODE (TREE_TYPE (args[0]));
    5965                 :       8629 :           code1 = TREE_CODE (TREE_TYPE (args[1]));
    5966                 :       8695 :           if (!((code0 == REAL_TYPE && code1 == REAL_TYPE)
    5967                 :       8629 :                 || (code0 == REAL_TYPE && code1 == INTEGER_TYPE)
    5968                 :         66 :                 || (code0 == INTEGER_TYPE && code1 == REAL_TYPE)))
    5969                 :            :             {
    5970                 :         19 :               error_at (loc, "non-floating-point arguments in call to "
    5971                 :            :                         "function %qE", fndecl);
    5972                 :         19 :               return false;
    5973                 :            :             }
    5974                 :            :           return true;
    5975                 :            :         }
    5976                 :            :       return false;
    5977                 :            : 
    5978                 :       2006 :     case BUILT_IN_FPCLASSIFY:
    5979                 :       2006 :       if (builtin_function_validate_nargs (loc, fndecl, nargs, 6))
    5980                 :            :         {
    5981                 :      11994 :           for (unsigned int i = 0; i < 5; i++)
    5982                 :       9998 :             if (TREE_CODE (args[i]) != INTEGER_CST)
    5983                 :            :               {
    5984                 :         12 :                 error_at (ARG_LOCATION (i), "non-const integer argument %u in "
    5985                 :            :                           "call to function %qE", i + 1, fndecl);
    5986                 :          6 :                 return false;
    5987                 :            :               }
    5988                 :            : 
    5989                 :       1996 :           if (TREE_CODE (TREE_TYPE (args[5])) != REAL_TYPE)
    5990                 :            :             {
    5991                 :          4 :               error_at (ARG_LOCATION (5), "non-floating-point argument in "
    5992                 :            :                         "call to function %qE", fndecl);
    5993                 :          2 :               return false;
    5994                 :            :             }
    5995                 :            :           return true;
    5996                 :            :         }
    5997                 :            :       return false;
    5998                 :            : 
    5999                 :        304 :     case BUILT_IN_ASSUME_ALIGNED:
    6000                 :        592 :       if (builtin_function_validate_nargs (loc, fndecl, nargs, 2 + (nargs > 2)))
    6001                 :            :         {
    6002                 :        302 :           if (nargs >= 3 && TREE_CODE (TREE_TYPE (args[2])) != INTEGER_TYPE)
    6003                 :            :             {
    6004                 :          6 :               error_at (ARG_LOCATION (2), "non-integer argument 3 in call to "
    6005                 :            :                         "function %qE", fndecl);
    6006                 :          3 :               return false;
    6007                 :            :             }
    6008                 :            :           return true;
    6009                 :            :         }
    6010                 :            :       return false;
    6011                 :            : 
    6012                 :      40271 :     case BUILT_IN_ADD_OVERFLOW:
    6013                 :      40271 :     case BUILT_IN_SUB_OVERFLOW:
    6014                 :      40271 :     case BUILT_IN_MUL_OVERFLOW:
    6015                 :      40271 :       if (builtin_function_validate_nargs (loc, fndecl, nargs, 3))
    6016                 :            :         {
    6017                 :            :           unsigned i;
    6018                 :     120354 :           for (i = 0; i < 2; i++)
    6019                 :      80248 :             if (!INTEGRAL_TYPE_P (TREE_TYPE (args[i])))
    6020                 :            :               {
    6021                 :         30 :                 error_at (ARG_LOCATION (i), "argument %u in call to function "
    6022                 :            :                           "%qE does not have integral type", i + 1, fndecl);
    6023                 :         23 :                 return false;
    6024                 :            :               }
    6025                 :      40106 :           if (TREE_CODE (TREE_TYPE (args[2])) != POINTER_TYPE
    6026                 :      40106 :               || !INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (args[2]))))
    6027                 :            :             {
    6028                 :         60 :               error_at (ARG_LOCATION (2), "argument 3 in call to function %qE "
    6029                 :            :                         "does not have pointer to integral type", fndecl);
    6030                 :         48 :               return false;
    6031                 :            :             }
    6032                 :      40058 :           else if (TREE_CODE (TREE_TYPE (TREE_TYPE (args[2]))) == ENUMERAL_TYPE)
    6033                 :            :             {
    6034                 :          6 :               error_at (ARG_LOCATION (2), "argument 3 in call to function %qE "
    6035                 :            :                         "has pointer to enumerated type", fndecl);
    6036                 :          5 :               return false;
    6037                 :            :             }
    6038                 :      40053 :           else if (TREE_CODE (TREE_TYPE (TREE_TYPE (args[2]))) == BOOLEAN_TYPE)
    6039                 :            :             {
    6040                 :          6 :               error_at (ARG_LOCATION (2), "argument 3 in call to function %qE "
    6041                 :            :                         "has pointer to boolean type", fndecl);
    6042                 :          5 :               return false;
    6043                 :            :             }
    6044                 :      40048 :           else if (TYPE_READONLY (TREE_TYPE (TREE_TYPE (args[2]))))
    6045                 :            :             {
    6046                 :         15 :               error_at (ARG_LOCATION (2), "argument 3 in call to function %qE "
    6047                 :            :                         "has pointer to %<const%> type (%qT)", fndecl,
    6048                 :         15 :                         TREE_TYPE (args[2]));
    6049                 :         15 :               return false;
    6050                 :            :             }
    6051                 :            :           return true;
    6052                 :            :         }
    6053                 :            :       return false;
    6054                 :            : 
    6055                 :      41484 :     case BUILT_IN_ADD_OVERFLOW_P:
    6056                 :      41484 :     case BUILT_IN_SUB_OVERFLOW_P:
    6057                 :      41484 :     case BUILT_IN_MUL_OVERFLOW_P:
    6058                 :      41484 :       if (builtin_function_validate_nargs (loc, fndecl, nargs, 3))
    6059                 :            :         {
    6060                 :            :           unsigned i;
    6061                 :     165751 :           for (i = 0; i < 3; i++)
    6062                 :     124332 :             if (!INTEGRAL_TYPE_P (TREE_TYPE (args[i])))
    6063                 :            :               {
    6064                 :         42 :                 error_at (ARG_LOCATION (i), "argument %u in call to function "
    6065                 :            :                           "%qE does not have integral type", i + 1, fndecl);
    6066                 :         35 :                 return false;
    6067                 :            :               }
    6068                 :      41419 :           if (TREE_CODE (TREE_TYPE (args[2])) == ENUMERAL_TYPE)
    6069                 :            :             {
    6070                 :          6 :               error_at (ARG_LOCATION (2), "argument 3 in call to function "
    6071                 :            :                         "%qE has enumerated type", fndecl);
    6072                 :          5 :               return false;
    6073                 :            :             }
    6074                 :      41414 :           else if (TREE_CODE (TREE_TYPE (args[2])) == BOOLEAN_TYPE)
    6075                 :            :             {
    6076                 :          6 :               error_at (ARG_LOCATION (2), "argument 3 in call to function "
    6077                 :            :                         "%qE has boolean type", fndecl);
    6078                 :          5 :               return false;
    6079                 :            :             }
    6080                 :            :           return true;
    6081                 :            :         }
    6082                 :            :       return false;
    6083                 :            : 
    6084                 :            :     default:
    6085                 :            :       return true;
    6086                 :            :     }
    6087                 :            : }
    6088                 :            : 
    6089                 :            : /* Subroutine of c_parse_error.
    6090                 :            :    Return the result of concatenating LHS and RHS. RHS is really
    6091                 :            :    a string literal, its first character is indicated by RHS_START and
    6092                 :            :    RHS_SIZE is its length (including the terminating NUL character).
    6093                 :            : 
    6094                 :            :    The caller is responsible for deleting the returned pointer.  */
    6095                 :            : 
    6096                 :            : static char *
    6097                 :       7673 : catenate_strings (const char *lhs, const char *rhs_start, int rhs_size)
    6098                 :            : {
    6099                 :       7673 :   const size_t lhs_size = strlen (lhs);
    6100                 :       7673 :   char *result = XNEWVEC (char, lhs_size + rhs_size);
    6101                 :       7673 :   memcpy (result, lhs, lhs_size);
    6102                 :       7673 :   memcpy (result + lhs_size, rhs_start, rhs_size);
    6103                 :       7673 :   return result;
    6104                 :            : }
    6105                 :            : 
    6106                 :            : /* Issue the error given by GMSGID at RICHLOC, indicating that it occurred
    6107                 :            :    before TOKEN, which had the associated VALUE.  */
    6108                 :            : 
    6109                 :            : void
    6110                 :       7691 : c_parse_error (const char *gmsgid, enum cpp_ttype token_type,
    6111                 :            :                tree value, unsigned char token_flags,
    6112                 :            :                rich_location *richloc)
    6113                 :            : {
    6114                 :            : #define catenate_messages(M1, M2) catenate_strings ((M1), (M2), sizeof (M2))
    6115                 :            : 
    6116                 :       7691 :   char *message = NULL;
    6117                 :            : 
    6118                 :       7691 :   if (token_type == CPP_EOF)
    6119                 :        450 :     message = catenate_messages (gmsgid, " at end of input");
    6120                 :       7241 :   else if (token_type == CPP_CHAR
    6121                 :            :            || token_type == CPP_WCHAR
    6122                 :            :            || token_type == CPP_CHAR16
    6123                 :            :            || token_type == CPP_CHAR32
    6124                 :       7241 :            || token_type == CPP_UTF8CHAR)
    6125                 :            :     {
    6126                 :         17 :       unsigned int val = TREE_INT_CST_LOW (value);
    6127                 :         17 :       const char *prefix;
    6128                 :            : 
    6129                 :         17 :       switch (token_type)
    6130                 :            :         {
    6131                 :            :         default:
    6132                 :            :           prefix = "";
    6133                 :            :           break;
    6134                 :          0 :         case CPP_WCHAR:
    6135                 :          0 :           prefix = "L";
    6136                 :          0 :           break;
    6137                 :          0 :         case CPP_CHAR16:
    6138                 :          0 :           prefix = "u";
    6139                 :          0 :           break;
    6140                 :          0 :         case CPP_CHAR32:
    6141                 :          0 :           prefix = "U";
    6142                 :          0 :           break;
    6143                 :          0 :         case CPP_UTF8CHAR:
    6144                 :          0 :           prefix = "u8";
    6145                 :          0 :           break;
    6146                 :            :         }
    6147                 :            : 
    6148                 :         17 :       if (val <= UCHAR_MAX && ISGRAPH (val))
    6149                 :         17 :         message = catenate_messages (gmsgid, " before %s'%c'");
    6150                 :            :       else
    6151                 :          0 :         message = catenate_messages (gmsgid, " before %s'\\x%x'");
    6152                 :            : 
    6153                 :         17 :       error_at (richloc, message, prefix, val);
    6154                 :         17 :       free (message);
    6155                 :         17 :       message = NULL;
    6156                 :            :     }
    6157                 :       7224 :   else if (token_type == CPP_CHAR_USERDEF
    6158                 :            :            || token_type == CPP_WCHAR_USERDEF
    6159                 :            :            || token_type == CPP_CHAR16_USERDEF
    6160                 :            :            || token_type == CPP_CHAR32_USERDEF
    6161                 :       7224 :            || token_type == CPP_UTF8CHAR_USERDEF)
    6162                 :         12 :     message = catenate_messages (gmsgid,
    6163                 :            :                                  " before user-defined character literal");
    6164                 :       7212 :   else if (token_type == CPP_STRING_USERDEF
    6165                 :            :            || token_type == CPP_WSTRING_USERDEF
    6166                 :            :            || token_type == CPP_STRING16_USERDEF
    6167                 :            :            || token_type == CPP_STRING32_USERDEF
    6168                 :       7212 :            || token_type == CPP_UTF8STRING_USERDEF)
    6169                 :         18 :     message = catenate_messages (gmsgid, " before user-defined string literal");
    6170                 :       7194 :   else if (token_type == CPP_STRING
    6171                 :            :            || token_type == CPP_WSTRING
    6172                 :            :            || token_type == CPP_STRING16
    6173                 :            :            || token_type == CPP_STRING32
    6174                 :       7194 :            || token_type == CPP_UTF8STRING)
    6175                 :         38 :     message = catenate_messages (gmsgid, " before string constant");
    6176                 :       7156 :   else if (token_type == CPP_NUMBER)
    6177                 :        639 :     message = catenate_messages (gmsgid, " before numeric constant");
    6178                 :       6517 :   else if (token_type == CPP_NAME)
    6179                 :            :     {
    6180                 :       1448 :       message = catenate_messages (gmsgid, " before %qE");
    6181                 :       1448 :       error_at (richloc, message, value);
    6182                 :       1448 :       free (message);
    6183                 :       1448 :       message = NULL;
    6184                 :            :     }
    6185                 :       5069 :   else if (token_type == CPP_PRAGMA)
    6186                 :         14 :     message = catenate_messages (gmsgid, " before %<#pragma%>");
    6187                 :       5055 :   else if (token_type == CPP_PRAGMA_EOL)
    6188                 :        405 :     message = catenate_messages (gmsgid, " before end of line");
    6189                 :       4650 :   else if (token_type == CPP_DECLTYPE)
    6190                 :          6 :     message = catenate_messages (gmsgid, " before %<decltype%>");
    6191                 :       4644 :   else if (token_type < N_TTYPES)
    6192                 :            :     {
    6193                 :       4626 :       message = catenate_messages (gmsgid, " before %qs token");
    6194                 :       4626 :       error_at (richloc, message, cpp_type2name (token_type, token_flags));
    6195                 :       4626 :       free (message);
    6196                 :       4626 :       message = NULL;
    6197                 :            :     }
    6198                 :            :   else
    6199                 :         18 :     error_at (richloc, gmsgid);
    6200                 :            : 
    6201                 :       7691 :   if (message)
    6202                 :            :     {
    6203                 :       1582 :       error_at (richloc, message);
    6204                 :       1582 :       free (message);
    6205                 :            :     }
    6206                 :            : #undef catenate_messages
    6207                 :       7691 : }
    6208                 :            : 
    6209                 :            : /* Return the gcc option code associated with the reason for a cpp
    6210                 :            :    message, or 0 if none.  */
    6211                 :            : 
    6212                 :            : static int
    6213                 :       7384 : c_option_controlling_cpp_diagnostic (enum cpp_warning_reason reason)
    6214                 :            : {
    6215                 :       7384 :   const struct cpp_reason_option_codes_t *entry;
    6216                 :            : 
    6217                 :     171482 :   for (entry = cpp_reason_option_codes; entry->reason != CPP_W_NONE; entry++)
    6218                 :            :     {
    6219                 :     165049 :       if (entry->reason == reason)
    6220                 :        951 :         return entry->option_code;
    6221                 :            :     }
    6222                 :            :   return 0;
    6223                 :            : }
    6224                 :            : 
    6225                 :            : /* Callback from cpp_diagnostic for PFILE to print diagnostics from the
    6226                 :            :    preprocessor.  The diagnostic is of type LEVEL, with REASON set
    6227                 :            :    to the reason code if LEVEL is represents a warning, at location
    6228                 :            :    RICHLOC unless this is after lexing and the compiler's location
    6229                 :            :    should be used instead; MSG is the translated message and AP
    6230                 :            :    the arguments.  Returns true if a diagnostic was emitted, false
    6231                 :            :    otherwise.  */
    6232                 :            : 
    6233                 :            : bool
    6234                 :       7386 : c_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
    6235                 :            :                   enum cpp_diagnostic_level level,
    6236                 :            :                   enum cpp_warning_reason reason,
    6237                 :            :                   rich_location *richloc,
    6238                 :            :                   const char *msg, va_list *ap)
    6239                 :            : {
    6240                 :       7386 :   diagnostic_info diagnostic;
    6241                 :       7386 :   diagnostic_t dlevel;
    6242                 :       7386 :   bool save_warn_system_headers = global_dc->dc_warn_system_headers;
    6243                 :       7386 :   bool ret;
    6244                 :            : 
    6245                 :       7386 :   switch (level)
    6246                 :            :     {
    6247                 :         52 :     case CPP_DL_WARNING_SYSHDR:
    6248                 :         52 :       if (flag_no_output)
    6249                 :            :         return false;
    6250                 :         51 :       global_dc->dc_warn_system_headers = 1;
    6251                 :            :       /* Fall through.  */
    6252                 :        644 :     case CPP_DL_WARNING:
    6253                 :        644 :       if (flag_no_output)
    6254                 :            :         return false;
    6255                 :            :       dlevel = DK_WARNING;
    6256                 :            :       break;
    6257                 :       4931 :     case CPP_DL_PEDWARN:
    6258                 :       4931 :       if (flag_no_output && !flag_pedantic_errors)
    6259                 :            :         return false;
    6260                 :            :       dlevel = DK_PEDWARN;
    6261                 :            :       break;
    6262                 :            :     case CPP_DL_ERROR:
    6263                 :            :       dlevel = DK_ERROR;
    6264                 :            :       break;
    6265                 :          0 :     case CPP_DL_ICE:
    6266                 :          0 :       dlevel = DK_ICE;
    6267                 :          0 :       break;
    6268                 :        213 :     case CPP_DL_NOTE:
    6269                 :        213 :       dlevel = DK_NOTE;
    6270                 :        213 :       break;
    6271                 :        241 :     case CPP_DL_FATAL:
    6272                 :        241 :       dlevel = DK_FATAL;
    6273                 :        241 :       break;
    6274                 :          0 :     default:
    6275                 :          0 :       gcc_unreachable ();
    6276                 :            :     }
    6277                 :       7384 :   if (done_lexing)
    6278                 :         32 :     richloc->set_range (0, input_location, SHOW_RANGE_WITH_CARET);
    6279                 :       7384 :   diagnostic_set_info_translated (&diagnostic, msg, ap,
    6280                 :            :                                   richloc, dlevel);
    6281                 :       7384 :   diagnostic_override_option_index
    6282                 :       7384 :     (&diagnostic,
    6283                 :            :      c_option_controlling_cpp_diagnostic (reason));
    6284                 :       7384 :   ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
    6285                 :       7143 :   if (level == CPP_DL_WARNING_SYSHDR)
    6286                 :         51 :     global_dc->dc_warn_system_headers = save_warn_system_headers;
    6287                 :            :   return ret;
    6288                 :            : }
    6289                 :            : 
    6290                 :            : /* Convert a character from the host to the target execution character
    6291                 :            :    set.  cpplib handles this, mostly.  */
    6292                 :            : 
    6293                 :            : HOST_WIDE_INT
    6294                 :    5436220 : c_common_to_target_charset (HOST_WIDE_INT c)
    6295                 :            : {
    6296                 :            :   /* Character constants in GCC proper are sign-extended under -fsigned-char,
    6297                 :            :      zero-extended under -fno-signed-char.  cpplib insists that characters
    6298                 :            :      and character constants are always unsigned.  Hence we must convert
    6299                 :            :      back and forth.  */
    6300                 :    5436220 :   cppchar_t uc = ((cppchar_t)c) & ((((cppchar_t)1) << CHAR_BIT)-1);
    6301                 :            : 
    6302                 :    5436220 :   uc = cpp_host_to_exec_charset (parse_in, uc);
    6303                 :            : 
    6304                 :    5436220 :   if (flag_signed_char)
    6305                 :    5436120 :     return ((HOST_WIDE_INT)uc) << (HOST_BITS_PER_WIDE_INT - CHAR_TYPE_SIZE)
    6306                 :    5436120 :                                >> (HOST_BITS_PER_WIDE_INT - CHAR_TYPE_SIZE);
    6307                 :            :   else
    6308                 :         97 :     return uc;
    6309                 :            : }
    6310                 :            : 
    6311                 :            : /* Fold an offsetof-like expression.  EXPR is a nested sequence of component
    6312                 :            :    references with an INDIRECT_REF of a constant at the bottom; much like the
    6313                 :            :    traditional rendering of offsetof as a macro.  TYPE is the desired type of
    6314                 :            :    the whole expression.  Return the folded result.  */
    6315                 :            : 
    6316                 :            : tree
    6317                 :      10651 : fold_offsetof (tree expr, tree type, enum tree_code ctx)
    6318                 :            : {
    6319                 :      10663 :   tree base, off, t;
    6320                 :      10663 :   tree_code code = TREE_CODE (expr);
    6321                 :      10663 :   switch (code)
    6322                 :            :     {
    6323                 :            :     case ERROR_MARK:
    6324                 :            :       return expr;
    6325                 :            : 
    6326                 :         16 :     case VAR_DECL:
    6327                 :         16 :       error ("cannot apply %<offsetof%> to static data member %qD", expr);
    6328                 :         16 :       return error_mark_node;
    6329                 :            : 
    6330                 :         12 :     case CALL_EXPR:
    6331                 :         12 :     case TARGET_EXPR:
    6332                 :         12 :       error ("cannot apply %<offsetof%> when %<operator[]%> is overloaded");
    6333                 :         12 :       return error_mark_node;
    6334                 :            : 
    6335                 :       4299 :     case NOP_EXPR:
    6336                 :       4299 :     case INDIRECT_REF:
    6337                 :       4299 :       if (!TREE_CONSTANT (TREE_OPERAND (expr, 0)))
    6338                 :            :         {
    6339                 :         22 :           error ("cannot apply %<offsetof%> to a non constant address");
    6340                 :         22 :           return error_mark_node;
    6341                 :            :         }
    6342                 :       4277 :       return convert (type, TREE_OPERAND (expr, 0));
    6343                 :            : 
    6344                 :       4921 :     case COMPONENT_REF:
    6345                 :       4921 :       base = fold_offsetof (TREE_OPERAND (expr, 0), type, code);
    6346                 :       4921 :       if (base == error_mark_node)
    6347                 :            :         return base;
    6348                 :            : 
    6349                 :       4917 :       t = TREE_OPERAND (expr, 1);
    6350                 :       4917 :       if (DECL_C_BIT_FIELD (t))
    6351                 :            :         {
    6352                 :          1 :           error ("attempt to take address of bit-field structure "
    6353                 :            :                  "member %qD", t);
    6354                 :          1 :           return error_mark_node;
    6355                 :            :         }
    6356                 :       4916 :       off = size_binop_loc (input_location, PLUS_EXPR, DECL_FIELD_OFFSET (t),
    6357                 :       4916 :                             size_int (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (t))
    6358                 :            :                                       / BITS_PER_UNIT));
    6359                 :       4916 :       break;
    6360                 :            : 
    6361                 :       1402 :     case ARRAY_REF:
    6362                 :       1402 :       base = fold_offsetof (TREE_OPERAND (expr, 0), type, code);
    6363                 :       1402 :       if (base == error_mark_node)
    6364                 :            :         return base;
    6365                 :            : 
    6366                 :       1398 :       t = TREE_OPERAND (expr, 1);
    6367                 :       1398 :       STRIP_ANY_LOCATION_WRAPPER (t);
    6368                 :            : 
    6369                 :            :       /* Check if the offset goes beyond the upper bound of the array.  */
    6370                 :       1398 :       if (TREE_CODE (t) == INTEGER_CST && tree_int_cst_sgn (t) >= 0)
    6371                 :            :         {
    6372                 :       1143 :           tree upbound = array_ref_up_bound (expr);
    6373                 :       1143 :           if (upbound != NULL_TREE
    6374                 :       1019 :               && TREE_CODE (upbound) == INTEGER_CST
    6375                 :       2162 :               && !tree_int_cst_equal (upbound,
    6376                 :       1019 :                                       TYPE_MAX_VALUE (TREE_TYPE (upbound))))
    6377                 :            :             {
    6378                 :       1007 :               if (ctx != ARRAY_REF && ctx != COMPONENT_REF)
    6379                 :        503 :                 upbound = size_binop (PLUS_EXPR, upbound,
    6380                 :            :                                       build_int_cst (TREE_TYPE (upbound), 1));
    6381                 :       1007 :               if (tree_int_cst_lt (upbound, t))
    6382                 :            :                 {
    6383                 :        305 :                   tree v;
    6384                 :            : 
    6385                 :        305 :                   for (v = TREE_OPERAND (expr, 0);
    6386                 :        525 :                        TREE_CODE (v) == COMPONENT_REF;
    6387                 :        220 :                        v = TREE_OPERAND (v, 0))
    6388                 :        350 :                     if (TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0)))
    6389                 :            :                         == RECORD_TYPE)
    6390                 :            :                       {
    6391                 :        275 :                         tree fld_chain = DECL_CHAIN (TREE_OPERAND (v, 1));
    6392                 :        391 :                         for (; fld_chain; fld_chain = DECL_CHAIN (fld_chain))
    6393                 :        246 :                           if (TREE_CODE (fld_chain) == FIELD_DECL)
    6394                 :            :                             break;
    6395                 :            : 
    6396                 :        275 :                         if (fld_chain)
    6397                 :            :                           break;
    6398                 :            :                       }
    6399                 :            :                   /* Don't warn if the array might be considered a poor
    6400                 :            :                      man's flexible array member with a very permissive
    6401                 :            :                      definition thereof.  */
    6402                 :        305 :                   if (TREE_CODE (v) == ARRAY_REF
    6403                 :        215 :                       || TREE_CODE (v) == COMPONENT_REF)
    6404                 :        440 :                     warning (OPT_Warray_bounds,
    6405                 :            :                              "index %E denotes an offset "
    6406                 :            :                              "greater than size of %qT",
    6407                 :        220 :                              t, TREE_TYPE (TREE_OPERAND (expr, 0)));
    6408                 :            :                 }
    6409                 :            :             }
    6410                 :            :         }
    6411                 :            : 
    6412                 :       1398 :       t = convert (sizetype, t);
    6413                 :       1398 :       off = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (TREE_TYPE (expr)), t);
    6414                 :       1398 :       break;
    6415                 :            : 
    6416                 :         12 :     case COMPOUND_EXPR:
    6417                 :            :       /* Handle static members of volatile structs.  */
    6418                 :         12 :       t = TREE_OPERAND (expr, 1);
    6419                 :         12 :       gcc_checking_assert (VAR_P (get_base_address (t)));
    6420                 :            :       return fold_offsetof (t, type);
    6421                 :            : 
    6422                 :          0 :     default:
    6423                 :          0 :       gcc_unreachable ();
    6424                 :            :     }
    6425                 :            : 
    6426                 :       6314 :   if (!POINTER_TYPE_P (type))
    6427                 :       5496 :     return size_binop (PLUS_EXPR, base, convert (type, off));
    6428                 :        818 :   return fold_build_pointer_plus (base, off);
    6429                 :            : }
    6430                 :            : 
    6431                 :            : /* *PTYPE is an incomplete array.  Complete it with a domain based on
    6432                 :            :    INITIAL_VALUE.  If INITIAL_VALUE is not present, use 1 if DO_DEFAULT
    6433                 :            :    is true.  Return 0 if successful, 1 if INITIAL_VALUE can't be deciphered,
    6434                 :            :    2 if INITIAL_VALUE was NULL, and 3 if INITIAL_VALUE was empty.  */
    6435                 :            : 
    6436                 :            : int
    6437                 :     232466 : complete_array_type (tree *ptype, tree initial_value, bool do_default)
    6438                 :            : {
    6439                 :     232466 :   tree maxindex, type, main_type, elt, unqual_elt;
    6440                 :     232466 :   int failure = 0, quals;
    6441                 :     232466 :   bool overflow_p = false;
    6442                 :            : 
    6443                 :     232466 :   maxindex = size_zero_node;
    6444                 :     232466 :   if (initial_value)
    6445                 :            :     {
    6446                 :     213623 :       STRIP_ANY_LOCATION_WRAPPER (initial_value);
    6447                 :            : 
    6448                 :     213623 :       if (TREE_CODE (initial_value) == STRING_CST)
    6449                 :            :         {
    6450                 :     203344 :           int eltsize
    6451                 :     203344 :             = int_size_in_bytes (TREE_TYPE (TREE_TYPE (initial_value)));
    6452                 :     203344 :           maxindex = size_int (TREE_STRING_LENGTH (initial_value)/eltsize - 1);
    6453                 :            :         }
    6454                 :      10279 :       else if (TREE_CODE (initial_value) == CONSTRUCTOR)
    6455                 :            :         {
    6456                 :       9384 :           vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (initial_value);
    6457                 :            : 
    6458                 :       9384 :           if (vec_safe_is_empty (v))
    6459                 :            :             {
    6460                 :        377 :               if (pedantic)
    6461                 :         49 :                 failure = 3;
    6462                 :        377 :               maxindex = ssize_int (-1);
    6463                 :            :             }
    6464                 :            :           else
    6465                 :            :             {
    6466                 :       9007 :               tree curindex;
    6467                 :       9007 :               unsigned HOST_WIDE_INT cnt;
    6468                 :       9007 :               constructor_elt *ce;
    6469                 :       9007 :               bool fold_p = false;
    6470                 :            : 
    6471                 :       9007 :               if ((*v)[0].index)
    6472                 :       8833 :                 maxindex = (*v)[0].index, fold_p = true;
    6473                 :            : 
    6474                 :       9007 :               curindex = maxindex;
    6475                 :            : 
    6476                 :    1056170 :               for (cnt = 1; vec_safe_iterate (v, cnt, &ce); cnt++)
    6477                 :            :                 {
    6478                 :    1047160 :                   bool curfold_p = false;
    6479                 :    1047160 :                   if (ce->index)
    6480                 :            :                     curindex = ce->index, curfold_p = true;
    6481                 :            :                   else
    6482                 :            :                     {
    6483                 :       6501 :                       if (fold_p)
    6484                 :            :                         {
    6485                 :            :                           /* Since we treat size types now as ordinary
    6486                 :            :                              unsigned types, we need an explicit overflow
    6487                 :            :                              check.  */
    6488                 :          0 :                           tree orig = curindex;
    6489                 :          0 :                           curindex = fold_convert (sizetype, curindex);
    6490                 :          0 :                           overflow_p |= tree_int_cst_lt (curindex, orig);
    6491                 :            :                         }
    6492                 :       6501 :                       curindex = size_binop (PLUS_EXPR, curindex,
    6493                 :            :                                              size_one_node);
    6494                 :            :                     }
    6495                 :    1047160 :                   if (tree_int_cst_lt (maxindex, curindex))
    6496                 :    1047160 :                     maxindex = curindex, fold_p = curfold_p;
    6497                 :            :                 }
    6498                 :       9007 :               if (fold_p)
    6499                 :            :                 {
    6500                 :       8833 :                   tree orig = maxindex;
    6501                 :       8833 :                   maxindex = fold_convert (sizetype, maxindex);
    6502                 :       8833 :                   overflow_p |= tree_int_cst_lt (maxindex, orig);
    6503                 :            :                 }
    6504                 :            :             }
    6505                 :            :         }
    6506                 :            :       else
    6507                 :            :         {
    6508                 :            :           /* Make an error message unless that happened already.  */
    6509                 :        895 :           if (initial_value != error_mark_node)
    6510                 :         36 :             failure = 1;
    6511                 :            :         }
    6512                 :            :     }
    6513                 :            :   else
    6514                 :            :     {
    6515                 :      18843 :       failure = 2;
    6516                 :      18843 :       if (!do_default)
    6517                 :            :         return failure;
    6518                 :            :     }
    6519                 :            : 
    6520                 :     213704 :   type = *ptype;
    6521                 :     213704 :   elt = TREE_TYPE (type);
    6522                 :     213704 :   quals = TYPE_QUALS (strip_array_types (elt));
    6523                 :     213704 :   if (quals == 0)
    6524                 :            :     unqual_elt = elt;
    6525                 :            :   else
    6526                 :     206837 :     unqual_elt = c_build_qualified_type (elt, KEEP_QUAL_ADDR_SPACE (quals));
    6527                 :            : 
    6528                 :            :   /* Using build_distinct_type_copy and modifying things afterward instead
    6529                 :            :      of using build_array_type to create a new type preserves all of the
    6530                 :            :      TYPE_LANG_FLAG_? bits that the front end may have set.  */
    6531                 :     213704 :   main_type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
    6532                 :     213704 :   TREE_TYPE (main_type) = unqual_elt;
    6533                 :     427408 :   TYPE_DOMAIN (main_type)
    6534                 :     427408 :     = build_range_type (TREE_TYPE (maxindex),
    6535                 :     213704 :                         build_int_cst (TREE_TYPE (maxindex), 0), maxindex);
    6536                 :     213704 :   TYPE_TYPELESS_STORAGE (main_type) = TYPE_TYPELESS_STORAGE (type);
    6537                 :     213704 :   layout_type (main_type);
    6538                 :            : 
    6539                 :            :   /* Make sure we have the canonical MAIN_TYPE. */
    6540                 :     213704 :   hashval_t hashcode = type_hash_canon_hash (main_type);
    6541                 :     213704 :   main_type = type_hash_canon (hashcode, main_type);
    6542                 :            : 
    6543                 :            :   /* Fix the canonical type.  */
    6544                 :     213704 :   if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (main_type))
    6545                 :     427381 :       || TYPE_STRUCTURAL_EQUALITY_P (TYPE_DOMAIN (main_type)))
    6546                 :         27 :     SET_TYPE_STRUCTURAL_EQUALITY (main_type);
    6547                 :     213677 :   else if (TYPE_CANONICAL (TREE_TYPE (main_type)) != TREE_TYPE (main_type)
    6548                 :     213677 :            || (TYPE_CANONICAL (TYPE_DOMAIN (main_type))
    6549                 :     211768 :                != TYPE_DOMAIN (main_type)))
    6550                 :       3818 :     TYPE_CANONICAL (main_type)
    6551                 :       1909 :       = build_array_type (TYPE_CANONICAL (TREE_TYPE (main_type)),
    6552                 :       1909 :                           TYPE_CANONICAL (TYPE_DOMAIN (main_type)),
    6553                 :       1909 :                           TYPE_TYPELESS_STORAGE (main_type));
    6554                 :            :   else
    6555                 :     211768 :     TYPE_CANONICAL (main_type) = main_type;
    6556                 :            : 
    6557                 :     213704 :   if (quals == 0)
    6558                 :            :     type = main_type;
    6559                 :            :   else
    6560                 :     206837 :     type = c_build_qualified_type (main_type, quals);
    6561                 :            : 
    6562                 :     213704 :   if (COMPLETE_TYPE_P (type)
    6563                 :     213704 :       && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST
    6564                 :     427402 :       && (overflow_p || TREE_OVERFLOW (TYPE_SIZE_UNIT (type))))
    6565                 :            :     {
    6566                 :          5 :       error ("size of array is too large");
    6567                 :            :       /* If we proceed with the array type as it is, we'll eventually
    6568                 :            :          crash in tree_to_[su]hwi().  */
    6569                 :          5 :       type = error_mark_node;
    6570                 :            :     }
    6571                 :            : 
    6572                 :     213704 :   *ptype = type;
    6573                 :     213704 :   return failure;
    6574                 :            : }
    6575                 :            : 
    6576                 :            : /* INIT is an constructor of a structure with a flexible array member.
    6577                 :            :    Complete the flexible array member with a domain based on it's value.  */
    6578                 :            : void
    6579                 :    4473590 : complete_flexible_array_elts (tree init)
    6580                 :            : {
    6581                 :    4492700 :   tree elt, type;
    6582                 :            : 
    6583                 :    4492700 :   if (init == NULL_TREE || TREE_CODE (init) != CONSTRUCTOR)
    6584                 :            :     return;
    6585                 :            : 
    6586                 :      19992 :   if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
    6587                 :            :     return;
    6588                 :            : 
    6589                 :      19252 :   elt = CONSTRUCTOR_ELTS (init)->last ().value;
    6590                 :      19252 :   type = TREE_TYPE (elt);
    6591                 :      19252 :   if (TREE_CODE (type) == ARRAY_TYPE
    6592                 :      20983 :       && TYPE_SIZE (type) == NULL_TREE)
    6593                 :        147 :     complete_array_type (&TREE_TYPE (elt), elt, false);
    6594                 :            :   else
    6595                 :            :     complete_flexible_array_elts (elt);
    6596                 :            : }
    6597                 :            : 
    6598                 :            : /* Like c_mark_addressable but don't check register qualifier.  */
    6599                 :            : void 
    6600                 :     355526 : c_common_mark_addressable_vec (tree t)
    6601                 :            : {   
    6602                 :     355526 :   if (TREE_CODE (t) == C_MAYBE_CONST_EXPR)
    6603                 :          4 :     t = C_MAYBE_CONST_EXPR_EXPR (t);
    6604                 :     423119 :   while (handled_component_p (t))
    6605                 :      67593 :     t = TREE_OPERAND (t, 0);
    6606                 :     355526 :   if (!VAR_P (t)
    6607                 :     355526 :       && TREE_CODE (t) != PARM_DECL
    6608                 :       3654 :       && TREE_CODE (t) != COMPOUND_LITERAL_EXPR)
    6609                 :            :     return;
    6610                 :     351916 :   if (!VAR_P (t) || !DECL_HARD_REGISTER (t))
    6611                 :     351854 :     TREE_ADDRESSABLE (t) = 1;
    6612                 :     351916 :   if (TREE_CODE (t) == COMPOUND_LITERAL_EXPR)
    6613                 :         44 :     TREE_ADDRESSABLE (COMPOUND_LITERAL_EXPR_DECL (t)) = 1;
    6614                 :            : }
    6615                 :            : 
    6616                 :            : 
    6617                 :            : 
    6618                 :            : /* Used to help initialize the builtin-types.def table.  When a type of
    6619                 :            :    the correct size doesn't exist, use error_mark_node instead of NULL.
    6620                 :            :    The later results in segfaults even when a decl using the type doesn't
    6621                 :            :    get invoked.  */
    6622                 :            : 
    6623                 :            : tree
    6624                 :     841987 : builtin_type_for_size (int size, bool unsignedp)
    6625                 :            : {
    6626                 :     841987 :   tree type = c_common_type_for_size (size, unsignedp);
    6627                 :     841987 :   return type ? type : error_mark_node;
    6628                 :            : }
    6629                 :            : 
    6630                 :            : /* Work out the size of the first argument of a call to
    6631                 :            :    __builtin_speculation_safe_value.  Only pointers and integral types
    6632                 :            :    are permitted.  Return -1 if the argument type is not supported or
    6633                 :            :    the size is too large; 0 if the argument type is a pointer or the
    6634                 :            :    size if it is integral.  */
    6635                 :            : static enum built_in_function
    6636                 :         41 : speculation_safe_value_resolve_call (tree function, vec<tree, va_gc> *params)
    6637                 :            : {
    6638                 :            :   /* Type of the argument.  */
    6639                 :         41 :   tree type;
    6640                 :         41 :   int size;
    6641                 :            : 
    6642                 :         41 :   if (vec_safe_is_empty (params))
    6643                 :            :     {
    6644                 :          0 :       error ("too few arguments to function %qE", function);
    6645                 :          0 :       return BUILT_IN_NONE;
    6646                 :            :     }
    6647                 :            : 
    6648                 :         41 :   type = TREE_TYPE ((*params)[0]);
    6649                 :         41 :   if (TREE_CODE (type) == ARRAY_TYPE && c_dialect_cxx ())
    6650                 :            :     {
    6651                 :            :       /* Force array-to-pointer decay for C++.   */
    6652                 :          0 :       (*params)[0] = default_conversion ((*params)[0]);
    6653                 :          0 :       type = TREE_TYPE ((*params)[0]);
    6654                 :            :     }
    6655                 :            : 
    6656                 :         41 :   if (POINTER_TYPE_P (type))
    6657                 :            :     return BUILT_IN_SPECULATION_SAFE_VALUE_PTR;
    6658                 :            : 
    6659                 :         36 :   if (!INTEGRAL_TYPE_P (type))
    6660                 :          0 :     goto incompatible;
    6661                 :            : 
    6662                 :         36 :   if (!COMPLETE_TYPE_P (type))
    6663                 :          0 :     goto incompatible;
    6664                 :            : 
    6665                 :         36 :   size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
    6666                 :         36 :   if (size == 1 || size == 2 || size == 4 || size == 8 || size == 16)
    6667                 :         36 :     return ((enum built_in_function)
    6668                 :         72 :             ((int) BUILT_IN_SPECULATION_SAFE_VALUE_1 + exact_log2 (size)));
    6669                 :            : 
    6670                 :          0 :  incompatible:
    6671                 :            :   /* Issue the diagnostic only if the argument is valid, otherwise
    6672                 :            :      it would be redundant at best and could be misleading.  */
    6673                 :          0 :   if (type != error_mark_node)
    6674                 :          0 :     error ("operand type %qT is incompatible with argument %d of %qE",
    6675                 :            :            type, 1, function);
    6676                 :            : 
    6677                 :            :   return BUILT_IN_NONE;
    6678                 :            : }
    6679                 :            : 
    6680                 :            : /* Validate and coerce PARAMS, the arguments to ORIG_FUNCTION to fit
    6681                 :            :    the prototype for FUNCTION.  The first argument is mandatory, a second
    6682                 :            :    argument, if present, must be type compatible with the first.  */
    6683                 :            : static bool
    6684                 :         41 : speculation_safe_value_resolve_params (location_t loc, tree orig_function,
    6685                 :            :                                        vec<tree, va_gc> *params)
    6686                 :            : {
    6687                 :         41 :   tree val;
    6688                 :            : 
    6689                 :         41 :   if (params->length () == 0)
    6690                 :            :     {
    6691                 :          0 :       error_at (loc, "too few arguments to function %qE", orig_function);
    6692                 :          0 :       return false;
    6693                 :            :     }
    6694                 :            : 
    6695                 :         41 :   else if (params->length () > 2)
    6696                 :            :     {
    6697                 :          0 :       error_at (loc, "too many arguments to function %qE", orig_function);
    6698                 :          0 :       return false;
    6699                 :            :     }
    6700                 :            : 
    6701                 :         41 :   val = (*params)[0];
    6702                 :         41 :   if (TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE)
    6703                 :          0 :     val = default_conversion (val);
    6704                 :         41 :   if (!(TREE_CODE (TREE_TYPE (val)) == POINTER_TYPE
    6705                 :         36 :         || TREE_CODE (TREE_TYPE (val)) == INTEGER_TYPE))
    6706                 :            :     {
    6707                 :          0 :       error_at (loc,
    6708                 :            :                 "expecting argument of type pointer or of type integer "
    6709                 :            :                 "for argument 1");
    6710                 :          0 :       return false;
    6711                 :            :     }
    6712                 :         41 :   (*params)[0] = val;
    6713                 :            : 
    6714                 :         41 :   if (params->length () == 2)
    6715                 :            :     {
    6716                 :          5 :       tree val2 = (*params)[1];
    6717                 :          5 :       if (TREE_CODE (TREE_TYPE (val2)) == ARRAY_TYPE)
    6718                 :          0 :         val2 = default_conversion (val2);
    6719                 :          6 :       if (!(TREE_TYPE (val) == TREE_TYPE (val2)
    6720                 :          1 :             || useless_type_conversion_p (TREE_TYPE (val), TREE_TYPE (val2))))
    6721                 :            :         {
    6722                 :          0 :           error_at (loc, "both arguments must be compatible");
    6723                 :          0 :           return false;
    6724                 :            :         }
    6725                 :          5 :       (*params)[1] = val2;
    6726                 :            :     }
    6727                 :            : 
    6728                 :            :   return true;
    6729                 :            : }
    6730                 :            : 
    6731                 :            : /* Cast the result of the builtin back to the type of the first argument,
    6732                 :            :    preserving any qualifiers that it might have.  */
    6733                 :            : static tree
    6734                 :         41 : speculation_safe_value_resolve_return (tree first_param, tree result)
    6735                 :            : {
    6736                 :         41 :   tree ptype = TREE_TYPE (first_param);
    6737                 :         41 :   tree rtype = TREE_TYPE (result);
    6738                 :         41 :   ptype = TYPE_MAIN_VARIANT (ptype);
    6739                 :            : 
    6740                 :         41 :   if (tree_int_cst_equal (TYPE_SIZE (ptype), TYPE_SIZE (rtype)))
    6741                 :         41 :     return convert (ptype, result);
    6742                 :            : 
    6743                 :            :   return result;
    6744                 :            : }
    6745                 :            : 
    6746                 :            : /* A helper function for resolve_overloaded_builtin in resolving the
    6747                 :            :    overloaded __sync_ builtins.  Returns a positive power of 2 if the
    6748                 :            :    first operand of PARAMS is a pointer to a supported data type.
    6749                 :            :    Returns 0 if an error is encountered.
    6750                 :            :    FETCH is true when FUNCTION is one of the _FETCH_OP_ or _OP_FETCH_
    6751                 :            :    built-ins.  */
    6752                 :            : 
    6753                 :            : static int
    6754                 :     177231 : sync_resolve_size (tree function, vec<tree, va_gc> *params, bool fetch)
    6755                 :            : {
    6756                 :            :   /* Type of the argument.  */
    6757                 :     177231 :   tree argtype;
    6758                 :            :   /* Type the argument points to.  */
    6759                 :     177231 :   tree type;
    6760                 :     177231 :   int size;
    6761                 :            : 
    6762                 :     177231 :   if (vec_safe_is_empty (params))
    6763                 :            :     {
    6764                 :          5 :       error ("too few arguments to function %qE", function);
    6765                 :          5 :       return 0;
    6766                 :            :     }
    6767                 :            : 
    6768                 :     177226 :   argtype = type = TREE_TYPE ((*params)[0]);
    6769                 :     177226 :   if (TREE_CODE (type) == ARRAY_TYPE && c_dialect_cxx ())
    6770                 :            :     {
    6771                 :            :       /* Force array-to-pointer decay for C++.  */
    6772                 :          4 :       (*params)[0] = default_conversion ((*params)[0]);
    6773                 :          4 :       type = TREE_TYPE ((*params)[0]);
    6774                 :            :     }
    6775                 :     177226 :   if (TREE_CODE (type) != POINTER_TYPE)
    6776                 :          6 :     goto incompatible;
    6777                 :            : 
    6778                 :     177220 :   type = TREE_TYPE (type);
    6779                 :     177220 :   if (!INTEGRAL_TYPE_P (type) && !POINTER_TYPE_P (type))
    6780                 :          0 :     goto incompatible;
    6781                 :            : 
    6782                 :     177220 :   if (!COMPLETE_TYPE_P (type))
    6783                 :          2 :     goto incompatible;
    6784                 :            : 
    6785                 :     177218 :   if (fetch && TREE_CODE (type) == BOOLEAN_TYPE)
    6786                 :         48 :     goto incompatible;
    6787                 :            : 
    6788                 :     177170 :   size = tree_to_uhwi (TYPE_SIZE_UNIT (type));
    6789                 :     177170 :   if (size == 1 || size == 2 || size == 4 || size == 8 || size == 16)
    6790                 :            :     return size;
    6791                 :            : 
    6792                 :          0 :  incompatible:
    6793                 :            :   /* Issue the diagnostic only if the argument is valid, otherwise
    6794                 :            :      it would be redundant at best and could be misleading.  */
    6795                 :         56 :   if (argtype != error_mark_node)
    6796                 :         50 :     error ("operand type %qT is incompatible with argument %d of %qE",
    6797                 :            :            argtype, 1, function);
    6798                 :            :   return 0;
    6799                 :            : }
    6800                 :            : 
    6801                 :            : /* A helper function for resolve_overloaded_builtin.  Adds casts to
    6802                 :            :    PARAMS to make arguments match up with those of FUNCTION.  Drops
    6803                 :            :    the variadic arguments at the end.  Returns false if some error
    6804                 :            :    was encountered; true on success.  */
    6805                 :            : 
    6806                 :            : static bool
    6807                 :     177170 : sync_resolve_params (location_t loc, tree orig_function, tree function,
    6808                 :            :                      vec<tree, va_gc> *params, bool orig_format)
    6809                 :            : {
    6810                 :     177170 :   function_args_iterator iter;
    6811                 :     177170 :   tree ptype;
    6812                 :     177170 :   unsigned int parmnum;
    6813                 :            : 
    6814                 :     177170 :   function_args_iter_init (&iter, TREE_TYPE (function));
    6815                 :            :   /* We've declared the implementation functions to use "volatile void *"
    6816                 :            :      as the pointer parameter, so we shouldn't get any complaints from the
    6817                 :            :      call to check_function_arguments what ever type the user used.  */
    6818                 :     177170 :   function_args_iter_next (&iter);
    6819                 :     177170 :   ptype = TREE_TYPE (TREE_TYPE ((*params)[0]));
    6820                 :     177170 :   ptype = TYPE_MAIN_VARIANT (ptype);
    6821                 :            : 
    6822                 :            :   /* For the rest of the values, we need to cast these to FTYPE, so that we
    6823                 :            :      don't get warnings for passing pointer types, etc.  */
    6824                 :     177170 :   parmnum = 0;
    6825                 :     987844 :   while (1)
    6826                 :            :     {
    6827                 :     582507 :       tree val, arg_type;
    6828                 :            : 
    6829                 :     582507 :       arg_type = function_args_iter_cond (&iter);
    6830                 :            :       /* XXX void_type_node belies the abstraction.  */
    6831                 :     582507 :       if (arg_type == void_type_node)
    6832                 :            :         break;
    6833                 :            : 
    6834                 :     405338 :       ++parmnum;
    6835                 :     405338 :       if (params->length () <= parmnum)
    6836                 :            :         {
    6837                 :          1 :           error_at (loc, "too few arguments to function %qE", orig_function);
    6838                 :          1 :           return false;
    6839                 :            :         }
    6840                 :            : 
    6841                 :            :       /* Only convert parameters if arg_type is unsigned integer type with
    6842                 :            :          new format sync routines, i.e. don't attempt to convert pointer
    6843                 :            :          arguments (e.g. EXPECTED argument of __atomic_compare_exchange_n),
    6844                 :            :          bool arguments (e.g. WEAK argument) or signed int arguments (memmodel
    6845                 :            :          kinds).  */
    6846                 :     730682 :       if (TREE_CODE (arg_type) == INTEGER_TYPE && TYPE_UNSIGNED (arg_type))
    6847                 :            :         {
    6848                 :            :           /* Ideally for the first conversion we'd use convert_for_assignment
    6849                 :            :              so that we get warnings for anything that doesn't match the pointer
    6850                 :            :              type.  This isn't portable across the C and C++ front ends atm.  */
    6851                 :     113968 :           val = (*params)[parmnum];
    6852                 :     113968 :           val = convert (ptype, val);
    6853                 :     113968 :           val = convert (arg_type, val);
    6854                 :     113968 :           (*params)[parmnum] = val;
    6855                 :            :         }
    6856                 :            : 
    6857                 :     405337 :       function_args_iter_next (&iter);
    6858                 :     405337 :     }
    6859                 :            : 
    6860                 :            :   /* __atomic routines are not variadic.  */
    6861                 :     177169 :   if (!orig_format && params->length () != parmnum + 1)
    6862                 :            :     {
    6863                 :          1 :       error_at (loc, "too many arguments to function %qE", orig_function);
    6864                 :          1 :       return false;
    6865                 :            :     }
    6866                 :            : 
    6867                 :            :   /* The definition of these primitives is variadic, with the remaining
    6868                 :            :      being "an optional list of variables protected by the memory barrier".
    6869                 :            :      No clue what that's supposed to mean, precisely, but we consider all
    6870                 :            :      call-clobbered variables to be protected so we're safe.  */
    6871                 :     177168 :   params->truncate (parmnum + 1);
    6872                 :            : 
    6873                 :     177168 :   return true;
    6874                 :            : }
    6875                 :            : 
    6876                 :            : /* A helper function for resolve_overloaded_builtin.  Adds a cast to
    6877                 :            :    RESULT to make it match the type of the first pointer argument in
    6878                 :            :    PARAMS.  */
    6879                 :            : 
    6880                 :            : static tree
    6881                 :     112615 : sync_resolve_return (tree first_param, tree result, bool orig_format)
    6882                 :            : {
    6883                 :     112615 :   tree ptype = TREE_TYPE (TREE_TYPE (first_param));
    6884                 :     112615 :   tree rtype = TREE_TYPE (result);
    6885                 :     112615 :   ptype = TYPE_MAIN_VARIANT (ptype);
    6886                 :            : 
    6887                 :            :   /* New format doesn't require casting unless the types are the same size.  */
    6888                 :     219713 :   if (orig_format || tree_int_cst_equal (TYPE_SIZE (ptype), TYPE_SIZE (rtype)))
    6889                 :     112615 :     return convert (ptype, result);
    6890                 :            :   else
    6891                 :            :     return result;
    6892                 :            : }
    6893                 :            : 
    6894                 :            : /* This function verifies the PARAMS to generic atomic FUNCTION.
    6895                 :            :    It returns the size if all the parameters are the same size, otherwise
    6896                 :            :    0 is returned if the parameters are invalid.  */
    6897                 :            : 
    6898                 :            : static int
    6899                 :      60075 : get_atomic_generic_size (location_t loc, tree function,
    6900                 :            :                          vec<tree, va_gc> *params)
    6901                 :            : {
    6902                 :      60075 :   unsigned int n_param;
    6903                 :      60075 :   unsigned int n_model;
    6904                 :      60075 :   unsigned int x;
    6905                 :      60075 :   int size_0;
    6906                 :      60075 :   tree type_0;
    6907                 :            : 
    6908                 :            :   /* Determine the parameter makeup.  */
    6909                 :      60075 :   switch (DECL_FUNCTION_CODE (function))
    6910                 :            :     {
    6911                 :            :     case BUILT_IN_ATOMIC_EXCHANGE:
    6912                 :            :       n_param = 4;
    6913                 :            :       n_model = 1;
    6914                 :            :       break;
    6915                 :      47243 :     case BUILT_IN_ATOMIC_LOAD:
    6916                 :      47243 :     case BUILT_IN_ATOMIC_STORE:
    6917                 :      47243 :       n_param = 3;
    6918                 :      47243 :       n_model = 1;
    6919                 :      47243 :       break;
    6920                 :      12550 :     case BUILT_IN_ATOMIC_COMPARE_EXCHANGE:
    6921                 :      12550 :       n_param = 6;
    6922                 :      12550 :       n_model = 2;
    6923                 :      12550 :       break;
    6924                 :          0 :     default:
    6925                 :          0 :       gcc_unreachable ();
    6926                 :            :     }
    6927                 :            : 
    6928                 :     120150 :   if (vec_safe_length (params) != n_param)
    6929                 :            :     {
    6930                 :          1 :       error_at (loc, "incorrect number of arguments to function %qE", function);
    6931                 :          1 :       return 0;
    6932                 :            :     }
    6933                 :            : 
    6934                 :            :   /* Get type of first parameter, and determine its size.  */
    6935                 :      60074 :   type_0 = TREE_TYPE ((*params)[0]);
    6936                 :      60074 :   if (TREE_CODE (type_0) == ARRAY_TYPE && c_dialect_cxx ())
    6937                 :            :     {
    6938                 :            :       /* Force array-to-pointer decay for C++.  */
    6939                 :         20 :       (*params)[0] = default_conversion ((*params)[0]);
    6940                 :         20 :       type_0 = TREE_TYPE ((*params)[0]);
    6941                 :            :     }
    6942                 :     120144 :   if (TREE_CODE (type_0) != POINTER_TYPE || VOID_TYPE_P (TREE_TYPE (type_0)))
    6943                 :            :     {
    6944                 :          5 :       error_at (loc, "argument 1 of %qE must be a non-void pointer type",
    6945                 :            :                 function);
    6946                 :          5 :       return 0;
    6947                 :            :     }
    6948                 :            : 
    6949                 :            :   /* Types must be compile time constant sizes. */
    6950                 :      60069 :   if (TREE_CODE ((TYPE_SIZE_UNIT (TREE_TYPE (type_0)))) != INTEGER_CST)
    6951                 :            :     {
    6952                 :          1 :       error_at (loc, 
    6953                 :            :                 "argument 1 of %qE must be a pointer to a constant size type",
    6954                 :            :                 function);
    6955                 :          1 :       return 0;
    6956                 :            :     }
    6957                 :            : 
    6958                 :      60068 :   size_0 = tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (type_0)));
    6959                 :            : 
    6960                 :            :   /* Zero size objects are not allowed.  */
    6961                 :      60068 :   if (size_0 == 0)
    6962                 :            :     {
    6963                 :          1 :       error_at (loc, 
    6964                 :            :                 "argument 1 of %qE must be a pointer to a nonzero size object",
    6965                 :            :                 function);
    6966                 :          1 :       return 0;
    6967                 :            :     }
    6968                 :            : 
    6969                 :            :   /* Check each other parameter is a pointer and the same size.  */
    6970                 :     205557 :   for (x = 0; x < n_param - n_model; x++)
    6971                 :            :     {
    6972                 :     145505 :       int size;
    6973                 :     145505 :       tree type = TREE_TYPE ((*params)[x]);
    6974                 :            :       /* __atomic_compare_exchange has a bool in the 4th position, skip it.  */
    6975                 :     145505 :       if (n_param == 6 && x == 3)
    6976                 :      12546 :         continue;
    6977                 :     132959 :       if (TREE_CODE (type) == ARRAY_TYPE && c_dialect_cxx ())
    6978                 :            :         {
    6979                 :            :           /* Force array-to-pointer decay for C++.  */
    6980                 :         24 :           (*params)[x] = default_conversion ((*params)[x]);
    6981                 :         24 :           type = TREE_TYPE ((*params)[x]);
    6982                 :            :         }
    6983                 :     132959 :       if (!POINTER_TYPE_P (type))
    6984                 :            :         {
    6985                 :          7 :           error_at (loc, "argument %d of %qE must be a pointer type", x + 1,
    6986                 :            :                     function);
    6987                 :          7 :           return 0;
    6988                 :            :         }
    6989                 :     132952 :       else if (TYPE_SIZE_UNIT (TREE_TYPE (type))
    6990                 :     132952 :                && TREE_CODE ((TYPE_SIZE_UNIT (TREE_TYPE (type))))
    6991                 :            :                   != INTEGER_CST)
    6992                 :            :         {
    6993                 :          1 :           error_at (loc, "argument %d of %qE must be a pointer to a constant "
    6994                 :            :                     "size type", x + 1, function);
    6995                 :          1 :           return 0;
    6996                 :            :         }
    6997                 :     132951 :       else if (FUNCTION_POINTER_TYPE_P (type))
    6998                 :            :         {
    6999                 :          1 :           error_at (loc, "argument %d of %qE must not be a pointer to a "
    7000                 :            :                     "function", x + 1, function);
    7001                 :          1 :           return 0;
    7002                 :            :         }
    7003                 :     132950 :       tree type_size = TYPE_SIZE_UNIT (TREE_TYPE (type));
    7004                 :     132950 :       size = type_size ? tree_to_uhwi (type_size) : 0;
    7005                 :     132950 :       if (size != size_0)
    7006                 :            :         {
    7007                 :          6 :           error_at (loc, "size mismatch in argument %d of %qE", x + 1,
    7008                 :            :                     function);
    7009                 :          6 :           return 0;
    7010                 :            :         }
    7011                 :            :     }
    7012                 :            : 
    7013                 :            :   /* Check memory model parameters for validity.  */
    7014                 :     132649 :   for (x = n_param - n_model ; x < n_param; x++)
    7015                 :            :     {
    7016                 :      72598 :       tree p = (*params)[x];
    7017                 :      72598 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (p)))
    7018                 :            :         {
    7019                 :          1 :           error_at (loc, "non-integer memory model argument %d of %qE", x + 1,
    7020                 :            :                     function);
    7021                 :          1 :           return 0;
    7022                 :            :         }
    7023                 :      72597 :       p = fold_for_warn (p);
    7024                 :      72597 :       if (TREE_CODE (p) == INTEGER_CST)
    7025                 :            :         {
    7026                 :            :           /* memmodel_base masks the low 16 bits, thus ignore any bits above
    7027                 :            :              it by using TREE_INT_CST_LOW instead of tree_to_*hwi.  Those high
    7028                 :            :              bits will be checked later during expansion in target specific
    7029                 :            :              way.  */
    7030                 :      72446 :           if (memmodel_base (TREE_INT_CST_LOW (p)) >= MEMMODEL_LAST)
    7031                 :          6 :             warning_at (loc, OPT_Winvalid_memory_model,
    7032                 :            :                         "invalid memory model argument %d of %qE", x + 1,
    7033                 :            :                         function);
    7034                 :            :         }
    7035                 :            :     }
    7036                 :            : 
    7037                 :            :   return size_0;
    7038                 :            : }
    7039                 :            : 
    7040                 :            : 
    7041                 :            : /* This will take an __atomic_ generic FUNCTION call, and add a size parameter N
    7042                 :            :    at the beginning of the parameter list PARAMS representing the size of the
    7043                 :            :    objects.  This is to match the library ABI requirement.  LOC is the location
    7044                 :            :    of the function call.  
    7045                 :            :    The new function is returned if it needed rebuilding, otherwise NULL_TREE is
    7046                 :            :    returned to allow the external call to be constructed.  */
    7047                 :            : 
    7048                 :            : static tree
    7049                 :       2244 : add_atomic_size_parameter (unsigned n, location_t loc, tree function, 
    7050                 :            :                            vec<tree, va_gc> *params)
    7051                 :            : {
    7052                 :       2244 :   tree size_node;
    7053                 :            : 
    7054                 :            :   /* Insert a SIZE_T parameter as the first param.  If there isn't
    7055                 :            :      enough space, allocate a new vector and recursively re-build with that.  */
    7056                 :       2244 :   if (!params->space (1))
    7057                 :            :     {
    7058                 :         14 :       unsigned int z, len;
    7059                 :         14 :       vec<tree, va_gc> *v;
    7060                 :         14 :       tree f;
    7061                 :            : 
    7062                 :         14 :       len = params->length ();
    7063                 :         14 :       vec_alloc (v, len + 1);
    7064                 :         14 :       v->quick_push (build_int_cst (size_type_node, n));
    7065                 :         70 :       for (z = 0; z < len; z++)
    7066                 :         56 :         v->quick_push ((*params)[z]);
    7067                 :         14 :       f = build_function_call_vec (loc, vNULL, function, v, NULL);
    7068                 :         14 :       vec_free (v);
    7069                 :         14 :       return f;
    7070                 :            :     }
    7071                 :            : 
    7072                 :            :   /* Add the size parameter and leave as a function call for processing.  */
    7073                 :       2230 :   size_node = build_int_cst (size_type_node, n);
    7074                 :       2230 :   params->quick_insert (0, size_node);
    7075                 :       2230 :   return NULL_TREE;
    7076                 :            : }
    7077                 :            : 
    7078                 :            : 
    7079                 :            : /* Return whether atomic operations for naturally aligned N-byte
    7080                 :            :    arguments are supported, whether inline or through libatomic.  */
    7081                 :            : static bool
    7082                 :      60051 : atomic_size_supported_p (int n)
    7083                 :            : {
    7084                 :          0 :   switch (n)
    7085                 :            :     {
    7086                 :            :     case 1:
    7087                 :            :     case 2:
    7088                 :            :     case 4:
    7089                 :            :     case 8:
    7090                 :            :       return true;
    7091                 :            : 
    7092                 :       6188 :     case 16:
    7093                 :       6188 :       return targetm.scalar_mode_supported_p (TImode);
    7094                 :            : 
    7095                 :          0 :     default:
    7096                 :          0 :       return false;
    7097                 :            :     }
    7098                 :            : }
    7099                 :            : 
    7100                 :            : /* This will process an __atomic_exchange function call, determine whether it
    7101                 :            :    needs to be mapped to the _N variation, or turned into a library call.
    7102                 :            :    LOC is the location of the builtin call.
    7103                 :            :    FUNCTION is the DECL that has been invoked;
    7104                 :            :    PARAMS is the argument list for the call.  The return value is non-null
    7105                 :            :    TRUE is returned if it is translated into the proper format for a call to the
    7106                 :            :    external library, and NEW_RETURN is set the tree for that function.
    7107                 :            :    FALSE is returned if processing for the _N variation is required, and 
    7108                 :            :    NEW_RETURN is set to the return value the result is copied into.  */
    7109                 :            : static bool
    7110                 :        282 : resolve_overloaded_atomic_exchange (location_t loc, tree function, 
    7111                 :            :                                     vec<tree, va_gc> *params, tree *new_return)
    7112                 :            : {       
    7113                 :        282 :   tree p0, p1, p2, p3;
    7114                 :        282 :   tree I_type, I_type_ptr;
    7115                 :        282 :   int n = get_atomic_generic_size (loc, function, params);
    7116                 :            : 
    7117                 :            :   /* Size of 0 is an error condition.  */
    7118                 :        282 :   if (n == 0)
    7119                 :            :     {
    7120                 :          5 :       *new_return = error_mark_node;
    7121                 :          5 :       return true;
    7122                 :            :     }
    7123                 :            : 
    7124                 :            :   /* If not a lock-free size, change to the library generic format.  */
    7125                 :        282 :   if (!atomic_size_supported_p (n))
    7126                 :            :     {
    7127                 :         14 :       *new_return = add_atomic_size_parameter (n, loc, function, params);
    7128                 :         14 :       return true;
    7129                 :            :     }
    7130                 :            : 
    7131                 :            :   /* Otherwise there is a lockfree match, transform the call from:
    7132                 :            :        void fn(T* mem, T* desired, T* return, model)
    7133                 :            :      into
    7134                 :            :        *return = (T) (fn (In* mem, (In) *desired, model))  */
    7135                 :            : 
    7136                 :        263 :   p0 = (*params)[0];
    7137                 :        263 :   p1 = (*params)[1];
    7138                 :        263 :   p2 = (*params)[2];
    7139                 :        263 :   p3 = (*params)[3];
    7140                 :            :   
    7141                 :            :   /* Create pointer to appropriate size.  */
    7142                 :        263 :   I_type = builtin_type_for_size (BITS_PER_UNIT * n, 1);
    7143                 :        263 :   I_type_ptr = build_pointer_type (I_type);
    7144                 :            : 
    7145                 :            :   /* Convert object pointer to required type.  */
    7146                 :        263 :   p0 = build1 (VIEW_CONVERT_EXPR, I_type_ptr, p0);
    7147                 :        263 :   (*params)[0] = p0; 
    7148                 :            :   /* Convert new value to required type, and dereference it.  */
    7149                 :        263 :   p1 = build_indirect_ref (loc, p1, RO_UNARY_STAR);
    7150                 :        263 :   p1 = build1 (VIEW_CONVERT_EXPR, I_type, p1);
    7151                 :        263 :   (*params)[1] = p1;
    7152                 :            : 
    7153                 :            :   /* Move memory model to the 3rd position, and end param list.  */
    7154                 :        263 :   (*params)[2] = p3;
    7155                 :        263 :   params->truncate (3);
    7156                 :            : 
    7157                 :            :   /* Convert return pointer and dereference it for later assignment.  */
    7158                 :        263 :   *new_return = build_indirect_ref (loc, p2, RO_UNARY_STAR);
    7159                 :            : 
    7160                 :        263 :   return false;
    7161                 :            : }
    7162                 :            : 
    7163                 :            : 
    7164                 :            : /* This will process an __atomic_compare_exchange function call, determine 
    7165                 :            :    whether it needs to be mapped to the _N variation, or turned into a lib call.
    7166                 :            :    LOC is the location of the builtin call.
    7167                 :            :    FUNCTION is the DECL that has been invoked;
    7168                 :            :    PARAMS is the argument list for the call.  The return value is non-null
    7169                 :            :    TRUE is returned if it is translated into the proper format for a call to the
    7170                 :            :    external library, and NEW_RETURN is set the tree for that function.
    7171                 :            :    FALSE is returned if processing for the _N variation is required.  */
    7172                 :            : 
    7173                 :            : static bool
    7174                 :      12550 : resolve_overloaded_atomic_compare_exchange (location_t loc, tree function, 
    7175                 :            :                                             vec<tree, va_gc> *params, 
    7176                 :            :                                             tree *new_return)
    7177                 :            : {       
    7178                 :      12550 :   tree p0, p1, p2;
    7179                 :      12550 :   tree I_type, I_type_ptr;
    7180                 :      12550 :   int n = get_atomic_generic_size (loc, function, params);
    7181                 :            : 
    7182                 :            :   /* Size of 0 is an error condition.  */
    7183                 :      12550 :   if (n == 0)
    7184                 :            :     {
    7185                 :          4 :       *new_return = error_mark_node;
    7186                 :          4 :       return true;
    7187                 :            :     }
    7188                 :            : 
    7189                 :            :   /* If not a lock-free size, change to the library generic format.  */
    7190                 :      14157 :   if (!atomic_size_supported_p (n))
    7191                 :            :     {
    7192                 :            :       /* The library generic format does not have the weak parameter, so 
    7193                 :            :          remove it from the param list.  Since a parameter has been removed,
    7194                 :            :          we can be sure that there is room for the SIZE_T parameter, meaning
    7195                 :            :          there will not be a recursive rebuilding of the parameter list, so
    7196                 :            :          there is no danger this will be done twice.  */
    7197                 :        610 :       if (n > 0)
    7198                 :            :         {
    7199                 :        610 :           (*params)[3] = (*params)[4];
    7200                 :        610 :           (*params)[4] = (*params)[5];
    7201                 :        610 :           params->truncate (5);
    7202                 :            :         }
    7203                 :        610 :       *new_return = add_atomic_size_parameter (n, loc, function, params);
    7204                 :        610 :       return true;
    7205                 :            :     }
    7206                 :            : 
    7207                 :            :   /* Otherwise, there is a match, so the call needs to be transformed from:
    7208                 :            :        bool fn(T* mem, T* desired, T* return, weak, success, failure)
    7209                 :            :      into
    7210                 :            :        bool fn ((In *)mem, (In *)expected, (In) *desired, weak, succ, fail)  */
    7211                 :            : 
    7212                 :      11936 :   p0 = (*params)[0];
    7213                 :      11936 :   p1 = (*params)[1];
    7214                 :      11936 :   p2 = (*params)[2];
    7215                 :            :   
    7216                 :            :   /* Create pointer to appropriate size.  */
    7217                 :      11936 :   I_type = builtin_type_for_size (BITS_PER_UNIT * n, 1);
    7218                 :      11936 :   I_type_ptr = build_pointer_type (I_type);
    7219                 :            : 
    7220                 :            :   /* Convert object pointer to required type.  */
    7221                 :      11936 :   p0 = build1 (VIEW_CONVERT_EXPR, I_type_ptr, p0);
    7222                 :      11936 :   (*params)[0] = p0;
    7223                 :            : 
    7224                 :            :   /* Convert expected pointer to required type.  */
    7225                 :      11936 :   p1 = build1 (VIEW_CONVERT_EXPR, I_type_ptr, p1);
    7226                 :      11936 :   (*params)[1] = p1;
    7227                 :            : 
    7228                 :            :   /* Convert desired value to required type, and dereference it.  */
    7229                 :      11936 :   p2 = build_indirect_ref (loc, p2, RO_UNARY_STAR);
    7230                 :      11936 :   p2 = build1 (VIEW_CONVERT_EXPR, I_type, p2);
    7231                 :      11936 :   (*params)[2] = p2;
    7232                 :            : 
    7233                 :            :   /* The rest of the parameters are fine. NULL means no special return value
    7234                 :            :      processing.*/
    7235                 :      11936 :   *new_return = NULL;
    7236                 :      11936 :   return false;
    7237                 :            : }
    7238                 :            : 
    7239                 :            : 
    7240                 :            : /* This will process an __atomic_load function call, determine whether it
    7241                 :            :    needs to be mapped to the _N variation, or turned into a library call.
    7242                 :            :    LOC is the location of the builtin call.
    7243                 :            :    FUNCTION is the DECL that has been invoked;
    7244                 :            :    PARAMS is the argument list for the call.  The return value is non-null
    7245                 :            :    TRUE is returned if it is translated into the proper format for a call to the
    7246                 :            :    external library, and NEW_RETURN is set the tree for that function.
    7247                 :            :    FALSE is returned if processing for the _N variation is required, and 
    7248                 :            :    NEW_RETURN is set to the return value the result is copied into.  */
    7249                 :            : 
    7250                 :            : static bool
    7251                 :      36382 : resolve_overloaded_atomic_load (location_t loc, tree function, 
    7252                 :            :                                 vec<tree, va_gc> *params, tree *new_return)
    7253                 :            : {       
    7254                 :      36382 :   tree p0, p1, p2;
    7255                 :      36382 :   tree I_type, I_type_ptr;
    7256                 :      36382 :   int n = get_atomic_generic_size (loc, function, params);
    7257                 :            : 
    7258                 :            :   /* Size of 0 is an error condition.  */
    7259                 :      36382 :   if (n == 0)
    7260                 :            :     {
    7261                 :          8 :       *new_return = error_mark_node;
    7262                 :          8 :       return true;
    7263                 :            :     }
    7264                 :            : 
    7265                 :            :   /* If not a lock-free size, change to the library generic format.  */
    7266                 :      39638 :   if (!atomic_size_supported_p (n))
    7267                 :            :     {
    7268                 :       1341 :       *new_return = add_atomic_size_parameter (n, loc, function, params);
    7269                 :       1341 :       return true;
    7270                 :            :     }
    7271                 :            : 
    7272                 :            :   /* Otherwise, there is a match, so the call needs to be transformed from:
    7273                 :            :        void fn(T* mem, T* return, model)
    7274                 :            :      into
    7275                 :            :        *return = (T) (fn ((In *) mem, model))  */
    7276                 :            : 
    7277                 :      35033 :   p0 = (*params)[0];
    7278                 :      35033 :   p1 = (*params)[1];
    7279                 :      35033 :   p2 = (*params)[2];
    7280                 :            :   
    7281                 :            :   /* Create pointer to appropriate size.  */
    7282                 :      35033 :   I_type = builtin_type_for_size (BITS_PER_UNIT * n, 1);
    7283                 :      35033 :   I_type_ptr = build_pointer_type (I_type);
    7284                 :            : 
    7285                 :            :   /* Convert object pointer to required type.  */
    7286                 :      35033 :   p0 = build1 (VIEW_CONVERT_EXPR, I_type_ptr, p0);
    7287                 :      35033 :   (*params)[0] = p0;
    7288                 :            : 
    7289                 :            :   /* Move memory model to the 2nd position, and end param list.  */
    7290                 :      35033 :   (*params)[1] = p2;
    7291                 :      35033 :   params->truncate (2);
    7292                 :            : 
    7293                 :            :   /* Convert return pointer and dereference it for later assignment.  */
    7294                 :      35033 :   *new_return = build_indirect_ref (loc, p1, RO_UNARY_STAR);
    7295                 :            : 
    7296                 :      35033 :   return false;
    7297                 :            : }
    7298                 :            : 
    7299                 :            : 
    7300                 :            : /* This will process an __atomic_store function call, determine whether it
    7301                 :            :    needs to be mapped to the _N variation, or turned into a library call.
    7302                 :            :    LOC is the location of the builtin call.
    7303                 :            :    FUNCTION is the DECL that has been invoked;
    7304                 :            :    PARAMS is the argument list for the call.  The return value is non-null
    7305                 :            :    TRUE is returned if it is translated into the proper format for a call to the
    7306                 :            :    external library, and NEW_RETURN is set the tree for that function.
    7307                 :            :    FALSE is returned if processing for the _N variation is required, and 
    7308                 :            :    NEW_RETURN is set to the return value the result is copied into.  */
    7309                 :            : 
    7310                 :            : static bool
    7311                 :      10861 : resolve_overloaded_atomic_store (location_t loc, tree function, 
    7312                 :            :                                  vec<tree, va_gc> *params, tree *new_return)
    7313                 :            : {       
    7314                 :      10861 :   tree p0, p1;
    7315                 :      10861 :   tree I_type, I_type_ptr;
    7316                 :      10861 :   int n = get_atomic_generic_size (loc, function, params);
    7317                 :            : 
    7318                 :            :   /* Size of 0 is an error condition.  */
    7319                 :      10861 :   if (n == 0)
    7320                 :            :     {
    7321                 :          7 :       *new_return = error_mark_node;
    7322                 :          7 :       return true;
    7323                 :            :     }
    7324                 :            : 
    7325                 :            :   /* If not a lock-free size, change to the library generic format.  */
    7326                 :      12162 :   if (!atomic_size_supported_p (n))
    7327                 :            :     {
    7328                 :        279 :       *new_return = add_atomic_size_parameter (n, loc, function, params);
    7329                 :        279 :       return true;
    7330                 :            :     }
    7331                 :            : 
    7332                 :            :   /* Otherwise, there is a match, so the call needs to be transformed from:
    7333                 :            :        void fn(T* mem, T* value, model)
    7334                 :            :      into
    7335                 :            :        fn ((In *) mem, (In) *value, model)  */
    7336                 :            : 
    7337                 :      10575 :   p0 = (*params)[0];
    7338                 :      10575 :   p1 = (*params)[1];
    7339                 :            :   
    7340                 :            :   /* Create pointer to appropriate size.  */
    7341                 :      10575 :   I_type = builtin_type_for_size (BITS_PER_UNIT * n, 1);
    7342                 :      10575 :   I_type_ptr = build_pointer_type (I_type);
    7343                 :            : 
    7344                 :            :   /* Convert object pointer to required type.  */
    7345                 :      10575 :   p0 = build1 (VIEW_CONVERT_EXPR, I_type_ptr, p0);
    7346                 :      10575 :   (*params)[0] = p0;
    7347                 :            : 
    7348                 :            :   /* Convert new value to required type, and dereference it.  */
    7349                 :      10575 :   p1 = build_indirect_ref (loc, p1, RO_UNARY_STAR);
    7350                 :      10575 :   p1 = build1 (VIEW_CONVERT_EXPR, I_type, p1);
    7351                 :      10575 :   (*params)[1] = p1;
    7352                 :            :   
    7353                 :            :   /* The memory model is in the right spot already. Return is void.  */
    7354                 :      10575 :   *new_return = NULL_TREE;
    7355                 :            : 
    7356                 :      10575 :   return false;
    7357                 :            : }
    7358                 :            : 
    7359                 :            : 
    7360                 :            : /* Some builtin functions are placeholders for other expressions.  This
    7361                 :            :    function should be called immediately after parsing the call expression
    7362                 :            :    before surrounding code has committed to the type of the expression.
    7363                 :            : 
    7364                 :            :    LOC is the location of the builtin call.
    7365                 :            : 
    7366                 :            :    FUNCTION is the DECL that has been invoked; it is known to be a builtin.
    7367                 :            :    PARAMS is the argument list for the call.  The return value is non-null
    7368                 :            :    when expansion is complete, and null if normal processing should
    7369                 :            :    continue.  */
    7370                 :            : 
    7371                 :            : tree
    7372                 :   28832900 : resolve_overloaded_builtin (location_t loc, tree function,
    7373                 :            :                             vec<tree, va_gc> *params)
    7374                 :            : {
    7375                 :            :   /* Is function one of the _FETCH_OP_ or _OP_FETCH_ built-ins?
    7376                 :            :      Those are not valid to call with a pointer to _Bool (or C++ bool)
    7377                 :            :      and so must be rejected.  */
    7378                 :   28832900 :   bool fetch_op = true;
    7379                 :   28832900 :   bool orig_format = true;
    7380                 :   28832900 :   tree new_return = NULL_TREE;
    7381                 :            : 
    7382                 :   28832900 :   switch (DECL_BUILT_IN_CLASS (function))
    7383                 :            :     {
    7384                 :    1845280 :     case BUILT_IN_NORMAL:
    7385                 :    1845280 :       break;
    7386                 :   18725700 :     case BUILT_IN_MD:
    7387                 :   18725700 :       if (targetm.resolve_overloaded_builtin)
    7388                 :          0 :         return targetm.resolve_overloaded_builtin (loc, function, params);
    7389                 :            :       else
    7390                 :            :         return NULL_TREE;
    7391                 :            :     default:
    7392                 :            :       return NULL_TREE;
    7393                 :            :     }
    7394                 :            : 
    7395                 :            :   /* Handle BUILT_IN_NORMAL here.  */
    7396                 :    1845280 :   enum built_in_function orig_code = DECL_FUNCTION_CODE (function);
    7397                 :    1845280 :   switch (orig_code)
    7398                 :            :     {
    7399                 :         41 :     case BUILT_IN_SPECULATION_SAFE_VALUE_N:
    7400                 :         41 :       {
    7401                 :         41 :         tree new_function, first_param, result;
    7402                 :         41 :         enum built_in_function fncode
    7403                 :         41 :           = speculation_safe_value_resolve_call (function, params);;
    7404                 :            : 
    7405                 :         41 :         first_param = (*params)[0];
    7406                 :         41 :         if (fncode == BUILT_IN_NONE
    7407                 :         41 :             || !speculation_safe_value_resolve_params (loc, function, params))
    7408                 :          0 :           return error_mark_node;
    7409                 :            : 
    7410                 :         41 :         if (targetm.have_speculation_safe_value (true))
    7411                 :            :           {
    7412                 :         41 :             new_function = builtin_decl_explicit (fncode);
    7413                 :         41 :             result = build_function_call_vec (loc, vNULL, new_function, params,
    7414                 :            :                                               NULL);
    7415                 :            : 
    7416                 :         41 :             if (result == error_mark_node)
    7417                 :            :               return result;
    7418                 :            : 
    7419                 :         41 :             return speculation_safe_value_resolve_return (first_param, result);
    7420                 :            :           }
    7421                 :            :         else
    7422                 :            :           {
    7423                 :            :             /* This target doesn't have, or doesn't need, active mitigation
    7424                 :            :                against incorrect speculative execution.  Simply return the
    7425                 :            :                first parameter to the builtin.  */
    7426                 :          0 :             if (!targetm.have_speculation_safe_value (false))
    7427                 :            :               /* The user has invoked __builtin_speculation_safe_value
    7428                 :            :                  even though __HAVE_SPECULATION_SAFE_VALUE is not
    7429                 :            :                  defined: emit a warning.  */
    7430                 :          0 :               warning_at (input_location, 0,
    7431                 :            :                           "this target does not define a speculation barrier; "
    7432                 :            :                           "your program will still execute correctly, "
    7433                 :            :                           "but incorrect speculation may not be "
    7434                 :            :                           "restricted");
    7435                 :            : 
    7436                 :            :             /* If the optional second argument is present, handle any side
    7437                 :            :                effects now.  */
    7438                 :          0 :             if (params->length () == 2
    7439                 :          0 :                 && TREE_SIDE_EFFECTS ((*params)[1]))
    7440                 :          0 :               return build2 (COMPOUND_EXPR, TREE_TYPE (first_param),
    7441                 :          0 :                              (*params)[1], first_param);
    7442                 :            : 
    7443                 :            :             return first_param;
    7444                 :            :           }
    7445                 :            :       }
    7446                 :            : 
    7447                 :      60075 :     case BUILT_IN_ATOMIC_EXCHANGE:
    7448                 :      60075 :     case BUILT_IN_ATOMIC_COMPARE_EXCHANGE:
    7449                 :      60075 :     case BUILT_IN_ATOMIC_LOAD:
    7450                 :      60075 :     case BUILT_IN_ATOMIC_STORE:
    7451                 :      60075 :       {
    7452                 :            :         /* Handle these 4 together so that they can fall through to the next
    7453                 :            :            case if the call is transformed to an _N variant.  */
    7454                 :      60075 :         switch (orig_code)
    7455                 :            :           {
    7456                 :        282 :           case BUILT_IN_ATOMIC_EXCHANGE:
    7457                 :        282 :             {
    7458                 :        282 :               if (resolve_overloaded_atomic_exchange (loc, function, params,
    7459                 :            :                                                       &new_return))
    7460                 :         19 :                 return new_return;
    7461                 :            :               /* Change to the _N variant.  */
    7462                 :            :               orig_code = BUILT_IN_ATOMIC_EXCHANGE_N;
    7463                 :            :               break;
    7464                 :            :             }
    7465                 :            : 
    7466                 :      12550 :           case BUILT_IN_ATOMIC_COMPARE_EXCHANGE:
    7467                 :      12550 :             {
    7468                 :      12550 :               if (resolve_overloaded_atomic_compare_exchange (loc, function,
    7469                 :            :                                                               params,
    7470                 :            :                                                               &new_return))
    7471                 :        614 :                 return new_return;
    7472                 :            :               /* Change to the _N variant.  */
    7473                 :            :               orig_code = BUILT_IN_ATOMIC_COMPARE_EXCHANGE_N;
    7474                 :            :               break;
    7475                 :            :             }
    7476                 :      36382 :           case BUILT_IN_ATOMIC_LOAD:
    7477                 :      36382 :             {
    7478                 :      36382 :               if (resolve_overloaded_atomic_load (loc, function, params,
    7479                 :            :                                                   &new_return))
    7480                 :       1349 :                 return new_return;
    7481                 :            :               /* Change to the _N variant.  */
    7482                 :            :               orig_code = BUILT_IN_ATOMIC_LOAD_N;
    7483                 :            :               break;
    7484                 :            :             }
    7485                 :      10861 :           case BUILT_IN_ATOMIC_STORE:
    7486                 :      10861 :             {
    7487                 :      10861 :               if (resolve_overloaded_atomic_store (loc, function, params,
    7488                 :            :                                                    &new_return))
    7489                 :        286 :                 return new_return;
    7490                 :            :               /* Change to the _N variant.  */
    7491                 :            :               orig_code = BUILT_IN_ATOMIC_STORE_N;
    7492                 :            :               break;
    7493                 :            :             }
    7494                 :          0 :           default:
    7495                 :          0 :             gcc_unreachable ();
    7496                 :            :           }
    7497                 :            :       }
    7498                 :            :       /* FALLTHRU */
    7499                 :            :     case BUILT_IN_ATOMIC_EXCHANGE_N:
    7500                 :            :     case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_N:
    7501                 :            :     case BUILT_IN_ATOMIC_LOAD_N:
    7502                 :            :     case BUILT_IN_ATOMIC_STORE_N:
    7503                 :            :       fetch_op = false;
    7504                 :            :       /* FALLTHRU */
    7505                 :            :     case BUILT_IN_ATOMIC_ADD_FETCH_N:
    7506                 :            :     case BUILT_IN_ATOMIC_SUB_FETCH_N:
    7507                 :            :     case BUILT_IN_ATOMIC_AND_FETCH_N:
    7508                 :            :     case BUILT_IN_ATOMIC_NAND_FETCH_N:
    7509                 :            :     case BUILT_IN_ATOMIC_XOR_FETCH_N:
    7510                 :            :     case BUILT_IN_ATOMIC_OR_FETCH_N:
    7511                 :            :     case BUILT_IN_ATOMIC_FETCH_ADD_N:
    7512                 :            :     case BUILT_IN_ATOMIC_FETCH_SUB_N:
    7513                 :            :     case BUILT_IN_ATOMIC_FETCH_AND_N:
    7514                 :            :     case BUILT_IN_ATOMIC_FETCH_NAND_N:
    7515                 :            :     case BUILT_IN_ATOMIC_FETCH_XOR_N:
    7516                 :            :     case BUILT_IN_ATOMIC_FETCH_OR_N:
    7517                 :            :       orig_format = false;
    7518                 :            :       /* FALLTHRU */
    7519                 :     177231 :     case BUILT_IN_SYNC_FETCH_AND_ADD_N:
    7520                 :     177231 :     case BUILT_IN_SYNC_FETCH_AND_SUB_N:
    7521                 :     177231 :     case BUILT_IN_SYNC_FETCH_AND_OR_N:
    7522                 :     177231 :     case BUILT_IN_SYNC_FETCH_AND_AND_N:
    7523                 :     177231 :     case BUILT_IN_SYNC_FETCH_AND_XOR_N:
    7524                 :     177231 :     case BUILT_IN_SYNC_FETCH_AND_NAND_N:
    7525                 :     177231 :     case BUILT_IN_SYNC_ADD_AND_FETCH_N:
    7526                 :     177231 :     case BUILT_IN_SYNC_SUB_AND_FETCH_N:
    7527                 :     177231 :     case BUILT_IN_SYNC_OR_AND_FETCH_N:
    7528                 :     177231 :     case BUILT_IN_SYNC_AND_AND_FETCH_N:
    7529                 :     177231 :     case BUILT_IN_SYNC_XOR_AND_FETCH_N:
    7530                 :     177231 :     case BUILT_IN_SYNC_NAND_AND_FETCH_N:
    7531                 :     177231 :     case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_N:
    7532                 :     177231 :     case BUILT_IN_SYNC_VAL_COMPARE_AND_SWAP_N:
    7533                 :     177231 :     case BUILT_IN_SYNC_LOCK_TEST_AND_SET_N:
    7534                 :     177231 :     case BUILT_IN_SYNC_LOCK_RELEASE_N:
    7535                 :     177231 :       {
    7536                 :            :         /* The following are not _FETCH_OPs and must be accepted with
    7537                 :            :            pointers to _Bool (or C++ bool).  */
    7538                 :     177231 :         if (fetch_op)
    7539                 :      29285 :           fetch_op =
    7540                 :      29285 :             (orig_code != BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_N
    7541                 :      29285 :              && orig_code != BUILT_IN_SYNC_VAL_COMPARE_AND_SWAP_N
    7542                 :      28550 :              && orig_code != BUILT_IN_SYNC_LOCK_TEST_AND_SET_N
    7543                 :      29285 :              && orig_code != BUILT_IN_SYNC_LOCK_RELEASE_N);
    7544                 :            : 
    7545                 :     177231 :         int n = sync_resolve_size (function, params, fetch_op);
    7546                 :     177231 :         tree new_function, first_param, result;
    7547                 :     177231 :         enum built_in_function fncode;
    7548                 :            : 
    7549                 :     177231 :         if (n == 0)
    7550                 :         61 :           return error_mark_node;
    7551                 :            : 
    7552                 :     177170 :         fncode = (enum built_in_function)((int)orig_code + exact_log2 (n) + 1);
    7553                 :     177170 :         new_function = builtin_decl_explicit (fncode);
    7554                 :     177170 :         if (!sync_resolve_params (loc, function, new_function, params,
    7555                 :            :                                   orig_format))
    7556                 :          2 :           return error_mark_node;
    7557                 :            : 
    7558                 :     177168 :         first_param = (*params)[0];
    7559                 :     177168 :         result = build_function_call_vec (loc, vNULL, new_function, params,
    7560                 :            :                                           NULL);
    7561                 :     177168 :         if (result == error_mark_node)
    7562                 :            :           return result;
    7563                 :     177156 :         if (orig_code != BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_N
    7564                 :     177156 :             && orig_code != BUILT_IN_SYNC_LOCK_RELEASE_N
    7565                 :     176885 :             && orig_code != BUILT_IN_ATOMIC_STORE_N
    7566                 :     176885 :             && orig_code != BUILT_IN_ATOMIC_COMPARE_EXCHANGE_N)
    7567                 :     112615 :           result = sync_resolve_return (first_param, result, orig_format);
    7568                 :            : 
    7569                 :     177156 :         if (fetch_op)
    7570                 :            :           /* Prevent -Wunused-value warning.  */
    7571                 :      27712 :           TREE_USED (result) = true;
    7572                 :            : 
    7573                 :            :         /* If new_return is set, assign function to that expr and cast the
    7574                 :            :            result to void since the generic interface returned void.  */
    7575                 :     177156 :         if (new_return)
    7576                 :            :           {
    7577                 :            :             /* Cast function result from I{1,2,4,8,16} to the required type.  */
    7578                 :      35296 :             result = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (new_return), result);
    7579                 :      35296 :             result = build2 (MODIFY_EXPR, TREE_TYPE (new_return), new_return,
    7580                 :            :                              result);
    7581                 :      35296 :             TREE_SIDE_EFFECTS (result) = 1;
    7582                 :      35296 :             protected_set_expr_location (result, loc);
    7583                 :      35296 :             result = convert (void_type_node, result);
    7584                 :            :           }
    7585                 :            :         return result;
    7586                 :            :       }
    7587                 :            : 
    7588                 :            :     default:
    7589                 :            :       return NULL_TREE;
    7590                 :            :     }
    7591                 :            : }
    7592                 :            : 
    7593                 :            : /* vector_types_compatible_elements_p is used in type checks of vectors
    7594                 :            :    values used as operands of binary operators.  Where it returns true, and
    7595                 :            :    the other checks of the caller succeed (being vector types in he first
    7596                 :            :    place, and matching number of elements), we can just treat the types
    7597                 :            :    as essentially the same.
    7598                 :            :    Contrast with vector_targets_convertible_p, which is used for vector
    7599                 :            :    pointer types,  and vector_types_convertible_p, which will allow
    7600                 :            :    language-specific matches under the control of flag_lax_vector_conversions,
    7601                 :            :    and might still require a conversion.  */
    7602                 :            : /* True if vector types T1 and T2 can be inputs to the same binary
    7603                 :            :    operator without conversion.
    7604                 :            :    We don't check the overall vector size here because some of our callers
    7605                 :            :    want to give different error messages when the vectors are compatible
    7606                 :            :    except for the element count.  */
    7607                 :            : 
    7608                 :            : bool
    7609                 :     630045 : vector_types_compatible_elements_p (tree t1, tree t2)
    7610                 :            : {
    7611                 :    1259950 :   bool opaque = TYPE_VECTOR_OPAQUE (t1) || TYPE_VECTOR_OPAQUE (t2);
    7612                 :     630045 :   t1 = TREE_TYPE (t1);
    7613                 :     630045 :   t2 = TREE_TYPE (t2);
    7614                 :            : 
    7615                 :     630045 :   enum tree_code c1 = TREE_CODE (t1), c2 = TREE_CODE (t2);
    7616                 :            : 
    7617                 :     630045 :   gcc_assert ((INTEGRAL_TYPE_P (t1)
    7618                 :            :                || c1 == REAL_TYPE
    7619                 :            :                || c1 == FIXED_POINT_TYPE)
    7620                 :            :               && (INTEGRAL_TYPE_P (t2)
    7621                 :            :                   || c2 == REAL_TYPE
    7622                 :            :                   || c2 == FIXED_POINT_TYPE));
    7623                 :            : 
    7624                 :     630045 :   t1 = c_common_signed_type (t1);
    7625                 :     630045 :   t2 = c_common_signed_type (t2);
    7626                 :            :   /* Equality works here because c_common_signed_type uses
    7627                 :            :      TYPE_MAIN_VARIANT.  */
    7628                 :     630045 :   if (t1 == t2)
    7629                 :            :     return