LCOV - code coverage report
Current view: top level - gcc/c - c-parser.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 89.5 % 16063 14373
Test Date: 2026-12-05 16:10:02 Functions: 92.0 % 351 323
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Parser for C and Objective-C.
       2              : 
       3              :    Copyright (C) 1987-2026 Free Software Foundation, Inc.
       4              :    Parser actions based on the old Bison parser; structure somewhat
       5              :    influenced by and fragments based on the C++ parser.
       6              : 
       7              : This file is part of GCC.
       8              : 
       9              : GCC is free software; you can redistribute it and/or modify it under
      10              : the terms of the GNU General Public License as published by the Free
      11              : Software Foundation; either version 3, or (at your option) any later
      12              : version.
      13              : 
      14              : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      15              : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      16              : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      17              : for more details.
      18              : 
      19              : You should have received a copy of the GNU General Public License
      20              : along with GCC; see the file COPYING3.  If not see
      21              : <http://www.gnu.org/licenses/>.  */
      22              : 
      23              : /* TODO:
      24              : 
      25              :    Make sure all relevant comments, and all relevant code from all
      26              :    actions, brought over from old parser.  Verify exact correspondence
      27              :    of syntax accepted.
      28              : 
      29              :    Add testcases covering every input symbol in every state in old and
      30              :    new parsers.
      31              : 
      32              :    Include full syntax for GNU C, including erroneous cases accepted
      33              :    with error messages, in syntax productions in comments.
      34              : 
      35              :    Make more diagnostics in the front end generally take an explicit
      36              :    location rather than implicitly using input_location.  */
      37              : 
      38              : #include "config.h"
      39              : #define INCLUDE_STRING
      40              : #include "system.h"
      41              : #include "coretypes.h"
      42              : #include "target.h"
      43              : #include "function.h"
      44              : #include "c-tree.h"
      45              : #include "timevar.h"
      46              : #include "stringpool.h"
      47              : #include "cgraph.h"
      48              : #include "attribs.h"
      49              : #include "stor-layout.h"
      50              : #include "varasm.h"
      51              : #include "trans-mem.h"
      52              : #include "c-family/c-pragma.h"
      53              : #include "c-lang.h"
      54              : #include "c-family/c-objc.h"
      55              : #include "plugin.h"
      56              : #include "omp-general.h"
      57              : #include "omp-offload.h"
      58              : #include "builtins.h"
      59              : #include "gomp-constants.h"
      60              : #include "c-family/c-indentation.h"
      61              : #include "gimple-expr.h"
      62              : #include "context.h"
      63              : #include "gcc-rich-location.h"
      64              : #include "c-parser.h"
      65              : #include "gimple-parser.h"
      66              : #include "read-rtl-function.h"
      67              : #include "run-rtl-passes.h"
      68              : #include "intl.h"
      69              : #include "c-family/name-hint.h"
      70              : #include "tree-iterator.h"
      71              : #include "tree-pretty-print.h"
      72              : #include "memmodel.h"
      73              : #include "c-family/known-headers.h"
      74              : #include "bitmap.h"
      75              : #include "analyzer/analyzer-language.h"
      76              : #include "toplev.h"
      77              : #include "asan.h"
      78              : #include "c-family/c-ubsan.h"
      79              : #include "gcc-urlifier.h"
      80              : 
      81              : /* We need to walk over decls with incomplete struct/union/enum types
      82              :    after parsing the whole translation unit.
      83              :    In finish_decl(), if the decl is static, has incomplete
      84              :    struct/union/enum type, it is appended to incomplete_record_decls.
      85              :    In c_parser_translation_unit(), we iterate over incomplete_record_decls
      86              :    and report error if any of the decls are still incomplete.  */
      87              : 
      88              : vec<tree> incomplete_record_decls;
      89              : 
      90              : void
      91    217571775 : set_c_expr_source_range (c_expr *expr,
      92              :                          location_t start, location_t finish)
      93              : {
      94    217571775 :   expr->src_range.m_start = start;
      95    217571775 :   expr->src_range.m_finish = finish;
      96    217571775 :   if (expr->value)
      97    217571679 :     set_source_range (expr->value, start, finish);
      98    217571775 : }
      99              : 
     100              : void
     101    239026312 : set_c_expr_source_range (c_expr *expr,
     102              :                          source_range src_range)
     103              : {
     104    239026312 :   expr->src_range = src_range;
     105    239026312 :   if (expr->value)
     106    239026307 :     set_source_range (expr->value, src_range);
     107    239026312 : }
     108              : 
     109              : 
     110              : /* Initialization routine for this file.  */
     111              : 
     112              : void
     113       116041 : c_parse_init (void)
     114              : {
     115              :   /* The only initialization required is of the reserved word
     116              :      identifiers.  */
     117       116041 :   unsigned int i;
     118       116041 :   tree id;
     119       116041 :   int mask = 0;
     120              : 
     121              :   /* Make sure RID_MAX hasn't grown past the 8 bits used to hold the keyword in
     122              :      the c_token structure.  */
     123       116041 :   gcc_assert (RID_MAX <= 255);
     124              : 
     125       116041 :   mask |= D_CXXONLY;
     126       116041 :   if (!flag_isoc99)
     127         6974 :     mask |= D_C99;
     128       116041 :   if (!flag_isoc23)
     129        13264 :     mask |= D_C23;
     130       116041 :   if (flag_no_asm)
     131              :     {
     132         6372 :       mask |= D_ASM | D_EXT;
     133         6372 :       if (!flag_isoc99)
     134         4023 :         mask |= D_EXT89;
     135         6372 :       if (!flag_isoc23)
     136         5171 :         mask |= D_EXT11;
     137              :     }
     138       116041 :   if (!c_dialect_objc ())
     139       116041 :     mask |= D_OBJC | D_CXX_OBJC;
     140              : 
     141       116041 :   ridpointers = ggc_cleared_vec_alloc<tree> ((int) RID_MAX);
     142     27617758 :   for (i = 0; i < num_c_common_reswords; i++)
     143              :     {
     144              :       /* If a keyword is disabled, do not enter it into the table
     145              :          and so create a canonical spelling that isn't a keyword.  */
     146     27501717 :       if (c_common_reswords[i].disable & mask)
     147              :         {
     148     10399168 :           if (warn_cxx_compat
     149       135864 :               && (c_common_reswords[i].disable & D_CXXWARN))
     150              :             {
     151        65064 :               id = get_identifier (c_common_reswords[i].word);
     152        65064 :               C_SET_RID_CODE (id, RID_CXX_COMPAT_WARN);
     153        65064 :               C_IS_RESERVED_WORD (id) = 1;
     154              :             }
     155     10399168 :           continue;
     156              :         }
     157              : 
     158     17102549 :       id = get_identifier (c_common_reswords[i].word);
     159     17102549 :       C_SET_RID_CODE (id, c_common_reswords[i].rid);
     160     17102549 :       C_IS_RESERVED_WORD (id) = 1;
     161     17102549 :       ridpointers [(int) c_common_reswords[i].rid] = id;
     162              :     }
     163              : 
     164       232082 :   for (i = 0; i < NUM_INT_N_ENTS; i++)
     165              :     {
     166              :       /* We always create the symbols but they aren't always supported.  */
     167       116041 :       char name[50];
     168       116041 :       sprintf (name, "__int%d", int_n_data[i].bitsize);
     169       116041 :       id = get_identifier (name);
     170       116041 :       C_SET_RID_CODE (id, RID_FIRST_INT_N + i);
     171       116041 :       C_IS_RESERVED_WORD (id) = 1;
     172              : 
     173       116041 :       sprintf (name, "__int%d__", int_n_data[i].bitsize);
     174       116041 :       id = get_identifier (name);
     175       116041 :       C_SET_RID_CODE (id, RID_FIRST_INT_N + i);
     176       116041 :       C_IS_RESERVED_WORD (id) = 1;
     177              :     }
     178              : 
     179       116041 :   if (flag_openmp)
     180              :     {
     181         2455 :       id = get_identifier ("omp_all_memory");
     182         2455 :       C_SET_RID_CODE (id, RID_OMP_ALL_MEMORY);
     183         2455 :       C_IS_RESERVED_WORD (id) = 1;
     184         2455 :       ridpointers [RID_OMP_ALL_MEMORY] = id;
     185              :     }
     186       116041 : }
     187              : 
     188              : /* A parser structure recording information about the state and
     189              :    context of parsing.  Includes lexer information with up to two
     190              :    tokens of look-ahead; more are not needed for C.  */
     191              : struct GTY(()) c_parser {
     192              :   /* The look-ahead tokens.  */
     193              :   c_token * GTY((skip)) tokens;
     194              :   /* Buffer for look-ahead tokens.  */
     195              :   c_token tokens_buf[4];
     196              :   /* How many look-ahead tokens are available (0 - 4, or
     197              :      more if parsing from pre-lexed tokens).  */
     198              :   unsigned int tokens_avail;
     199              :   /* Raw look-ahead tokens, used only for checking in Objective-C
     200              :      whether '[[' starts attributes.  */
     201              :   vec<c_token, va_gc> *raw_tokens;
     202              :   /* The number of raw look-ahead tokens that have since been fully
     203              :      lexed.  */
     204              :   unsigned int raw_tokens_used;
     205              :   /* True if a syntax error is being recovered from; false otherwise.
     206              :      c_parser_error sets this flag.  It should clear this flag when
     207              :      enough tokens have been consumed to recover from the error.  */
     208              :   bool error : 1;
     209              :   /* True if we're processing a pragma, and shouldn't automatically
     210              :      consume CPP_PRAGMA_EOL.  */
     211              :   bool in_pragma : 1;
     212              :   /* True if we're parsing the outermost block of an if statement.  */
     213              :   bool in_if_block : 1;
     214              :   /* True if we want to lex a translated, joined string (for an
     215              :      initial #pragma pch_preprocess).  Otherwise the parser is
     216              :      responsible for concatenating strings and translating to the
     217              :      execution character set as needed.  */
     218              :   bool lex_joined_string : 1;
     219              :   /* True if, when the parser is concatenating string literals, it
     220              :      should translate them to the execution character set (false
     221              :      inside attributes).  */
     222              :   bool translate_strings_p : 1;
     223              : 
     224              :   /* Objective-C specific parser/lexer information.  */
     225              : 
     226              :   /* True if we are in a context where the Objective-C "PQ" keywords
     227              :      are considered keywords.  */
     228              :   bool objc_pq_context : 1;
     229              :   /* True if we are parsing a (potential) Objective-C foreach
     230              :      statement.  This is set to true after we parsed 'for (' and while
     231              :      we wait for 'in' or ';' to decide if it's a standard C for loop or an
     232              :      Objective-C foreach loop.  */
     233              :   bool objc_could_be_foreach_context : 1;
     234              :   /* The following flag is needed to contextualize Objective-C lexical
     235              :      analysis.  In some cases (e.g., 'int NSObject;'), it is
     236              :      undesirable to bind an identifier to an Objective-C class, even
     237              :      if a class with that name exists.  */
     238              :   bool objc_need_raw_identifier : 1;
     239              :   /* Nonzero if we're processing a __transaction statement.  The value
     240              :      is 1 | TM_STMT_ATTR_*.  */
     241              :   unsigned int in_transaction : 4;
     242              :   /* True if we are in a context where the Objective-C "Property attribute"
     243              :      keywords are valid.  */
     244              :   bool objc_property_attr_context : 1;
     245              : 
     246              :   /* Whether we have just seen/constructed a string-literal.  Set when
     247              :      returning a string-literal from c_parser_string_literal.  Reset
     248              :      in consume_token.  Useful when we get a parse error and see an
     249              :      unknown token, which could have been a string-literal constant
     250              :      macro.  */
     251              :   bool seen_string_literal : 1;
     252              : 
     253              :   /* TRUE if omp::directive, omp::decl or omp::sequence attributes may not
     254              :      appear.  */
     255              :   bool omp_attrs_forbidden_p : 1;
     256              : 
     257              :   /* Location of the last consumed token.  */
     258              :   location_t last_token_location;
     259              : 
     260              :   /* Holds state for parsing collapsed OMP_FOR loops.  Managed by
     261              :      c_parser_omp_for_loop.  */
     262              :   struct omp_for_parse_data * GTY((skip)) omp_for_parse_state;
     263              : 
     264              :   /* If we're in the context of OpenMP directives written as C23
     265              :      attributes turned into pragma, the tokens field is temporarily
     266              :      redirected.  This holds data needed to restore state afterwards.
     267              :      It's NULL otherwise.  */
     268              :   struct omp_attribute_pragma_state *in_omp_attribute_pragma;
     269              : 
     270              :   /* Set for omp::decl attribute parsing to the decl to which it
     271              :      appertains.  */
     272              :   tree in_omp_decl_attribute;
     273              : 
     274              :   /* Non-null only when parsing the body of an OpenMP metadirective.
     275              :      Managed by c_parser_omp_metadirective.  */
     276              :   struct omp_metadirective_parse_data * GTY((skip))
     277              :     omp_metadirective_state;
     278              : };
     279              : 
     280              : /* Holds data needed to restore the token stream to its previous state
     281              :    after parsing an OpenMP attribute-syntax pragma.  */
     282              : struct GTY(()) omp_attribute_pragma_state
     283              : {
     284              :   vec<c_token, va_gc> *token_vec;
     285              :   c_token * GTY((skip)) save_tokens;
     286              :   unsigned int save_tokens_avail;
     287              : };
     288              : 
     289              : /* Holds data for deferred lookup of base functions for OpenMP
     290              :    "begin declare variant", which are permitted to be declared after
     291              :    the variant.  */
     292              : struct GTY(()) omp_begin_declare_variant_map_entry {
     293              :   tree variant;         /* The variant decl.  */
     294              :   tree id;              /* Name of base function.  */
     295              :   tree ctx;             /* The context selector associated with the variant.  */
     296              : };
     297              : vec<omp_begin_declare_variant_map_entry, va_gc> *omp_begin_declare_variant_map;
     298              : 
     299              : static tree omp_start_variant_function (c_declarator *, tree);
     300              : static void omp_finish_variant_function (tree, tree, tree);
     301              : 
     302              : /* Return a pointer to the Nth token in PARSERs tokens_buf.  */
     303              : 
     304              : c_token *
     305          338 : c_parser_tokens_buf (c_parser *parser, unsigned n)
     306              : {
     307          338 :   return &parser->tokens_buf[n];
     308              : }
     309              : 
     310              : /* Return the error state of PARSER.  */
     311              : 
     312              : bool
     313        13715 : c_parser_error (c_parser *parser)
     314              : {
     315        13715 :   return parser->error;
     316              : }
     317              : 
     318              : /* Set the error state of PARSER to ERR.  */
     319              : 
     320              : void
     321            0 : c_parser_set_error (c_parser *parser, bool err)
     322              : {
     323            0 :   parser->error = err;
     324            0 : }
     325              : 
     326              : 
     327              : /* The actual parser and external interface.  ??? Does this need to be
     328              :    garbage-collected?  */
     329              : 
     330              : static GTY (()) c_parser *the_parser;
     331              : 
     332              : /* Read in and lex a single token, storing it in *TOKEN.  If RAW,
     333              :    context-sensitive postprocessing of the token is not done.  */
     334              : 
     335              : static void
     336   2405921502 : c_lex_one_token (c_parser *parser, c_token *token, bool raw = false)
     337              : {
     338   2405921502 :   timevar_push (TV_LEX);
     339              : 
     340   2405921502 :   if (raw || vec_safe_length (parser->raw_tokens) == 0)
     341              :     {
     342   2405812968 :       token->type = c_lex_with_flags (&token->value, &token->location,
     343              :                                       &token->flags,
     344   2405812968 :                                       (parser->lex_joined_string
     345              :                                        ? 0 : C_LEX_STRING_NO_JOIN));
     346   2405812815 :       token->id_kind = C_ID_NONE;
     347   2405812815 :       token->keyword = RID_MAX;
     348   2405812815 :       token->pragma_kind = PRAGMA_NONE;
     349              :     }
     350              :   else
     351              :     {
     352              :       /* Use a token previously lexed as a raw look-ahead token, and
     353              :          complete the processing on it.  */
     354       108534 :       *token = (*parser->raw_tokens)[parser->raw_tokens_used];
     355       108534 :       ++parser->raw_tokens_used;
     356       108534 :       if (parser->raw_tokens_used == vec_safe_length (parser->raw_tokens))
     357              :         {
     358        16595 :           vec_free (parser->raw_tokens);
     359        16595 :           parser->raw_tokens_used = 0;
     360              :         }
     361              :     }
     362              : 
     363   2405921349 :   if (raw)
     364       108534 :     goto out;
     365              : 
     366   2405812815 :   switch (token->type)
     367              :     {
     368   1082396574 :     case CPP_NAME:
     369   1082396574 :       {
     370   1082396574 :         tree decl;
     371              : 
     372   1082396574 :         bool objc_force_identifier = parser->objc_need_raw_identifier;
     373   1082396574 :         if (c_dialect_objc ())
     374            0 :           parser->objc_need_raw_identifier = false;
     375              : 
     376   1082396574 :         if (C_IS_RESERVED_WORD (token->value))
     377              :           {
     378    300956392 :             enum rid rid_code = C_RID_CODE (token->value);
     379              : 
     380    300956392 :             if (rid_code == RID_CXX_COMPAT_WARN)
     381              :               {
     382           35 :                 warning_at (token->location,
     383           35 :                             OPT_Wc___compat,
     384              :                             "identifier %qE conflicts with C++ keyword",
     385              :                             token->value);
     386              :               }
     387    300956357 :             else if (rid_code >= RID_FIRST_ADDR_SPACE
     388    300956357 :                      && rid_code <= RID_LAST_ADDR_SPACE)
     389              :               {
     390          185 :                 addr_space_t as;
     391          185 :                 as = (addr_space_t) (rid_code - RID_FIRST_ADDR_SPACE);
     392          185 :                 targetm.addr_space.diagnose_usage (as, token->location);
     393          185 :                 token->id_kind = C_ID_ADDRSPACE;
     394          185 :                 token->keyword = rid_code;
     395          185 :                 break;
     396              :               }
     397    300956172 :             else if (c_dialect_objc () && OBJC_IS_PQ_KEYWORD (rid_code))
     398              :               {
     399              :                 /* We found an Objective-C "pq" keyword (in, out,
     400              :                    inout, bycopy, byref, oneway).  They need special
     401              :                    care because the interpretation depends on the
     402              :                    context.  */
     403            0 :                 if (parser->objc_pq_context)
     404              :                   {
     405            0 :                     token->type = CPP_KEYWORD;
     406            0 :                     token->keyword = rid_code;
     407            0 :                     break;
     408              :                   }
     409            0 :                 else if (parser->objc_could_be_foreach_context
     410            0 :                          && rid_code == RID_IN)
     411              :                   {
     412              :                     /* We are in Objective-C, inside a (potential)
     413              :                        foreach context (which means after having
     414              :                        parsed 'for (', but before having parsed ';'),
     415              :                        and we found 'in'.  We consider it the keyword
     416              :                        which terminates the declaration at the
     417              :                        beginning of a foreach-statement.  Note that
     418              :                        this means you can't use 'in' for anything else
     419              :                        in that context; in particular, in Objective-C
     420              :                        you can't use 'in' as the name of the running
     421              :                        variable in a C for loop.  We could potentially
     422              :                        try to add code here to disambiguate, but it
     423              :                        seems a reasonable limitation.  */
     424            0 :                     token->type = CPP_KEYWORD;
     425            0 :                     token->keyword = rid_code;
     426            0 :                     break;
     427              :                   }
     428              :                 /* Else, "pq" keywords outside of the "pq" context are
     429              :                    not keywords, and we fall through to the code for
     430              :                    normal tokens.  */
     431              :               }
     432    300956172 :             else if (c_dialect_objc () && OBJC_IS_PATTR_KEYWORD (rid_code))
     433              :               {
     434              :                 /* We found an Objective-C "property attribute"
     435              :                    keyword (getter, setter, readonly, etc). These are
     436              :                    only valid in the property context.  */
     437            0 :                 if (parser->objc_property_attr_context)
     438              :                   {
     439            0 :                     token->type = CPP_KEYWORD;
     440            0 :                     token->keyword = rid_code;
     441            0 :                     break;
     442              :                   }
     443              :                 /* Else they are not special keywords.
     444              :                 */
     445              :               }
     446    300956172 :             else if (c_dialect_objc ()
     447            0 :                      && (OBJC_IS_AT_KEYWORD (rid_code)
     448              :                          || OBJC_IS_CXX_KEYWORD (rid_code)))
     449              :               {
     450              :                 /* We found one of the Objective-C "@" keywords (defs,
     451              :                    selector, synchronized, etc) or one of the
     452              :                    Objective-C "cxx" keywords (class, private,
     453              :                    protected, public, try, catch, throw) without a
     454              :                    preceding '@' sign.  Do nothing and fall through to
     455              :                    the code for normal tokens (in C++ we would still
     456              :                    consider the CXX ones keywords, but not in C).  */
     457              :                 ;
     458              :               }
     459              :             else
     460              :               {
     461    300956172 :                 token->type = CPP_KEYWORD;
     462    300956172 :                 token->keyword = rid_code;
     463    300956172 :                 break;
     464              :               }
     465              :           }
     466              : 
     467    781440217 :         decl = lookup_name (token->value);
     468    781440217 :         if (decl)
     469              :           {
     470    437261968 :             if (TREE_CODE (decl) == TYPE_DECL)
     471              :               {
     472    254971807 :                 token->id_kind = C_ID_TYPENAME;
     473    254971807 :                 break;
     474              :               }
     475              :           }
     476    344178249 :         else if (c_dialect_objc ())
     477              :           {
     478            0 :             tree objc_interface_decl = objc_is_class_name (token->value);
     479              :             /* Objective-C class names are in the same namespace as
     480              :                variables and typedefs, and hence are shadowed by local
     481              :                declarations.  */
     482            0 :             if (objc_interface_decl
     483            0 :                 && (!objc_force_identifier || global_bindings_p ()))
     484              :               {
     485            0 :                 token->value = objc_interface_decl;
     486            0 :                 token->id_kind = C_ID_CLASSNAME;
     487            0 :                 break;
     488              :               }
     489              :           }
     490    526468410 :         token->id_kind = C_ID_ID;
     491              :       }
     492    526468410 :       break;
     493            0 :     case CPP_AT_NAME:
     494              :       /* This only happens in Objective-C; it must be a keyword.  */
     495            0 :       token->type = CPP_KEYWORD;
     496            0 :       switch (C_RID_CODE (token->value))
     497              :         {
     498              :           /* Replace 'class' with '@class', 'private' with '@private',
     499              :              etc.  This prevents confusion with the C++ keyword
     500              :              'class', and makes the tokens consistent with other
     501              :              Objective-C 'AT' keywords.  For example '@class' is
     502              :              reported as RID_AT_CLASS which is consistent with
     503              :              '@synchronized', which is reported as
     504              :              RID_AT_SYNCHRONIZED.
     505              :           */
     506            0 :         case RID_CLASS:     token->keyword = RID_AT_CLASS; break;
     507            0 :         case RID_PRIVATE:   token->keyword = RID_AT_PRIVATE; break;
     508            0 :         case RID_PROTECTED: token->keyword = RID_AT_PROTECTED; break;
     509            0 :         case RID_PUBLIC:    token->keyword = RID_AT_PUBLIC; break;
     510            0 :         case RID_THROW:     token->keyword = RID_AT_THROW; break;
     511            0 :         case RID_TRY:       token->keyword = RID_AT_TRY; break;
     512            0 :         case RID_CATCH:     token->keyword = RID_AT_CATCH; break;
     513            0 :         case RID_SYNCHRONIZED: token->keyword = RID_AT_SYNCHRONIZED; break;
     514            0 :         default:            token->keyword = C_RID_CODE (token->value);
     515              :         }
     516              :       break;
     517    725858187 :     case CPP_COLON:
     518    725858187 :     case CPP_COMMA:
     519    725858187 :     case CPP_CLOSE_PAREN:
     520    725858187 :     case CPP_SEMICOLON:
     521              :       /* These tokens may affect the interpretation of any identifiers
     522              :          following, if doing Objective-C.  */
     523    725858187 :       if (c_dialect_objc ())
     524            0 :         parser->objc_need_raw_identifier = false;
     525              :       break;
     526      1982006 :     case CPP_PRAGMA:
     527              :       /* We smuggled the cpp_token->u.pragma value in an INTEGER_CST.  */
     528      1982006 :       token->pragma_kind = (enum pragma_kind) TREE_INT_CST_LOW (token->value);
     529      1982006 :       token->value = NULL;
     530      1982006 :       break;
     531              :     default:
     532              :       break;
     533              :     }
     534   2405921349 :  out:
     535   2405921349 :   timevar_pop (TV_LEX);
     536   2405921349 : }
     537              : 
     538              : /* Return a pointer to the next token from PARSER, reading it in if
     539              :    necessary.  */
     540              : 
     541              : c_token *
     542  17934495186 : c_parser_peek_token (c_parser *parser)
     543              : {
     544  17934495186 :   if (parser->tokens_avail == 0)
     545              :     {
     546   1971211230 :       c_lex_one_token (parser, &parser->tokens[0]);
     547   1971211077 :       parser->tokens_avail = 1;
     548              :     }
     549  17934495033 :   return &parser->tokens[0];
     550              : }
     551              : 
     552              : /* Return a pointer to the next-but-one token from PARSER, reading it
     553              :    in if necessary.  The next token is already read in.  */
     554              : 
     555              : c_token *
     556    164876635 : c_parser_peek_2nd_token (c_parser *parser)
     557              : {
     558    164876635 :   if (parser->tokens_avail >= 2)
     559      9225440 :     return &parser->tokens[1];
     560    155651195 :   gcc_assert (parser->tokens_avail == 1);
     561    155651195 :   gcc_assert (parser->tokens[0].type != CPP_EOF);
     562    155651195 :   gcc_assert (parser->tokens[0].type != CPP_PRAGMA_EOL);
     563    155651195 :   c_lex_one_token (parser, &parser->tokens[1]);
     564    155651195 :   parser->tokens_avail = 2;
     565    155651195 :   return &parser->tokens[1];
     566              : }
     567              : 
     568              : /* Return a pointer to the Nth token from PARSER, reading it
     569              :    in if necessary.  The N-1th token is already read in.  */
     570              : 
     571              : c_token *
     572   1336610117 : c_parser_peek_nth_token (c_parser *parser, unsigned int n)
     573              : {
     574              :   /* N is 1-based, not zero-based.  */
     575   1336610117 :   gcc_assert (n > 0);
     576              : 
     577   1336610117 :   if (parser->tokens_avail >= n)
     578   1057659574 :     return &parser->tokens[n - 1];
     579    278950543 :   gcc_assert (parser->tokens_avail == n - 1);
     580    278950543 :   c_lex_one_token (parser, &parser->tokens[n - 1]);
     581    278950543 :   parser->tokens_avail = n;
     582    278950543 :   return &parser->tokens[n - 1];
     583              : }
     584              : 
     585              : /* Return a pointer to the Nth token from PARSER, reading it in as a
     586              :    raw look-ahead token if necessary.  The N-1th token is already read
     587              :    in.  Raw look-ahead tokens remain available for when the non-raw
     588              :    functions above are called.  */
     589              : 
     590              : c_token *
     591       147587 : c_parser_peek_nth_token_raw (c_parser *parser, unsigned int n)
     592              : {
     593              :   /* N is 1-based, not zero-based.  */
     594       147587 :   gcc_assert (n > 0);
     595              : 
     596       147587 :   if (parser->tokens_avail >= n)
     597        10593 :     return &parser->tokens[n - 1];
     598       136994 :   unsigned int raw_len = vec_safe_length (parser->raw_tokens);
     599       136994 :   unsigned int raw_avail
     600       136994 :     = parser->tokens_avail + raw_len - parser->raw_tokens_used;
     601       136994 :   gcc_assert (raw_avail >= n - 1);
     602       136994 :   if (raw_avail >= n)
     603        28460 :     return &(*parser->raw_tokens)[parser->raw_tokens_used
     604        28460 :                                   + n - 1 - parser->tokens_avail];
     605       108534 :   vec_safe_reserve (parser->raw_tokens, 1);
     606       108534 :   parser->raw_tokens->quick_grow (raw_len + 1);
     607       108534 :   c_lex_one_token (parser, &(*parser->raw_tokens)[raw_len], true);
     608       108534 :   return &(*parser->raw_tokens)[raw_len];
     609              : }
     610              : 
     611              : bool
     612     46369953 : c_keyword_starts_typename (enum rid keyword)
     613              : {
     614     46369953 :   switch (keyword)
     615              :     {
     616              :     case RID_UNSIGNED:
     617              :     case RID_LONG:
     618              :     case RID_SHORT:
     619              :     case RID_SIGNED:
     620              :     case RID_COMPLEX:
     621              :     case RID_INT:
     622              :     case RID_CHAR:
     623              :     case RID_FLOAT:
     624              :     case RID_DOUBLE:
     625              :     case RID_VOID:
     626              :     case RID_DFLOAT32:
     627              :     case RID_DFLOAT64:
     628              :     case RID_DFLOAT128:
     629              :     case RID_DFLOAT64X:
     630              :     CASE_RID_FLOATN_NX:
     631              :     case RID_BOOL:
     632              :     case RID_BITINT:
     633              :     case RID_ENUM:
     634              :     case RID_STRUCT:
     635              :     case RID_UNION:
     636              :     case RID_TYPEOF:
     637              :     case RID_TYPEOF_UNQUAL:
     638              :     case RID_CONST:
     639              :     case RID_ATOMIC:
     640              :     case RID_VOLATILE:
     641              :     case RID_RESTRICT:
     642              :     case RID_ATTRIBUTE:
     643              :     case RID_FRACT:
     644              :     case RID_ACCUM:
     645              :     case RID_SAT:
     646              :     case RID_AUTO_TYPE:
     647              :     case RID_ALIGNAS:
     648              :       return true;
     649     38012662 :     default:
     650     38012662 :       if (keyword >= RID_FIRST_INT_N
     651              :           && keyword < RID_FIRST_INT_N + NUM_INT_N_ENTS
     652          595 :           && int_n_enabled_p[keyword - RID_FIRST_INT_N])
     653              :         return true;
     654              :       return false;
     655              :     }
     656              : }
     657              : 
     658              : /* Return true if TOKEN can start a type name,
     659              :    false otherwise.  */
     660              : bool
     661    466056339 : c_token_starts_typename (c_token *token)
     662              : {
     663    466056339 :   switch (token->type)
     664              :     {
     665    412462253 :     case CPP_NAME:
     666    412462253 :       switch (token->id_kind)
     667              :         {
     668              :         case C_ID_ID:
     669              :           return false;
     670              :         case C_ID_ADDRSPACE:
     671              :           return true;
     672              :         case C_ID_TYPENAME:
     673              :           return true;
     674            0 :         case C_ID_CLASSNAME:
     675            0 :           gcc_assert (c_dialect_objc ());
     676              :           return true;
     677            0 :         default:
     678            0 :           gcc_unreachable ();
     679              :         }
     680     46313310 :     case CPP_KEYWORD:
     681     46313310 :       return c_keyword_starts_typename (token->keyword);
     682            0 :     case CPP_LESS:
     683            0 :       if (c_dialect_objc ())
     684              :         return true;
     685              :       return false;
     686              :     default:
     687              :       return false;
     688              :     }
     689              : }
     690              : 
     691              : /* Return true if the next token from PARSER, starting from token N, can start
     692              :    a type name, false otherwise.  LA specifies how to do lookahead in order to
     693              :    detect unknown type names.  If unsure, pick CLA_PREFER_ID.  */
     694              : 
     695              : static inline bool
     696    331309356 : c_parser_next_tokens_start_typename (c_parser *parser, enum c_lookahead_kind la,
     697              :                                      unsigned int n = 1)
     698              : {
     699    331309356 :   c_token *token = c_parser_peek_nth_token (parser, n);
     700    331309356 :   if (c_token_starts_typename (token))
     701              :     return true;
     702              : 
     703              :   /* Try a bit harder to detect an unknown typename.  */
     704     72440309 :   if (la != cla_prefer_id
     705     46028265 :       && token->type == CPP_NAME
     706      6743203 :       && token->id_kind == C_ID_ID
     707              : 
     708              :       /* Do not try too hard when we could have "object in array".  */
     709      6743203 :       && !parser->objc_could_be_foreach_context
     710              : 
     711      6743203 :       && (la == cla_prefer_type
     712      6743106 :           || c_parser_peek_nth_token (parser, n + 1)->type == CPP_NAME
     713      6743024 :           || c_parser_peek_nth_token (parser, n + 1)->type == CPP_MULT)
     714              : 
     715              :       /* Only unknown identifiers.  */
     716     72441754 :       && !lookup_name (token->value))
     717          197 :     return true;
     718              : 
     719              :   return false;
     720              : }
     721              : 
     722              : /* Return true if TOKEN, after an open parenthesis, can start a
     723              :    compound literal (either a storage class specifier allowed in that
     724              :    context, or a type name), false otherwise.  */
     725              : static bool
     726    134742659 : c_token_starts_compound_literal (c_token *token)
     727              : {
     728    134742659 :   switch (token->type)
     729              :     {
     730      4688059 :     case CPP_KEYWORD:
     731      4688059 :       switch (token->keyword)
     732              :         {
     733              :         case RID_CONSTEXPR:
     734              :         case RID_REGISTER:
     735              :         case RID_STATIC:
     736              :         case RID_THREAD:
     737              :           return true;
     738              :         default:
     739              :           break;
     740              :         }
     741              :       /* Fall through.  */
     742    134742349 :     default:
     743    134742349 :       return c_token_starts_typename (token);
     744              :     }
     745              : }
     746              : 
     747              : /* Return true if TOKEN is a type qualifier, false otherwise.  */
     748              : static bool
     749    453142849 : c_token_is_qualifier (c_token *token)
     750              : {
     751    453142849 :   switch (token->type)
     752              :     {
     753    449192127 :     case CPP_NAME:
     754    449192127 :       switch (token->id_kind)
     755              :         {
     756              :         case C_ID_ADDRSPACE:
     757              :           return true;
     758              :         default:
     759              :           return false;
     760              :         }
     761      3950722 :     case CPP_KEYWORD:
     762      3950722 :       switch (token->keyword)
     763              :         {
     764              :         case RID_CONST:
     765              :         case RID_VOLATILE:
     766              :         case RID_RESTRICT:
     767              :         case RID_ATTRIBUTE:
     768              :         case RID_ATOMIC:
     769              :           return true;
     770              :         default:
     771              :           return false;
     772              :         }
     773              :     case CPP_LESS:
     774              :       return false;
     775            0 :     default:
     776            0 :       gcc_unreachable ();
     777              :     }
     778              : }
     779              : 
     780              : /* Return true if the next token from PARSER is a type qualifier,
     781              :    false otherwise.  */
     782              : static inline bool
     783    453142849 : c_parser_next_token_is_qualifier (c_parser *parser)
     784              : {
     785    453142849 :   c_token *token = c_parser_peek_token (parser);
     786    453142849 :   return c_token_is_qualifier (token);
     787              : }
     788              : 
     789              : /* Return true if TOKEN can start declaration specifiers (not
     790              :    including standard attributes), false otherwise.  */
     791              : static bool
     792    182429555 : c_token_starts_declspecs (c_token *token)
     793              : {
     794    182429555 :   switch (token->type)
     795              :     {
     796    101660841 :     case CPP_NAME:
     797    101660841 :       switch (token->id_kind)
     798              :         {
     799              :         case C_ID_ID:
     800              :           return false;
     801              :         case C_ID_ADDRSPACE:
     802              :           return true;
     803              :         case C_ID_TYPENAME:
     804              :           return true;
     805            0 :         case C_ID_CLASSNAME:
     806            0 :           gcc_assert (c_dialect_objc ());
     807              :           return true;
     808            0 :         default:
     809            0 :           gcc_unreachable ();
     810              :         }
     811     79042483 :     case CPP_KEYWORD:
     812     79042483 :       switch (token->keyword)
     813              :         {
     814              :         case RID_STATIC:
     815              :         case RID_EXTERN:
     816              :         case RID_REGISTER:
     817              :         case RID_TYPEDEF:
     818              :         case RID_INLINE:
     819              :         case RID_NORETURN:
     820              :         case RID_AUTO:
     821              :         case RID_THREAD:
     822              :         case RID_UNSIGNED:
     823              :         case RID_LONG:
     824              :         case RID_SHORT:
     825              :         case RID_SIGNED:
     826              :         case RID_COMPLEX:
     827              :         case RID_INT:
     828              :         case RID_CHAR:
     829              :         case RID_FLOAT:
     830              :         case RID_DOUBLE:
     831              :         case RID_VOID:
     832              :         case RID_DFLOAT32:
     833              :         case RID_DFLOAT64:
     834              :         case RID_DFLOAT128:
     835              :         case RID_DFLOAT64X:
     836              :         CASE_RID_FLOATN_NX:
     837              :         case RID_BOOL:
     838              :         case RID_BITINT:
     839              :         case RID_ENUM:
     840              :         case RID_STRUCT:
     841              :         case RID_UNION:
     842              :         case RID_TYPEOF:
     843              :         case RID_TYPEOF_UNQUAL:
     844              :         case RID_CONST:
     845              :         case RID_VOLATILE:
     846              :         case RID_RESTRICT:
     847              :         case RID_ATTRIBUTE:
     848              :         case RID_FRACT:
     849              :         case RID_ACCUM:
     850              :         case RID_SAT:
     851              :         case RID_ALIGNAS:
     852              :         case RID_ATOMIC:
     853              :         case RID_AUTO_TYPE:
     854              :         case RID_CONSTEXPR:
     855              :           return true;
     856     37660638 :         default:
     857     37660638 :           if (token->keyword >= RID_FIRST_INT_N
     858              :               && token->keyword < RID_FIRST_INT_N + NUM_INT_N_ENTS
     859          542 :               && int_n_enabled_p[token->keyword - RID_FIRST_INT_N])
     860              :             return true;
     861              :           return false;
     862              :         }
     863            2 :     case CPP_LESS:
     864            2 :       if (c_dialect_objc ())
     865              :         return true;
     866              :       return false;
     867              :     default:
     868              :       return false;
     869              :     }
     870              : }
     871              : 
     872              : 
     873              : /* Return true if TOKEN can start declaration specifiers (not
     874              :    including standard attributes) or a static assertion, false
     875              :    otherwise.  */
     876              : static bool
     877     52826793 : c_token_starts_declaration (c_token *token)
     878              : {
     879     52826793 :   if (c_token_starts_declspecs (token)
     880     52826793 :       || token->keyword == RID_STATIC_ASSERT)
     881      7755167 :     return true;
     882              :   else
     883              :     return false;
     884              : }
     885              : 
     886              : /* Return true if the next token from PARSER can start declaration
     887              :    specifiers (not including standard attributes), false
     888              :    otherwise.  */
     889              : bool
     890    129602762 : c_parser_next_token_starts_declspecs (c_parser *parser)
     891              : {
     892    129602762 :   c_token *token = c_parser_peek_token (parser);
     893              : 
     894              :   /* In Objective-C, a classname normally starts a declspecs unless it
     895              :      is immediately followed by a dot.  In that case, it is the
     896              :      Objective-C 2.0 "dot-syntax" for class objects, ie, calls the
     897              :      setter/getter on the class.  c_token_starts_declspecs() can't
     898              :      differentiate between the two cases because it only checks the
     899              :      current token, so we have a special check here.  */
     900    129602762 :   if (c_dialect_objc ()
     901            0 :       && token->type == CPP_NAME
     902            0 :       && token->id_kind == C_ID_CLASSNAME
     903    129602762 :       && c_parser_peek_2nd_token (parser)->type == CPP_DOT)
     904              :     return false;
     905              : 
     906    129602762 :   return c_token_starts_declspecs (token);
     907              : }
     908              : 
     909              : static bool c_parser_check_balanced_raw_token_sequence (c_parser *,
     910              :                                                         unsigned int *);
     911              : 
     912              : /* Return true if the next tokens from PARSER (starting with token N, 1-based)
     913              :    can start declaration specifiers (not including standard attributes) or a
     914              :    static assertion, false otherwise.  */
     915              : bool
     916     52828254 : c_parser_next_tokens_start_declaration (c_parser *parser, unsigned int n)
     917              : {
     918     52828254 :   c_token *token = c_parser_peek_nth_token (parser, n);
     919              : 
     920              :   /* Same as above.  */
     921     52828254 :   if (c_dialect_objc ()
     922            0 :       && token->type == CPP_NAME
     923            0 :       && token->id_kind == C_ID_CLASSNAME
     924     52828254 :       && c_parser_peek_nth_token (parser, n + 1)->type == CPP_DOT)
     925              :     return false;
     926              : 
     927              :   /* Labels do not start declarations.  */
     928     52828254 :   if (token->type == CPP_NAME
     929     52828254 :       && c_parser_peek_nth_token (parser, n + 1)->type == CPP_COLON)
     930              :     return false;
     931              : 
     932              :   /* A static assertion is only a declaration if followed by a semicolon;
     933              :      otherwise, it may be an expression in C2Y.  */
     934     52828236 :   if (token->keyword == RID_STATIC_ASSERT
     935     52828236 :       && c_parser_peek_nth_token (parser, n + 1)->type == CPP_OPEN_PAREN)
     936              :     {
     937         1443 :       n += 2;
     938         1443 :       if (!c_parser_check_balanced_raw_token_sequence (parser, &n)
     939         1443 :           || c_parser_peek_nth_token_raw (parser, n)->type != CPP_CLOSE_PAREN)
     940              :         /* Invalid static assertion syntax; treat as a declaration and report a
     941              :            syntax error there.  */
     942              :         return true;
     943         1438 :       return c_parser_peek_nth_token_raw (parser, n + 1)->type == CPP_SEMICOLON;
     944              :     }
     945              : 
     946     52826793 :   if (c_token_starts_declaration (token))
     947              :     return true;
     948              : 
     949     45071626 :   if (c_parser_next_tokens_start_typename (parser, cla_nonabstract_decl, n))
     950              :     return true;
     951              : 
     952              :   return false;
     953              : }
     954              : 
     955              : /* Consume the next token from PARSER.  */
     956              : 
     957              : void
     958   2403767151 : c_parser_consume_token (c_parser *parser)
     959              : {
     960   2403767151 :   gcc_assert (parser->tokens_avail >= 1);
     961   2403767151 :   gcc_assert (parser->tokens[0].type != CPP_EOF);
     962   2403767151 :   gcc_assert (!parser->in_pragma || parser->tokens[0].type != CPP_PRAGMA_EOL);
     963              :   /* CPP_PRAGMA should not show up here except if there was an error or inside
     964              :      another pragma.  */
     965   2403767151 :   gcc_assert (parser->in_pragma
     966              :               || parser->error
     967              :               || parser->tokens[0].type != CPP_PRAGMA);
     968   2403767151 :   parser->last_token_location = parser->tokens[0].location;
     969   2403767151 :   if (parser->tokens != &parser->tokens_buf[0])
     970        46303 :     parser->tokens++;
     971   2403720848 :   else if (parser->tokens_avail >= 2)
     972              :     {
     973    158983544 :       parser->tokens[0] = parser->tokens[1];
     974    158983544 :       if (parser->tokens_avail >= 3)
     975              :         {
     976        34191 :           parser->tokens[1] = parser->tokens[2];
     977        34191 :           if (parser->tokens_avail >= 4)
     978        12914 :             parser->tokens[2] = parser->tokens[3];
     979              :         }
     980              :     }
     981   2403767151 :   parser->tokens_avail--;
     982   2403767151 :   parser->seen_string_literal = false;
     983   2403767151 : }
     984              : 
     985              : /* Expect the current token to be a #pragma.  Consume it and remember
     986              :    that we've begun parsing a pragma.  */
     987              : 
     988              : static void
     989      1982819 : c_parser_consume_pragma (c_parser *parser)
     990              : {
     991      1982819 :   gcc_assert (!parser->in_pragma);
     992      1982819 :   gcc_assert (parser->tokens_avail >= 1);
     993      1982819 :   gcc_assert (parser->tokens[0].type == CPP_PRAGMA);
     994      1982819 :   if (parser->tokens != &parser->tokens_buf[0])
     995          924 :     parser->tokens++;
     996      1981895 :   else if (parser->tokens_avail >= 2)
     997              :     {
     998          312 :       parser->tokens[0] = parser->tokens[1];
     999          312 :       if (parser->tokens_avail >= 3)
    1000           10 :         parser->tokens[1] = parser->tokens[2];
    1001              :     }
    1002      1982819 :   parser->tokens_avail--;
    1003      1982819 :   parser->in_pragma = true;
    1004      1982819 : }
    1005              : 
    1006              : /* Update the global input_location from TOKEN.  */
    1007              : static inline void
    1008      8342128 : c_parser_set_source_position_from_token (c_token *token)
    1009              : {
    1010      8342128 :   if (token->type != CPP_EOF)
    1011              :     {
    1012      8342047 :       input_location = token->location;
    1013              :     }
    1014              : }
    1015              : 
    1016              : /* Helper function for c_parser_error.
    1017              :    Having peeked a token of kind TOK1_KIND that might signify
    1018              :    a conflict marker, peek successor tokens to determine
    1019              :    if we actually do have a conflict marker.
    1020              :    Specifically, we consider a run of 7 '<', '=' or '>' characters
    1021              :    at the start of a line as a conflict marker.
    1022              :    These come through the lexer as three pairs and a single,
    1023              :    e.g. three CPP_LSHIFT ("<<") and a CPP_LESS ('<').
    1024              :    If it returns true, *OUT_LOC is written to with the location/range
    1025              :    of the marker.  */
    1026              : 
    1027              : static bool
    1028           30 : c_parser_peek_conflict_marker (c_parser *parser, enum cpp_ttype tok1_kind,
    1029              :                                location_t *out_loc)
    1030              : {
    1031           30 :   c_token *token2 = c_parser_peek_2nd_token (parser);
    1032           30 :   if (token2->type != tok1_kind)
    1033              :     return false;
    1034           25 :   c_token *token3 = c_parser_peek_nth_token (parser, 3);
    1035           25 :   if (token3->type != tok1_kind)
    1036              :     return false;
    1037           22 :   c_token *token4 = c_parser_peek_nth_token (parser, 4);
    1038           22 :   if (token4->type != conflict_marker_get_final_tok_kind (tok1_kind))
    1039              :     return false;
    1040              : 
    1041              :   /* It must be at the start of the line.  */
    1042           15 :   location_t start_loc = c_parser_peek_token (parser)->location;
    1043           15 :   if (LOCATION_COLUMN (start_loc) != 1)
    1044              :     return false;
    1045              : 
    1046              :   /* We have a conflict marker.  Construct a location of the form:
    1047              :        <<<<<<<
    1048              :        ^~~~~~~
    1049              :      with start == caret, finishing at the end of the marker.  */
    1050           12 :   location_t finish_loc = get_finish (token4->location);
    1051           12 :   *out_loc = make_location (start_loc, start_loc, finish_loc);
    1052              : 
    1053           12 :   return true;
    1054              : }
    1055              : 
    1056              : /* Issue a diagnostic of the form
    1057              :       FILE:LINE: MESSAGE before TOKEN
    1058              :    where TOKEN is the next token in the input stream of PARSER.
    1059              :    MESSAGE (specified by the caller) is usually of the form "expected
    1060              :    OTHER-TOKEN".
    1061              : 
    1062              :    Use RICHLOC as the location of the diagnostic.
    1063              : 
    1064              :    Do not issue a diagnostic if still recovering from an error.
    1065              : 
    1066              :    Return true iff an error was actually emitted.
    1067              : 
    1068              :    ??? This is taken from the C++ parser, but building up messages in
    1069              :    this way is not i18n-friendly and some other approach should be
    1070              :    used.  */
    1071              : 
    1072              : static bool
    1073         3158 : c_parser_error_richloc (c_parser *parser, const char *gmsgid,
    1074              :                         rich_location *richloc)
    1075              : {
    1076         3158 :   c_token *token = c_parser_peek_token (parser);
    1077         3158 :   if (parser->error)
    1078              :     return false;
    1079         2403 :   parser->error = true;
    1080         2403 :   if (!gmsgid)
    1081              :     return false;
    1082              : 
    1083              :   /* If this is actually a conflict marker, report it as such.  */
    1084         2288 :   if (token->type == CPP_LSHIFT
    1085         2288 :       || token->type == CPP_RSHIFT
    1086         2269 :       || token->type == CPP_EQ_EQ)
    1087              :     {
    1088           30 :       location_t loc;
    1089           30 :       if (c_parser_peek_conflict_marker (parser, token->type, &loc))
    1090              :         {
    1091           12 :           error_at (loc, "version control conflict marker in file");
    1092           12 :           return true;
    1093              :         }
    1094              :     }
    1095              : 
    1096              :   /* If we were parsing a string-literal and there is an unknown name
    1097              :      token right after, then check to see if that could also have been
    1098              :      a literal string by checking the name against a list of known
    1099              :      standard string literal constants defined in header files. If
    1100              :      there is one, then add that as an hint to the error message. */
    1101         2276 :   auto_diagnostic_group d;
    1102         2276 :   name_hint h;
    1103         2276 :   if (parser->seen_string_literal && token->type == CPP_NAME)
    1104              :     {
    1105           16 :       tree name = token->value;
    1106           16 :       const char *token_name = IDENTIFIER_POINTER (name);
    1107           16 :       const char *header_hint
    1108           16 :         = get_c_stdlib_header_for_string_macro_name (token_name);
    1109           16 :       if (header_hint != NULL)
    1110           48 :         h = name_hint (nullptr,
    1111              :                        std::make_unique<suggest_missing_header>
    1112           32 :                          (token->location,
    1113              :                           token_name,
    1114           16 :                           header_hint));
    1115              :     }
    1116              : 
    1117         2276 :   c_parse_error (gmsgid,
    1118              :                  /* Because c_parse_error does not understand
    1119              :                     CPP_KEYWORD, keywords are treated like
    1120              :                     identifiers.  */
    1121         2276 :                  (token->type == CPP_KEYWORD ? CPP_NAME : token->type),
    1122              :                  /* ??? The C parser does not save the cpp flags of a
    1123              :                     token, we need to pass 0 here and we will not get
    1124              :                     the source spelling of some tokens but rather the
    1125              :                     canonical spelling.  */
    1126              :                  token->value, /*flags=*/0, richloc);
    1127         2276 :   return true;
    1128         2276 : }
    1129              : 
    1130              : /* As c_parser_error_richloc, but issue the message at the
    1131              :    location of PARSER's next token, or at input_location
    1132              :    if the next token is EOF.  */
    1133              : 
    1134              : bool
    1135         2015 : c_parser_error (c_parser *parser, const char *gmsgid)
    1136              : {
    1137         2015 :   c_token *token = c_parser_peek_token (parser);
    1138         2015 :   c_parser_set_source_position_from_token (token);
    1139         2015 :   rich_location richloc (line_table, input_location);
    1140         2015 :   return c_parser_error_richloc (parser, gmsgid, &richloc);
    1141         2015 : }
    1142              : 
    1143              : /* Some tokens naturally come in pairs e.g.'(' and ')'.
    1144              :    This class is for tracking such a matching pair of symbols.
    1145              :    In particular, it tracks the location of the first token,
    1146              :    so that if the second token is missing, we can highlight the
    1147              :    location of the first token when notifying the user about the
    1148              :    problem.  */
    1149              : 
    1150              : template <typename traits_t>
    1151              : class token_pair
    1152              : {
    1153              :  public:
    1154              :   /* token_pair's ctor.  */
    1155    184357507 :   token_pair () : m_open_loc (UNKNOWN_LOCATION) {}
    1156              : 
    1157              :   /* If the next token is the opening symbol for this pair, consume it and
    1158              :      return true.
    1159              :      Otherwise, issue an error and return false.
    1160              :      In either case, record the location of the opening token.  */
    1161              : 
    1162      4598646 :   bool require_open (c_parser *parser)
    1163              :   {
    1164      4598646 :     c_token *token = c_parser_peek_token (parser);
    1165      4598646 :     if (token)
    1166      4598646 :       m_open_loc = token->location;
    1167              : 
    1168      4598646 :     return c_parser_require (parser, traits_t::open_token_type,
    1169      4598646 :                              traits_t::open_gmsgid);
    1170              :   }
    1171              : 
    1172              :   /* Consume the next token from PARSER, recording its location as
    1173              :      that of the opening token within the pair.  */
    1174              : 
    1175    179759188 :   void consume_open (c_parser *parser)
    1176              :   {
    1177    179759188 :     c_token *token = c_parser_peek_token (parser);
    1178    179759188 :     gcc_assert (token->type == traits_t::open_token_type);
    1179    179759188 :     m_open_loc = token->location;
    1180    179759188 :     c_parser_consume_token (parser);
    1181    179759188 :   }
    1182              : 
    1183              :   /* If the next token is the closing symbol for this pair, consume it
    1184              :      and return true.
    1185              :      Otherwise, issue an error, highlighting the location of the
    1186              :      corresponding opening token, and return false.  */
    1187              : 
    1188      1811305 :   bool require_close (c_parser *parser) const
    1189              :   {
    1190      1811305 :     return c_parser_require (parser, traits_t::close_token_type,
    1191      1811305 :                              traits_t::close_gmsgid, m_open_loc);
    1192              :   }
    1193              : 
    1194              :   /* Like token_pair::require_close, except that tokens will be skipped
    1195              :      until the desired token is found.  An error message is still produced
    1196              :      if the next token is not as expected.  */
    1197              : 
    1198    181140690 :   void skip_until_found_close (c_parser *parser) const
    1199              :   {
    1200    181140690 :     c_parser_skip_until_found (parser, traits_t::close_token_type,
    1201    181140690 :                                traits_t::close_gmsgid, m_open_loc);
    1202              :   }
    1203              : 
    1204              :  private:
    1205              :   location_t m_open_loc;
    1206              : };
    1207              : 
    1208              : /* Traits for token_pair<T> for tracking matching pairs of parentheses.  */
    1209              : 
    1210              : struct matching_paren_traits
    1211              : {
    1212              :   static const enum cpp_ttype open_token_type = CPP_OPEN_PAREN;
    1213              :   static const char * const open_gmsgid;
    1214              :   static const enum cpp_ttype close_token_type = CPP_CLOSE_PAREN;
    1215              :   static const char * const close_gmsgid;
    1216              : };
    1217              : 
    1218              : const char * const matching_paren_traits::open_gmsgid = "expected %<(%>";
    1219              : const char * const matching_paren_traits::close_gmsgid = "expected %<)%>";
    1220              : 
    1221              : /* "matching_parens" is a token_pair<T> class for tracking matching
    1222              :    pairs of parentheses.  */
    1223              : 
    1224              : typedef token_pair<matching_paren_traits> matching_parens;
    1225              : 
    1226              : /* Traits for token_pair<T> for tracking matching pairs of braces.  */
    1227              : 
    1228              : struct matching_brace_traits
    1229              : {
    1230              :   static const enum cpp_ttype open_token_type = CPP_OPEN_BRACE;
    1231              :   static const char * const open_gmsgid;
    1232              :   static const enum cpp_ttype close_token_type = CPP_CLOSE_BRACE;
    1233              :   static const char * const close_gmsgid;
    1234              : };
    1235              : 
    1236              : const char * const matching_brace_traits::open_gmsgid = "expected %<{%>";
    1237              : const char * const matching_brace_traits::close_gmsgid = "expected %<}%>";
    1238              : 
    1239              : /* "matching_braces" is a token_pair<T> class for tracking matching
    1240              :    pairs of braces.  */
    1241              : 
    1242              : typedef token_pair<matching_brace_traits> matching_braces;
    1243              : 
    1244              : /* Get a description of the matching symbol to TYPE e.g. "(" for
    1245              :    CPP_CLOSE_PAREN.  */
    1246              : 
    1247              : static const char *
    1248            4 : get_matching_symbol (enum cpp_ttype type)
    1249              : {
    1250            4 :   switch (type)
    1251              :     {
    1252            0 :     default:
    1253            0 :       gcc_unreachable ();
    1254              :     case CPP_CLOSE_PAREN:
    1255              :       return "(";
    1256            1 :     case CPP_CLOSE_BRACE:
    1257            1 :       return "{";
    1258              :     }
    1259              : }
    1260              : 
    1261              : /* If the next token is of the indicated TYPE, consume it.  Otherwise,
    1262              :    issue the error MSGID.  If MSGID is NULL then a message has already
    1263              :    been produced and no message will be produced this time.  Returns
    1264              :    true if found, false otherwise.
    1265              : 
    1266              :    If MATCHING_LOCATION is not UNKNOWN_LOCATION, then highlight it
    1267              :    within any error as the location of an "opening" token matching
    1268              :    the close token TYPE (e.g. the location of the '(' when TYPE is
    1269              :    CPP_CLOSE_PAREN).
    1270              : 
    1271              :    If TYPE_IS_UNIQUE is true (the default) then msgid describes exactly
    1272              :    one type (e.g. "expected %<)%>") and thus it may be reasonable to
    1273              :    attempt to generate a fix-it hint for the problem.
    1274              :    Otherwise msgid describes multiple token types (e.g.
    1275              :    "expected %<;%>, %<,%> or %<)%>"), and thus we shouldn't attempt to
    1276              :    generate a fix-it hint.  */
    1277              : 
    1278              : bool
    1279    471340627 : c_parser_require (c_parser *parser,
    1280              :                   enum cpp_ttype type,
    1281              :                   const char *msgid,
    1282              :                   location_t matching_location,
    1283              :                   bool type_is_unique)
    1284              : {
    1285    471340627 :   if (c_parser_next_token_is (parser, type))
    1286              :     {
    1287    471339484 :       c_parser_consume_token (parser);
    1288    471339484 :       return true;
    1289              :     }
    1290              :   else
    1291              :     {
    1292         1143 :       location_t next_token_loc = c_parser_peek_token (parser)->location;
    1293         1143 :       gcc_rich_location richloc (next_token_loc);
    1294              : 
    1295              :       /* Potentially supply a fix-it hint, suggesting to add the
    1296              :          missing token immediately after the *previous* token.
    1297              :          This may move the primary location within richloc.  */
    1298         1143 :       if (!parser->error && type_is_unique)
    1299          674 :         maybe_suggest_missing_token_insertion (&richloc, type,
    1300              :                                                parser->last_token_location);
    1301              : 
    1302              :       /* If matching_location != UNKNOWN_LOCATION, highlight it.
    1303              :          Attempt to consolidate diagnostics by printing it as a
    1304              :          secondary range within the main diagnostic.  */
    1305         1143 :       bool added_matching_location = false;
    1306         1143 :       if (matching_location != UNKNOWN_LOCATION)
    1307          422 :         added_matching_location
    1308          422 :           = richloc.add_location_if_nearby (*global_dc, matching_location);
    1309              : 
    1310         1143 :       if (c_parser_error_richloc (parser, msgid, &richloc))
    1311              :         /* If we weren't able to consolidate matching_location, then
    1312              :            print it as a secondary diagnostic.  */
    1313          567 :         if (matching_location != UNKNOWN_LOCATION && !added_matching_location)
    1314            4 :           inform (matching_location, "to match this %qs",
    1315              :                   get_matching_symbol (type));
    1316              : 
    1317         1143 :       return false;
    1318         1143 :     }
    1319              : }
    1320              : 
    1321              : /* If the next token is the indicated keyword, consume it.  Otherwise,
    1322              :    issue the error MSGID.  Returns true if found, false otherwise.  */
    1323              : 
    1324              : static bool
    1325       149898 : c_parser_require_keyword (c_parser *parser,
    1326              :                           enum rid keyword,
    1327              :                           const char *msgid)
    1328              : {
    1329       149898 :   if (c_parser_next_token_is_keyword (parser, keyword))
    1330              :     {
    1331       149897 :       c_parser_consume_token (parser);
    1332       149897 :       return true;
    1333              :     }
    1334              :   else
    1335              :     {
    1336            1 :       c_parser_error (parser, msgid);
    1337            1 :       return false;
    1338              :     }
    1339              : }
    1340              : 
    1341              : /* Like c_parser_require, except that tokens will be skipped until the
    1342              :    desired token is found.  An error message is still produced if the
    1343              :    next token is not as expected.  If MSGID is NULL then a message has
    1344              :    already been produced and no message will be produced this
    1345              :    time.
    1346              : 
    1347              :    If MATCHING_LOCATION is not UNKNOWN_LOCATION, then highlight it
    1348              :    within any error as the location of an "opening" token matching
    1349              :    the close token TYPE (e.g. the location of the '(' when TYPE is
    1350              :    CPP_CLOSE_PAREN).  */
    1351              : 
    1352              : void
    1353    235611640 : c_parser_skip_until_found (c_parser *parser,
    1354              :                            enum cpp_ttype type,
    1355              :                            const char *msgid,
    1356              :                            location_t matching_location)
    1357              : {
    1358    235611640 :   unsigned nesting_depth = 0;
    1359              : 
    1360    235611640 :   if (c_parser_require (parser, type, msgid, matching_location))
    1361              :     {
    1362    235610727 :       if (UNLIKELY (type == CPP_PRAGMA_EOL) && parser->in_omp_attribute_pragma)
    1363              :         {
    1364            0 :           c_token *token = c_parser_peek_token (parser);
    1365            0 :           if (token->type == CPP_EOF)
    1366              :             {
    1367            0 :               parser->tokens = parser->in_omp_attribute_pragma->save_tokens;
    1368            0 :               parser->tokens_avail
    1369            0 :                 = parser->in_omp_attribute_pragma->save_tokens_avail;
    1370            0 :               parser->in_omp_attribute_pragma = NULL;
    1371              :             }
    1372              :         }
    1373              :       return;
    1374              :     }
    1375              : 
    1376              :   /* Skip tokens until the desired token is found.  */
    1377         6073 :   while (true)
    1378              :     {
    1379              :       /* Peek at the next token.  */
    1380         3493 :       c_token *token = c_parser_peek_token (parser);
    1381              :       /* If we've reached the token we want, consume it and stop.  */
    1382         3493 :       if (token->type == type && !nesting_depth)
    1383              :         {
    1384          710 :           c_parser_consume_token (parser);
    1385          710 :           if (UNLIKELY (type == CPP_PRAGMA_EOL)
    1386          108 :               && parser->in_omp_attribute_pragma)
    1387              :             {
    1388            1 :               c_token *token = c_parser_peek_token (parser);
    1389            1 :               if (token->type == CPP_EOF)
    1390              :                 {
    1391            1 :                   parser->tokens = parser->in_omp_attribute_pragma->save_tokens;
    1392            1 :                   parser->tokens_avail
    1393            1 :                     = parser->in_omp_attribute_pragma->save_tokens_avail;
    1394            1 :                   parser->in_omp_attribute_pragma = NULL;
    1395              :                 }
    1396              :             }
    1397              :           break;
    1398              :         }
    1399              : 
    1400              :       /* If we've run out of tokens, stop.  */
    1401         2783 :       if (token->type == CPP_EOF)
    1402              :         return;
    1403         2764 :       if (token->type == CPP_PRAGMA_EOL && parser->in_pragma)
    1404              :         return;
    1405         2698 :       if (token->type == CPP_OPEN_BRACE
    1406              :           || token->type == CPP_OPEN_PAREN
    1407              :           || token->type == CPP_OPEN_SQUARE)
    1408          296 :         ++nesting_depth;
    1409              :       else if (token->type == CPP_CLOSE_BRACE
    1410              :                || token->type == CPP_CLOSE_PAREN
    1411              :                || token->type == CPP_CLOSE_SQUARE)
    1412              :         {
    1413          414 :           if (nesting_depth-- == 0)
    1414              :             break;
    1415              :         }
    1416              :       /* Consume this token.  */
    1417         2580 :       c_parser_consume_token (parser);
    1418         2580 :     }
    1419          828 :   parser->error = false;
    1420              : }
    1421              : 
    1422              : /* Skip tokens until the end of a parameter is found, but do not
    1423              :    consume the comma, semicolon or closing delimiter.  */
    1424              : 
    1425              : static void
    1426          101 : c_parser_skip_to_end_of_parameter (c_parser *parser)
    1427              : {
    1428          101 :   unsigned nesting_depth = 0;
    1429              : 
    1430          521 :   while (true)
    1431              :     {
    1432          311 :       c_token *token = c_parser_peek_token (parser);
    1433          311 :       if ((token->type == CPP_COMMA || token->type == CPP_SEMICOLON)
    1434           27 :           && !nesting_depth)
    1435              :         break;
    1436              :       /* If we've run out of tokens, stop.  */
    1437          284 :       if (token->type == CPP_EOF)
    1438              :         return;
    1439          284 :       if (token->type == CPP_PRAGMA_EOL && parser->in_pragma)
    1440              :         return;
    1441          284 :       if (token->type == CPP_OPEN_BRACE
    1442              :           || token->type == CPP_OPEN_PAREN
    1443              :           || token->type == CPP_OPEN_SQUARE)
    1444            3 :         ++nesting_depth;
    1445              :       else if (token->type == CPP_CLOSE_BRACE
    1446              :                || token->type == CPP_CLOSE_PAREN
    1447              :                || token->type == CPP_CLOSE_SQUARE)
    1448              :         {
    1449           77 :           if (nesting_depth-- == 0)
    1450              :             break;
    1451              :         }
    1452              :       /* Consume this token.  */
    1453          210 :       c_parser_consume_token (parser);
    1454          210 :     }
    1455          101 :   parser->error = false;
    1456              : }
    1457              : 
    1458              : /* Skip tokens until a non-nested closing curly brace is the next
    1459              :    token, or there are no more tokens. Return true in the first case,
    1460              :    false otherwise.  */
    1461              : 
    1462              : static bool
    1463           26 : c_parser_skip_to_closing_brace (c_parser *parser)
    1464              : {
    1465           26 :   unsigned nesting_depth = 0;
    1466              : 
    1467           96 :   while (true)
    1468              :     {
    1469           61 :       c_token *token = c_parser_peek_token (parser);
    1470              : 
    1471           61 :       switch (token->type)
    1472              :         {
    1473            2 :         case CPP_PRAGMA_EOL:
    1474            2 :           if (!parser->in_pragma)
    1475              :             break;
    1476              :           /* FALLTHRU */
    1477              :         case CPP_EOF:
    1478              :           /* If we've run out of tokens, stop.  */
    1479              :           return false;
    1480              : 
    1481           24 :         case CPP_CLOSE_BRACE:
    1482              :           /* If the next token is a non-nested `}', then we have reached
    1483              :              the end of the current block.  */
    1484           24 :           if (nesting_depth-- == 0)
    1485              :             return true;
    1486              :           break;
    1487              : 
    1488            0 :         case CPP_OPEN_BRACE:
    1489              :           /* If it the next token is a `{', then we are entering a new
    1490              :              block.  Consume the entire block.  */
    1491            0 :           ++nesting_depth;
    1492            0 :           break;
    1493              : 
    1494              :         default:
    1495              :           break;
    1496              :         }
    1497              : 
    1498              :       /* Consume the token.  */
    1499           35 :       c_parser_consume_token (parser);
    1500           35 :     }
    1501              : }
    1502              : 
    1503              : /* Expect to be at the end of the pragma directive and consume an
    1504              :    end of line marker.  */
    1505              : 
    1506              : static void
    1507      1984010 : c_parser_skip_to_pragma_eol (c_parser *parser, bool error_if_not_eol = true)
    1508              : {
    1509      1984010 :   gcc_assert (parser->in_pragma);
    1510      1984010 :   parser->in_pragma = false;
    1511              : 
    1512      1984010 :   if (error_if_not_eol && c_parser_peek_token (parser)->type != CPP_PRAGMA_EOL)
    1513          217 :     c_parser_error (parser, "expected end of line");
    1514              : 
    1515      1985441 :   cpp_ttype token_type;
    1516      1985441 :   do
    1517              :     {
    1518      1985441 :       c_token *token = c_parser_peek_token (parser);
    1519      1985441 :       token_type = token->type;
    1520      1985441 :       if (token_type == CPP_EOF)
    1521              :         break;
    1522      1985441 :       c_parser_consume_token (parser);
    1523              :     }
    1524      1985441 :   while (token_type != CPP_PRAGMA_EOL);
    1525              : 
    1526      1984010 :   if (parser->in_omp_attribute_pragma)
    1527              :     {
    1528          754 :       c_token *token = c_parser_peek_token (parser);
    1529          754 :       if (token->type == CPP_EOF)
    1530              :         {
    1531          607 :           parser->tokens = parser->in_omp_attribute_pragma->save_tokens;
    1532          607 :           parser->tokens_avail
    1533          607 :             = parser->in_omp_attribute_pragma->save_tokens_avail;
    1534          607 :           parser->in_omp_attribute_pragma = NULL;
    1535              :         }
    1536              :     }
    1537              : 
    1538      1984010 :   parser->error = false;
    1539      1984010 : }
    1540              : 
    1541              : /* Skip tokens up to and including "#pragma omp end declare variant".
    1542              :    Properly handle nested "#pragma omp begin declare variant" pragmas.  */
    1543              : static void
    1544            6 : c_parser_skip_to_pragma_omp_end_declare_variant (c_parser *parser)
    1545              : {
    1546          166 :   for (int depth = 0; depth >= 0; )
    1547              :     {
    1548          160 :       c_token *token = c_parser_peek_token (parser);
    1549              : 
    1550          160 :       switch (token->type)
    1551              :         {
    1552            0 :         case CPP_PRAGMA_EOL:
    1553            0 :           if (!parser->in_pragma)
    1554              :             break;
    1555              :           /* FALLTHRU */
    1556              :         case CPP_EOF:
    1557              :           /* If we've run out of tokens, stop.  */
    1558              :           return;
    1559              : 
    1560           10 :         case CPP_PRAGMA:
    1561           10 :           if ((token->pragma_kind == PRAGMA_OMP_BEGIN
    1562            8 :                || token->pragma_kind == PRAGMA_OMP_END)
    1563           10 :               && c_parser_peek_nth_token (parser, 2)->type == CPP_NAME
    1564           20 :               && c_parser_peek_nth_token (parser, 3)->type == CPP_NAME)
    1565              :             {
    1566           10 :               tree id1 = c_parser_peek_nth_token (parser, 2)->value;
    1567           10 :               tree id2 = c_parser_peek_nth_token (parser, 3)->value;
    1568           10 :               if (strcmp (IDENTIFIER_POINTER (id1), "declare") == 0
    1569           20 :                   && strcmp (IDENTIFIER_POINTER (id2), "variant") == 0)
    1570              :                 {
    1571           10 :                   if (token->pragma_kind == PRAGMA_OMP_BEGIN)
    1572            2 :                     depth++;
    1573              :                   else
    1574            8 :                     depth--;
    1575              :                 }
    1576              :             }
    1577           10 :           c_parser_consume_pragma (parser);
    1578           10 :           c_parser_skip_to_pragma_eol (parser, false);
    1579           10 :           continue;
    1580              : 
    1581              :         default:
    1582              :           break;
    1583           10 :         }
    1584              : 
    1585              :       /* Consume the token.  */
    1586          150 :       c_parser_consume_token (parser);
    1587              :     }
    1588              : }
    1589              : 
    1590              : /* Skip tokens until we have consumed an entire block, or until we
    1591              :    have consumed a non-nested ';'.  */
    1592              : 
    1593              : static void
    1594          535 : c_parser_skip_to_end_of_block_or_statement (c_parser *parser,
    1595              :                                             bool metadirective_p = false)
    1596              : {
    1597          535 :   unsigned nesting_depth = 0;
    1598          535 :   int bracket_depth = 0;
    1599          535 :   bool save_error = parser->error;
    1600              : 
    1601         1949 :   while (true)
    1602              :     {
    1603         1949 :       c_token *token;
    1604              : 
    1605              :       /* Peek at the next token.  */
    1606         1949 :       token = c_parser_peek_token (parser);
    1607              : 
    1608         1949 :       switch (token->type)
    1609              :         {
    1610              :         case CPP_EOF:
    1611              :           return;
    1612              : 
    1613            0 :         case CPP_PRAGMA_EOL:
    1614            0 :           if (parser->in_pragma)
    1615              :             return;
    1616              :           break;
    1617              : 
    1618          466 :         case CPP_SEMICOLON:
    1619              :           /* If the next token is a ';', we have reached the
    1620              :              end of the statement.  */
    1621          466 :           if (!nesting_depth && (!metadirective_p || bracket_depth <= 0))
    1622              :             {
    1623              :               /* Consume the ';'.  */
    1624          399 :               c_parser_consume_token (parser);
    1625          399 :               goto finished;
    1626              :             }
    1627              :           break;
    1628              : 
    1629          112 :         case CPP_CLOSE_BRACE:
    1630              :           /* If the next token is a non-nested '}', then we have
    1631              :              reached the end of the current block.  */
    1632           63 :           if ((nesting_depth == 0 || --nesting_depth == 0)
    1633          175 :               && (!metadirective_p || bracket_depth <= 0))
    1634              :             {
    1635          112 :               c_parser_consume_token (parser);
    1636          112 :               goto finished;
    1637              :             }
    1638              :           break;
    1639              : 
    1640           63 :         case CPP_OPEN_BRACE:
    1641              :           /* If it the next token is a '{', then we are entering a new
    1642              :              block.  Consume the entire block.  */
    1643           63 :           ++nesting_depth;
    1644           63 :           break;
    1645              : 
    1646           72 :         case CPP_OPEN_PAREN:
    1647              :           /* Track parentheses in case the statement is a standalone 'for'
    1648              :              statement - we want to skip over the semicolons separating the
    1649              :              operands.  */
    1650           72 :           if (metadirective_p && nesting_depth == 0)
    1651            2 :             ++bracket_depth;
    1652              :           break;
    1653              : 
    1654           98 :         case CPP_CLOSE_PAREN:
    1655           98 :           if (metadirective_p && nesting_depth == 0)
    1656            2 :             --bracket_depth;
    1657              :           break;
    1658              : 
    1659            7 :         case CPP_PRAGMA:
    1660              :           /* If we see a pragma, consume the whole thing at once.  We
    1661              :              have some safeguards against consuming pragmas willy-nilly.
    1662              :              Normally, we'd expect to be here with parser->error set,
    1663              :              which disables these safeguards.  But it's possible to get
    1664              :              here for secondary error recovery, after parser->error has
    1665              :              been cleared.  */
    1666            7 :           c_parser_consume_pragma (parser);
    1667            7 :           c_parser_skip_to_pragma_eol (parser, false);
    1668            7 :           parser->error = save_error;
    1669            7 :           continue;
    1670              : 
    1671              :         default:
    1672              :           break;
    1673              :         }
    1674              : 
    1675         1407 :       c_parser_consume_token (parser);
    1676              :     }
    1677              : 
    1678          511 :  finished:
    1679          511 :   parser->error = false;
    1680              : }
    1681              : 
    1682              : /* CPP's options (initialized by c-opts.cc).  */
    1683              : extern cpp_options *cpp_opts;
    1684              : 
    1685              : /* Save the warning flags which are controlled by __extension__.  */
    1686              : 
    1687              : static inline int
    1688       982653 : disable_extension_diagnostics (void)
    1689              : {
    1690      1965306 :   int ret = (pedantic
    1691       982653 :              | (warn_pointer_arith << 1)
    1692       982653 :              | (warn_traditional << 2)
    1693       982653 :              | (flag_iso << 3)
    1694       982653 :              | (warn_long_long << 4)
    1695       982653 :              | (warn_cxx_compat << 5)
    1696       982653 :              | (warn_overlength_strings << 6)
    1697              :              /* warn_c90_c99_compat has three states: -1/0/1, so we must
    1698              :                 play tricks to properly restore it.  */
    1699       982653 :              | ((warn_c90_c99_compat == 1) << 7)
    1700       982653 :              | ((warn_c90_c99_compat == -1) << 8)
    1701              :              /* Similarly for warn_c99_c11_compat.  */
    1702       982653 :              | ((warn_c99_c11_compat == 1) << 9)
    1703       982653 :              | ((warn_c99_c11_compat == -1) << 10)
    1704              :              /* Similarly for warn_c11_c23_compat.  */
    1705       982653 :              | ((warn_c11_c23_compat == 1) << 11)
    1706       982653 :              | ((warn_c11_c23_compat == -1) << 12)
    1707              :              /* Similarly for warn_c23_c2y_compat.  */
    1708       982653 :              | ((warn_c23_c2y_compat == 1) << 13)
    1709       982653 :              | ((warn_c23_c2y_compat == -1) << 14)
    1710              :              );
    1711       982653 :   cpp_opts->cpp_pedantic = pedantic = 0;
    1712       982653 :   warn_pointer_arith = 0;
    1713       982653 :   cpp_opts->cpp_warn_traditional = warn_traditional = 0;
    1714       982653 :   flag_iso = 0;
    1715       982653 :   cpp_opts->cpp_warn_long_long = warn_long_long = 0;
    1716       982653 :   warn_cxx_compat = 0;
    1717       982653 :   warn_overlength_strings = 0;
    1718       982653 :   warn_c90_c99_compat = 0;
    1719       982653 :   warn_c99_c11_compat = 0;
    1720       982653 :   warn_c11_c23_compat = 0;
    1721       982653 :   warn_c23_c2y_compat = 0;
    1722       982653 :   return ret;
    1723              : }
    1724              : 
    1725              : /* Restore the warning flags which are controlled by __extension__.
    1726              :    FLAGS is the return value from disable_extension_diagnostics.  */
    1727              : 
    1728              : static inline void
    1729       982653 : restore_extension_diagnostics (int flags)
    1730              : {
    1731       982653 :   cpp_opts->cpp_pedantic = pedantic = flags & 1;
    1732       982653 :   warn_pointer_arith = (flags >> 1) & 1;
    1733       982653 :   cpp_opts->cpp_warn_traditional = warn_traditional = (flags >> 2) & 1;
    1734       982653 :   flag_iso = (flags >> 3) & 1;
    1735       982653 :   cpp_opts->cpp_warn_long_long = warn_long_long = (flags >> 4) & 1;
    1736       982653 :   warn_cxx_compat = (flags >> 5) & 1;
    1737       982653 :   warn_overlength_strings = (flags >> 6) & 1;
    1738              :   /* See above for why is this needed.  */
    1739       982653 :   warn_c90_c99_compat = (flags >> 7) & 1 ? 1 : ((flags >> 8) & 1 ? -1 : 0);
    1740       982653 :   warn_c99_c11_compat = (flags >> 9) & 1 ? 1 : ((flags >> 10) & 1 ? -1 : 0);
    1741       982653 :   warn_c11_c23_compat = (flags >> 11) & 1 ? 1 : ((flags >> 12) & 1 ? -1 : 0);
    1742       982653 :   warn_c23_c2y_compat = (flags >> 13) & 1 ? 1 : ((flags >> 14) & 1 ? -1 : 0);
    1743       982653 : }
    1744              : 
    1745              : /* Helper data structure for parsing #pragma acc routine.  */
    1746              : struct oacc_routine_data {
    1747              :   bool error_seen; /* Set if error has been reported.  */
    1748              :   bool fndecl_seen; /* Set if one fn decl/definition has been seen already.  */
    1749              :   tree clauses;
    1750              :   location_t loc;
    1751              : };
    1752              : 
    1753              : /* Used for parsing objc foreach statements.  */
    1754              : static tree objc_foreach_break_label, objc_foreach_continue_label;
    1755              : 
    1756              : /* Used for parsing OMP for loops.
    1757              : 
    1758              :    Some notes on flags used for context:
    1759              :    parser->omp_for_parse_state is non-null anywhere inside the OMP FOR
    1760              :    construct, except for the final-loop-body.
    1761              :    The want_nested_loop flag is true if inside a {} sequence where
    1762              :    a loop-nest (or another {} sequence containing a loop-nest) is expected,
    1763              :    but has not yet been seen.  It's false when parsing intervening code
    1764              :    statements or their substatements that cannot contain a loop-nest.
    1765              :    The in_intervening_code flag is true when parsing any intervening code,
    1766              :    including substatements, and whether or not want_nested_loop is true.
    1767              : 
    1768              :    And, about error handling:
    1769              :    The saw_intervening_code flag is set if the loop is not perfectly
    1770              :    nested, even in the usual case where this is not an error.
    1771              :    perfect_nesting_fail is set if an error has been diagnosed because an
    1772              :    imperfectly-nested loop was found where a perfectly-nested one is
    1773              :    required (we diagnose this only once).
    1774              :    fail is set if any kind of structural error in the loop nest
    1775              :    has been found and diagnosed.
    1776              :   */
    1777              : struct omp_for_parse_data {
    1778              :   enum tree_code code;
    1779              :   tree declv, condv, incrv, initv;
    1780              :   tree pre_body;
    1781              :   tree bindings;
    1782              :   int count;    /* Expected nesting depth.  */
    1783              :   int depth;    /* Current nesting depth.  */
    1784              :   location_t for_loc;
    1785              :   bool ordered : 1;
    1786              :   bool inscan : 1;
    1787              :   bool want_nested_loop : 1;
    1788              :   bool in_intervening_code : 1;
    1789              :   bool saw_intervening_code: 1;
    1790              :   bool perfect_nesting_fail : 1;
    1791              :   bool fail : 1;
    1792              : };
    1793              : 
    1794              : struct attr_state
    1795              : {
    1796              :   /* True if we parsed a musttail attribute for return.  */
    1797              :   bool musttail_p;
    1798              : 
    1799     52251997 :   void reset () { musttail_p = false; }
    1800              : };
    1801              : 
    1802              : static bool c_parser_nth_token_starts_std_attributes (c_parser *,
    1803              :                                                       unsigned int);
    1804              : static tree c_parser_std_attribute_specifier_sequence (c_parser *);
    1805              : static void c_parser_external_declaration (c_parser *);
    1806              : static void c_parser_asm_definition (c_parser *);
    1807              : static tree c_parser_declaration_or_fndef (c_parser *, bool, bool, bool,
    1808              :                                            bool, bool, bool, tree * = NULL,
    1809              :                                            vec<c_token> * = NULL,
    1810              :                                            bool have_attrs = false,
    1811              :                                            tree attrs = NULL,
    1812              :                                            struct oacc_routine_data * = NULL,
    1813              :                                            bool * = NULL);
    1814              : static bool c_parser_handle_statement_omp_attributes (c_parser *, tree &,
    1815              :                                                       bool *);
    1816              : static void c_parser_static_assert_declaration_no_semi (c_parser *);
    1817              : static void c_parser_static_assert_declaration (c_parser *);
    1818              : static struct c_typespec c_parser_enum_specifier (c_parser *);
    1819              : static struct c_typespec c_parser_struct_or_union_specifier (c_parser *);
    1820              : static tree c_parser_struct_declaration (c_parser *, tree *);
    1821              : static struct c_typespec c_parser_typeof_specifier (c_parser *);
    1822              : static tree c_parser_alignas_specifier (c_parser *);
    1823              : static struct c_declarator *c_parser_direct_declarator (c_parser *, bool,
    1824              :                                                         c_dtr_syn, bool *);
    1825              : static struct c_declarator *c_parser_direct_declarator_inner (c_parser *,
    1826              :                                                               bool,
    1827              :                                                               struct c_declarator *);
    1828              : static struct c_arg_info *c_parser_parms_declarator (c_parser *, bool, tree,
    1829              :                                                      bool);
    1830              : static struct c_arg_info *c_parser_parms_list_declarator (c_parser *, tree,
    1831              :                                                           tree, bool);
    1832              : static struct c_parm *c_parser_parameter_declaration (c_parser *, tree, bool);
    1833              : static tree c_parser_asm_string_literal (c_parser *);
    1834              : static tree c_parser_simple_asm_expr (c_parser *);
    1835              : static tree c_parser_gnu_attributes (c_parser *);
    1836              : static struct c_expr c_parser_initializer (c_parser *, tree);
    1837              : static struct c_expr c_parser_braced_init (c_parser *, tree, bool,
    1838              :                                            struct obstack *, bool);
    1839              : static void c_parser_initelt (c_parser *, struct obstack *);
    1840              : static void c_parser_initval (c_parser *, struct c_expr *,
    1841              :                               struct obstack *);
    1842              : static tree c_parser_compound_statement (c_parser *, location_t * = NULL);
    1843              : static location_t c_parser_compound_statement_nostart (c_parser *);
    1844              : static void c_parser_label (c_parser *, tree);
    1845              : static void c_parser_statement (c_parser *, bool *, location_t * = NULL);
    1846              : static void c_parser_statement_after_labels (c_parser *, bool *, tree,
    1847              :                                              vec<tree> * = NULL,
    1848              :                                              attr_state = {});
    1849              : static tree c_parser_c99_block_statement (c_parser *, bool *,
    1850              :                                           location_t * = NULL);
    1851              : static void c_parser_if_statement (c_parser *, bool *, vec<tree> *);
    1852              : static void c_parser_switch_statement (c_parser *, bool *, tree);
    1853              : static void c_parser_while_statement (c_parser *, bool, unsigned short, bool,
    1854              :                                       bool *, tree);
    1855              : static void c_parser_do_statement (c_parser *, bool, unsigned short, bool,
    1856              :                                    tree);
    1857              : static void c_parser_for_statement (c_parser *, bool, unsigned short, bool,
    1858              :                                     bool *, tree);
    1859              : static tree c_parser_asm_statement (c_parser *);
    1860              : static tree c_parser_asm_operands (c_parser *);
    1861              : static tree c_parser_asm_goto_operands (c_parser *);
    1862              : static tree c_parser_asm_clobbers (c_parser *);
    1863              : static struct c_expr c_parser_expr_no_commas (c_parser *, struct c_expr *,
    1864              :                                               tree = NULL_TREE);
    1865              : static struct c_expr c_parser_conditional_expression (c_parser *,
    1866              :                                                       struct c_expr *, tree);
    1867              : static struct c_expr c_parser_binary_expression (c_parser *, struct c_expr *,
    1868              :                                                  tree);
    1869              : static struct c_expr c_parser_cast_expression (c_parser *, struct c_expr *);
    1870              : static struct c_expr c_parser_unary_expression (c_parser *);
    1871              : static struct c_expr c_parser_sizeof_or_countof_expression (c_parser *,
    1872              :                                                             enum rid);
    1873              : static struct c_expr c_parser_alignof_expression (c_parser *);
    1874              : static struct c_expr c_parser_maxof_or_minof_expression (c_parser *, enum rid);
    1875              : static struct c_expr c_parser_postfix_expression (c_parser *);
    1876              : static struct c_expr c_parser_postfix_expression_after_paren_type (c_parser *,
    1877              :                                                                    struct c_declspecs *,
    1878              :                                                                    struct c_type_name *,
    1879              :                                                                    location_t);
    1880              : static struct c_expr c_parser_postfix_expression_after_primary (c_parser *,
    1881              :                                                                 location_t loc,
    1882              :                                                                 struct c_expr);
    1883              : static tree c_parser_transaction (c_parser *, enum rid);
    1884              : static struct c_expr c_parser_transaction_expression (c_parser *, enum rid);
    1885              : static tree c_parser_transaction_cancel (c_parser *);
    1886              : static struct c_expr c_parser_expression (c_parser *);
    1887              : static struct c_expr c_parser_expression_conv (c_parser *);
    1888              : static vec<tree, va_gc> *c_parser_expr_list (c_parser *, bool, bool,
    1889              :                                              vec<tree, va_gc> **, location_t *,
    1890              :                                              tree *, vec<location_t> *,
    1891              :                                              unsigned int * = NULL);
    1892              : static struct c_expr c_parser_has_attribute_expression (c_parser *);
    1893              : 
    1894              : static void c_parser_oacc_declare (c_parser *);
    1895              : static void c_parser_oacc_enter_exit_data (c_parser *, bool);
    1896              : static void c_parser_oacc_update (c_parser *);
    1897              : static void c_parser_omp_construct (c_parser *, bool *);
    1898              : static void c_parser_omp_groupprivate (c_parser *);
    1899              : static void c_parser_omp_threadprivate (c_parser *);
    1900              : static void c_parser_omp_barrier (c_parser *);
    1901              : static void c_parser_omp_depobj (c_parser *);
    1902              : static void c_parser_omp_flush (c_parser *);
    1903              : static bool c_parser_omp_next_tokens_can_be_canon_loop (c_parser *,
    1904              :                                                         enum tree_code, bool);
    1905              : static tree c_parser_omp_loop_nest (c_parser *, bool *);
    1906              : static tree c_parser_omp_for_loop (location_t, c_parser *, enum tree_code,
    1907              :                                    tree, tree *, bool *);
    1908              : static void c_parser_omp_taskwait (c_parser *);
    1909              : static void c_parser_omp_taskyield (c_parser *);
    1910              : static void c_parser_omp_cancel (c_parser *);
    1911              : static void c_parser_omp_nothing (c_parser *);
    1912              : static void c_parser_omp_metadirective (c_parser *, bool *);
    1913              : 
    1914              : enum pragma_context { pragma_external, pragma_struct, pragma_param,
    1915              :                       pragma_stmt, pragma_compound };
    1916              : static bool c_parser_pragma (c_parser *, enum pragma_context, bool *, tree);
    1917              : static bool c_parser_omp_cancellation_point (c_parser *, enum pragma_context);
    1918              : static bool c_parser_omp_target (c_parser *, enum pragma_context, bool *);
    1919              : static void c_parser_omp_begin (c_parser *);
    1920              : static void c_parser_omp_end (c_parser *);
    1921              : static bool c_parser_omp_declare (c_parser *, enum pragma_context);
    1922              : static void c_parser_omp_requires (c_parser *);
    1923              : static bool c_parser_omp_error (c_parser *, enum pragma_context);
    1924              : static void c_parser_omp_assumption_clauses (c_parser *, bool);
    1925              : static void c_parser_omp_allocate (c_parser *);
    1926              : static void c_parser_omp_assumes (c_parser *);
    1927              : static bool c_parser_omp_ordered (c_parser *, enum pragma_context, bool *);
    1928              : static tree c_parser_omp_dispatch (location_t, c_parser *);
    1929              : static void c_parser_omp_interop (c_parser *);
    1930              : static void c_parser_oacc_routine (c_parser *, enum pragma_context);
    1931              : 
    1932              : /* These Objective-C parser functions are only ever called when
    1933              :    compiling Objective-C.  */
    1934              : static void c_parser_objc_class_definition (c_parser *, tree);
    1935              : static void c_parser_objc_class_instance_variables (c_parser *);
    1936              : static void c_parser_objc_class_declaration (c_parser *);
    1937              : static void c_parser_objc_alias_declaration (c_parser *);
    1938              : static void c_parser_objc_protocol_definition (c_parser *, tree);
    1939              : static bool c_parser_objc_method_type (c_parser *);
    1940              : static void c_parser_objc_method_definition (c_parser *);
    1941              : static void c_parser_objc_methodprotolist (c_parser *);
    1942              : static void c_parser_objc_methodproto (c_parser *);
    1943              : static tree c_parser_objc_method_decl (c_parser *, bool, tree *, tree *);
    1944              : static tree c_parser_objc_type_name (c_parser *);
    1945              : static tree c_parser_objc_protocol_refs (c_parser *);
    1946              : static void c_parser_objc_try_catch_finally_statement (c_parser *);
    1947              : static void c_parser_objc_synchronized_statement (c_parser *);
    1948              : static tree c_parser_objc_selector (c_parser *);
    1949              : static tree c_parser_objc_selector_arg (c_parser *);
    1950              : static tree c_parser_objc_receiver (c_parser *);
    1951              : static tree c_parser_objc_message_args (c_parser *);
    1952              : static tree c_parser_objc_keywordexpr (c_parser *);
    1953              : static void c_parser_objc_at_property_declaration (c_parser *);
    1954              : static void c_parser_objc_at_synthesize_declaration (c_parser *);
    1955              : static void c_parser_objc_at_dynamic_declaration (c_parser *);
    1956              : static bool c_parser_objc_diagnose_bad_element_prefix
    1957              :   (c_parser *, struct c_declspecs *);
    1958              : static location_t c_parser_parse_rtl_body (c_parser *, char *);
    1959              : static tree c_parser_handle_musttail (c_parser *, tree, attr_state &);
    1960              : 
    1961              : #if ENABLE_ANALYZER
    1962              : 
    1963              : namespace ana {
    1964              : 
    1965              : /* Concrete implementation of ana::translation_unit for the C frontend.  */
    1966              : 
    1967              : class c_translation_unit : public translation_unit
    1968              : {
    1969              : public:
    1970              :   /* Implementation of translation_unit::lookup_constant_by_id for use by the
    1971              :      analyzer to look up named constants in the user's source code.  */
    1972        12040 :   tree lookup_constant_by_id (tree id) const final override
    1973              :   {
    1974              :     /* Consider decls.  */
    1975        12040 :     if (tree decl = lookup_name (id))
    1976           45 :       if (TREE_CODE (decl) == CONST_DECL)
    1977           45 :         if (tree value = DECL_INITIAL (decl))
    1978           45 :           if (TREE_CODE (value) == INTEGER_CST)
    1979              :             return value;
    1980              : 
    1981              :     /* Consider macros.  */
    1982        11995 :     cpp_hashnode *hashnode = C_CPP_HASHNODE (id);
    1983        11995 :     if (cpp_macro_p (hashnode))
    1984           93 :       if (tree value = consider_macro (hashnode->value.macro))
    1985              :         return value;
    1986              : 
    1987              :     return NULL_TREE;
    1988              :   }
    1989              : 
    1990              :   tree
    1991            0 :   lookup_type_by_id (tree id) const final override
    1992              :   {
    1993            0 :     if (tree type_decl = lookup_name (id))
    1994            0 :         if (TREE_CODE (type_decl) == TYPE_DECL)
    1995              :           {
    1996            0 :             tree record_type = TREE_TYPE (type_decl);
    1997            0 :             if (TREE_CODE (record_type) == RECORD_TYPE)
    1998            0 :               return record_type;
    1999              :           }
    2000              : 
    2001              :     return NULL_TREE;
    2002              :   }
    2003              : 
    2004              :   tree
    2005            0 :   lookup_global_var_by_id (tree id) const final override
    2006              :   {
    2007            0 :     if (tree var_decl = lookup_name (id))
    2008            0 :       if (TREE_CODE (var_decl) == VAR_DECL)
    2009            0 :                                 return var_decl;
    2010              : 
    2011              :     return NULL_TREE;
    2012              :   }
    2013              : 
    2014              : private:
    2015              :   /* Attempt to get an INTEGER_CST from MACRO.
    2016              :      Only handle the simplest cases: where MACRO's definition is a single
    2017              :      token containing a number, by lexing the number again.
    2018              :      This will handle e.g.
    2019              :        #define NAME 42
    2020              :      and other bases but not negative numbers, parentheses or e.g.
    2021              :        #define NAME 1 << 7
    2022              :      as doing so would require a parser.
    2023              :      Also handle the case where MACRO's definition is a single identifier
    2024              :      that is itself a macro name (e.g. "#define O_CREAT _FCREAT"), by
    2025              :      following the chain of aliases.  */
    2026           93 :   tree consider_macro (cpp_macro *macro, int depth = 0) const
    2027              :   {
    2028              :     /* UInteger option variables are stored as int, so "depth" must be signed
    2029              :        to avoid a signed/unsigned comparison here. */
    2030           95 :     gcc_assert (depth >= 0);
    2031              : 
    2032           95 :     if (macro->paramc > 0)
    2033              :       return NULL_TREE;
    2034           92 :     if (macro->kind != cmk_macro)
    2035              :       return NULL_TREE;
    2036           92 :     if (macro->count != 1)
    2037              :       return NULL_TREE;
    2038           86 :     const cpp_token &tok = macro->exp.tokens[0];
    2039           86 :     if (tok.type == CPP_NAME)
    2040              :       {
    2041              :         /* Limit recursion.  */
    2042            4 :         if (depth >= param_analyzer_max_macro_alias_depth)
    2043              :           return NULL_TREE;
    2044              : 
    2045            3 :         cpp_hashnode *alias = tok.val.node.node;
    2046            3 :         if (cpp_macro_p (alias))
    2047            2 :           return consider_macro (alias->value.macro, depth + 1);
    2048              : 
    2049              :         /* Not a simple alias.  */
    2050              :         return NULL_TREE;
    2051              :       }
    2052           82 :     else if (tok.type != CPP_NUMBER)
    2053              :       return NULL_TREE;
    2054              : 
    2055           80 :     cpp_reader *old_parse_in = parse_in;
    2056           80 :     parse_in = cpp_create_reader (CLK_GNUC89, NULL, line_table);
    2057              : 
    2058           80 :     pretty_printer pp;
    2059           80 :     pp_string (&pp, (const char *) tok.val.str.text);
    2060           80 :     pp_newline (&pp);
    2061          160 :     cpp_push_buffer (parse_in,
    2062           80 :                      (const unsigned char *) pp_formatted_text (&pp),
    2063              :                      strlen (pp_formatted_text (&pp)),
    2064              :                      0);
    2065              : 
    2066           80 :     tree value;
    2067           80 :     location_t loc;
    2068           80 :     unsigned char cpp_flags;
    2069           80 :     c_lex_with_flags (&value, &loc, &cpp_flags, 0);
    2070              : 
    2071           80 :     cpp_destroy (parse_in);
    2072           80 :     parse_in = old_parse_in;
    2073              : 
    2074           80 :     if (value && TREE_CODE (value) == INTEGER_CST)
    2075           80 :       return value;
    2076              : 
    2077              :     return NULL_TREE;
    2078           80 :   }
    2079              : };
    2080              : 
    2081              : } // namespace ana
    2082              : 
    2083              : #endif /* #if ENABLE_ANALYZER */
    2084              : 
    2085              : /* Parse a translation unit (C90 6.7, C99 6.9, C11 6.9).
    2086              : 
    2087              :    translation-unit:
    2088              :      external-declarations
    2089              : 
    2090              :    external-declarations:
    2091              :      external-declaration
    2092              :      external-declarations external-declaration
    2093              : 
    2094              :    GNU extensions:
    2095              : 
    2096              :    translation-unit:
    2097              :      empty
    2098              : */
    2099              : 
    2100              : static void
    2101       110158 : c_parser_translation_unit (c_parser *parser)
    2102              : {
    2103       110158 :   if (c_parser_next_token_is (parser, CPP_EOF))
    2104              :     {
    2105         1181 :       pedwarn (c_parser_peek_token (parser)->location, OPT_Wpedantic,
    2106              :                "ISO C forbids an empty translation unit");
    2107              :     }
    2108              :   else
    2109              :     {
    2110       108977 :       void *obstack_position = obstack_alloc (&parser_obstack, 0);
    2111       108977 :       mark_valid_location_for_stdc_pragma (false);
    2112     60470542 :       do
    2113              :         {
    2114     60470542 :           ggc_collect ();
    2115     60470542 :           c_parser_external_declaration (parser);
    2116     60470537 :           obstack_free (&parser_obstack, obstack_position);
    2117              :         }
    2118     60470537 :       while (c_parser_next_token_is_not (parser, CPP_EOF));
    2119              :     }
    2120              : 
    2121       110068 :   unsigned int i;
    2122       110068 :   tree decl;
    2123       110203 :   FOR_EACH_VEC_ELT (incomplete_record_decls, i, decl)
    2124          135 :     if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node)
    2125           37 :       error ("storage size of %q+D isn%'t known", decl);
    2126              : 
    2127       110068 :   if (vec_safe_length (current_omp_declare_target_attribute))
    2128              :     {
    2129            4 :       c_omp_declare_target_attr
    2130            4 :         a = current_omp_declare_target_attribute->pop ();
    2131            4 :       if (!errorcount)
    2132            3 :         error ("%qs without corresponding %qs",
    2133              :                a.device_type >= 0 ? "#pragma omp begin declare target"
    2134              :                                   : "#pragma omp declare target",
    2135              :                "#pragma omp end declare target");
    2136            4 :       vec_safe_truncate (current_omp_declare_target_attribute, 0);
    2137              :     }
    2138       110068 :   if (vec_safe_length (current_omp_begin_assumes))
    2139              :     {
    2140            1 :       if (!errorcount)
    2141            1 :         error ("%qs without corresponding %qs",
    2142              :                "#pragma omp begin assumes", "#pragma omp end assumes");
    2143            1 :       vec_safe_truncate (current_omp_begin_assumes, 0);
    2144              :     }
    2145       110068 :   if (vec_safe_length (current_omp_declare_variant_attribute))
    2146              :     {
    2147            0 :       if (!errorcount)
    2148            0 :         error ("%<omp begin declare variant%> without corresponding "
    2149              :                "%<omp end declare variant%>");
    2150            0 :       vec_safe_truncate (current_omp_declare_variant_attribute, 0);
    2151              :     }
    2152       110068 :   if (vec_safe_length (omp_begin_declare_variant_map))
    2153              :     {
    2154              :       unsigned int i;
    2155              :       omp_begin_declare_variant_map_entry *e;
    2156           35 :       FOR_EACH_VEC_ELT (*omp_begin_declare_variant_map, i, e)
    2157           26 :         omp_finish_variant_function (e->variant, e->id, e->ctx);
    2158            9 :       vec_safe_truncate (omp_begin_declare_variant_map, 0);
    2159              :     }
    2160              : 
    2161              : #if ENABLE_ANALYZER
    2162       110068 :   if (flag_analyzer)
    2163              :     {
    2164         1505 :       ana::c_translation_unit tu;
    2165         1505 :       ana::on_finish_translation_unit (tu);
    2166              :     }
    2167              : #endif
    2168       110068 : }
    2169              : 
    2170              : /* Parse an external declaration (C90 6.7, C99 6.9, C11 6.9).
    2171              : 
    2172              :    external-declaration:
    2173              :      function-definition
    2174              :      declaration
    2175              : 
    2176              :    GNU extensions:
    2177              : 
    2178              :    external-declaration:
    2179              :      asm-definition
    2180              :      ;
    2181              :      __extension__ external-declaration
    2182              : 
    2183              :    Objective-C:
    2184              : 
    2185              :    external-declaration:
    2186              :      objc-class-definition
    2187              :      objc-class-declaration
    2188              :      objc-alias-declaration
    2189              :      objc-protocol-definition
    2190              :      objc-method-definition
    2191              :      @end
    2192              : */
    2193              : 
    2194              : static void
    2195     60918951 : c_parser_external_declaration (c_parser *parser)
    2196              : {
    2197     60918951 :   int ext;
    2198     60918951 :   switch (c_parser_peek_token (parser)->type)
    2199              :     {
    2200     59054577 :     case CPP_KEYWORD:
    2201     59054577 :       switch (c_parser_peek_token (parser)->keyword)
    2202              :         {
    2203       448409 :         case RID_EXTENSION:
    2204       448409 :           ext = disable_extension_diagnostics ();
    2205       448409 :           c_parser_consume_token (parser);
    2206       448409 :           c_parser_external_declaration (parser);
    2207       448409 :           restore_extension_diagnostics (ext);
    2208       448409 :           break;
    2209          214 :         case RID_ASM:
    2210          214 :           c_parser_asm_definition (parser);
    2211          214 :           break;
    2212            0 :         case RID_AT_INTERFACE:
    2213            0 :         case RID_AT_IMPLEMENTATION:
    2214            0 :           gcc_assert (c_dialect_objc ());
    2215            0 :           c_parser_objc_class_definition (parser, NULL_TREE);
    2216            0 :           break;
    2217            0 :         case RID_AT_CLASS:
    2218            0 :           gcc_assert (c_dialect_objc ());
    2219            0 :           c_parser_objc_class_declaration (parser);
    2220            0 :           break;
    2221            0 :         case RID_AT_ALIAS:
    2222            0 :           gcc_assert (c_dialect_objc ());
    2223            0 :           c_parser_objc_alias_declaration (parser);
    2224            0 :           break;
    2225            0 :         case RID_AT_PROTOCOL:
    2226            0 :           gcc_assert (c_dialect_objc ());
    2227            0 :           c_parser_objc_protocol_definition (parser, NULL_TREE);
    2228            0 :           break;
    2229            0 :         case RID_AT_PROPERTY:
    2230            0 :           gcc_assert (c_dialect_objc ());
    2231            0 :           c_parser_objc_at_property_declaration (parser);
    2232            0 :           break;
    2233            0 :         case RID_AT_SYNTHESIZE:
    2234            0 :           gcc_assert (c_dialect_objc ());
    2235            0 :           c_parser_objc_at_synthesize_declaration (parser);
    2236            0 :           break;
    2237            0 :         case RID_AT_DYNAMIC:
    2238            0 :           gcc_assert (c_dialect_objc ());
    2239            0 :           c_parser_objc_at_dynamic_declaration (parser);
    2240            0 :           break;
    2241            0 :         case RID_AT_END:
    2242            0 :           gcc_assert (c_dialect_objc ());
    2243            0 :           c_parser_consume_token (parser);
    2244            0 :           objc_finish_implementation ();
    2245            0 :           break;
    2246     58605954 :         default:
    2247     58605954 :           goto decl_or_fndef;
    2248              :         }
    2249              :       break;
    2250         2296 :     case CPP_SEMICOLON:
    2251         2296 :       pedwarn (c_parser_peek_token (parser)->location, OPT_Wpedantic,
    2252              :                "ISO C does not allow extra %<;%> outside of a function");
    2253         2296 :       c_parser_consume_token (parser);
    2254         2296 :       break;
    2255      1637214 :     case CPP_PRAGMA:
    2256      1637214 :       mark_valid_location_for_stdc_pragma (true);
    2257      1637214 :       c_parser_pragma (parser, pragma_external, NULL, NULL_TREE);
    2258      1637214 :       mark_valid_location_for_stdc_pragma (false);
    2259      1637214 :       break;
    2260            1 :     case CPP_PLUS:
    2261            1 :     case CPP_MINUS:
    2262            1 :       if (c_dialect_objc ())
    2263              :         {
    2264            0 :           c_parser_objc_method_definition (parser);
    2265            0 :           break;
    2266              :         }
    2267              :       /* Else fall through, and yield a syntax error trying to parse
    2268              :          as a declaration or function definition.  */
    2269              :       /* FALLTHRU */
    2270     58830818 :     default:
    2271            1 :     decl_or_fndef:
    2272              :       /* A declaration or a function definition (or, in Objective-C,
    2273              :          an @interface or @protocol with prefix attributes).  We can
    2274              :          only tell which after parsing the declaration specifiers, if
    2275              :          any, and the first declarator.  */
    2276     58830818 :       c_parser_declaration_or_fndef (parser, true, true, true, false, true,
    2277              :                                      false);
    2278     58830818 :       break;
    2279              :     }
    2280     60918946 : }
    2281              : 
    2282              : static void c_parser_handle_directive_omp_attributes (tree &, vec<c_token> *&,
    2283              :                                                       vec<c_token> *);
    2284              : static void c_finish_omp_declare_simd (c_parser *, tree, tree, vec<c_token> *);
    2285              : static void c_finish_oacc_routine (struct oacc_routine_data *, tree, bool);
    2286              : 
    2287              : /* Build and add a DEBUG_BEGIN_STMT statement with location LOC.  */
    2288              : 
    2289              : static void
    2290    110922465 : add_debug_begin_stmt (location_t loc)
    2291              : {
    2292              :   /* Don't add DEBUG_BEGIN_STMTs outside of functions, see PR84721.  */
    2293    110922465 :   if (!MAY_HAVE_DEBUG_MARKER_STMTS || !building_stmt_list_p ())
    2294              :     return;
    2295              : 
    2296      2813938 :   tree stmt = build0 (DEBUG_BEGIN_STMT, void_type_node);
    2297      2813938 :   SET_EXPR_LOCATION (stmt, loc);
    2298      2813938 :   add_stmt (stmt);
    2299              : }
    2300              : 
    2301              : /* Helper function for c_parser_declaration_or_fndef and
    2302              :    Handle assume attribute(s).  */
    2303              : 
    2304              : static tree
    2305           44 : handle_assume_attribute (location_t here, tree attrs, bool nested)
    2306              : {
    2307           44 :   if (nested)
    2308           90 :     for (tree attr = lookup_attribute ("gnu", "assume", attrs); attr;
    2309           47 :          attr = lookup_attribute ("gnu", "assume", TREE_CHAIN (attr)))
    2310              :       {
    2311           47 :         tree args = TREE_VALUE (attr);
    2312           47 :         int nargs = list_length (args);
    2313           47 :         if (nargs != 1)
    2314              :           {
    2315            6 :             error_at (here, "wrong number of arguments specified "
    2316              :                             "for %qE attribute",
    2317              :                       get_attribute_name (attr));
    2318            6 :             inform (here, "expected %i, found %i", 1, nargs);
    2319              :           }
    2320              :         else
    2321              :           {
    2322           41 :             tree arg = TREE_VALUE (args);
    2323           41 :             arg = c_objc_common_truthvalue_conversion (here, arg);
    2324           41 :             arg = c_fully_fold (arg, false, NULL);
    2325           41 :             if (arg != error_mark_node)
    2326              :               {
    2327           39 :                 tree fn = build_call_expr_internal_loc (here, IFN_ASSUME,
    2328              :                                                         void_type_node, 1,
    2329              :                                                         arg);
    2330           39 :                 add_stmt (fn);
    2331              :               }
    2332              :           }
    2333              :       }
    2334              :   else
    2335            1 :     pedwarn (here, OPT_Wattributes,
    2336              :              "%<assume%> attribute at top level");
    2337              : 
    2338           44 :   return remove_attribute ("gnu", "assume", attrs);
    2339              : }
    2340              : 
    2341              : /* We might need to reclassify any previously-lexed identifier, e.g.
    2342              :    when we've left a for loop with an if-statement without else in the
    2343              :    body - we might have used a wrong scope for the token.  See PR67784.  */
    2344              : 
    2345              : static void
    2346     39389793 : c_parser_maybe_reclassify_token (c_parser *parser)
    2347              : {
    2348     39389793 :   if (c_parser_next_token_is (parser, CPP_NAME))
    2349              :     {
    2350       211193 :       c_token *token = c_parser_peek_token (parser);
    2351              : 
    2352       211193 :       if (token->id_kind == C_ID_ID || token->id_kind == C_ID_TYPENAME)
    2353              :         {
    2354       211192 :           tree decl = lookup_name (token->value);
    2355              : 
    2356       211192 :           token->id_kind = C_ID_ID;
    2357       211192 :           if (decl)
    2358              :             {
    2359       207919 :               if (TREE_CODE (decl) == TYPE_DECL)
    2360         2359 :                 token->id_kind = C_ID_TYPENAME;
    2361              :             }
    2362         3273 :           else if (c_dialect_objc ())
    2363              :             {
    2364            0 :               tree objc_interface_decl = objc_is_class_name (token->value);
    2365              :               /* Objective-C class names are in the same namespace as
    2366              :                  variables and typedefs, and hence are shadowed by local
    2367              :                  declarations.  */
    2368            0 :               if (objc_interface_decl)
    2369              :                 {
    2370            0 :                   token->value = objc_interface_decl;
    2371            0 :                   token->id_kind = C_ID_CLASSNAME;
    2372              :                 }
    2373              :             }
    2374              :         }
    2375              :     }
    2376     39389793 : }
    2377              : 
    2378              : /* Parse a declaration or function definition (C90 6.5, 6.7.1, C99
    2379              :    6.7, 6.9.1, C11 6.7, 6.9.1).  If FNDEF_OK is true, a function definition
    2380              :    is accepted; otherwise (old-style parameter declarations) only other
    2381              :    declarations are accepted.  If STATIC_ASSERT_OK is true, a static
    2382              :    assertion is accepted; otherwise (old-style parameter declarations)
    2383              :    it is not.  If NESTED is true, we are inside a function or parsing
    2384              :    old-style parameter declarations; any functions encountered are
    2385              :    nested functions and declaration specifiers are required; otherwise
    2386              :    we are at top level and functions are normal functions and
    2387              :    declaration specifiers may be optional.  If EMPTY_OK is true, empty
    2388              :    declarations are OK (subject to all other constraints); otherwise
    2389              :    (old-style parameter declarations) they are diagnosed.  If
    2390              :    START_ATTR_OK is true, the declaration specifiers may start with
    2391              :    attributes (GNU or standard); otherwise they may not.
    2392              :    OBJC_FOREACH_OBJECT_DECLARATION can be used to get back the parsed
    2393              :    declaration when parsing an Objective-C foreach statement.
    2394              :    FALLTHRU_ATTR_P is used to signal whether this function parsed
    2395              :    "__attribute__((fallthrough));".  ATTRS are any standard attributes
    2396              :    parsed in the caller (in contexts where such attributes had to be
    2397              :    parsed to determine whether what follows is a declaration or a
    2398              :    statement); HAVE_ATTRS says whether there were any such attributes
    2399              :    (even empty).  If SIMPLE_OK, the construct can be a simple-declaration;
    2400              :    in that case, the ';' is not consumed (left to the caller so that it
    2401              :    can figure out if there was a simple-declaration or not), there must
    2402              :    be an initializer, and only one object may be declared.  When SIMPLE_OK
    2403              :    is true we are called from c_parser_selection_header.
    2404              : 
    2405              :    Returns the resulting declaration, if there was any with an initializer.
    2406              : 
    2407              :    declaration:
    2408              :      declaration-specifiers init-declarator-list[opt] ;
    2409              :      static_assert-declaration
    2410              : 
    2411              :    function-definition:
    2412              :      declaration-specifiers[opt] declarator declaration-list[opt]
    2413              :        compound-statement
    2414              : 
    2415              :    declaration-list:
    2416              :      declaration
    2417              :      declaration-list declaration
    2418              : 
    2419              :    init-declarator-list:
    2420              :      init-declarator
    2421              :      init-declarator-list , init-declarator
    2422              : 
    2423              :    init-declarator:
    2424              :      declarator simple-asm-expr[opt] gnu-attributes[opt]
    2425              :      declarator simple-asm-expr[opt] gnu-attributes[opt] = initializer
    2426              : 
    2427              :    simple-declaration:
    2428              :      attribute-specifier-sequence[opt] declaration-specifiers declarator
    2429              :        = initializer
    2430              : 
    2431              :    GNU extensions:
    2432              : 
    2433              :    nested-function-definition:
    2434              :      declaration-specifiers declarator declaration-list[opt]
    2435              :        compound-statement
    2436              : 
    2437              :    attribute ;
    2438              : 
    2439              :    Objective-C:
    2440              :      gnu-attributes objc-class-definition
    2441              :      gnu-attributes objc-category-definition
    2442              :      gnu-attributes objc-protocol-definition
    2443              : 
    2444              :    The simple-asm-expr and gnu-attributes are GNU extensions.
    2445              : 
    2446              :    This function does not handle __extension__; that is handled in its
    2447              :    callers.  ??? Following the old parser, __extension__ may start
    2448              :    external declarations, declarations in functions and declarations
    2449              :    at the start of "for" loops, but not old-style parameter
    2450              :    declarations.
    2451              : 
    2452              :    C99 requires declaration specifiers in a function definition; the
    2453              :    absence is diagnosed through the diagnosis of implicit int.  In GNU
    2454              :    C we also allow but diagnose declarations without declaration
    2455              :    specifiers, but only at top level (elsewhere they conflict with
    2456              :    other syntax).
    2457              : 
    2458              :    In Objective-C, declarations of the looping variable in a foreach
    2459              :    statement are exceptionally terminated by 'in' (for example, 'for
    2460              :    (NSObject *object in array) { ... }').
    2461              : 
    2462              :    OpenMP:
    2463              : 
    2464              :    declaration:
    2465              :      threadprivate-directive
    2466              : 
    2467              :    GIMPLE:
    2468              : 
    2469              :    gimple-function-definition:
    2470              :      declaration-specifiers[opt] __GIMPLE (gimple-or-rtl-pass-list) declarator
    2471              :        declaration-list[opt] compound-statement
    2472              : 
    2473              :    rtl-function-definition:
    2474              :      declaration-specifiers[opt] __RTL (gimple-or-rtl-pass-list) declarator
    2475              :        declaration-list[opt] compound-statement  */
    2476              : 
    2477              : static tree
    2478     66597070 : c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
    2479              :                                bool static_assert_ok, bool empty_ok,
    2480              :                                bool nested, bool start_attr_ok,
    2481              :                                bool simple_ok,
    2482              :                                tree *objc_foreach_object_declaration
    2483              :                                /* = NULL */,
    2484              :                                vec<c_token> *omp_declare_simd_clauses
    2485              :                                /* = NULL */,
    2486              :                                bool have_attrs /* = false */,
    2487              :                                tree attrs /* = NULL_TREE */,
    2488              :                                struct oacc_routine_data *oacc_routine_data
    2489              :                                /* = NULL */,
    2490              :                                bool *fallthru_attr_p /* = NULL */)
    2491              : {
    2492     66597070 :   struct c_declspecs *specs;
    2493     66597070 :   tree prefix_attrs;
    2494     66597070 :   tree all_prefix_attrs;
    2495     66597070 :   bool diagnosed_no_specs = false;
    2496     66597070 :   location_t here = c_parser_peek_token (parser)->location;
    2497     66597070 :   tree result = NULL_TREE;
    2498              : 
    2499     66597070 :   add_debug_begin_stmt (c_parser_peek_token (parser)->location);
    2500              : 
    2501     66597070 :   if (static_assert_ok
    2502    133180793 :       && c_parser_next_token_is_keyword (parser, RID_STATIC_ASSERT))
    2503              :     {
    2504         3201 :       c_parser_static_assert_declaration (parser);
    2505         3201 :       return result;
    2506              :     }
    2507     66593869 :   specs = build_null_declspecs ();
    2508              : 
    2509              :   /* Handle any standard attributes parsed in the caller.  */
    2510     66593869 :   if (have_attrs)
    2511              :     {
    2512          143 :       declspecs_add_attrs (here, specs, attrs);
    2513          143 :       specs->non_std_attrs_seen_p = false;
    2514              :     }
    2515              : 
    2516              :   /* Try to detect an unknown type name when we have "A B" or "A *B".  */
    2517     66593869 :   if (c_parser_peek_token (parser)->type == CPP_NAME
    2518      5974079 :       && c_parser_peek_token (parser)->id_kind == C_ID_ID
    2519         9291 :       && (c_parser_peek_2nd_token (parser)->type == CPP_NAME
    2520         9186 :           || c_parser_peek_2nd_token (parser)->type == CPP_MULT)
    2521     66593998 :       && (!nested || !lookup_name (c_parser_peek_token (parser)->value)))
    2522              :     {
    2523          127 :       tree name = c_parser_peek_token (parser)->value;
    2524              : 
    2525              :       /* Issue a warning about NAME being an unknown type name, perhaps
    2526              :          with some kind of hint.
    2527              :          If the user forgot a "struct" etc, suggest inserting
    2528              :          it.  Otherwise, attempt to look for misspellings.  */
    2529          127 :       gcc_rich_location richloc (here);
    2530          127 :       if (tag_exists_p (RECORD_TYPE, name))
    2531              :         {
    2532              :           /* This is not C++ with its implicit typedef.  */
    2533            3 :           richloc.add_fixit_insert_before ("struct ");
    2534            3 :           error_at (&richloc,
    2535              :                     "unknown type name %qE;"
    2536              :                     " use %<struct%> keyword to refer to the type",
    2537              :                     name);
    2538              :         }
    2539          124 :       else if (tag_exists_p (UNION_TYPE, name))
    2540              :         {
    2541            3 :           richloc.add_fixit_insert_before ("union ");
    2542            3 :           error_at (&richloc,
    2543              :                     "unknown type name %qE;"
    2544              :                     " use %<union%> keyword to refer to the type",
    2545              :                     name);
    2546              :         }
    2547          121 :       else if (tag_exists_p (ENUMERAL_TYPE, name))
    2548              :         {
    2549            3 :           richloc.add_fixit_insert_before ("enum ");
    2550            3 :           error_at (&richloc,
    2551              :                     "unknown type name %qE;"
    2552              :                     " use %<enum%> keyword to refer to the type",
    2553              :                     name);
    2554              :         }
    2555              :       else
    2556              :         {
    2557          118 :           auto_diagnostic_group d;
    2558          118 :           name_hint hint = lookup_name_fuzzy (name, FUZZY_LOOKUP_TYPENAME,
    2559          118 :                                               here);
    2560          118 :           if (const char *suggestion = hint.suggestion ())
    2561              :             {
    2562           10 :               richloc.add_fixit_replace (suggestion);
    2563           10 :               error_at (&richloc,
    2564              :                         "unknown type name %qE; did you mean %qs?",
    2565              :                         name, suggestion);
    2566              :             }
    2567              :           else
    2568          108 :             error_at (here, "unknown type name %qE", name);
    2569          118 :         }
    2570              : 
    2571              :       /* Parse declspecs normally to get a correct pointer type, but avoid
    2572              :          a further "fails to be a type name" error.  Refuse nested functions
    2573              :          since it is not how the user likely wants us to recover.  */
    2574          127 :       c_parser_peek_token (parser)->type = CPP_KEYWORD;
    2575          127 :       c_parser_peek_token (parser)->keyword = RID_VOID;
    2576          127 :       c_parser_peek_token (parser)->value = error_mark_node;
    2577          127 :       fndef_ok = !nested;
    2578          127 :     }
    2579              : 
    2580              :   /* When there are standard attributes at the start of the
    2581              :      declaration (to apply to the entity being declared), an
    2582              :      init-declarator-list or function definition must be present.  */
    2583     66593869 :   if (c_parser_nth_token_starts_std_attributes (parser, 1))
    2584         1780 :     have_attrs = true;
    2585              : 
    2586     66593869 :   c_parser_declspecs (parser, specs, true, true, start_attr_ok,
    2587              :                       true, true, start_attr_ok, true, cla_nonabstract_decl);
    2588     66593869 :   if (parser->error)
    2589              :     {
    2590           31 :       c_parser_skip_to_end_of_block_or_statement (parser);
    2591           31 :       return result;
    2592              :     }
    2593     66593838 :   if (nested && !specs->declspecs_seen_p)
    2594              :     {
    2595           63 :       c_parser_error (parser, "expected declaration specifiers");
    2596           63 :       c_parser_skip_to_end_of_block_or_statement (parser);
    2597           63 :       return result;
    2598              :     }
    2599              : 
    2600     66593775 :   finish_declspecs (specs);
    2601              :   /* When the decl is declared, its type is a top level type, we should
    2602              :      call verify_counted_by_for_top_anonymous_type.  */
    2603     66593775 :   if (specs->typespec_kind == ctsk_tagdef)
    2604      1218302 :     verify_counted_by_for_top_anonymous_type (specs->type);
    2605              : 
    2606     66593775 :   bool gnu_auto_type_p = specs->typespec_word == cts_auto_type;
    2607     66593775 :   bool std_auto_type_p = specs->c23_auto_p;
    2608     66593775 :   bool any_auto_type_p = gnu_auto_type_p || std_auto_type_p;
    2609     66593775 :   gcc_assert (!(gnu_auto_type_p && std_auto_type_p));
    2610     66593775 :   const char *auto_type_keyword = gnu_auto_type_p ? "__auto_type" : "auto";
    2611     66593775 :   if (specs->constexpr_p)
    2612              :     {
    2613              :       /* An underspecified declaration may not declare tags or members
    2614              :          or structures or unions; it is undefined behavior to declare
    2615              :          the members of an enumeration.  Where the structure, union or
    2616              :          enumeration type is declared within an initializer, this is
    2617              :          diagnosed elsewhere.  Diagnose here the case of declaring
    2618              :          such a type in the type specifiers of a constexpr
    2619              :          declaration.  */
    2620          398 :       switch (specs->typespec_kind)
    2621              :         {
    2622            6 :         case ctsk_tagfirstref:
    2623            6 :         case ctsk_tagfirstref_attrs:
    2624            6 :           error_at (here, "%qT declared in underspecified object declaration",
    2625              :                     specs->type);
    2626            6 :           break;
    2627              : 
    2628           10 :         case ctsk_tagdef:
    2629           10 :           error_at (here, "%qT defined in underspecified object declaration",
    2630              :                     specs->type);
    2631           10 :           break;
    2632              : 
    2633              :         default:
    2634              :           break;
    2635              :         }
    2636              :     }
    2637              : 
    2638     66593775 :   if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    2639              :     {
    2640       516742 :       bool handled_assume = false;
    2641       516742 :       if (specs->attrs
    2642          510 :           && !nested
    2643          127 :           && specs->typespec_kind == ctsk_none
    2644       516851 :           && c_parser_handle_statement_omp_attributes (parser, specs->attrs,
    2645              :                                                        NULL))
    2646              :         {
    2647           88 :           if (specs->attrs)
    2648            0 :             c_warn_unused_attributes (specs->attrs);
    2649          177 :           while (parser->in_omp_attribute_pragma)
    2650              :             {
    2651           89 :               gcc_assert (c_parser_next_token_is (parser, CPP_PRAGMA));
    2652           89 :               c_parser_pragma (parser, pragma_external, NULL, NULL_TREE);
    2653              :             }
    2654           88 :           c_parser_consume_token (parser);
    2655           88 :           return result;
    2656              :         }
    2657       516654 :       if (specs->typespec_kind == ctsk_none
    2658       516654 :           && lookup_attribute ("gnu", "assume", specs->attrs))
    2659              :         {
    2660           44 :           handled_assume = true;
    2661           44 :           specs->attrs
    2662           44 :             = handle_assume_attribute (here, specs->attrs, nested);
    2663              :         }
    2664       516654 :       if (any_auto_type_p)
    2665            6 :         error_at (here, "%qs in empty declaration", auto_type_keyword);
    2666       516648 :       else if (specs->typespec_kind == ctsk_none
    2667       516648 :                && attribute_fallthrough_p (specs->attrs))
    2668              :         {
    2669          328 :           if (fallthru_attr_p != NULL)
    2670          327 :             *fallthru_attr_p = true;
    2671          328 :           if (nested)
    2672              :             {
    2673          327 :               tree fn = build_call_expr_internal_loc (here, IFN_FALLTHROUGH,
    2674              :                                                       void_type_node, 0);
    2675          327 :               add_stmt (fn);
    2676              :             }
    2677              :           else
    2678            1 :             pedwarn (here, OPT_Wattributes,
    2679              :                      "%<fallthrough%> attribute at top level");
    2680              :         }
    2681       516320 :       else if (empty_ok
    2682       516303 :                && !(have_attrs && specs->non_std_attrs_seen_p)
    2683       516300 :                && !handled_assume)
    2684       516256 :         shadow_tag (specs);
    2685              :       else
    2686              :         {
    2687           64 :           shadow_tag_warned (specs, 1);
    2688           64 :           if (!handled_assume)
    2689           20 :             pedwarn (here, 0, "empty declaration");
    2690              :         }
    2691              :       /* We still have to evaluate size expressions.  */
    2692       516654 :       if (specs->expr)
    2693          117 :         add_stmt (fold_convert (void_type_node, specs->expr));
    2694       516654 :       c_parser_consume_token (parser);
    2695       516654 :       if (oacc_routine_data)
    2696            0 :         c_finish_oacc_routine (oacc_routine_data, NULL_TREE, false);
    2697              :       return result;
    2698              :     }
    2699     66077033 :   else if (specs->typespec_kind == ctsk_none
    2700              :            && nested
    2701              :            /* Only parse __attribute__((musttail)) when called from
    2702              :               c_parser_compound_statement_nostart.  This certainly isn't
    2703              :               a declaration in that case, but we don't do tentative parsing
    2704              :               of GNU attributes right now.  */
    2705         9777 :            && fallthru_attr_p
    2706     66077118 :            && c_parser_next_token_is_keyword (parser, RID_RETURN))
    2707              :     {
    2708           14 :       attr_state astate = {};
    2709           14 :       specs->attrs = c_parser_handle_musttail (parser, specs->attrs, astate);
    2710           14 :       if (astate.musttail_p)
    2711              :         {
    2712           14 :           if (specs->attrs)
    2713              :             {
    2714            0 :               auto_urlify_attributes sentinel;
    2715            0 :               warning_at (c_parser_peek_token (parser)->location,
    2716            0 :                           OPT_Wattributes,
    2717              :                           "attribute %<musttail%> mixed with other attributes "
    2718              :                           "on %<return%> statement");
    2719            0 :             }
    2720           14 :           c_parser_statement_after_labels (parser, NULL, NULL_TREE, NULL,
    2721              :                                            astate);
    2722           14 :           return result;
    2723              :         }
    2724              :     }
    2725              : 
    2726              :   /* Provide better error recovery.  Note that a type name here is usually
    2727              :      better diagnosed as a redeclaration.  */
    2728     66077019 :   if (empty_ok
    2729     66063886 :       && specs->typespec_kind == ctsk_tagdef
    2730       791410 :       && c_parser_next_token_starts_declspecs (parser)
    2731     66077049 :       && !c_parser_next_token_is (parser, CPP_NAME))
    2732              :     {
    2733            9 :       c_parser_error (parser, "expected %<;%>, identifier or %<(%>");
    2734            9 :       parser->error = false;
    2735            9 :       shadow_tag_warned (specs, 1);
    2736            9 :       return result;
    2737              :     }
    2738     66077010 :   else if (c_dialect_objc () && !any_auto_type_p)
    2739              :     {
    2740              :       /* Prefix attributes are an error on method decls.  */
    2741            0 :       switch (c_parser_peek_token (parser)->type)
    2742              :         {
    2743            0 :           case CPP_PLUS:
    2744            0 :           case CPP_MINUS:
    2745            0 :             if (c_parser_objc_diagnose_bad_element_prefix (parser, specs))
    2746              :               return result;
    2747            0 :             if (specs->attrs)
    2748              :               {
    2749            0 :                 warning_at (c_parser_peek_token (parser)->location,
    2750            0 :                             OPT_Wattributes,
    2751              :                             "prefix attributes are ignored for methods");
    2752            0 :                 specs->attrs = NULL_TREE;
    2753              :               }
    2754            0 :             if (fndef_ok)
    2755            0 :               c_parser_objc_method_definition (parser);
    2756              :             else
    2757            0 :               c_parser_objc_methodproto (parser);
    2758              :             return result;
    2759            0 :             break;
    2760            0 :           default:
    2761            0 :             break;
    2762              :         }
    2763              :       /* This is where we parse 'attributes @interface ...',
    2764              :          'attributes @implementation ...', 'attributes @protocol ...'
    2765              :          (where attributes could be, for example, __attribute__
    2766              :          ((deprecated)).
    2767              :       */
    2768            0 :       switch (c_parser_peek_token (parser)->keyword)
    2769              :         {
    2770            0 :         case RID_AT_INTERFACE:
    2771            0 :           {
    2772            0 :             if (c_parser_objc_diagnose_bad_element_prefix (parser, specs))
    2773              :               return result;
    2774            0 :             c_parser_objc_class_definition (parser, specs->attrs);
    2775            0 :             return result;
    2776              :           }
    2777            0 :           break;
    2778            0 :         case RID_AT_IMPLEMENTATION:
    2779            0 :           {
    2780            0 :             if (c_parser_objc_diagnose_bad_element_prefix (parser, specs))
    2781              :               return result;
    2782            0 :             if (specs->attrs)
    2783              :               {
    2784            0 :                 warning_at (c_parser_peek_token (parser)->location,
    2785            0 :                         OPT_Wattributes,
    2786              :                         "prefix attributes are ignored for implementations");
    2787            0 :                 specs->attrs = NULL_TREE;
    2788              :               }
    2789            0 :             c_parser_objc_class_definition (parser, NULL_TREE);
    2790            0 :             return result;
    2791              :           }
    2792            0 :           break;
    2793            0 :         case RID_AT_PROTOCOL:
    2794            0 :           {
    2795            0 :             if (c_parser_objc_diagnose_bad_element_prefix (parser, specs))
    2796              :               return result;
    2797            0 :             c_parser_objc_protocol_definition (parser, specs->attrs);
    2798            0 :             return result;
    2799              :           }
    2800            0 :           break;
    2801            0 :         case RID_AT_ALIAS:
    2802            0 :         case RID_AT_CLASS:
    2803            0 :         case RID_AT_END:
    2804            0 :         case RID_AT_PROPERTY:
    2805            0 :           if (specs->attrs)
    2806              :             {
    2807            0 :               c_parser_error (parser, "unexpected attribute");
    2808            0 :               specs->attrs = NULL;
    2809              :             }
    2810              :           break;
    2811              :         default:
    2812              :           break;
    2813              :         }
    2814              :     }
    2815     66077010 :   else if (attribute_fallthrough_p (specs->attrs))
    2816            5 :     warning_at (here, OPT_Wattributes,
    2817              :                 "%<fallthrough%> attribute not followed by %<;%>");
    2818     66077005 :   else if (lookup_attribute ("gnu", "assume", specs->attrs))
    2819            2 :     warning_at (here, OPT_Wattributes,
    2820              :                 "%<assume%> attribute not followed by %<;%>");
    2821              : 
    2822    132154015 :   auto_vec<c_token> omp_declare_simd_attr_clauses;
    2823     66077010 :   c_parser_handle_directive_omp_attributes (specs->attrs,
    2824              :                                             omp_declare_simd_clauses,
    2825              :                                             &omp_declare_simd_attr_clauses);
    2826     66077010 :   pending_xref_error ();
    2827     66077010 :   prefix_attrs = specs->attrs;
    2828     66077010 :   all_prefix_attrs = prefix_attrs;
    2829     66077010 :   specs->attrs = NULL_TREE;
    2830     66077010 :   bool more_than_one_decl = false;
    2831     66942672 :   while (true)
    2832              :     {
    2833     66509841 :       struct c_declarator *declarator;
    2834     66509841 :       bool dummy = false;
    2835     66509841 :       timevar_id_t tv;
    2836     66509841 :       tree fnbody = NULL_TREE;
    2837     66509841 :       tree underspec_name = NULL_TREE;
    2838     66509841 :       auto_vec<c_token> omp_dsimd_idattr_clauses;
    2839              :       /* Declaring either one or more declarators (in which case we
    2840              :          should diagnose if there were no declaration specifiers) or a
    2841              :          function definition (in which case the diagnostic for
    2842              :          implicit int suffices).  */
    2843    133019682 :       declarator = c_parser_declarator (parser,
    2844     66509841 :                                         specs->typespec_kind != ctsk_none,
    2845              :                                         C_DTR_NORMAL, &dummy);
    2846     66509841 :       if (declarator == NULL)
    2847              :         {
    2848          257 :           if (omp_declare_simd_clauses)
    2849            1 :             c_finish_omp_declare_simd (parser, NULL_TREE, NULL_TREE,
    2850              :                                        omp_declare_simd_clauses);
    2851          257 :           if (oacc_routine_data)
    2852            0 :             c_finish_oacc_routine (oacc_routine_data, NULL_TREE, false);
    2853              :           /* This check is here purely to improve the diagnostic.  */
    2854          257 :           if (!simple_ok)
    2855          237 :             c_parser_skip_to_end_of_block_or_statement (parser);
    2856              :           return result;
    2857              :         }
    2858     66509584 :       if (flag_openmp || flag_openmp_simd)
    2859              :         {
    2860              :           struct c_declarator *d = declarator;
    2861       953810 :           while (d->kind != cdk_id)
    2862       415364 :             d = d->declarator;
    2863       538446 :           vec<c_token> *dummy = NULL;
    2864       538446 :           c_parser_handle_directive_omp_attributes (d->u.id.attrs, dummy,
    2865              :                                                     &omp_dsimd_idattr_clauses);
    2866              :         }
    2867     66509584 :       if (gnu_auto_type_p && declarator->kind != cdk_id)
    2868              :         {
    2869            1 :           error_at (here,
    2870              :                     "%<__auto_type%> requires a plain identifier"
    2871              :                     " as declarator");
    2872            1 :           c_parser_skip_to_end_of_block_or_statement (parser);
    2873            1 :           return result;
    2874              :         }
    2875     66509583 :       if (std_auto_type_p)
    2876              :         {
    2877              :           struct c_declarator *d = declarator;
    2878           84 :           while (d->kind == cdk_attrs)
    2879            0 :             d = d->declarator;
    2880           84 :           if (d->kind != cdk_id)
    2881              :             {
    2882            1 :               error_at (here,
    2883              :                         "%<auto%> requires a plain identifier, possibly with"
    2884              :                         " attributes, as declarator");
    2885            1 :               c_parser_skip_to_end_of_block_or_statement (parser);
    2886            1 :               return result;
    2887              :             }
    2888           83 :           underspec_name = d->u.id.id;
    2889              :         }
    2890     66509499 :       else if (specs->constexpr_p)
    2891              :         {
    2892              :           struct c_declarator *d = declarator;
    2893          462 :           while (d->kind != cdk_id)
    2894           79 :             d = d->declarator;
    2895          383 :           underspec_name = d->u.id.id;
    2896              :         }
    2897     66509582 :       if (c_parser_next_token_is (parser, CPP_EQ)
    2898     60078893 :           || c_parser_next_token_is (parser, CPP_COMMA)
    2899     59764743 :           || c_parser_next_token_is (parser, CPP_SEMICOLON)
    2900     51590536 :           || c_parser_next_token_is_keyword (parser, RID_ASM)
    2901     50709344 :           || c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE)
    2902    104223661 :           || c_parser_next_token_is_keyword (parser, RID_IN))
    2903              :         {
    2904     28795503 :           tree asm_name = NULL_TREE;
    2905     28795503 :           tree postfix_attrs = NULL_TREE;
    2906     28795503 :           if (!diagnosed_no_specs && !specs->declspecs_seen_p)
    2907              :             {
    2908           79 :               diagnosed_no_specs = true;
    2909           79 :               pedwarn (here, 0, "data definition has no type or storage class");
    2910              :             }
    2911              :           /* Having seen a data definition, there cannot now be a
    2912              :              function definition.  */
    2913     28795503 :           fndef_ok = false;
    2914     28795503 :           if (c_parser_next_token_is_keyword (parser, RID_ASM))
    2915       881192 :             asm_name = c_parser_simple_asm_expr (parser);
    2916     28795503 :           if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
    2917              :             {
    2918     13823670 :               postfix_attrs = c_parser_gnu_attributes (parser);
    2919     13823670 :               if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
    2920              :                 {
    2921              :                   /* This means there is an attribute specifier after
    2922              :                      the declarator in a function definition.  Provide
    2923              :                      some more information for the user.  */
    2924            1 :                   error_at (here, "attributes should be specified before the "
    2925              :                             "declarator in a function definition");
    2926            1 :                   c_parser_skip_to_end_of_block_or_statement (parser);
    2927            1 :                   return result;
    2928              :                 }
    2929              :             }
    2930     28795502 :           if (c_parser_next_token_is (parser, CPP_EQ))
    2931              :             {
    2932      6432175 :               tree d;
    2933      6432175 :               struct c_expr init;
    2934      6432175 :               location_t init_loc;
    2935      6432175 :               c_parser_consume_token (parser);
    2936      6432175 :               if (any_auto_type_p)
    2937              :                 {
    2938         1969 :                   init_loc = c_parser_peek_token (parser)->location;
    2939         1969 :                   rich_location richloc (line_table, init_loc);
    2940         1969 :                   unsigned int underspec_state = 0;
    2941         1969 :                   if (std_auto_type_p)
    2942           81 :                     underspec_state =
    2943           81 :                       start_underspecified_init (init_loc, underspec_name);
    2944         3874 :                   start_init (NULL_TREE, asm_name,
    2945         1969 :                               (global_bindings_p ()
    2946         1905 :                                || specs->storage_class == csc_static
    2947         1903 :                                || specs->constexpr_p),
    2948              :                               specs->constexpr_p, &richloc);
    2949              :                   /* A parameter is initialized, which is invalid.  Don't
    2950              :                      attempt to instrument the initializer.  */
    2951         1969 :                   sanitize_code_type flag_sanitize_save = flag_sanitize;
    2952         1969 :                   if (nested && !empty_ok)
    2953           30 :                     flag_sanitize = 0;
    2954         1969 :                   init = c_parser_expr_no_commas (parser, NULL);
    2955         1969 :                   if (std_auto_type_p)
    2956           81 :                     finish_underspecified_init (underspec_name,
    2957              :                                                 underspec_state);
    2958         1969 :                   flag_sanitize = flag_sanitize_save;
    2959         1969 :                   if (gnu_auto_type_p
    2960         1888 :                       && TREE_CODE (init.value) == COMPONENT_REF
    2961         1970 :                       && DECL_C_BIT_FIELD (TREE_OPERAND (init.value, 1)))
    2962            1 :                     error_at (here,
    2963              :                               "%<__auto_type%> used with a bit-field"
    2964              :                               " initializer");
    2965         1969 :                   init = convert_lvalue_to_rvalue (init_loc, init, true, true,
    2966              :                                                    true);
    2967         1969 :                   tree init_type = TREE_TYPE (init.value);
    2968         1969 :                   bool vm_type = c_type_variably_modified_p (init_type);
    2969         1969 :                   if (vm_type)
    2970           95 :                     init.value = save_expr (init.value);
    2971         1969 :                   finish_init ();
    2972         1969 :                   specs->typespec_kind = ctsk_typeof;
    2973         1969 :                   specs->locations[cdw_typedef] = init_loc;
    2974         1969 :                   specs->typedef_p = true;
    2975         1969 :                   specs->type = init_type;
    2976         1969 :                   if (specs->postfix_attrs)
    2977              :                     {
    2978              :                       /* Postfix [[]] attributes are valid with C23
    2979              :                          auto, although not with __auto_type, and
    2980              :                          modify the type given by the initializer.  */
    2981            2 :                       specs->postfix_attrs
    2982            2 :                         = c_warn_type_attributes (specs->type,
    2983              :                                                   specs->postfix_attrs);
    2984            2 :                       decl_attributes (&specs->type, specs->postfix_attrs, 0);
    2985            2 :                       specs->postfix_attrs = NULL_TREE;
    2986              :                     }
    2987         1969 :                   if (vm_type)
    2988              :                     {
    2989           95 :                       bool maybe_const = true;
    2990           95 :                       tree type_expr = c_fully_fold (init.value, false,
    2991              :                                                      &maybe_const);
    2992           95 :                       specs->expr_const_operands &= maybe_const;
    2993           95 :                       if (specs->expr)
    2994            0 :                         specs->expr = build2 (COMPOUND_EXPR,
    2995            0 :                                               TREE_TYPE (type_expr),
    2996              :                                               specs->expr, type_expr);
    2997              :                       else
    2998              :                         specs->expr = type_expr;
    2999              :                     }
    3000         1969 :                   d = start_decl (declarator, specs, true,
    3001              :                                   chainon (postfix_attrs, all_prefix_attrs));
    3002         1969 :                   if (!d)
    3003           12 :                     d = error_mark_node;
    3004         1969 :                   if (omp_declare_simd_clauses)
    3005            0 :                     c_finish_omp_declare_simd (parser, d, NULL_TREE,
    3006              :                                                omp_declare_simd_clauses);
    3007         1969 :                   if (!omp_dsimd_idattr_clauses.is_empty ())
    3008            0 :                     c_finish_omp_declare_simd (parser, d, NULL_TREE,
    3009              :                                                &omp_dsimd_idattr_clauses);
    3010         1969 :                 }
    3011              :               else
    3012              :                 {
    3013              :                   /* The declaration of the variable is in effect while
    3014              :                      its initializer is parsed, except for a constexpr
    3015              :                      variable.  */
    3016      6430206 :                   init_loc = c_parser_peek_token (parser)->location;
    3017      6430206 :                   rich_location richloc (line_table, init_loc);
    3018      6430206 :                   unsigned int underspec_state = 0;
    3019      6430206 :                   if (specs->constexpr_p)
    3020          378 :                     underspec_state =
    3021          378 :                       start_underspecified_init (init_loc, underspec_name);
    3022      6430206 :                   d = start_decl (declarator, specs, true,
    3023              :                                   chainon (postfix_attrs,
    3024              :                                            all_prefix_attrs),
    3025      6430206 :                                   !specs->constexpr_p);
    3026      6430206 :                   if (!d)
    3027            4 :                     d = error_mark_node;
    3028      6430206 :                   if (!specs->constexpr_p && omp_declare_simd_clauses)
    3029            0 :                     c_finish_omp_declare_simd (parser, d, NULL_TREE,
    3030              :                                                omp_declare_simd_clauses);
    3031      6430206 :                   if (!specs->constexpr_p
    3032      6430206 :                       && !omp_dsimd_idattr_clauses.is_empty ())
    3033            0 :                     c_finish_omp_declare_simd (parser, d, NULL_TREE,
    3034              :                                                &omp_dsimd_idattr_clauses);
    3035      6430206 :                   start_init (d, asm_name,
    3036      6430206 :                               TREE_STATIC (d) || specs->constexpr_p,
    3037              :                               specs->constexpr_p, &richloc);
    3038              :                   /* A parameter is initialized, which is invalid.  Don't
    3039              :                      attempt to instrument the initializer.  */
    3040      6430206 :                   sanitize_code_type flag_sanitize_save = flag_sanitize;
    3041      6430206 :                   if (TREE_CODE (d) == PARM_DECL)
    3042           35 :                     flag_sanitize = 0;
    3043      6430206 :                   init = c_parser_initializer (parser, d);
    3044      6430204 :                   flag_sanitize = flag_sanitize_save;
    3045      6430204 :                   if (specs->constexpr_p)
    3046              :                     {
    3047          378 :                       finish_underspecified_init (underspec_name,
    3048              :                                                   underspec_state);
    3049          378 :                       d = pushdecl (d);
    3050          378 :                       if (omp_declare_simd_clauses)
    3051            0 :                         c_finish_omp_declare_simd (parser, d, NULL_TREE,
    3052              :                                                    omp_declare_simd_clauses);
    3053          378 :                   if (!specs->constexpr_p
    3054          378 :                       && !omp_dsimd_idattr_clauses.is_empty ())
    3055            0 :                     c_finish_omp_declare_simd (parser, d, NULL_TREE,
    3056              :                                                &omp_dsimd_idattr_clauses);
    3057              :                     }
    3058      6430204 :                   finish_init ();
    3059      6430204 :                 }
    3060      6432173 :               if (oacc_routine_data)
    3061            0 :                 c_finish_oacc_routine (oacc_routine_data, d, false);
    3062      6432173 :               if (d != error_mark_node)
    3063              :                 {
    3064      6432157 :                   maybe_warn_string_init (init_loc, TREE_TYPE (d), init);
    3065      6432157 :                   finish_decl (d, init_loc, init.value,
    3066              :                                init.original_type, asm_name);
    3067      6432157 :                   result = d;
    3068              :                 }
    3069              :             }
    3070              :           else
    3071              :             {
    3072     22363327 :               if (any_auto_type_p || specs->constexpr_p)
    3073              :                 {
    3074            8 :                   error_at (here,
    3075              :                             "%qs requires an initialized data declaration",
    3076              :                             any_auto_type_p ? auto_type_keyword : "constexpr");
    3077            5 :                   c_parser_skip_to_end_of_block_or_statement (parser);
    3078            5 :                   return result;
    3079              :                 }
    3080              : 
    3081     22363322 :               location_t lastloc = UNKNOWN_LOCATION;
    3082     22363322 :               tree attrs = chainon (postfix_attrs, all_prefix_attrs);
    3083     22363322 :               tree d = start_decl (declarator, specs, false, attrs, true,
    3084              :                                    &lastloc);
    3085     22363321 :               if (d && TREE_CODE (d) == FUNCTION_DECL)
    3086              :                 {
    3087              :                   /* Find the innermost declarator that is neither cdk_id
    3088              :                      nor cdk_attrs.  */
    3089              :                   const struct c_declarator *decl = declarator;
    3090              :                   const struct c_declarator *last_non_id_attrs = NULL;
    3091              : 
    3092     31175987 :                   while (decl)
    3093     31175987 :                     switch (decl->kind)
    3094              :                       {
    3095     15816837 :                       case cdk_array:
    3096     15816837 :                       case cdk_function:
    3097     15816837 :                       case cdk_pointer:
    3098     15816837 :                         last_non_id_attrs = decl;
    3099     15816837 :                         decl = decl->declarator;
    3100     15816837 :                         break;
    3101              : 
    3102          119 :                       case cdk_attrs:
    3103          119 :                         decl = decl->declarator;
    3104          119 :                         break;
    3105              : 
    3106              :                       case cdk_id:
    3107              :                         decl = 0;
    3108              :                         break;
    3109              : 
    3110            0 :                       default:
    3111            0 :                         gcc_unreachable ();
    3112              :                       }
    3113              : 
    3114              :                   /* If it exists and is cdk_function declaration whose
    3115              :                      arguments have not been set yet, use its arguments.  */
    3116     15359031 :                   if (last_non_id_attrs
    3117     14738040 :                       && last_non_id_attrs->kind == cdk_function)
    3118              :                     {
    3119     14738040 :                       tree parms = last_non_id_attrs->u.arg_info->parms;
    3120     14738040 :                       if (DECL_ARGUMENTS (d) == NULL_TREE
    3121     14738040 :                           && DECL_INITIAL (d) == NULL_TREE)
    3122     14205030 :                         DECL_ARGUMENTS (d) = parms;
    3123              : 
    3124     14738040 :                       warn_parms_array_mismatch (lastloc, d, parms);
    3125              :                     }
    3126              :                 }
    3127     22363321 :               if (omp_declare_simd_clauses
    3128     22363321 :                   || !omp_dsimd_idattr_clauses.is_empty ())
    3129              :                 {
    3130          507 :                   tree parms = NULL_TREE;
    3131          507 :                   if (d && TREE_CODE (d) == FUNCTION_DECL)
    3132              :                     {
    3133              :                       struct c_declarator *ce = declarator;
    3134          496 :                       while (ce != NULL)
    3135          496 :                         if (ce->kind == cdk_function)
    3136              :                           {
    3137          493 :                             parms = ce->u.arg_info->parms;
    3138          493 :                             break;
    3139              :                           }
    3140              :                         else
    3141            3 :                           ce = ce->declarator;
    3142              :                     }
    3143          493 :                   if (parms)
    3144          267 :                     temp_store_parm_decls (d, parms);
    3145          507 :                   if (omp_declare_simd_clauses)
    3146          487 :                     c_finish_omp_declare_simd (parser, d, parms,
    3147              :                                                omp_declare_simd_clauses);
    3148          507 :                   if (!specs->constexpr_p
    3149          507 :                       && !omp_dsimd_idattr_clauses.is_empty ())
    3150           22 :                     c_finish_omp_declare_simd (parser, d, parms,
    3151              :                                                &omp_dsimd_idattr_clauses);
    3152          507 :                   if (parms)
    3153          267 :                     temp_pop_parm_decls ();
    3154              :                 }
    3155     22363321 :               if (oacc_routine_data)
    3156           72 :                 c_finish_oacc_routine (oacc_routine_data, d, false);
    3157     22363321 :               if (d)
    3158     22363313 :                 finish_decl (d, UNKNOWN_LOCATION, NULL_TREE,
    3159              :                              NULL_TREE, asm_name);
    3160              : 
    3161     22363321 :               if (c_parser_next_token_is_keyword (parser, RID_IN))
    3162              :                 {
    3163            0 :                   if (d)
    3164            0 :                     *objc_foreach_object_declaration = d;
    3165              :                   else
    3166            0 :                     *objc_foreach_object_declaration = error_mark_node;
    3167              :                 }
    3168              :             }
    3169     28795494 :           if (c_parser_next_token_is (parser, CPP_COMMA))
    3170              :             {
    3171       432834 :               more_than_one_decl = true;
    3172       432834 :               if (any_auto_type_p || specs->constexpr_p)
    3173              :                 {
    3174            4 :                   error_at (here,
    3175              :                             "%qs may only be used with a single declarator",
    3176              :                             any_auto_type_p ? auto_type_keyword : "constexpr");
    3177            3 :                   c_parser_skip_to_end_of_block_or_statement (parser);
    3178            3 :                   return result;
    3179              :                 }
    3180       432831 :               c_parser_consume_token (parser);
    3181       432831 :               if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
    3182           19 :                 all_prefix_attrs = chainon (c_parser_gnu_attributes (parser),
    3183              :                                             prefix_attrs);
    3184              :               else
    3185              :                 all_prefix_attrs = prefix_attrs;
    3186       432831 :               continue;
    3187              :             }
    3188     28362660 :           else if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    3189              :             {
    3190     28362515 :               if (!simple_ok)
    3191     28362416 :                 c_parser_consume_token (parser);
    3192              :               return result;
    3193              :             }
    3194          145 :           else if (c_parser_next_token_is_keyword (parser, RID_IN))
    3195              :             {
    3196              :               /* This can only happen in Objective-C: we found the
    3197              :                  'in' that terminates the declaration inside an
    3198              :                  Objective-C foreach statement.  Do not consume the
    3199              :                  token, so that the caller can use it to determine
    3200              :                  that this indeed is a foreach context.  */
    3201              :               return result;
    3202              :             }
    3203              :           else
    3204              :             {
    3205          145 :               if (!simple_ok)
    3206              :                 {
    3207           53 :                   c_parser_error (parser, "expected %<,%> or %<;%>");
    3208           53 :                   c_parser_skip_to_end_of_block_or_statement (parser);
    3209              :                 }
    3210              :               /* It's not valid to use if (int i = 2, j = 3).  */
    3211           92 :               else if (more_than_one_decl)
    3212            4 :                 error_at (here, "declaration in condition can only declare "
    3213              :                           "a single object");
    3214              :               return result;
    3215              :             }
    3216              :         }
    3217     37714079 :       else if (any_auto_type_p || specs->constexpr_p)
    3218              :         {
    3219            4 :           error_at (here,
    3220              :                     "%qs requires an initialized data declaration",
    3221              :                     any_auto_type_p ? auto_type_keyword : "constexpr");
    3222            4 :           c_parser_skip_to_end_of_block_or_statement (parser);
    3223            4 :           return result;
    3224              :         }
    3225     37714075 :       else if (!fndef_ok)
    3226              :         {
    3227           74 :           if (simple_ok && c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    3228              :             /* Let c_parser_selection_header emit the error.  */;
    3229              :           else
    3230              :             {
    3231           34 :               c_parser_error (parser, "expected %<=%>, %<,%>, %<;%>, "
    3232              :                               "%<asm%> or %<__attribute__%>");
    3233           34 :               c_parser_skip_to_end_of_block_or_statement (parser);
    3234              :             }
    3235              :           return result;
    3236              :         }
    3237              :       /* Function definition (nested or otherwise).  */
    3238     37714021 :       if (nested)
    3239              :         {
    3240         1627 :           pedwarn (here, OPT_Wpedantic, "ISO C forbids nested functions");
    3241         1627 :           c_push_function_context ();
    3242              :         }
    3243              : 
    3244              :       /* If we're in an OpenMP "begin declare variant" block, the
    3245              :          name in the declarator refers to the base function.  We need
    3246              :          to save that and modify the declarator to have the mangled
    3247              :          name for the variant function instead.  */
    3248     37714021 :       tree dv_base = NULL_TREE;
    3249     37714021 :       tree dv_ctx = NULL_TREE;
    3250     37714021 :       if (!vec_safe_is_empty (current_omp_declare_variant_attribute))
    3251              :         {
    3252           26 :           c_omp_declare_variant_attr a
    3253           26 :             = current_omp_declare_variant_attribute->last ();
    3254           26 :           dv_ctx = copy_list (a.selector);
    3255           26 :           dv_base = omp_start_variant_function (declarator, dv_ctx);
    3256              :         }
    3257              : 
    3258     37714021 :       if (!start_function (specs, declarator, all_prefix_attrs))
    3259              :         {
    3260              :           /* At this point we've consumed:
    3261              :                declaration-specifiers declarator
    3262              :              and the next token isn't CPP_EQ, CPP_COMMA, CPP_SEMICOLON,
    3263              :              RID_ASM, RID_ATTRIBUTE, or RID_IN,
    3264              :              but the
    3265              :                declaration-specifiers declarator
    3266              :              aren't grokkable as a function definition, so we have
    3267              :              an error.  */
    3268           36 :           gcc_assert (!c_parser_next_token_is (parser, CPP_SEMICOLON));
    3269           36 :           if (c_parser_next_token_starts_declspecs (parser))
    3270              :             {
    3271              :               /* If we have
    3272              :                    declaration-specifiers declarator decl-specs
    3273              :                  then assume we have a missing semicolon, which would
    3274              :                  give us:
    3275              :                    declaration-specifiers declarator  decl-specs
    3276              :                                                     ^
    3277              :                                                     ;
    3278              :                    <~~~~~~~~~ declaration ~~~~~~~~~~>
    3279              :                  Use c_parser_require to get an error with a fix-it hint.  */
    3280           13 :               c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>");
    3281           13 :               parser->error = false;
    3282              :             }
    3283              :           else
    3284              :             {
    3285              :               /* This can appear in many cases looking nothing like a
    3286              :                  function definition, so we don't give a more specific
    3287              :                  error suggesting there was one.  */
    3288           23 :               c_parser_error (parser, "expected %<=%>, %<,%>, %<;%>, %<asm%> "
    3289              :                               "or %<__attribute__%>");
    3290              :             }
    3291           36 :           if (nested)
    3292            1 :             c_pop_function_context ();
    3293              :           break;
    3294              :         }
    3295              : 
    3296     37713985 :       if (DECL_DECLARED_INLINE_P (current_function_decl))
    3297              :         tv = TV_PARSE_INLINE;
    3298              :       else
    3299       709329 :         tv = TV_PARSE_FUNC;
    3300     37713985 :       auto_timevar at (g_timer, tv);
    3301              : 
    3302              :       /* Parse old-style parameter declarations.  ??? Attributes are
    3303              :          not allowed to start declaration specifiers here because of a
    3304              :          syntax conflict between a function declaration with attribute
    3305              :          suffix and a function definition with an attribute prefix on
    3306              :          first old-style parameter declaration.  Following the old
    3307              :          parser, they are not accepted on subsequent old-style
    3308              :          parameter declarations either.  However, there is no
    3309              :          ambiguity after the first declaration, nor indeed on the
    3310              :          first as long as we don't allow postfix attributes after a
    3311              :          declarator with a nonempty identifier list in a definition;
    3312              :          and postfix attributes have never been accepted here in
    3313              :          function definitions either.  */
    3314     37713985 :       int save_debug_nonbind_markers_p = debug_nonbind_markers_p;
    3315     37713985 :       debug_nonbind_markers_p = 0;
    3316     37713985 :       c_parser_maybe_reclassify_token (parser);
    3317     37713985 :       while (c_parser_next_token_is_not (parser, CPP_EOF)
    3318     75453910 :              && c_parser_next_token_is_not (parser, CPP_OPEN_BRACE))
    3319        12978 :         c_parser_declaration_or_fndef (parser, false, false, false,
    3320              :                                        true, false, false);
    3321     37713985 :       debug_nonbind_markers_p = save_debug_nonbind_markers_p;
    3322     37713985 :       store_parm_decls ();
    3323     37713985 :       if (omp_declare_simd_clauses)
    3324          375 :         c_finish_omp_declare_simd (parser, current_function_decl, NULL_TREE,
    3325              :                                    omp_declare_simd_clauses);
    3326     37713985 :       if (!omp_dsimd_idattr_clauses.is_empty ())
    3327            4 :         c_finish_omp_declare_simd (parser, current_function_decl, NULL_TREE,
    3328              :                                    &omp_dsimd_idattr_clauses);
    3329     37713985 :       if (oacc_routine_data)
    3330          130 :         c_finish_oacc_routine (oacc_routine_data, current_function_decl, true);
    3331     37713985 :       location_t startloc = c_parser_peek_token (parser)->location;
    3332     37713985 :       DECL_STRUCT_FUNCTION (current_function_decl)->function_start_locus
    3333     37713985 :         = startloc;
    3334     37713985 :       location_t endloc = startloc;
    3335              :       /* If this function was in a "begin declare variant" block,
    3336              :          remember it.  We will associate it with the base function at
    3337              :          the end of processing the translation unit, since it is permitted
    3338              :          for the variant definition to appear before the base declaration.  */
    3339     37713985 :       if (dv_base && current_function_decl != error_mark_node)
    3340              :         {
    3341           26 :           omp_begin_declare_variant_map_entry e
    3342           26 :             = { current_function_decl, dv_base, dv_ctx };
    3343           26 :           vec_safe_push (omp_begin_declare_variant_map, e);
    3344              :         }
    3345              : 
    3346              :       /* If the definition was marked with __RTL, use the RTL parser now,
    3347              :          consuming the function body.  */
    3348     37713985 :       if (specs->declspec_il == cdil_rtl)
    3349              :         {
    3350           39 :           endloc = c_parser_parse_rtl_body (parser, specs->gimple_or_rtl_pass);
    3351              : 
    3352              :           /* Normally, store_parm_decls sets next_is_function_body,
    3353              :              anticipating a function body.  We need a push_scope/pop_scope
    3354              :              pair to flush out this state, or subsequent function parsing
    3355              :              will go wrong.  */
    3356           38 :           push_scope ();
    3357           38 :           pop_scope ();
    3358              : 
    3359           38 :           finish_function (endloc);
    3360           38 :           return result;
    3361              :         }
    3362              :       /* If the definition was marked with __GIMPLE then parse the
    3363              :          function body as GIMPLE.  */
    3364     37713946 :       else if (specs->declspec_il != cdil_none)
    3365              :         {
    3366         1088 :           bool saved = in_late_binary_op;
    3367         1088 :           in_late_binary_op = true;
    3368         1088 :           c_parser_parse_gimple_body (parser, specs->gimple_or_rtl_pass,
    3369         1088 :                                       specs->declspec_il,
    3370              :                                       specs->entry_bb_count);
    3371         1088 :           in_late_binary_op = saved;
    3372              :         }
    3373              :       else
    3374     37712858 :         fnbody = c_parser_compound_statement (parser, &endloc);
    3375     37713945 :       tree fndecl = current_function_decl;
    3376     37713945 :       if (nested && specs->declspec_il == cdil_none)
    3377              :         {
    3378         1625 :           tree decl = current_function_decl;
    3379         1625 :           add_stmt (fnbody);
    3380         1625 :           finish_function (endloc);
    3381         1625 :           c_pop_function_context ();
    3382         1625 :           add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl));
    3383         1625 :         }
    3384            1 :       else if (nested)
    3385              :         {
    3386            1 :           if (specs->declspec_il == cdil_rtl)
    3387            0 :             error ("%<__RTL%> function cannot be a nested function");
    3388              :           else
    3389            1 :             error ("%<__GIMPLE%> function cannot be a nested function");
    3390            1 :           finish_function (endloc);
    3391            1 :           c_pop_function_context ();
    3392              :         }
    3393              :       else
    3394              :         {
    3395     37712319 :           if (fnbody)
    3396     37711232 :             add_stmt (fnbody);
    3397     37712319 :           finish_function (endloc);
    3398              :         }
    3399              :       /* Get rid of the empty stmt list for GIMPLE/RTL.  */
    3400     37713945 :       if (specs->declspec_il != cdil_none)
    3401         1088 :         DECL_SAVED_TREE (fndecl) = NULL_TREE;
    3402              : 
    3403     37713945 :       break;
    3404     28795855 :     }
    3405              : 
    3406     37713981 :   return result;
    3407              : }
    3408              : 
    3409              : /* Parse an asm-definition (asm() outside a function body).  This is a
    3410              :    GNU extension.
    3411              : 
    3412              :    asm-definition:
    3413              :      simple-asm-expr ;
    3414              :      asm ( toplevel-asm-argument ) ;
    3415              : 
    3416              :    toplevel-asm-argument:
    3417              :      asm-string-literal
    3418              :      asm-string-literal : asm-operands[opt]
    3419              :      asm-string-literal : asm-operands[opt] : asm-operands[opt]
    3420              : 
    3421              :    The :: token is considered equivalent to two consecutive : tokens.  */
    3422              : 
    3423              : static void
    3424          214 : c_parser_asm_definition (c_parser *parser)
    3425              : {
    3426          214 :   location_t asm_loc = c_parser_peek_token (parser)->location;
    3427          214 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_ASM));
    3428          214 :   c_parser_consume_token (parser);
    3429          214 :   matching_parens parens;
    3430          214 :   tree asm_str = NULL_TREE;
    3431          214 :   tree outputs = NULL_TREE, inputs = NULL_TREE;
    3432          214 :   if (!parens.require_open (parser))
    3433            5 :     goto done;
    3434          209 :   asm_str = c_parser_asm_string_literal (parser);
    3435          209 :   if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    3436              :     {
    3437          154 :       parens.require_close (parser);
    3438          154 :       goto done;
    3439              :     }
    3440           73 :   for (int section = 0; section < 2; ++section)
    3441              :     {
    3442           71 :       if (c_parser_next_token_is (parser, CPP_SCOPE))
    3443              :         {
    3444           29 :           ++section;
    3445           29 :           if (section == 2)
    3446              :             {
    3447            0 :               c_parser_error (parser, "expected %<)%>");
    3448            1 :             error_close_paren:
    3449            1 :               c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
    3450            1 :               asm_str = NULL_TREE;
    3451            1 :               goto done;
    3452              :             }
    3453           29 :           c_parser_consume_token (parser);
    3454              :         }
    3455           42 :       else if (!c_parser_require (parser, CPP_COLON,
    3456              :                                   "expected %<:%> or %<)%>",
    3457              :                                   UNKNOWN_LOCATION, false))
    3458            1 :         goto error_close_paren;
    3459           70 :       if (!c_parser_next_token_is (parser, CPP_COLON)
    3460           56 :           && !c_parser_next_token_is (parser, CPP_SCOPE)
    3461          126 :           && !c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    3462              :         {
    3463           56 :           if (section)
    3464           45 :             inputs = c_parser_asm_operands (parser);
    3465              :           else
    3466           11 :             outputs = c_parser_asm_operands (parser);
    3467              :         }
    3468           70 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    3469              :         break;
    3470              :     }
    3471              : 
    3472           54 :   if (!parens.require_close (parser))
    3473              :     {
    3474            2 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
    3475            2 :       asm_str = NULL_TREE;
    3476              :     }
    3477              : 
    3478           54 :   if (asm_str)
    3479           52 :     asm_str = build_asm_expr (asm_loc, asm_str, outputs, inputs,
    3480              :                               NULL_TREE, NULL_TREE, false, false);
    3481          212 : done:
    3482          212 :   if (asm_str)
    3483          206 :     symtab->finalize_toplevel_asm (asm_str);
    3484          214 :   c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
    3485          214 : }
    3486              : 
    3487              : /* Parse a static assertion (C11 6.7.10).
    3488              : 
    3489              :    static_assert-declaration:
    3490              :      static_assert-declaration-no-semi ;
    3491              : */
    3492              : 
    3493              : static void
    3494         3201 : c_parser_static_assert_declaration (c_parser *parser)
    3495              : {
    3496         3201 :   c_parser_static_assert_declaration_no_semi (parser);
    3497         3201 :   if (parser->error
    3498         3201 :       || !c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
    3499            8 :     c_parser_skip_to_end_of_block_or_statement (parser);
    3500         3201 : }
    3501              : 
    3502              : /* Parse a static assertion (C11 6.7.10), without the trailing
    3503              :    semicolon.
    3504              : 
    3505              :    static_assert-declaration-no-semi:
    3506              :      _Static_assert ( constant-expression , string-literal )
    3507              : 
    3508              :    C23:
    3509              :    static_assert-declaration-no-semi:
    3510              :      _Static_assert ( constant-expression )
    3511              : */
    3512              : 
    3513              : static void
    3514         3386 : c_parser_static_assert_declaration_no_semi (c_parser *parser)
    3515              : {
    3516         3386 :   location_t assert_loc, value_loc;
    3517         3386 :   tree value;
    3518         3386 :   tree string = NULL_TREE;
    3519              : 
    3520         3386 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_STATIC_ASSERT));
    3521         3386 :   tree spelling = c_parser_peek_token (parser)->value;
    3522         3386 :   assert_loc = c_parser_peek_token (parser)->location;
    3523         3386 :   if (flag_isoc99)
    3524         3382 :     pedwarn_c99 (assert_loc, OPT_Wpedantic,
    3525              :                  "ISO C99 does not support %qE", spelling);
    3526              :   else
    3527            4 :     pedwarn_c99 (assert_loc, OPT_Wpedantic,
    3528              :                  "ISO C90 does not support %qE", spelling);
    3529         3386 :   c_parser_consume_token (parser);
    3530         3386 :   matching_parens parens;
    3531         3386 :   if (!parens.require_open (parser))
    3532           15 :     return;
    3533         3385 :   location_t value_tok_loc = c_parser_peek_token (parser)->location;
    3534         3385 :   value = convert_lvalue_to_rvalue (value_tok_loc,
    3535              :                                     c_parser_expr_no_commas (parser, NULL),
    3536              :                                     true, true).value;
    3537         3385 :   value_loc = EXPR_LOC_OR_LOC (value, value_tok_loc);
    3538         3385 :   if (c_parser_next_token_is (parser, CPP_COMMA))
    3539              :     {
    3540         2665 :       c_parser_consume_token (parser);
    3541         2665 :       switch (c_parser_peek_token (parser)->type)
    3542              :         {
    3543         2662 :         case CPP_STRING:
    3544         2662 :         case CPP_STRING16:
    3545         2662 :         case CPP_STRING32:
    3546         2662 :         case CPP_WSTRING:
    3547         2662 :         case CPP_UTF8STRING:
    3548         2662 :           string = c_parser_string_literal (parser, false, true).value;
    3549         2662 :           break;
    3550            3 :         default:
    3551            3 :           c_parser_error (parser, "expected string literal");
    3552            3 :           return;
    3553              :         }
    3554              :     }
    3555          720 :   else if (flag_isoc11)
    3556              :     /* If pedantic for pre-C11, the use of _Static_assert itself will
    3557              :        have been diagnosed, so do not also diagnose the use of this
    3558              :        new C23 feature of _Static_assert.  */
    3559          718 :     pedwarn_c11 (assert_loc, OPT_Wpedantic,
    3560              :                  "ISO C11 does not support omitting the string in "
    3561              :                  "%qE", spelling);
    3562         3382 :   parens.require_close (parser);
    3563              : 
    3564         3382 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (value)))
    3565              :     {
    3566            5 :       error_at (value_loc, "expression in static assertion is not an integer");
    3567            5 :       return;
    3568              :     }
    3569         3377 :   if (TREE_CODE (value) != INTEGER_CST)
    3570              :     {
    3571           12 :       value = c_fully_fold (value, false, NULL);
    3572              :       /* Strip no-op conversions.  */
    3573           24 :       STRIP_TYPE_NOPS (value);
    3574           12 :       if (TREE_CODE (value) == INTEGER_CST)
    3575            6 :         pedwarn (value_loc, OPT_Wpedantic, "expression in static assertion "
    3576              :                  "is not an integer constant expression");
    3577              :     }
    3578         3377 :   if (TREE_CODE (value) != INTEGER_CST)
    3579              :     {
    3580            6 :       error_at (value_loc, "expression in static assertion is not constant");
    3581            6 :       return;
    3582              :     }
    3583         3371 :   constant_expression_warning (value);
    3584         3371 :   if (integer_zerop (value))
    3585              :     {
    3586           41 :       if (string)
    3587           22 :         error_at (assert_loc, "static assertion failed: %E", string);
    3588              :       else
    3589           19 :         error_at (assert_loc, "static assertion failed");
    3590              :     }
    3591              : }
    3592              : 
    3593              : /* Parse some declaration specifiers (possibly none) (C90 6.5, C99
    3594              :    6.7, C11 6.7), adding them to SPECS (which may already include some).
    3595              :    Storage class specifiers are accepted iff SCSPEC_OK; type
    3596              :    specifiers are accepted iff TYPESPEC_OK; alignment specifiers are
    3597              :    accepted iff ALIGNSPEC_OK; gnu-attributes are accepted at the start
    3598              :    iff START_ATTR_OK; __auto_type is accepted iff AUTO_TYPE_OK.  In
    3599              :    addition to the syntax shown, standard attributes are accepted at
    3600              :    the start iff START_STD_ATTR_OK and at the end iff END_STD_ATTR_OK;
    3601              :    unlike gnu-attributes, they are not accepted in the middle of the
    3602              :    list.  (This combines various different syntax productions in the C
    3603              :    standard, and in some cases gnu-attributes and standard attributes
    3604              :    at the start may already have been parsed before this function is
    3605              :    called.)
    3606              : 
    3607              :    declaration-specifiers:
    3608              :      storage-class-specifier declaration-specifiers[opt]
    3609              :      type-specifier declaration-specifiers[opt]
    3610              :      type-qualifier declaration-specifiers[opt]
    3611              :      function-specifier declaration-specifiers[opt]
    3612              :      alignment-specifier declaration-specifiers[opt]
    3613              : 
    3614              :    Function specifiers (inline) are from C99, and are currently
    3615              :    handled as storage class specifiers, as is __thread.  Alignment
    3616              :    specifiers are from C11.
    3617              : 
    3618              :    C90 6.5.1, C99 6.7.1, C11 6.7.1:
    3619              :    storage-class-specifier:
    3620              :      typedef
    3621              :      extern
    3622              :      static
    3623              :      auto
    3624              :      register
    3625              :      _Thread_local
    3626              : 
    3627              :    (_Thread_local is new in C11.)
    3628              : 
    3629              :    C99 6.7.4, C11 6.7.4:
    3630              :    function-specifier:
    3631              :      inline
    3632              :      _Noreturn
    3633              : 
    3634              :    (_Noreturn is new in C11.)
    3635              : 
    3636              :    C90 6.5.2, C99 6.7.2, C11 6.7.2:
    3637              :    type-specifier:
    3638              :      void
    3639              :      char
    3640              :      short
    3641              :      int
    3642              :      long
    3643              :      float
    3644              :      double
    3645              :      signed
    3646              :      unsigned
    3647              :      _Bool
    3648              :      _Complex
    3649              :      [_Imaginary removed in C99 TC2]
    3650              :      _BitInt ( constant-expression )
    3651              :      struct-or-union-specifier
    3652              :      enum-specifier
    3653              :      typedef-name
    3654              :      atomic-type-specifier
    3655              : 
    3656              :    (_Bool and _Complex are new in C99.)
    3657              :    (atomic-type-specifier is new in C11.)
    3658              :    (_BitInt is new in C23.)
    3659              : 
    3660              :    C90 6.5.3, C99 6.7.3, C11 6.7.3:
    3661              : 
    3662              :    type-qualifier:
    3663              :      const
    3664              :      restrict
    3665              :      volatile
    3666              :      address-space-qualifier
    3667              :      _Atomic
    3668              : 
    3669              :    (restrict is new in C99.)
    3670              :    (_Atomic is new in C11.)
    3671              : 
    3672              :    GNU extensions:
    3673              : 
    3674              :    declaration-specifiers:
    3675              :      gnu-attributes declaration-specifiers[opt]
    3676              : 
    3677              :    type-qualifier:
    3678              :      address-space
    3679              : 
    3680              :    address-space:
    3681              :      identifier recognized by the target
    3682              : 
    3683              :    storage-class-specifier:
    3684              :      __thread
    3685              : 
    3686              :    type-specifier:
    3687              :      typeof-specifier
    3688              :      __auto_type
    3689              :      __intN
    3690              :      _Decimal32
    3691              :      _Decimal64
    3692              :      _Decimal128
    3693              :      _Fract
    3694              :      _Accum
    3695              :      _Sat
    3696              : 
    3697              :   (_Fract, _Accum, and _Sat are new from ISO/IEC DTR 18037:
    3698              :    http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf)
    3699              : 
    3700              :    atomic-type-specifier
    3701              :     _Atomic ( type-name )
    3702              : 
    3703              :    Objective-C:
    3704              : 
    3705              :    type-specifier:
    3706              :      class-name objc-protocol-refs[opt]
    3707              :      typedef-name objc-protocol-refs
    3708              :      objc-protocol-refs
    3709              : */
    3710              : 
    3711              : void
    3712    346042146 : c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
    3713              :                     bool scspec_ok, bool typespec_ok, bool start_attr_ok,
    3714              :                     bool alignspec_ok, bool auto_type_ok,
    3715              :                     bool start_std_attr_ok, bool end_std_attr_ok,
    3716              :                     enum c_lookahead_kind la)
    3717              : {
    3718    346042146 :   bool attrs_ok = start_attr_ok;
    3719    346042146 :   bool seen_type = specs->typespec_kind != ctsk_none;
    3720              : 
    3721    346042146 :   if (!typespec_ok)
    3722     19999608 :     gcc_assert (la == cla_prefer_id);
    3723              : 
    3724    346042146 :   if (start_std_attr_ok
    3725    346042146 :       && c_parser_nth_token_starts_std_attributes (parser, 1))
    3726              :     {
    3727         1818 :       gcc_assert (!specs->non_std_attrs_seen_p);
    3728         1818 :       location_t loc = c_parser_peek_token (parser)->location;
    3729         1818 :       tree attrs = c_parser_std_attribute_specifier_sequence (parser);
    3730         1818 :       declspecs_add_attrs (loc, specs, attrs);
    3731         1818 :       specs->non_std_attrs_seen_p = false;
    3732              :     }
    3733              : 
    3734    838772217 :   while (c_parser_next_token_is (parser, CPP_NAME)
    3735    389579906 :          || c_parser_next_token_is (parser, CPP_KEYWORD)
    3736    990536668 :          || (c_dialect_objc () && c_parser_next_token_is (parser, CPP_LESS)))
    3737              :     {
    3738    687007766 :       struct c_typespec t;
    3739    687007766 :       tree attrs;
    3740    687007766 :       tree align;
    3741    687007766 :       location_t loc = c_parser_peek_token (parser)->location;
    3742              : 
    3743              :       /* If we cannot accept a type, exit if the next token must start
    3744              :          one.  Also, if we already have seen a tagged definition,
    3745              :          a typename would be an error anyway and likely the user
    3746              :          has simply forgotten a semicolon, so we exit.  */
    3747    670262490 :       if ((!typespec_ok || specs->typespec_kind == ctsk_tagdef)
    3748     17692103 :           && c_parser_next_tokens_start_typename (parser, la)
    3749      3950829 :           && !c_parser_next_token_is_qualifier (parser)
    3750    687007893 :           && !c_parser_next_token_is_keyword (parser, RID_ALIGNAS))
    3751              :         break;
    3752              : 
    3753    687007648 :       if (c_parser_next_token_is (parser, CPP_NAME))
    3754              :         {
    3755    449192205 :           c_token *name_token = c_parser_peek_token (parser);
    3756    449192205 :           tree value = name_token->value;
    3757    449192205 :           c_id_kind kind = name_token->id_kind;
    3758              : 
    3759    449192205 :           if (kind == C_ID_ADDRSPACE)
    3760              :             {
    3761          185 :               addr_space_t as
    3762          185 :                 = name_token->keyword - RID_FIRST_ADDR_SPACE;
    3763          185 :               declspecs_add_addrspace (name_token->location, specs, as);
    3764          185 :               c_parser_consume_token (parser);
    3765          185 :               attrs_ok = true;
    3766    254917366 :               continue;
    3767          185 :             }
    3768              : 
    3769    449192020 :           gcc_assert (!c_parser_next_token_is_qualifier (parser));
    3770              : 
    3771              :           /* If we cannot accept a type, and the next token must start one,
    3772              :              exit.  Do the same if we already have seen a tagged definition,
    3773              :              since it would be an error anyway and likely the user has simply
    3774              :              forgotten a semicolon.  */
    3775    449192020 :           if (seen_type || !c_parser_next_tokens_start_typename (parser, la))
    3776              :             break;
    3777              : 
    3778              :           /* Now at an unknown typename (C_ID_ID), a C_ID_TYPENAME or
    3779              :              a C_ID_CLASSNAME.  */
    3780    254917181 :           c_parser_consume_token (parser);
    3781    254917181 :           seen_type = true;
    3782    254917181 :           attrs_ok = true;
    3783    254917181 :           if (kind == C_ID_ID)
    3784              :             {
    3785           51 :               auto_diagnostic_group d;
    3786           51 :               name_hint hint = lookup_name_fuzzy (value, FUZZY_LOOKUP_TYPENAME,
    3787           51 :                                                   loc);
    3788           51 :               if (const char *suggestion = hint.suggestion ())
    3789              :                 {
    3790            2 :                   gcc_rich_location richloc (loc);
    3791            2 :                   richloc.add_fixit_replace (suggestion);
    3792            2 :                   error_at (&richloc,
    3793              :                             "unknown type name %qE; did you mean %qs?",
    3794              :                             value, suggestion);
    3795            2 :                 }
    3796              :               else
    3797           49 :                 error_at (loc, "unknown type name %qE", value);
    3798           51 :               t.kind = ctsk_typedef;
    3799           51 :               t.spec = error_mark_node;
    3800           51 :             }
    3801    254917130 :           else if (kind == C_ID_TYPENAME
    3802    254917130 :                    && (!c_dialect_objc ()
    3803            0 :                        || c_parser_next_token_is_not (parser, CPP_LESS)))
    3804              :             {
    3805    254917130 :               t.kind = ctsk_typedef;
    3806              :               /* For a typedef name, record the meaning, not the name.
    3807              :                  In case of 'foo foo, bar;'.  */
    3808    254917130 :               t.spec = lookup_name (value);
    3809              :             }
    3810              :           else
    3811              :             {
    3812            0 :               tree proto = NULL_TREE;
    3813            0 :               gcc_assert (c_dialect_objc ());
    3814            0 :               t.kind = ctsk_objc;
    3815            0 :               if (c_parser_next_token_is (parser, CPP_LESS))
    3816            0 :                 proto = c_parser_objc_protocol_refs (parser);
    3817            0 :               t.spec = objc_get_protocol_qualified_type (value, proto);
    3818              :             }
    3819    254917181 :           t.expr = NULL_TREE;
    3820    254917181 :           t.expr_const_operands = true;
    3821    254917181 :           t.has_enum_type_specifier = false;
    3822    254917181 :           declspecs_add_type (name_token->location, specs, t);
    3823    254917181 :           continue;
    3824    254917181 :         }
    3825    237815443 :       if (c_parser_next_token_is (parser, CPP_LESS))
    3826              :         {
    3827              :           /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>" -
    3828              :              nisse@lysator.liu.se.  */
    3829            0 :           tree proto;
    3830            0 :           gcc_assert (c_dialect_objc ());
    3831            0 :           if (!typespec_ok || seen_type)
    3832              :             break;
    3833            0 :           proto = c_parser_objc_protocol_refs (parser);
    3834            0 :           t.kind = ctsk_objc;
    3835            0 :           t.spec = objc_get_protocol_qualified_type (NULL_TREE, proto);
    3836            0 :           t.expr = NULL_TREE;
    3837            0 :           t.expr_const_operands = true;
    3838            0 :           t.has_enum_type_specifier = false;
    3839            0 :           declspecs_add_type (loc, specs, t);
    3840            0 :           continue;
    3841            0 :         }
    3842    237815443 :       gcc_assert (c_parser_next_token_is (parser, CPP_KEYWORD));
    3843    237815443 :       switch (c_parser_peek_token (parser)->keyword)
    3844              :         {
    3845     93903327 :         case RID_STATIC:
    3846     93903327 :         case RID_EXTERN:
    3847     93903327 :         case RID_REGISTER:
    3848     93903327 :         case RID_TYPEDEF:
    3849     93903327 :         case RID_INLINE:
    3850     93903327 :         case RID_NORETURN:
    3851     93903327 :         case RID_AUTO:
    3852     93903327 :         case RID_THREAD:
    3853     93903327 :         case RID_CONSTEXPR:
    3854     93903327 :           if (!scspec_ok)
    3855         2738 :             goto out;
    3856     93903194 :           attrs_ok = true;
    3857              :           /* TODO: Distinguish between function specifiers (inline, noreturn)
    3858              :              and storage class specifiers, either here or in
    3859              :              declspecs_add_scspec.  */
    3860     93903194 :           declspecs_add_scspec (loc, specs,
    3861     93903194 :                                 c_parser_peek_token (parser)->value);
    3862     93903194 :           c_parser_consume_token (parser);
    3863     93903194 :           break;
    3864         1898 :         case RID_AUTO_TYPE:
    3865         1898 :           if (!auto_type_ok)
    3866            0 :             goto out;
    3867              :           /* Fall through.  */
    3868     85953899 :         case RID_UNSIGNED:
    3869     85953899 :         case RID_LONG:
    3870     85953899 :         case RID_SHORT:
    3871     85953899 :         case RID_SIGNED:
    3872     85953899 :         case RID_COMPLEX:
    3873     85953899 :         case RID_INT:
    3874     85953899 :         case RID_CHAR:
    3875     85953899 :         case RID_FLOAT:
    3876     85953899 :         case RID_DOUBLE:
    3877     85953899 :         case RID_VOID:
    3878     85953899 :         case RID_DFLOAT32:
    3879     85953899 :         case RID_DFLOAT64:
    3880     85953899 :         case RID_DFLOAT128:
    3881     85953899 :         case RID_DFLOAT64X:
    3882     85953899 :         CASE_RID_FLOATN_NX:
    3883     85953899 :         case RID_BOOL:
    3884     85953899 :         case RID_FRACT:
    3885     85953899 :         case RID_ACCUM:
    3886     85953899 :         case RID_SAT:
    3887     85953899 :         case RID_INT_N_0:
    3888     85953899 :         case RID_INT_N_1:
    3889     85953899 :         case RID_INT_N_2:
    3890     85953899 :         case RID_INT_N_3:
    3891     85953899 :           if (!typespec_ok)
    3892            0 :             goto out;
    3893     85953899 :           attrs_ok = true;
    3894     85953899 :           seen_type = true;
    3895     85953899 :           if (c_dialect_objc ())
    3896            0 :             parser->objc_need_raw_identifier = true;
    3897     85953899 :           t.kind = ctsk_resword;
    3898     85953899 :           t.spec = c_parser_peek_token (parser)->value;
    3899     85953899 :           t.expr = NULL_TREE;
    3900     85953899 :           t.expr_const_operands = true;
    3901     85953899 :           t.has_enum_type_specifier = false;
    3902     85953899 :           declspecs_add_type (loc, specs, t);
    3903     85953899 :           c_parser_consume_token (parser);
    3904     85953899 :           break;
    3905       248006 :         case RID_ENUM:
    3906       248006 :           if (!typespec_ok)
    3907            0 :             goto out;
    3908       248006 :           attrs_ok = true;
    3909       248006 :           seen_type = true;
    3910       248006 :           t = c_parser_enum_specifier (parser);
    3911       248006 :           invoke_plugin_callbacks (PLUGIN_FINISH_TYPE, t.spec);
    3912       248006 :           declspecs_add_type (loc, specs, t);
    3913       248006 :           break;
    3914      2250724 :         case RID_STRUCT:
    3915      2250724 :         case RID_UNION:
    3916      2250724 :           if (!typespec_ok)
    3917            0 :             goto out;
    3918      2250724 :           attrs_ok = true;
    3919      2250724 :           seen_type = true;
    3920      2250724 :           t = c_parser_struct_or_union_specifier (parser);
    3921      2250724 :           invoke_plugin_callbacks (PLUGIN_FINISH_TYPE, t.spec);
    3922      2250724 :           declspecs_add_type (loc, specs, t);
    3923      2250724 :           break;
    3924       822456 :         case RID_TYPEOF:
    3925       822456 :         case RID_TYPEOF_UNQUAL:
    3926              :           /* ??? The old parser rejected typeof after other type
    3927              :              specifiers, but is a syntax error the best way of
    3928              :              handling this?  */
    3929       822456 :           if (!typespec_ok || seen_type)
    3930            2 :             goto out;
    3931       822454 :           attrs_ok = true;
    3932       822454 :           seen_type = true;
    3933       822454 :           t = c_parser_typeof_specifier (parser);
    3934       822454 :           declspecs_add_type (loc, specs, t);
    3935       822454 :           break;
    3936        48551 :         case RID_BITINT:
    3937        48551 :           if (!typespec_ok)
    3938            0 :             goto out;
    3939              :           else
    3940              :             {
    3941        48551 :               attrs_ok = true;
    3942        48551 :               seen_type = true;
    3943        48551 :               t.kind = ctsk_resword;
    3944        48551 :               t.spec = c_parser_peek_token (parser)->value;
    3945        48551 :               t.expr = error_mark_node;
    3946        48551 :               t.expr_const_operands = true;
    3947        48551 :               t.has_enum_type_specifier = false;
    3948        48551 :               c_parser_consume_token (parser);
    3949        48551 :               matching_parens parens;
    3950        48551 :               if (parens.require_open (parser))
    3951              :                 {
    3952        48551 :                   c_expr expr = c_parser_expr_no_commas (parser, NULL);
    3953        48551 :                   t.expr = convert_lvalue_to_rvalue (loc, expr, true,
    3954        48551 :                                                      true).value;
    3955        48551 :                   parens.skip_until_found_close (parser);
    3956              :                 }
    3957        48551 :               declspecs_add_type (loc, specs, t);
    3958              :             }
    3959        48551 :           break;
    3960        33946 :         case RID_ATOMIC:
    3961              :           /* C parser handling of Objective-C constructs needs
    3962              :              checking for correct lvalue-to-rvalue conversions, and
    3963              :              the code in build_modify_expr handling various
    3964              :              Objective-C cases, and that in build_unary_op handling
    3965              :              Objective-C cases for increment / decrement, also needs
    3966              :              updating; uses of TYPE_MAIN_VARIANT in objc_compare_types
    3967              :              and objc_types_are_equivalent may also need updates.  */
    3968        33946 :           if (c_dialect_objc ())
    3969            0 :             sorry ("%<_Atomic%> in Objective-C");
    3970        33946 :           if (flag_isoc99)
    3971        33895 :             pedwarn_c99 (loc, OPT_Wpedantic,
    3972              :                          "ISO C99 does not support the %<_Atomic%> qualifier");
    3973              :           else
    3974           51 :             pedwarn_c99 (loc, OPT_Wpedantic,
    3975              :                          "ISO C90 does not support the %<_Atomic%> qualifier");
    3976        33946 :           attrs_ok = true;
    3977        33946 :           tree value;
    3978        33946 :           value = c_parser_peek_token (parser)->value;
    3979        33946 :           c_parser_consume_token (parser);
    3980        67682 :           if (typespec_ok && c_parser_next_token_is (parser, CPP_OPEN_PAREN))
    3981              :             {
    3982              :               /* _Atomic ( type-name ).  */
    3983        13431 :               seen_type = true;
    3984        13431 :               c_parser_consume_token (parser);
    3985        13431 :               struct c_type_name *type = c_parser_type_name (parser);
    3986        13431 :               t.kind = ctsk_typeof;
    3987        13431 :               t.spec = error_mark_node;
    3988        13431 :               t.expr = NULL_TREE;
    3989        13431 :               t.expr_const_operands = true;
    3990        13431 :               t.has_enum_type_specifier = false;
    3991        13431 :               if (type != NULL)
    3992        13430 :                 t.spec = groktypename (type, &t.expr,
    3993              :                                        &t.expr_const_operands);
    3994        13431 :               c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    3995              :                                          "expected %<)%>");
    3996        13431 :               if (t.spec != error_mark_node)
    3997              :                 {
    3998        13430 :                   if (TREE_CODE (t.spec) == ARRAY_TYPE)
    3999            1 :                     error_at (loc, "%<_Atomic%>-qualified array type");
    4000        13429 :                   else if (TREE_CODE (t.spec) == FUNCTION_TYPE)
    4001            1 :                     error_at (loc, "%<_Atomic%>-qualified function type");
    4002        13428 :                   else if (TYPE_QUALS (t.spec) != TYPE_UNQUALIFIED)
    4003            4 :                     error_at (loc, "%<_Atomic%> applied to a qualified type");
    4004              :                   else
    4005        13424 :                     t.spec = c_build_qualified_type (t.spec, TYPE_QUAL_ATOMIC);
    4006              :                 }
    4007        13431 :               declspecs_add_type (loc, specs, t);
    4008              :             }
    4009              :           else
    4010        20515 :             declspecs_add_qual (loc, specs, value);
    4011              :           break;
    4012     17231022 :         case RID_CONST:
    4013     17231022 :         case RID_VOLATILE:
    4014     17231022 :         case RID_RESTRICT:
    4015     17231022 :           attrs_ok = true;
    4016     17231022 :           declspecs_add_qual (loc, specs, c_parser_peek_token (parser)->value);
    4017     17231022 :           c_parser_consume_token (parser);
    4018     17231022 :           break;
    4019     37319579 :         case RID_ATTRIBUTE:
    4020     37319579 :           if (!attrs_ok)
    4021            0 :             goto out;
    4022     37319579 :           attrs = c_parser_gnu_attributes (parser);
    4023     37319579 :           declspecs_add_attrs (loc, specs, attrs);
    4024     37319579 :           break;
    4025          218 :         case RID_ALIGNAS:
    4026          218 :           if (!alignspec_ok)
    4027           16 :             goto out;
    4028          202 :           align = c_parser_alignas_specifier (parser);
    4029          202 :           declspecs_add_alignas (loc, specs, align);
    4030          202 :           break;
    4031         1089 :         case RID_GIMPLE:
    4032         1089 :           if (! flag_gimple)
    4033            0 :             error_at (loc, "%<__GIMPLE%> only valid with %<-fgimple%>");
    4034         1089 :           c_parser_consume_token (parser);
    4035         1089 :           specs->declspec_il = cdil_gimple;
    4036         1089 :           specs->locations[cdw_gimple] = loc;
    4037         1089 :           c_parser_gimple_or_rtl_pass_list (parser, specs);
    4038         1089 :           break;
    4039           39 :         case RID_RTL:
    4040           39 :           c_parser_consume_token (parser);
    4041           39 :           specs->declspec_il = cdil_rtl;
    4042           39 :           specs->locations[cdw_rtl] = loc;
    4043           39 :           c_parser_gimple_or_rtl_pass_list (parser, specs);
    4044           39 :           break;
    4045         2587 :         default:
    4046         2587 :           goto out;
    4047              :         }
    4048              :     }
    4049    346042146 :  out:
    4050    346042146 :   if (end_std_attr_ok
    4051    346042146 :       && c_parser_nth_token_starts_std_attributes (parser, 1))
    4052          119 :     specs->postfix_attrs = c_parser_std_attribute_specifier_sequence (parser);
    4053    346042146 : }
    4054              : 
    4055              : /* Complain about a non-CPP_NAME within an enumerator list.  */
    4056              : 
    4057              : static void
    4058           11 : report_bad_enum_name (c_parser *parser)
    4059              : {
    4060           11 :   if (!parser->error)
    4061              :     {
    4062           11 :       c_token *token = c_parser_peek_token (parser);
    4063           11 :       switch (token->type)
    4064              :         {
    4065              :         default:
    4066              :           break;
    4067            6 :         case CPP_CLOSE_BRACE:
    4068              :           /* Give a nicer error for "enum {}".  */
    4069            6 :           error_at (token->location,
    4070              :                     "empty enum is invalid");
    4071            6 :           parser->error = true;
    4072            6 :           return;
    4073            3 :         case CPP_KEYWORD:
    4074              :           /* Give a nicer error for attempts to use "true" and "false"
    4075              :              in enums with C23 onwards.  */
    4076            3 :           if (token->keyword == RID_FALSE
    4077            2 :               || token->keyword == RID_TRUE)
    4078              :             {
    4079            2 :               auto_diagnostic_group d;
    4080            4 :               error_at (token->location,
    4081              :                         "cannot use keyword %qs as enumeration constant",
    4082            2 :                         IDENTIFIER_POINTER (token->value));
    4083            2 :               add_note_about_new_keyword (token->location,
    4084              :                                           token->value);
    4085            2 :               parser->error = true;
    4086            2 :               return;
    4087            2 :             }
    4088              :           break;
    4089              :         }
    4090              :     }
    4091              : 
    4092              :   /* Otherwise, a more generic error message.  */
    4093            3 :   c_parser_error (parser, "expected identifier");
    4094              : }
    4095              : 
    4096              : /* Parse an enum specifier (C90 6.5.2.2, C99 6.7.2.2, C11 6.7.2.2).
    4097              : 
    4098              :    enum-specifier:
    4099              :      enum gnu-attributes[opt] identifier[opt] enum-type-specifier[opt]
    4100              :        { enumerator-list } gnu-attributes[opt]
    4101              :      enum gnu-attributes[opt] identifier[opt] enum-type-specifier[opt]
    4102              :        { enumerator-list , } gnu-attributes[opt] enum-type-specifier[opt]
    4103              :      enum gnu-attributes[opt] identifier
    4104              : 
    4105              :    The form with trailing comma is new in C99; enum-type-specifiers
    4106              :    are new in C23.  The forms with gnu-attributes are GNU extensions.
    4107              :    In GNU C, we accept any expression without commas in the syntax
    4108              :    (assignment expressions, not just conditional expressions);
    4109              :    assignment expressions will be diagnosed as non-constant.
    4110              : 
    4111              :    enum-type-specifier:
    4112              :      : specifier-qualifier-list
    4113              : 
    4114              :    enumerator-list:
    4115              :      enumerator
    4116              :      enumerator-list , enumerator
    4117              : 
    4118              :    enumerator:
    4119              :      enumeration-constant attribute-specifier-sequence[opt]
    4120              :      enumeration-constant attribute-specifier-sequence[opt]
    4121              :        = constant-expression
    4122              : 
    4123              :    GNU Extensions:
    4124              : 
    4125              :    enumerator:
    4126              :      enumeration-constant attribute-specifier-sequence[opt] gnu-attributes[opt]
    4127              :      enumeration-constant attribute-specifier-sequence[opt] gnu-attributes[opt]
    4128              :        = constant-expression
    4129              : 
    4130              : */
    4131              : 
    4132              : static struct c_typespec
    4133       248006 : c_parser_enum_specifier (c_parser *parser)
    4134              : {
    4135       248006 :   struct c_typespec ret;
    4136       248006 :   bool have_std_attrs;
    4137       248006 :   bool potential_nesting_p = false;
    4138       248006 :   tree std_attrs = NULL_TREE;
    4139       248006 :   tree attrs;
    4140       248006 :   tree ident = NULL_TREE;
    4141       248006 :   tree fixed_underlying_type = NULL_TREE;
    4142       248006 :   location_t enum_loc;
    4143       248006 :   location_t ident_loc = UNKNOWN_LOCATION;  /* Quiet warning.  */
    4144       248006 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_ENUM));
    4145       248006 :   c_parser_consume_token (parser);
    4146       248006 :   have_std_attrs = c_parser_nth_token_starts_std_attributes (parser, 1);
    4147       248006 :   if (have_std_attrs)
    4148           14 :     std_attrs = c_parser_std_attribute_specifier_sequence (parser);
    4149       248006 :   attrs = c_parser_gnu_attributes (parser);
    4150       248006 :   enum_loc = c_parser_peek_token (parser)->location;
    4151              :   /* Set the location in case we create a decl now.  */
    4152       248006 :   c_parser_set_source_position_from_token (c_parser_peek_token (parser));
    4153       248006 :   if (c_parser_next_token_is (parser, CPP_NAME))
    4154              :     {
    4155       135939 :       ident = c_parser_peek_token (parser)->value;
    4156       135939 :       ident_loc = c_parser_peek_token (parser)->location;
    4157       135939 :       enum_loc = ident_loc;
    4158       135939 :       c_parser_consume_token (parser);
    4159              :     }
    4160       248006 :   if (c_parser_next_token_is (parser, CPP_COLON)
    4161              :       /* Distinguish an enum-type-specifier from a bit-field
    4162              :          declaration of the form "enum e : constant-expression;".  */
    4163       248006 :       && c_token_starts_typename (c_parser_peek_2nd_token (parser)))
    4164              :     {
    4165          387 :       pedwarn_c11 (enum_loc, OPT_Wpedantic,
    4166              :                    "ISO C does not support specifying %<enum%> underlying "
    4167              :                    "types before C23");
    4168          387 :       if (ident)
    4169              :         {
    4170              :           /* The tag is in scope during the enum-type-specifier (which
    4171              :              may refer to the tag inside typeof).  */
    4172          383 :           ret = parser_xref_tag (ident_loc, ENUMERAL_TYPE, ident,
    4173              :                                  have_std_attrs, std_attrs, true);
    4174          383 :           if (!ENUM_FIXED_UNDERLYING_TYPE_P (ret.spec))
    4175            3 :             error_at (enum_loc, "%<enum%> declared both with and without "
    4176              :                       "fixed underlying type");
    4177          383 :           potential_nesting_p = NULL_TREE == TYPE_VALUES (ret.spec);
    4178              :         }
    4179              :       else
    4180              :         {
    4181              :           /* There must be an enum definition, so this initialization
    4182              :              (to avoid possible warnings about uninitialized data)
    4183              :              will be replaced later (either with the results of that
    4184              :              definition, or with the results of error handling for the
    4185              :              case of no tag and no definition).  */
    4186            4 :           ret.spec = NULL_TREE;
    4187            4 :           ret.kind = ctsk_tagdef;
    4188            4 :           ret.expr = NULL_TREE;
    4189            4 :           ret.expr_const_operands = true;
    4190            4 :           ret.has_enum_type_specifier = true;
    4191              :         }
    4192          387 :       c_parser_consume_token (parser);
    4193          387 :       struct c_declspecs *specs = build_null_declspecs ();
    4194          387 :       c_parser_declspecs (parser, specs, false, true, false, false, false,
    4195              :                           false, true, cla_prefer_id);
    4196          387 :       finish_declspecs (specs);
    4197          387 :       if (specs->default_int_p)
    4198            1 :         error_at (enum_loc, "no %<enum%> underlying type specified");
    4199          386 :       else if (TREE_CODE (specs->type) != INTEGER_TYPE
    4200          386 :                && TREE_CODE (specs->type) != BOOLEAN_TYPE
    4201           31 :                && (!flag_isoc2y || TREE_CODE (specs->type) != BITINT_TYPE))
    4202              :         {
    4203            9 :           error_at (enum_loc, "invalid %<enum%> underlying type");
    4204            9 :           specs->type = integer_type_node;
    4205              :         }
    4206          377 :       else if (specs->restrict_p)
    4207            1 :         error_at (enum_loc, "invalid use of %<restrict%>");
    4208          387 :       fixed_underlying_type = TYPE_MAIN_VARIANT (specs->type);
    4209          387 :       if (ident)
    4210              :         {
    4211              :           /* The type specified must be consistent with any previously
    4212              :              specified underlying type.  If this is a newly declared
    4213              :              type, it is now a complete type.  */
    4214          383 :           if (ENUM_FIXED_UNDERLYING_TYPE_P (ret.spec)
    4215          383 :               && ENUM_UNDERLYING_TYPE (ret.spec) == NULL_TREE)
    4216              :             {
    4217         1086 :               TYPE_MIN_VALUE (ret.spec) =
    4218          362 :                 TYPE_MIN_VALUE (fixed_underlying_type);
    4219         1086 :               TYPE_MAX_VALUE (ret.spec) =
    4220          362 :                 TYPE_MAX_VALUE (fixed_underlying_type);
    4221          362 :               TYPE_UNSIGNED (ret.spec) = TYPE_UNSIGNED (fixed_underlying_type);
    4222          362 :               SET_TYPE_ALIGN (ret.spec, TYPE_ALIGN (fixed_underlying_type));
    4223          362 :               TYPE_SIZE (ret.spec) = NULL_TREE;
    4224          362 :               TYPE_PRECISION (ret.spec) =
    4225          362 :                 TYPE_PRECISION (fixed_underlying_type);
    4226          362 :               ENUM_UNDERLYING_TYPE (ret.spec) = fixed_underlying_type;
    4227          362 :               layout_type (ret.spec);
    4228              :             }
    4229           21 :           else if (ENUM_FIXED_UNDERLYING_TYPE_P (ret.spec)
    4230           37 :                    && !comptypes (fixed_underlying_type,
    4231           16 :                                   ENUM_UNDERLYING_TYPE (ret.spec)))
    4232              :             {
    4233            3 :               error_at (enum_loc, "%<enum%> underlying type incompatible with "
    4234              :                         "previous declaration");
    4235            3 :               fixed_underlying_type = ENUM_UNDERLYING_TYPE (ret.spec);
    4236              :             }
    4237              :         }
    4238              :     }
    4239       248006 :   if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
    4240              :     {
    4241              :       /* Parse an enum definition.  */
    4242       187619 :       struct c_enum_contents the_enum;
    4243       187619 :       tree type;
    4244       187619 :       tree postfix_attrs;
    4245              :       /* We chain the enumerators in reverse order, then put them in
    4246              :          forward order at the end.  */
    4247       187619 :       tree values;
    4248       187619 :       timevar_push (TV_PARSE_ENUM);
    4249       187619 :       type = start_enum (enum_loc, &the_enum, ident, fixed_underlying_type,
    4250              :                          potential_nesting_p);
    4251       187619 :       values = NULL_TREE;
    4252       187619 :       c_parser_consume_token (parser);
    4253      5841293 :       while (true)
    4254              :         {
    4255      5841293 :           tree enum_id;
    4256      5841293 :           tree enum_value;
    4257      5841293 :           tree enum_decl;
    4258      5841293 :           bool seen_comma;
    4259      5841293 :           c_token *token;
    4260      5841293 :           location_t comma_loc = UNKNOWN_LOCATION;  /* Quiet warning.  */
    4261      5841293 :           location_t decl_loc, value_loc;
    4262      5841293 :           if (c_parser_next_token_is_not (parser, CPP_NAME))
    4263              :             {
    4264           11 :               report_bad_enum_name (parser);
    4265           11 :               c_parser_skip_until_found (parser, CPP_CLOSE_BRACE, NULL);
    4266           11 :               values = error_mark_node;
    4267           11 :               break;
    4268              :             }
    4269      5841282 :           token = c_parser_peek_token (parser);
    4270      5841282 :           enum_id = token->value;
    4271              :           /* Set the location in case we create a decl now.  */
    4272      5841282 :           c_parser_set_source_position_from_token (token);
    4273      5841282 :           decl_loc = value_loc = token->location;
    4274      5841282 :           c_parser_consume_token (parser);
    4275              :           /* Parse any specified attributes.  */
    4276      5841282 :           tree std_attrs = NULL_TREE;
    4277      5841282 :           if (c_parser_nth_token_starts_std_attributes (parser, 1))
    4278           12 :             std_attrs = c_parser_std_attribute_specifier_sequence (parser);
    4279      5841282 :           tree enum_attrs = chainon (std_attrs,
    4280              :                                      c_parser_gnu_attributes (parser));
    4281      5841282 :           if (c_parser_next_token_is (parser, CPP_EQ))
    4282              :             {
    4283      3649288 :               c_parser_consume_token (parser);
    4284      3649288 :               value_loc = c_parser_peek_token (parser)->location;
    4285      3649288 :               enum_value = convert_lvalue_to_rvalue (value_loc,
    4286              :                                                      (c_parser_expr_no_commas
    4287              :                                                       (parser, NULL)),
    4288              :                                                      true, true).value;
    4289              :             }
    4290              :           else
    4291              :             enum_value = NULL_TREE;
    4292      5841282 :           enum_decl = build_enumerator (decl_loc, value_loc,
    4293              :                                         &the_enum, enum_id, enum_value);
    4294      5841282 :           if (enum_attrs)
    4295         3800 :             decl_attributes (&TREE_PURPOSE (enum_decl), enum_attrs, 0);
    4296      5841282 :           TREE_CHAIN (enum_decl) = values;
    4297      5841282 :           values = enum_decl;
    4298      5841282 :           seen_comma = false;
    4299      5841282 :           if (c_parser_next_token_is (parser, CPP_COMMA))
    4300              :             {
    4301      5674944 :               comma_loc = c_parser_peek_token (parser)->location;
    4302      5674944 :               seen_comma = true;
    4303      5674944 :               c_parser_consume_token (parser);
    4304              :             }
    4305      5841282 :           if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
    4306              :             {
    4307       187593 :               if (seen_comma)
    4308        21270 :                 pedwarn_c90 (comma_loc, OPT_Wpedantic,
    4309              :                              "comma at end of enumerator list");
    4310       187593 :               c_parser_consume_token (parser);
    4311       187593 :               break;
    4312              :             }
    4313      5653689 :           if (!seen_comma)
    4314              :             {
    4315           15 :               c_parser_error (parser, "expected %<,%> or %<}%>");
    4316           15 :               c_parser_skip_until_found (parser, CPP_CLOSE_BRACE, NULL);
    4317           15 :               values = error_mark_node;
    4318           15 :               break;
    4319              :             }
    4320              :         }
    4321       187619 :       postfix_attrs = c_parser_gnu_attributes (parser);
    4322       187619 :       ret.spec = finish_enum (type, nreverse (values),
    4323              :                               chainon (std_attrs,
    4324              :                                        chainon (attrs, postfix_attrs)));
    4325       187619 :       ret.kind = ctsk_tagdef;
    4326       187619 :       ret.expr = NULL_TREE;
    4327       187619 :       ret.expr_const_operands = true;
    4328       187619 :       ret.has_enum_type_specifier = fixed_underlying_type != NULL_TREE;
    4329       187619 :       timevar_pop (TV_PARSE_ENUM);
    4330       187619 :       return ret;
    4331              :     }
    4332        60387 :   else if (!ident)
    4333              :     {
    4334            1 :       c_parser_error (parser, "expected %<{%>");
    4335            1 :       ret.spec = error_mark_node;
    4336            1 :       ret.kind = ctsk_tagref;
    4337            1 :       ret.expr = NULL_TREE;
    4338            1 :       ret.expr_const_operands = true;
    4339            1 :       ret.has_enum_type_specifier = false;
    4340            1 :       return ret;
    4341              :     }
    4342              :   /* Attributes may only appear when the members are defined or in
    4343              :      certain forward declarations (treat enum forward declarations in
    4344              :      GNU C analogously to struct and union forward declarations in
    4345              :      standard C).  */
    4346        60387 :   if (have_std_attrs && c_parser_next_token_is_not (parser, CPP_SEMICOLON))
    4347            1 :     c_parser_error (parser, "expected %<;%>");
    4348        60386 :   if (fixed_underlying_type == NULL_TREE)
    4349              :     {
    4350        60336 :       ret = parser_xref_tag (ident_loc, ENUMERAL_TYPE, ident, have_std_attrs,
    4351              :                              std_attrs, false);
    4352              :       /* In ISO C, enumerated types without a fixed underlying type
    4353              :          can be referred to only if already defined.  */
    4354        60336 :       if (pedantic && !COMPLETE_TYPE_P (ret.spec))
    4355              :         {
    4356           11 :           gcc_assert (ident);
    4357           11 :           pedwarn (enum_loc, OPT_Wpedantic,
    4358              :                    "ISO C forbids forward references to %<enum%> types");
    4359              :         }
    4360              :     }
    4361              :   return ret;
    4362              : }
    4363              : 
    4364              : /* Parse a struct or union specifier (C90 6.5.2.1, C99 6.7.2.1, C11 6.7.2.1).
    4365              : 
    4366              :    struct-or-union-specifier:
    4367              :      struct-or-union attribute-specifier-sequence[opt] gnu-attributes[opt]
    4368              :        identifier[opt] { struct-contents } gnu-attributes[opt]
    4369              :      struct-or-union attribute-specifier-sequence[opt] gnu-attributes[opt]
    4370              :        identifier
    4371              : 
    4372              :    struct-contents:
    4373              :      struct-declaration-list
    4374              : 
    4375              :    struct-declaration-list:
    4376              :      struct-declaration ;
    4377              :      struct-declaration-list struct-declaration ;
    4378              : 
    4379              :    GNU extensions:
    4380              : 
    4381              :    struct-contents:
    4382              :      empty
    4383              :      struct-declaration
    4384              :      struct-declaration-list struct-declaration
    4385              : 
    4386              :    struct-declaration-list:
    4387              :      struct-declaration-list ;
    4388              :      ;
    4389              : 
    4390              :    (Note that in the syntax here, unlike that in ISO C, the semicolons
    4391              :    are included here rather than in struct-declaration, in order to
    4392              :    describe the syntax with extra semicolons and missing semicolon at
    4393              :    end.)
    4394              : 
    4395              :    Objective-C:
    4396              : 
    4397              :    struct-declaration-list:
    4398              :      @defs ( class-name )
    4399              : 
    4400              :    (Note this does not include a trailing semicolon, but can be
    4401              :    followed by further declarations, and gets a pedwarn-if-pedantic
    4402              :    when followed by a semicolon.)  */
    4403              : 
    4404              : static struct c_typespec
    4405      2250724 : c_parser_struct_or_union_specifier (c_parser *parser)
    4406              : {
    4407      2250724 :   struct c_typespec ret;
    4408      2250724 :   bool have_std_attrs;
    4409      2250724 :   tree std_attrs = NULL_TREE;
    4410      2250724 :   tree attrs;
    4411      2250724 :   tree ident = NULL_TREE;
    4412      2250724 :   location_t struct_loc;
    4413      2250724 :   location_t ident_loc = UNKNOWN_LOCATION;
    4414      2250724 :   enum tree_code code;
    4415      2250724 :   switch (c_parser_peek_token (parser)->keyword)
    4416              :     {
    4417              :     case RID_STRUCT:
    4418              :       code = RECORD_TYPE;
    4419              :       break;
    4420       426247 :     case RID_UNION:
    4421       426247 :       code = UNION_TYPE;
    4422       426247 :       break;
    4423            0 :     default:
    4424            0 :       gcc_unreachable ();
    4425              :     }
    4426      2250724 :   struct_loc = c_parser_peek_token (parser)->location;
    4427      2250724 :   c_parser_consume_token (parser);
    4428      2250724 :   have_std_attrs = c_parser_nth_token_starts_std_attributes (parser, 1);
    4429      2250724 :   if (have_std_attrs)
    4430           34 :     std_attrs = c_parser_std_attribute_specifier_sequence (parser);
    4431      2250724 :   attrs = c_parser_gnu_attributes (parser);
    4432              : 
    4433              :   /* Set the location in case we create a decl now.  */
    4434      2250724 :   c_parser_set_source_position_from_token (c_parser_peek_token (parser));
    4435              : 
    4436      2250724 :   if (c_parser_next_token_is (parser, CPP_NAME))
    4437              :     {
    4438      1546636 :       ident = c_parser_peek_token (parser)->value;
    4439      1546636 :       ident_loc = c_parser_peek_token (parser)->location;
    4440      1546636 :       struct_loc = ident_loc;
    4441      1546636 :       c_parser_consume_token (parser);
    4442              :     }
    4443      2250724 :   if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
    4444              :     {
    4445              :       /* Parse a struct or union definition.  Start the scope of the
    4446              :          tag before parsing components.  */
    4447      1199842 :       class c_struct_parse_info *struct_info;
    4448      1199842 :       tree type = start_struct (struct_loc, code, ident, &struct_info);
    4449      1199842 :       tree postfix_attrs;
    4450              :       /* We chain the components in reverse order, then put them in
    4451              :          forward order at the end.  Each struct-declaration may
    4452              :          declare multiple components (comma-separated), so we must use
    4453              :          chainon to join them, although when parsing each
    4454              :          struct-declaration we can use TREE_CHAIN directly.
    4455              : 
    4456              :          The theory behind all this is that there will be more
    4457              :          semicolon separated fields than comma separated fields, and
    4458              :          so we'll be minimizing the number of node traversals required
    4459              :          by chainon.  */
    4460      1199842 :       tree contents;
    4461      1199842 :       tree expr = NULL;
    4462      1199842 :       timevar_push (TV_PARSE_STRUCT);
    4463      1199842 :       contents = NULL_TREE;
    4464      1199842 :       c_parser_consume_token (parser);
    4465              :       /* Handle the Objective-C @defs construct,
    4466              :          e.g. foo(sizeof(struct{ @defs(ClassName) }));.  */
    4467      1199842 :       if (c_parser_next_token_is_keyword (parser, RID_AT_DEFS))
    4468              :         {
    4469            0 :           tree name;
    4470            0 :           gcc_assert (c_dialect_objc ());
    4471            0 :           c_parser_consume_token (parser);
    4472            0 :           matching_parens parens;
    4473            0 :           if (!parens.require_open (parser))
    4474            0 :             goto end_at_defs;
    4475            0 :           if (c_parser_next_token_is (parser, CPP_NAME)
    4476            0 :               && c_parser_peek_token (parser)->id_kind == C_ID_CLASSNAME)
    4477              :             {
    4478            0 :               name = c_parser_peek_token (parser)->value;
    4479            0 :               c_parser_consume_token (parser);
    4480              :             }
    4481              :           else
    4482              :             {
    4483            0 :               c_parser_error (parser, "expected class name");
    4484            0 :               c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
    4485            0 :               goto end_at_defs;
    4486              :             }
    4487            0 :           parens.skip_until_found_close (parser);
    4488            0 :           contents = nreverse (objc_get_class_ivars (name));
    4489              :         }
    4490      1199842 :     end_at_defs:
    4491              :       /* Parse the struct-declarations and semicolons.  Problems with
    4492              :          semicolons are diagnosed here; empty structures are diagnosed
    4493              :          elsewhere.  */
    4494      5526315 :       while (true)
    4495              :         {
    4496      5526315 :           tree decls;
    4497              :           /* Parse any stray semicolon.  */
    4498      5526315 :           if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    4499              :             {
    4500           14 :               location_t semicolon_loc
    4501           14 :                 = c_parser_peek_token (parser)->location;
    4502           14 :               gcc_rich_location richloc (semicolon_loc);
    4503           14 :               richloc.add_fixit_remove ();
    4504           14 :               pedwarn (&richloc, OPT_Wpedantic,
    4505              :                        "extra semicolon in struct or union specified");
    4506           14 :               c_parser_consume_token (parser);
    4507           14 :               continue;
    4508           14 :             }
    4509              :           /* Stop if at the end of the struct or union contents.  */
    4510      5526301 :           if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
    4511              :             {
    4512      1199833 :               c_parser_consume_token (parser);
    4513      1199833 :               break;
    4514              :             }
    4515              :           /* Accept #pragmas at struct scope.  */
    4516      4326468 :           if (c_parser_next_token_is (parser, CPP_PRAGMA))
    4517              :             {
    4518           20 :               c_parser_pragma (parser, pragma_struct, NULL, NULL_TREE);
    4519           20 :               continue;
    4520              :             }
    4521              :           /* Parse some comma-separated declarations, but not the
    4522              :              trailing semicolon if any.  */
    4523      4326448 :           decls = c_parser_struct_declaration (parser, &expr);
    4524      4326448 :           contents = chainon (decls, contents);
    4525              :           /* If no semicolon follows, either we have a parse error or
    4526              :              are at the end of the struct or union and should
    4527              :              pedwarn.  */
    4528      4326448 :           if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    4529      4326402 :             c_parser_consume_token (parser);
    4530              :           else
    4531              :             {
    4532           46 :               if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
    4533           35 :                 pedwarn (c_parser_peek_token (parser)->location, 0,
    4534              :                          "no semicolon at end of struct or union");
    4535           11 :               else if (parser->error
    4536           11 :                        || !c_parser_next_token_starts_declspecs (parser))
    4537              :                 {
    4538            9 :                   c_parser_error (parser, "expected %<;%>");
    4539            9 :                   c_parser_skip_until_found (parser, CPP_CLOSE_BRACE, NULL);
    4540            9 :                   break;
    4541              :                 }
    4542              : 
    4543              :               /* If we come here, we have already emitted an error
    4544              :                  for an expected `;', identifier or `(', and we also
    4545              :                  recovered already.  Go on with the next field. */
    4546              :             }
    4547              :         }
    4548      1199842 :       postfix_attrs = c_parser_gnu_attributes (parser);
    4549      1199842 :       ret.spec = finish_struct (struct_loc, type, nreverse (contents),
    4550              :                                 chainon (std_attrs,
    4551              :                                          chainon (attrs, postfix_attrs)),
    4552              :                                 struct_info, &expr);
    4553      1199842 :       ret.kind = ctsk_tagdef;
    4554      1199842 :       ret.expr = expr;
    4555      1199842 :       ret.expr_const_operands = true;
    4556      1199842 :       ret.has_enum_type_specifier = false;
    4557      1199842 :       timevar_pop (TV_PARSE_STRUCT);
    4558      1199842 :       return ret;
    4559              :     }
    4560      1050882 :   else if (!ident)
    4561              :     {
    4562           10 :       c_parser_error (parser, "expected %<{%>");
    4563           10 :       ret.spec = error_mark_node;
    4564           10 :       ret.kind = ctsk_tagref;
    4565           10 :       ret.expr = NULL_TREE;
    4566           10 :       ret.expr_const_operands = true;
    4567           10 :       ret.has_enum_type_specifier = false;
    4568           10 :       return ret;
    4569              :     }
    4570              :   /* Attributes may only appear when the members are defined or in
    4571              :      certain forward declarations.  */
    4572      1050882 :   if (have_std_attrs && c_parser_next_token_is_not (parser, CPP_SEMICOLON))
    4573            2 :     c_parser_error (parser, "expected %<;%>");
    4574              :   /* ??? Existing practice is that GNU attributes are ignored after
    4575              :      the struct or union keyword when not defining the members.  */
    4576      1050872 :   ret = parser_xref_tag (ident_loc, code, ident, have_std_attrs, std_attrs,
    4577              :                          false);
    4578      1050872 :   return ret;
    4579              : }
    4580              : 
    4581              : /* Parse a struct-declaration (C90 6.5.2.1, C99 6.7.2.1, C11 6.7.2.1),
    4582              :    *without* the trailing semicolon.
    4583              : 
    4584              :    struct-declaration:
    4585              :      attribute-specifier-sequence[opt] specifier-qualifier-list
    4586              :        attribute-specifier-sequence[opt] struct-declarator-list
    4587              :      static_assert-declaration-no-semi
    4588              : 
    4589              :    specifier-qualifier-list:
    4590              :      type-specifier specifier-qualifier-list[opt]
    4591              :      type-qualifier specifier-qualifier-list[opt]
    4592              :      alignment-specifier specifier-qualifier-list[opt]
    4593              :      gnu-attributes specifier-qualifier-list[opt]
    4594              : 
    4595              :    struct-declarator-list:
    4596              :      struct-declarator
    4597              :      struct-declarator-list , gnu-attributes[opt] struct-declarator
    4598              : 
    4599              :    struct-declarator:
    4600              :      declarator gnu-attributes[opt]
    4601              :      declarator[opt] : constant-expression gnu-attributes[opt]
    4602              : 
    4603              :    GNU extensions:
    4604              : 
    4605              :    struct-declaration:
    4606              :      __extension__ struct-declaration
    4607              :      specifier-qualifier-list
    4608              : 
    4609              :    Unlike the ISO C syntax, semicolons are handled elsewhere.  The use
    4610              :    of gnu-attributes where shown is a GNU extension.  In GNU C, we accept
    4611              :    any expression without commas in the syntax (assignment
    4612              :    expressions, not just conditional expressions); assignment
    4613              :    expressions will be diagnosed as non-constant.  */
    4614              : 
    4615              : static tree
    4616      4393629 : c_parser_struct_declaration (c_parser *parser, tree *expr)
    4617              : {
    4618      4393629 :   struct c_declspecs *specs;
    4619      4393629 :   tree prefix_attrs;
    4620      4393629 :   tree all_prefix_attrs;
    4621      4393629 :   tree decls;
    4622      4393629 :   location_t decl_loc;
    4623      4393629 :   if (c_parser_next_token_is_keyword (parser, RID_EXTENSION))
    4624              :     {
    4625        67181 :       int ext;
    4626        67181 :       tree decl;
    4627        67181 :       ext = disable_extension_diagnostics ();
    4628        67181 :       c_parser_consume_token (parser);
    4629        67181 :       decl = c_parser_struct_declaration (parser, expr);
    4630        67181 :       restore_extension_diagnostics (ext);
    4631        67181 :       return decl;
    4632              :     }
    4633      4326448 :   if (c_parser_next_token_is_keyword (parser, RID_STATIC_ASSERT))
    4634              :     {
    4635           17 :       c_parser_static_assert_declaration_no_semi (parser);
    4636           17 :       return NULL_TREE;
    4637              :     }
    4638      4326431 :   specs = build_null_declspecs ();
    4639      4326431 :   decl_loc = c_parser_peek_token (parser)->location;
    4640              :   /* Strictly by the standard, we shouldn't allow _Alignas here,
    4641              :      but it appears to have been intended to allow it there, so
    4642              :      we're keeping it as it is until WG14 reaches a conclusion
    4643              :      of N1731.
    4644              :      <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1731.pdf>  */
    4645      4326431 :   c_parser_declspecs (parser, specs, false, true, true,
    4646              :                       true, false, true, true, cla_nonabstract_decl);
    4647      4326431 :   if (parser->error)
    4648              :     return NULL_TREE;
    4649      4326423 :   if (!specs->declspecs_seen_p)
    4650              :     {
    4651            1 :       c_parser_error (parser, "expected specifier-qualifier-list");
    4652            1 :       return NULL_TREE;
    4653              :     }
    4654      4326422 :   finish_declspecs (specs);
    4655      4326422 :   if (c_parser_next_token_is (parser, CPP_SEMICOLON)
    4656      8641920 :       || c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
    4657              :     {
    4658        10928 :       tree ret;
    4659        10928 :       if (specs->typespec_kind == ctsk_none)
    4660              :         {
    4661            3 :           pedwarn (decl_loc, OPT_Wpedantic,
    4662              :                    "ISO C forbids member declarations with no members");
    4663            3 :           shadow_tag_warned (specs, pedantic);
    4664            3 :           ret = NULL_TREE;
    4665              :         }
    4666              :       else
    4667              :         {
    4668              :           /* Support for unnamed structs or unions as members of
    4669              :              structs or unions (which is [a] useful and [b] supports
    4670              :              MS P-SDK).  */
    4671        10925 :           tree attrs = NULL;
    4672              : 
    4673        10925 :           ret = grokfield (c_parser_peek_token (parser)->location,
    4674              :                            build_id_declarator (NULL_TREE), specs,
    4675              :                            NULL_TREE, &attrs, expr);
    4676        10925 :           if (ret)
    4677        10896 :             decl_attributes (&ret, attrs, 0);
    4678              :         }
    4679        10928 :       return ret;
    4680              :     }
    4681              : 
    4682              :   /* Provide better error recovery.  Note that a type name here is valid,
    4683              :      and will be treated as a field name.  */
    4684      4315494 :   if (specs->typespec_kind == ctsk_tagdef
    4685       156556 :       && TREE_CODE (specs->type) != ENUMERAL_TYPE
    4686       156403 :       && c_parser_next_token_starts_declspecs (parser)
    4687      4315497 :       && !c_parser_next_token_is (parser, CPP_NAME))
    4688              :     {
    4689            2 :       c_parser_error (parser, "expected %<;%>, identifier or %<(%>");
    4690            2 :       parser->error = false;
    4691            2 :       return NULL_TREE;
    4692              :     }
    4693              : 
    4694      4315492 :   pending_xref_error ();
    4695      4315492 :   prefix_attrs = specs->attrs;
    4696      4315492 :   all_prefix_attrs = prefix_attrs;
    4697      4315492 :   specs->attrs = NULL_TREE;
    4698      4315492 :   decls = NULL_TREE;
    4699      4431854 :   while (true)
    4700              :     {
    4701              :       /* Declaring one or more declarators or un-named bit-fields.  */
    4702      4373673 :       struct c_declarator *declarator;
    4703      4373673 :       bool dummy = false;
    4704      4373673 :       if (c_parser_next_token_is (parser, CPP_COLON))
    4705        11630 :         declarator = build_id_declarator (NULL_TREE);
    4706              :       else
    4707      4362043 :         declarator = c_parser_declarator (parser,
    4708      4362043 :                                           specs->typespec_kind != ctsk_none,
    4709              :                                           C_DTR_NORMAL, &dummy);
    4710      4373673 :       if (declarator == NULL)
    4711              :         {
    4712            1 :           c_parser_skip_to_end_of_block_or_statement (parser);
    4713            1 :           break;
    4714              :         }
    4715      4373672 :       if (c_parser_next_token_is (parser, CPP_COLON)
    4716      4318442 :           || c_parser_next_token_is (parser, CPP_COMMA)
    4717      4262589 :           || c_parser_next_token_is (parser, CPP_SEMICOLON)
    4718        33224 :           || c_parser_next_token_is (parser, CPP_CLOSE_BRACE)
    4719      4406866 :           || c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
    4720              :         {
    4721      4373672 :           tree postfix_attrs = NULL_TREE;
    4722      4373672 :           tree width = NULL_TREE;
    4723      4373672 :           tree d;
    4724      4373672 :           if (c_parser_next_token_is (parser, CPP_COLON))
    4725              :             {
    4726        55230 :               c_parser_consume_token (parser);
    4727        55230 :               location_t loc = c_parser_peek_token (parser)->location;
    4728        55230 :               width = convert_lvalue_to_rvalue (loc,
    4729              :                                                 (c_parser_expr_no_commas
    4730              :                                                  (parser, NULL)),
    4731              :                                                 true, true).value;
    4732              :             }
    4733      4373672 :           if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
    4734        33377 :             postfix_attrs = c_parser_gnu_attributes (parser);
    4735      4373672 :           d = grokfield (c_parser_peek_token (parser)->location,
    4736              :                          declarator, specs, width, &all_prefix_attrs, expr);
    4737      4373672 :           decl_attributes (&d, chainon (postfix_attrs,
    4738              :                                         all_prefix_attrs), 0);
    4739      4373672 :           DECL_CHAIN (d) = decls;
    4740      4373672 :           decls = d;
    4741      4373672 :           if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
    4742            0 :             all_prefix_attrs = chainon (c_parser_gnu_attributes (parser),
    4743              :                                         prefix_attrs);
    4744              :           else
    4745              :             all_prefix_attrs = prefix_attrs;
    4746      4373672 :           if (c_parser_next_token_is (parser, CPP_COMMA))
    4747        58181 :             c_parser_consume_token (parser);
    4748      4315491 :           else if (c_parser_next_token_is (parser, CPP_SEMICOLON)
    4749      4315521 :                    || c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
    4750              :             {
    4751              :               /* Semicolon consumed in caller.  */
    4752              :               break;
    4753              :             }
    4754              :           else
    4755              :             {
    4756            0 :               c_parser_error (parser, "expected %<,%>, %<;%> or %<}%>");
    4757            0 :               break;
    4758              :             }
    4759              :         }
    4760              :       else
    4761              :         {
    4762            0 :           c_parser_error (parser,
    4763              :                           "expected %<:%>, %<,%>, %<;%>, %<}%> or "
    4764              :                           "%<__attribute__%>");
    4765            0 :           break;
    4766              :         }
    4767        58181 :     }
    4768      4315492 :   return decls;
    4769              : }
    4770              : 
    4771              : /* Parse a typeof specifier (a GNU extension adopted in C23).
    4772              : 
    4773              :    typeof-specifier:
    4774              :      typeof ( expression )
    4775              :      typeof ( type-name )
    4776              :      typeof_unqual ( expression )
    4777              :      typeof_unqual ( type-name )
    4778              : */
    4779              : 
    4780              : static struct c_typespec
    4781       822454 : c_parser_typeof_specifier (c_parser *parser)
    4782              : {
    4783       822454 :   bool is_unqual;
    4784       822454 :   bool is_std;
    4785       822454 :   struct c_typespec ret;
    4786       822454 :   ret.kind = ctsk_typeof;
    4787       822454 :   ret.spec = error_mark_node;
    4788       822454 :   ret.expr = NULL_TREE;
    4789       822454 :   ret.expr_const_operands = true;
    4790       822454 :   ret.has_enum_type_specifier = false;
    4791       822454 :   if (c_parser_next_token_is_keyword (parser, RID_TYPEOF))
    4792              :     {
    4793       822362 :       is_unqual = false;
    4794       822362 :       tree spelling = c_parser_peek_token (parser)->value;
    4795       822362 :       is_std = (flag_isoc23
    4796       925614 :                 && strcmp (IDENTIFIER_POINTER (spelling), "typeof") == 0);
    4797              :     }
    4798              :   else
    4799              :     {
    4800           92 :       gcc_assert (c_parser_next_token_is_keyword (parser, RID_TYPEOF_UNQUAL));
    4801           92 :       is_unqual = true;
    4802           92 :       tree spelling = c_parser_peek_token (parser)->value;
    4803           92 :       is_std = strcmp (IDENTIFIER_POINTER (spelling), "typeof_unqual") == 0;
    4804              :     }
    4805       822454 :   c_parser_consume_token (parser);
    4806       822454 :   c_inhibit_evaluation_warnings++;
    4807       822454 :   in_typeof++;
    4808       822454 :   matching_parens parens;
    4809       822454 :   if (!parens.require_open (parser))
    4810              :     {
    4811            0 :       c_inhibit_evaluation_warnings--;
    4812            0 :       in_typeof--;
    4813            0 :       return ret;
    4814              :     }
    4815       822454 :   if (c_parser_next_tokens_start_typename (parser, cla_prefer_id))
    4816              :     {
    4817          691 :       struct c_type_name *type = c_parser_type_name (parser);
    4818          691 :       c_inhibit_evaluation_warnings--;
    4819          691 :       in_typeof--;
    4820          691 :       if (type != NULL)
    4821              :         {
    4822          691 :           ret.spec = groktypename (type, &ret.expr, &ret.expr_const_operands);
    4823          691 :           pop_maybe_used (c_type_variably_modified_p (ret.spec));
    4824              :         }
    4825              :     }
    4826              :   else
    4827              :     {
    4828       821763 :       bool was_vm;
    4829       821763 :       location_t here = c_parser_peek_token (parser)->location;
    4830       821763 :       struct c_expr expr = c_parser_expression (parser);
    4831       821763 :       c_inhibit_evaluation_warnings--;
    4832       821763 :       in_typeof--;
    4833       821763 :       if (TREE_CODE (expr.value) == COMPONENT_REF
    4834       821763 :           && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
    4835           13 :         error_at (here, "%<typeof%> applied to a bit-field");
    4836       821763 :       mark_exp_read (expr.value);
    4837       821763 :       ret.spec = TREE_TYPE (expr.value);
    4838       821763 :       was_vm = c_type_variably_modified_p (ret.spec);
    4839              :       /* This is returned with the type so that when the type is
    4840              :          evaluated, this can be evaluated.  */
    4841       821763 :       if (was_vm)
    4842          238 :         ret.expr = c_fully_fold (expr.value, false, &ret.expr_const_operands);
    4843       821763 :       pop_maybe_used (was_vm);
    4844              :     }
    4845       822454 :   parens.skip_until_found_close (parser);
    4846       822454 :   if (ret.spec != error_mark_node)
    4847              :     {
    4848       822443 :       if (is_unqual)
    4849              :         {
    4850           92 :           bool is_array = TREE_CODE (ret.spec) == ARRAY_TYPE;
    4851           92 :           auto quals = TYPE_QUALS (strip_array_types (ret.spec));
    4852           92 :           if ((is_array ? quals.without (TYPE_QUAL_ATOMIC) : quals)
    4853       822494 :               != TYPE_UNQUALIFIED)
    4854              :             {
    4855           51 :               ret.spec = TYPE_MAIN_VARIANT (ret.spec);
    4856           51 :               if (quals.has (TYPE_QUAL_ATOMIC) && is_array)
    4857            4 :                 ret.spec = c_build_qualified_type (ret.spec,
    4858              :                                                    TYPE_QUAL_ATOMIC);
    4859              :             }
    4860              :         }
    4861       822443 :       if (is_std)
    4862              :         {
    4863              :           /* In ISO C terms, _Noreturn is not part of the type of
    4864              :              expressions such as &abort, but in GCC it is represented
    4865              :              internally as a type qualifier.  */
    4866         4313 :           if (TREE_CODE (ret.spec) == FUNCTION_TYPE
    4867         4313 :               && TYPE_QUALS (ret.spec) != TYPE_UNQUALIFIED)
    4868            2 :             ret.spec = TYPE_MAIN_VARIANT (ret.spec);
    4869         2925 :           else if (FUNCTION_POINTER_TYPE_P (ret.spec)
    4870         7135 :                    && TYPE_QUALS (TREE_TYPE (ret.spec)) != TYPE_UNQUALIFIED)
    4871            2 :             ret.spec
    4872            2 :               = c_build_pointer_type (TYPE_MAIN_VARIANT (TREE_TYPE (ret.spec)));
    4873              :         }
    4874              :     }
    4875              :   return ret;
    4876              : }
    4877              : 
    4878              : /* Parse an alignment-specifier.
    4879              : 
    4880              :    C11 6.7.5:
    4881              : 
    4882              :    alignment-specifier:
    4883              :      _Alignas ( type-name )
    4884              :      _Alignas ( constant-expression )
    4885              : */
    4886              : 
    4887              : static tree
    4888          202 : c_parser_alignas_specifier (c_parser * parser)
    4889              : {
    4890          202 :   tree ret = error_mark_node;
    4891          202 :   location_t loc = c_parser_peek_token (parser)->location;
    4892          202 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_ALIGNAS));
    4893          202 :   tree spelling = c_parser_peek_token (parser)->value;
    4894          202 :   c_parser_consume_token (parser);
    4895          202 :   if (flag_isoc99)
    4896          199 :     pedwarn_c99 (loc, OPT_Wpedantic,
    4897              :                  "ISO C99 does not support %qE", spelling);
    4898              :   else
    4899            3 :     pedwarn_c99 (loc, OPT_Wpedantic,
    4900              :                  "ISO C90 does not support %qE", spelling);
    4901          202 :   matching_parens parens;
    4902          202 :   if (!parens.require_open (parser))
    4903              :     return ret;
    4904          202 :   if (c_parser_next_tokens_start_typename (parser, cla_prefer_id))
    4905              :     {
    4906          132 :       struct c_type_name *type = c_parser_type_name (parser);
    4907          132 :       if (type != NULL)
    4908          131 :         ret = c_sizeof_or_alignof_type (loc, groktypename (type, NULL, NULL),
    4909              :                                         false, true, 1);
    4910              :     }
    4911              :   else
    4912           70 :     ret = convert_lvalue_to_rvalue (loc,
    4913              :                                     c_parser_expr_no_commas (parser, NULL),
    4914              :                                     true, true).value;
    4915          202 :   parens.skip_until_found_close (parser);
    4916          202 :   return ret;
    4917              : }
    4918              : 
    4919              : /* Parse a declarator, possibly an abstract declarator (C90 6.5.4,
    4920              :    6.5.5, C99 6.7.5, 6.7.6, C11 6.7.6, 6.7.7).  If TYPE_SEEN_P then
    4921              :    a typedef name may be redeclared; otherwise it may not.  KIND
    4922              :    indicates which kind of declarator is wanted.  Returns a valid
    4923              :    declarator except in the case of a syntax error in which case NULL is
    4924              :    returned.  *SEEN_ID is set to true if an identifier being declared is
    4925              :    seen; this is used to diagnose bad forms of abstract array declarators
    4926              :    and to determine whether an identifier list is syntactically permitted.
    4927              : 
    4928              :    declarator:
    4929              :      pointer[opt] direct-declarator
    4930              : 
    4931              :    direct-declarator:
    4932              :      identifier
    4933              :      ( gnu-attributes[opt] declarator )
    4934              :      direct-declarator array-declarator
    4935              :      direct-declarator ( parameter-type-list )
    4936              :      direct-declarator ( identifier-list[opt] )
    4937              : 
    4938              :    pointer:
    4939              :      * type-qualifier-list[opt]
    4940              :      * type-qualifier-list[opt] pointer
    4941              : 
    4942              :    type-qualifier-list:
    4943              :      type-qualifier
    4944              :      gnu-attributes
    4945              :      type-qualifier-list type-qualifier
    4946              :      type-qualifier-list gnu-attributes
    4947              : 
    4948              :    array-declarator:
    4949              :      [ type-qualifier-list[opt] assignment-expression[opt] ]
    4950              :      [ static type-qualifier-list[opt] assignment-expression ]
    4951              :      [ type-qualifier-list static assignment-expression ]
    4952              :      [ type-qualifier-list[opt] * ]
    4953              : 
    4954              :    parameter-type-list:
    4955              :      parameter-list
    4956              :      parameter-list , ...
    4957              : 
    4958              :    parameter-list:
    4959              :      parameter-declaration
    4960              :      parameter-list , parameter-declaration
    4961              : 
    4962              :    parameter-declaration:
    4963              :      declaration-specifiers declarator gnu-attributes[opt]
    4964              :      declaration-specifiers abstract-declarator[opt] gnu-attributes[opt]
    4965              : 
    4966              :    identifier-list:
    4967              :      identifier
    4968              :      identifier-list , identifier
    4969              : 
    4970              :    abstract-declarator:
    4971              :      pointer
    4972              :      pointer[opt] direct-abstract-declarator
    4973              : 
    4974              :    direct-abstract-declarator:
    4975              :      ( gnu-attributes[opt] abstract-declarator )
    4976              :      direct-abstract-declarator[opt] array-declarator
    4977              :      direct-abstract-declarator[opt] ( parameter-type-list[opt] )
    4978              : 
    4979              :    GNU extensions:
    4980              : 
    4981              :    direct-declarator:
    4982              :      direct-declarator ( parameter-forward-declarations
    4983              :                          parameter-type-list[opt] )
    4984              : 
    4985              :    direct-abstract-declarator:
    4986              :      direct-abstract-declarator[opt] ( parameter-forward-declarations
    4987              :                                        parameter-type-list[opt] )
    4988              : 
    4989              :    parameter-forward-declarations:
    4990              :      parameter-list ;
    4991              :      parameter-forward-declarations parameter-list ;
    4992              : 
    4993              :    The uses of gnu-attributes shown above are GNU extensions.
    4994              : 
    4995              :    Some forms of array declarator are not included in C99 in the
    4996              :    syntax for abstract declarators; these are disallowed elsewhere.
    4997              :    This may be a defect (DR#289).
    4998              : 
    4999              :    This function also accepts an omitted abstract declarator as being
    5000              :    an abstract declarator, although not part of the formal syntax.  */
    5001              : 
    5002              : struct c_declarator *
    5003    345074970 : c_parser_declarator (c_parser *parser, bool type_seen_p, c_dtr_syn kind,
    5004              :                      bool *seen_id)
    5005              : {
    5006              :   /* Parse any initial pointer part.  */
    5007    345074970 :   if (c_parser_next_token_is (parser, CPP_MULT))
    5008              :     {
    5009     18840936 :       struct c_declspecs *quals_attrs = build_null_declspecs ();
    5010     18840936 :       struct c_declarator *inner;
    5011     18840936 :       c_parser_consume_token (parser);
    5012     18840936 :       c_parser_declspecs (parser, quals_attrs, false, false, true,
    5013              :                           false, false, true, false, cla_prefer_id);
    5014     18840936 :       inner = c_parser_declarator (parser, type_seen_p, kind, seen_id);
    5015     18840936 :       if (inner == NULL)
    5016              :         return NULL;
    5017              :       else
    5018     18840927 :         return make_pointer_declarator (quals_attrs, inner);
    5019              :     }
    5020              :   /* Now we have a direct declarator, direct abstract declarator or
    5021              :      nothing (which counts as a direct abstract declarator here).  */
    5022    326234034 :   return c_parser_direct_declarator (parser, type_seen_p, kind, seen_id);
    5023              : }
    5024              : 
    5025              : /* Parse a direct declarator or direct abstract declarator; arguments
    5026              :    as c_parser_declarator.  */
    5027              : 
    5028              : static struct c_declarator *
    5029    326234034 : c_parser_direct_declarator (c_parser *parser, bool type_seen_p, c_dtr_syn kind,
    5030              :                             bool *seen_id)
    5031              : {
    5032              :   /* The direct declarator must start with an identifier (possibly
    5033              :      omitted) or a parenthesized declarator (possibly abstract).  In
    5034              :      an ordinary declarator, initial parentheses must start a
    5035              :      parenthesized declarator.  In an abstract declarator or parameter
    5036              :      declarator, they could start a parenthesized declarator or a
    5037              :      parameter list.  To tell which, the open parenthesis and any
    5038              :      following gnu-attributes must be read.  If a declaration
    5039              :      specifier or standard attributes follow, then it is a parameter
    5040              :      list; if the specifier is a typedef name, there might be an
    5041              :      ambiguity about redeclaring it, which is resolved in the
    5042              :      direction of treating it as a typedef name.  If a close
    5043              :      parenthesis follows, it is also an empty parameter list, as the
    5044              :      syntax does not permit empty abstract declarators.  Otherwise, it
    5045              :      is a parenthesized declarator (in which case the analysis may be
    5046              :      repeated inside it, recursively).
    5047              : 
    5048              :      ??? There is an ambiguity in a parameter declaration "int
    5049              :      (__attribute__((foo)) x)", where x is not a typedef name: it
    5050              :      could be an abstract declarator for a function, or declare x with
    5051              :      parentheses.  The proper resolution of this ambiguity needs
    5052              :      documenting.  At present we follow an accident of the old
    5053              :      parser's implementation, whereby the first parameter must have
    5054              :      some declaration specifiers other than just gnu-attributes.  Thus as
    5055              :      a parameter declaration it is treated as a parenthesized
    5056              :      parameter named x, and as an abstract declarator it is
    5057              :      rejected.
    5058              : 
    5059              :      ??? Also following the old parser, gnu-attributes inside an empty
    5060              :      parameter list are ignored, making it a list not yielding a
    5061              :      prototype, rather than giving an error or making it have one
    5062              :      parameter with implicit type int.
    5063              : 
    5064              :      ??? Also following the old parser, typedef names may be
    5065              :      redeclared in declarators, but not Objective-C class names.  */
    5066              : 
    5067    326234034 :   if (kind != C_DTR_ABSTRACT
    5068    199661317 :       && c_parser_next_token_is (parser, CPP_NAME)
    5069    520957051 :       && ((type_seen_p
    5070    194713155 :            && (c_parser_peek_token (parser)->id_kind == C_ID_TYPENAME
    5071    194665221 :                || c_parser_peek_token (parser)->id_kind == C_ID_CLASSNAME))
    5072    194675083 :           || c_parser_peek_token (parser)->id_kind == C_ID_ID))
    5073              :     {
    5074    194723017 :       struct c_declarator *inner
    5075    194723017 :         = build_id_declarator (c_parser_peek_token (parser)->value);
    5076    194723017 :       *seen_id = true;
    5077    194723017 :       inner->id_loc = c_parser_peek_token (parser)->location;
    5078    194723017 :       c_parser_consume_token (parser);
    5079    194723017 :       if (c_parser_nth_token_starts_std_attributes (parser, 1))
    5080           93 :         inner->u.id.attrs = c_parser_std_attribute_specifier_sequence (parser);
    5081    194723017 :       return c_parser_direct_declarator_inner (parser, *seen_id, inner);
    5082              :     }
    5083              : 
    5084    131511017 :   if (kind != C_DTR_NORMAL
    5085    131370448 :       && c_parser_next_token_is (parser, CPP_OPEN_SQUARE)
    5086    131535415 :       && !c_parser_nth_token_starts_std_attributes (parser, 1))
    5087              :     {
    5088        24398 :       struct c_declarator *inner = build_id_declarator (NULL_TREE);
    5089        24398 :       inner->id_loc = c_parser_peek_token (parser)->location;
    5090        24398 :       return c_parser_direct_declarator_inner (parser, *seen_id, inner);
    5091              :     }
    5092              : 
    5093              :   /* Either we are at the end of an abstract declarator, or we have
    5094              :      parentheses.  */
    5095              : 
    5096    131486619 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
    5097              :     {
    5098       240368 :       tree attrs;
    5099       240368 :       struct c_declarator *inner;
    5100       240368 :       c_parser_consume_token (parser);
    5101       240368 :       bool have_gnu_attrs = c_parser_next_token_is_keyword (parser,
    5102              :                                                             RID_ATTRIBUTE);
    5103       240368 :       attrs = c_parser_gnu_attributes (parser);
    5104       240368 :       if (kind != C_DTR_NORMAL
    5105       240368 :           && (c_parser_next_token_starts_declspecs (parser)
    5106        99911 :               || (!have_gnu_attrs
    5107        99753 :                   && (c_parser_nth_token_starts_std_attributes (parser, 1)
    5108        99753 :                       || c_parser_next_token_is (parser, CPP_ELLIPSIS)))
    5109        99906 :               || c_parser_next_token_is (parser, CPP_CLOSE_PAREN)))
    5110              :         {
    5111           64 :           struct c_arg_info *args
    5112           64 :             = c_parser_parms_declarator (parser, kind == C_DTR_NORMAL,
    5113              :                                          attrs, have_gnu_attrs);
    5114           64 :           if (args == NULL)
    5115              :             return NULL;
    5116              :           else
    5117              :             {
    5118           64 :               inner = build_id_declarator (NULL_TREE);
    5119           89 :               if (!(args->types
    5120           25 :                     && args->types != error_mark_node
    5121           25 :                     && TREE_CODE (TREE_VALUE (args->types)) == IDENTIFIER_NODE)
    5122           89 :                   && c_parser_nth_token_starts_std_attributes (parser, 1))
    5123              :                 {
    5124            4 :                   tree std_attrs
    5125            4 :                     = c_parser_std_attribute_specifier_sequence (parser);
    5126            4 :                   if (std_attrs)
    5127            2 :                     inner = build_attrs_declarator (std_attrs, inner);
    5128              :                 }
    5129           64 :               inner = build_function_declarator (args, inner);
    5130           64 :               return c_parser_direct_declarator_inner (parser, *seen_id,
    5131           64 :                                                        inner);
    5132              :             }
    5133              :         }
    5134              :       /* A parenthesized declarator.  */
    5135       240304 :       inner = c_parser_declarator (parser, type_seen_p, kind, seen_id);
    5136       240304 :       if (inner != NULL && attrs != NULL)
    5137          179 :         inner = build_attrs_declarator (attrs, inner);
    5138       240304 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5139              :         {
    5140       240288 :           c_parser_consume_token (parser);
    5141       240288 :           if (inner == NULL)
    5142              :             return NULL;
    5143              :           else
    5144       240288 :             return c_parser_direct_declarator_inner (parser, *seen_id, inner);
    5145              :         }
    5146              :       else
    5147              :         {
    5148           16 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    5149              :                                      "expected %<)%>");
    5150           16 :           return NULL;
    5151              :         }
    5152              :     }
    5153              :   else
    5154              :     {
    5155    131246251 :       if (kind == C_DTR_NORMAL)
    5156              :         {
    5157          137 :           c_parser_error (parser, "expected identifier or %<(%>");
    5158          137 :           return NULL;
    5159              :         }
    5160              :       else
    5161    131246114 :         return build_id_declarator (NULL_TREE);
    5162              :     }
    5163              : }
    5164              : 
    5165              : /* Parse part of a direct declarator or direct abstract declarator,
    5166              :    given that some (in INNER) has already been parsed; ID_PRESENT is
    5167              :    true if an identifier is present, false for an abstract
    5168              :    declarator.  */
    5169              : 
    5170              : static struct c_declarator *
    5171    194987767 : c_parser_direct_declarator_inner (c_parser *parser, bool id_present,
    5172              :                                   struct c_declarator *inner)
    5173              : {
    5174              :   /* Parse a sequence of array declarators and parameter lists.  */
    5175    248807394 :   if (c_parser_next_token_is (parser, CPP_OPEN_SQUARE)
    5176    248807394 :       && !c_parser_nth_token_starts_std_attributes (parser, 1))
    5177              :     {
    5178      1158561 :       location_t brace_loc = c_parser_peek_token (parser)->location;
    5179      1158561 :       struct c_declarator *declarator;
    5180      1158561 :       struct c_declspecs *quals_attrs = build_null_declspecs ();
    5181      1158561 :       struct c_expr dimen;
    5182      1158561 :       dimen.value = NULL_TREE;
    5183      1158561 :       dimen.original_code = ERROR_MARK;
    5184      1158561 :       dimen.original_type = NULL_TREE;
    5185      1158561 :       c_parser_consume_token (parser);
    5186      1158561 :       c_parser_declspecs (parser, quals_attrs, false, false, true,
    5187              :                           false, false, false, false, cla_prefer_id);
    5188              : 
    5189      1158561 :       location_t static_loc = UNKNOWN_LOCATION;
    5190      1158561 :       if (c_parser_next_token_is_keyword (parser, RID_STATIC))
    5191              :         {
    5192          131 :           static_loc = c_parser_peek_token (parser)->location;
    5193          131 :           c_parser_consume_token (parser);
    5194          131 :           if (!quals_attrs->declspecs_seen_p)
    5195          111 :             c_parser_declspecs (parser, quals_attrs, false, false, true,
    5196              :                                 false, false, false, false, cla_prefer_id);
    5197              :         }
    5198      1158561 :       if (!quals_attrs->declspecs_seen_p)
    5199      1157590 :         quals_attrs = NULL;
    5200              :       /* If "static" is present, there must be an array dimension.
    5201              :          Otherwise, there may be a dimension, "*", or no
    5202              :          dimension.  */
    5203      1158561 :       const bool static_seen = (static_loc != UNKNOWN_LOCATION);
    5204      1158561 :       bool star_seen = false;
    5205      1158561 :       if (c_parser_next_token_is (parser, CPP_MULT)
    5206      1158561 :           && c_parser_peek_2nd_token (parser)->type == CPP_CLOSE_SQUARE)
    5207              :         {
    5208          155 :           star_seen = true;
    5209          155 :           c_parser_consume_token (parser);
    5210              :         }
    5211      1158406 :       else if (!c_parser_next_token_is (parser, CPP_CLOSE_SQUARE))
    5212       985498 :         dimen = c_parser_expr_no_commas (parser, NULL);
    5213              : 
    5214      1158561 :       if (static_seen)
    5215              :         {
    5216          131 :           if (star_seen)
    5217              :             {
    5218            3 :               error_at (static_loc,
    5219              :                         "%<static%> may not be used with an unspecified "
    5220              :                         "variable length array size");
    5221              :               /* Prevent further errors.  */
    5222            3 :               star_seen = false;
    5223            3 :               dimen.value = error_mark_node;
    5224              :             }
    5225          128 :           else if (!dimen.value)
    5226            2 :             error_at (static_loc,
    5227              :                       "%<static%> may not be used without an array size");
    5228              :         }
    5229              : 
    5230      1158561 :       if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE))
    5231      1158546 :         c_parser_consume_token (parser);
    5232              :       else
    5233              :         {
    5234           15 :           c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
    5235              :                                      "expected %<]%>");
    5236           15 :           return NULL;
    5237              :         }
    5238      1158546 :       if (dimen.value)
    5239       985486 :         dimen = convert_lvalue_to_rvalue (brace_loc, dimen, true, true);
    5240      1158546 :       declarator = build_array_declarator (brace_loc, dimen.value, quals_attrs,
    5241              :                                            static_seen, star_seen);
    5242      1158546 :       if (declarator == NULL)
    5243              :         return NULL;
    5244      1158546 :       if (c_parser_nth_token_starts_std_attributes (parser, 1))
    5245              :         {
    5246           16 :           tree std_attrs
    5247           16 :             = c_parser_std_attribute_specifier_sequence (parser);
    5248           16 :           if (std_attrs)
    5249           10 :             inner = build_attrs_declarator (std_attrs, inner);
    5250              :         }
    5251      1158546 :       inner = set_array_declarator_inner (declarator, inner);
    5252      1158546 :       return c_parser_direct_declarator_inner (parser, id_present, inner);
    5253              :     }
    5254    247648833 :   else if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
    5255              :     {
    5256     52661191 :       tree attrs;
    5257     52661191 :       struct c_arg_info *args;
    5258     52661191 :       c_parser_consume_token (parser);
    5259     52661191 :       bool have_gnu_attrs = c_parser_next_token_is_keyword (parser,
    5260              :                                                             RID_ATTRIBUTE);
    5261     52661191 :       attrs = c_parser_gnu_attributes (parser);
    5262     52661191 :       args = c_parser_parms_declarator (parser, id_present, attrs,
    5263              :                                         have_gnu_attrs);
    5264     52661191 :       if (args == NULL)
    5265              :         return NULL;
    5266              :       else
    5267              :         {
    5268    104531989 :           if (!(args->types
    5269     51870908 :                 && args->types != error_mark_node
    5270     51870908 :                 && TREE_CODE (TREE_VALUE (args->types)) == IDENTIFIER_NODE)
    5271    104523303 :               && c_parser_nth_token_starts_std_attributes (parser, 1))
    5272              :             {
    5273          138 :               tree std_attrs
    5274          138 :                 = c_parser_std_attribute_specifier_sequence (parser);
    5275          138 :               if (std_attrs)
    5276          121 :                 inner = build_attrs_declarator (std_attrs, inner);
    5277              :             }
    5278     52661081 :           inner = build_function_declarator (args, inner);
    5279     52661081 :           return c_parser_direct_declarator_inner (parser, id_present, inner);
    5280              :         }
    5281              :     }
    5282              :   return inner;
    5283              : }
    5284              : 
    5285              : /* Parse a parameter list or identifier list, including the closing
    5286              :    parenthesis but not the opening one.  ATTRS are the gnu-attributes
    5287              :    at the start of the list.  ID_LIST_OK is true if an identifier list
    5288              :    is acceptable; such a list must not have attributes at the start.
    5289              :    HAVE_GNU_ATTRS says whether any gnu-attributes (including empty
    5290              :    attributes) were present (in which case standard attributes cannot
    5291              :    occur).  */
    5292              : 
    5293              : static struct c_arg_info *
    5294     52661255 : c_parser_parms_declarator (c_parser *parser, bool id_list_ok, tree attrs,
    5295              :                            bool have_gnu_attrs)
    5296              : {
    5297     52661255 :   push_scope ();
    5298     52661255 :   declare_parm_level ();
    5299              :   /* If the list starts with an identifier, it is an identifier list.
    5300              :      Otherwise, it is either a prototype list or an empty list.  */
    5301     52661255 :   if (id_list_ok
    5302     52661255 :       && !attrs
    5303     52649072 :       && c_parser_next_token_is (parser, CPP_NAME)
    5304     35069419 :       && c_parser_peek_token (parser)->id_kind == C_ID_ID
    5305              : 
    5306              :       /* Look ahead to detect typos in type names.  */
    5307         8699 :       && c_parser_peek_2nd_token (parser)->type != CPP_NAME
    5308         8690 :       && c_parser_peek_2nd_token (parser)->type != CPP_MULT
    5309         8689 :       && c_parser_peek_2nd_token (parser)->type != CPP_OPEN_PAREN
    5310         8688 :       && c_parser_peek_2nd_token (parser)->type != CPP_OPEN_SQUARE
    5311     52669942 :       && c_parser_peek_2nd_token (parser)->type != CPP_KEYWORD)
    5312              :     {
    5313         8686 :       tree list = NULL_TREE, *nextp = &list;
    5314         8686 :       while (c_parser_next_token_is (parser, CPP_NAME)
    5315        34291 :              && c_parser_peek_token (parser)->id_kind == C_ID_ID)
    5316              :         {
    5317        34291 :           *nextp = build_tree_list (NULL_TREE,
    5318        34291 :                                     c_parser_peek_token (parser)->value);
    5319        34291 :           nextp = & TREE_CHAIN (*nextp);
    5320        34291 :           c_parser_consume_token (parser);
    5321        34291 :           if (c_parser_next_token_is_not (parser, CPP_COMMA))
    5322              :             break;
    5323        25605 :           c_parser_consume_token (parser);
    5324        25605 :           if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5325              :             {
    5326            0 :               c_parser_error (parser, "expected identifier");
    5327            0 :               break;
    5328              :             }
    5329              :         }
    5330         8686 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5331              :         {
    5332         8686 :           struct c_arg_info *ret = build_arg_info ();
    5333         8686 :           ret->types = list;
    5334         8686 :           c_parser_consume_token (parser);
    5335         8686 :           pop_scope ();
    5336         8686 :           return ret;
    5337              :         }
    5338              :       else
    5339              :         {
    5340            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    5341              :                                      "expected %<)%>");
    5342            0 :           pop_scope ();
    5343            0 :           return NULL;
    5344              :         }
    5345              :     }
    5346              :   else
    5347              :     {
    5348     52652569 :       struct c_arg_info *ret
    5349     52652569 :         = c_parser_parms_list_declarator (parser, attrs, NULL, have_gnu_attrs);
    5350     52652569 :       pop_scope ();
    5351     52652569 :       return ret;
    5352              :     }
    5353              : }
    5354              : 
    5355              : /* Parse a parameter list (possibly empty), including the closing
    5356              :    parenthesis but not the opening one.  ATTRS are the gnu-attributes
    5357              :    at the start of the list; if HAVE_GNU_ATTRS, there were some such
    5358              :    attributes (possibly empty, in which case ATTRS is NULL_TREE),
    5359              :    which means standard attributes cannot start the list.  EXPR is
    5360              :    NULL or an expression that needs to be evaluated for the side
    5361              :    effects of array size expressions in the parameters.  */
    5362              : 
    5363              : static struct c_arg_info *
    5364     52652611 : c_parser_parms_list_declarator (c_parser *parser, tree attrs, tree expr,
    5365              :                                 bool have_gnu_attrs)
    5366              : {
    5367     52652611 :   bool bad_parm = false;
    5368              : 
    5369              :   /* ??? Following the old parser, forward parameter declarations may
    5370              :      use abstract declarators, and if no real parameter declarations
    5371              :      follow the forward declarations then this is not diagnosed.  Also
    5372              :      note as above that gnu-attributes are ignored as the only contents of
    5373              :      the parentheses, or as the only contents after forward
    5374              :      declarations.  */
    5375     52652611 :   if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5376              :     {
    5377       790052 :       struct c_arg_info *ret = build_arg_info ();
    5378       790052 :       c_parser_consume_token (parser);
    5379       790052 :       return ret;
    5380              :     }
    5381     51862559 :   if (c_parser_next_token_is (parser, CPP_ELLIPSIS) && !have_gnu_attrs)
    5382              :     {
    5383          137 :       struct c_arg_info *ret = build_arg_info ();
    5384              : 
    5385          137 :       ret->types = NULL_TREE;
    5386          137 :       pedwarn_c11 (c_parser_peek_token (parser)->location, OPT_Wpedantic,
    5387              :                    "ISO C requires a named argument before %<...%> "
    5388              :                    "before C23");
    5389          137 :       c_parser_consume_token (parser);
    5390          137 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5391              :         {
    5392          137 :           ret->no_named_args_stdarg_p = true;
    5393          137 :           c_parser_consume_token (parser);
    5394          137 :           return ret;
    5395              :         }
    5396              :       else
    5397              :         {
    5398            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    5399              :                                      "expected %<)%>");
    5400            0 :           return NULL;
    5401              :         }
    5402              :     }
    5403              :   /* Nonempty list of parameters, either terminated with semicolon
    5404              :      (forward declarations; recurse) or with close parenthesis (normal
    5405              :      function) or with ", ... )" (variadic function).  */
    5406    128550504 :   while (true)
    5407              :     {
    5408              :       /* Parse a parameter.  */
    5409    128550504 :       struct c_parm *parm = c_parser_parameter_declaration (parser, attrs,
    5410              :                                                             have_gnu_attrs);
    5411    128550504 :       attrs = NULL_TREE;
    5412    128550504 :       have_gnu_attrs = false;
    5413    128550504 :       if (parm == NULL)
    5414              :         bad_parm = true;
    5415              :       else
    5416    128550391 :         push_parm_decl (parm, &expr);
    5417    128550504 :       if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    5418              :         {
    5419           42 :           tree new_attrs;
    5420           42 :           c_parser_consume_token (parser);
    5421           42 :           mark_forward_parm_decls ();
    5422           42 :           bool new_have_gnu_attrs
    5423           42 :             = c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE);
    5424           42 :           new_attrs = c_parser_gnu_attributes (parser);
    5425           42 :           return c_parser_parms_list_declarator (parser, new_attrs, expr,
    5426           42 :                                                  new_have_gnu_attrs);
    5427              :         }
    5428    128550462 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5429              :         {
    5430     51646883 :           c_parser_consume_token (parser);
    5431     51646883 :           if (bad_parm)
    5432              :             return NULL;
    5433              :           else
    5434     51646796 :             return get_parm_info (false, expr);
    5435              :         }
    5436     76903579 :       if (!c_parser_require (parser, CPP_COMMA,
    5437              :                              "expected %<;%>, %<,%> or %<)%>",
    5438              :                              UNKNOWN_LOCATION, false))
    5439              :         {
    5440            8 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
    5441            8 :           return NULL;
    5442              :         }
    5443     76903571 :       if (c_parser_next_token_is (parser, CPP_ELLIPSIS))
    5444              :         {
    5445       215489 :           c_parser_consume_token (parser);
    5446       215489 :           if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5447              :             {
    5448       215482 :               c_parser_consume_token (parser);
    5449       215482 :               if (bad_parm)
    5450              :                 return NULL;
    5451              :               else
    5452       215474 :                 return get_parm_info (true, expr);
    5453              :             }
    5454              :           else
    5455              :             {
    5456            7 :               c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    5457              :                                          "expected %<)%>");
    5458            7 :               return NULL;
    5459              :             }
    5460              :         }
    5461              :     }
    5462              : }
    5463              : 
    5464              : /* Parse a parameter declaration.  ATTRS are the gnu-attributes at the
    5465              :    start of the declaration if it is the first parameter;
    5466              :    HAVE_GNU_ATTRS is true if there were any gnu-attributes there (even
    5467              :    empty) there.  */
    5468              : 
    5469              : static struct c_parm *
    5470    128550504 : c_parser_parameter_declaration (c_parser *parser, tree attrs,
    5471              :                                 bool have_gnu_attrs)
    5472              : {
    5473    128550504 :   struct c_declspecs *specs;
    5474    128550504 :   struct c_declarator *declarator;
    5475    128550504 :   tree prefix_attrs;
    5476    128550504 :   tree postfix_attrs = NULL_TREE;
    5477    128550504 :   bool dummy = false;
    5478              : 
    5479              :   /* Accept #pragmas between parameter declarations.  */
    5480    128550506 :   while (c_parser_next_token_is (parser, CPP_PRAGMA))
    5481            2 :     c_parser_pragma (parser, pragma_param, NULL, NULL_TREE);
    5482              : 
    5483    128550504 :   if (!c_parser_next_token_starts_declspecs (parser)
    5484    128550504 :       && !c_parser_nth_token_starts_std_attributes (parser, 1))
    5485              :     {
    5486          101 :       c_token *token = c_parser_peek_token (parser);
    5487          101 :       if (parser->error)
    5488              :         return NULL;
    5489          101 :       c_parser_set_source_position_from_token (token);
    5490          101 :       if (c_parser_next_tokens_start_typename (parser, cla_prefer_type))
    5491              :         {
    5492           83 :           auto_diagnostic_group d;
    5493           83 :           name_hint hint = lookup_name_fuzzy (token->value,
    5494              :                                               FUZZY_LOOKUP_TYPENAME,
    5495           83 :                                               token->location);
    5496           83 :           if (const char *suggestion = hint.suggestion ())
    5497              :             {
    5498           30 :               gcc_rich_location richloc (token->location);
    5499           30 :               richloc.add_fixit_replace (suggestion);
    5500           30 :               error_at (&richloc,
    5501              :                         "unknown type name %qE; did you mean %qs?",
    5502              :                         token->value, suggestion);
    5503           30 :             }
    5504              :           else
    5505           53 :             error_at (token->location, "unknown type name %qE", token->value);
    5506           83 :           parser->error = true;
    5507           83 :         }
    5508              :       /* ??? In some Objective-C cases '...' isn't applicable so there
    5509              :          should be a different message.  */
    5510              :       else
    5511           18 :         c_parser_error (parser,
    5512              :                         "expected declaration specifiers or %<...%>");
    5513          101 :       c_parser_skip_to_end_of_parameter (parser);
    5514          101 :       return NULL;
    5515              :     }
    5516              : 
    5517    128550403 :   location_t start_loc = c_parser_peek_token (parser)->location;
    5518              : 
    5519    128550403 :   specs = build_null_declspecs ();
    5520    128550403 :   if (attrs)
    5521              :     {
    5522          341 :       declspecs_add_attrs (input_location, specs, attrs);
    5523          341 :       attrs = NULL_TREE;
    5524              :     }
    5525    128550403 :   c_parser_declspecs (parser, specs, true, true, true, true, false,
    5526              :                       !have_gnu_attrs, true, cla_nonabstract_decl);
    5527    128550403 :   finish_declspecs (specs);
    5528              :   /* When the param is declared, its type is a top level type, we should
    5529              :      call verify_counted_by_for_top_anonymous_type.  */
    5530    128550403 :   if (specs->typespec_kind == ctsk_tagdef)
    5531           67 :     verify_counted_by_for_top_anonymous_type (specs->type);
    5532              : 
    5533    128550403 :   pending_xref_error ();
    5534    128550403 :   prefix_attrs = specs->attrs;
    5535    128550403 :   specs->attrs = NULL_TREE;
    5536    257100806 :   declarator = c_parser_declarator (parser,
    5537    128550403 :                                     specs->typespec_kind != ctsk_none,
    5538              :                                     C_DTR_PARM, &dummy);
    5539    128550403 :   if (declarator == NULL)
    5540              :     {
    5541           12 :       c_parser_skip_until_found (parser, CPP_COMMA, NULL);
    5542           12 :       return NULL;
    5543              :     }
    5544    128550391 :   if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
    5545        17370 :     postfix_attrs = c_parser_gnu_attributes (parser);
    5546              : 
    5547              :   /* Generate a location for the parameter, ranging from the start of the
    5548              :      initial token to the end of the final token.
    5549              : 
    5550              :      If we have a identifier, then use it for the caret location, e.g.
    5551              : 
    5552              :        extern int callee (int one, int (*two)(int, int), float three);
    5553              :                                    ~~~~~~^~~~~~~~~~~~~~
    5554              : 
    5555              :      otherwise, reuse the start location for the caret location e.g.:
    5556              : 
    5557              :        extern int callee (int one, int (*)(int, int), float three);
    5558              :                                    ^~~~~~~~~~~~~~~~~
    5559              :   */
    5560    128550391 :   location_t end_loc = parser->last_token_location;
    5561              : 
    5562              :   /* Find any cdk_id declarator; determine if we have an identifier.  */
    5563    128550391 :   c_declarator *id_declarator = declarator;
    5564    141911808 :   while (id_declarator && id_declarator->kind != cdk_id)
    5565     13361417 :     id_declarator = id_declarator->declarator;
    5566    123846794 :   location_t caret_loc = (id_declarator->u.id.id
    5567    128550391 :                           ? id_declarator->id_loc
    5568              :                           : start_loc);
    5569    128550391 :   location_t param_loc = make_location (caret_loc, start_loc, end_loc);
    5570              : 
    5571    128550391 :   return build_c_parm (specs, chainon (postfix_attrs, prefix_attrs),
    5572    128550391 :                        declarator, param_loc);
    5573              : }
    5574              : 
    5575              : /* Parse a string literal in an asm expression.  It should not be
    5576              :    translated, and wide string literals are an error although
    5577              :    permitted by the syntax.  This is a GNU extension.
    5578              : 
    5579              :    asm-string-literal:
    5580              :      string-literal
    5581              : */
    5582              : 
    5583              : static tree
    5584      2065846 : c_parser_asm_string_literal (c_parser *parser)
    5585              : {
    5586      2065846 :   tree str;
    5587      2065846 :   int save_flag = warn_overlength_strings;
    5588      2065846 :   warn_overlength_strings = 0;
    5589      2065846 :   str = c_parser_string_literal (parser, false, false).value;
    5590      2065846 :   warn_overlength_strings = save_flag;
    5591      2065846 :   return str;
    5592              : }
    5593              : 
    5594              : /* Parse a simple asm expression.  This is used in restricted
    5595              :    contexts, where a full expression with inputs and outputs does not
    5596              :    make sense.  This is a GNU extension.
    5597              : 
    5598              :    simple-asm-expr:
    5599              :      asm ( asm-string-literal )
    5600              : */
    5601              : 
    5602              : static tree
    5603       881192 : c_parser_simple_asm_expr (c_parser *parser)
    5604              : {
    5605       881192 :   tree str;
    5606       881192 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_ASM));
    5607       881192 :   c_parser_consume_token (parser);
    5608       881192 :   matching_parens parens;
    5609       881192 :   if (!parens.require_open (parser))
    5610              :     return NULL_TREE;
    5611       881192 :   str = c_parser_asm_string_literal (parser);
    5612       881192 :   if (!parens.require_close (parser))
    5613              :     {
    5614            0 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
    5615            0 :       return NULL_TREE;
    5616              :     }
    5617              :   return str;
    5618              : }
    5619              : 
    5620              : static tree
    5621    141118443 : c_parser_gnu_attribute_any_word (c_parser *parser)
    5622              : {
    5623    141118443 :   tree attr_name = NULL_TREE;
    5624              : 
    5625    141118443 :   if (c_parser_next_token_is (parser, CPP_KEYWORD))
    5626              :     {
    5627              :       /* ??? See comment above about what keywords are accepted here.  */
    5628       913575 :       bool ok;
    5629       913575 :       switch (c_parser_peek_token (parser)->keyword)
    5630              :         {
    5631              :         case RID_STATIC:
    5632              :         case RID_UNSIGNED:
    5633              :         case RID_LONG:
    5634              :         case RID_CONST:
    5635              :         case RID_EXTERN:
    5636              :         case RID_REGISTER:
    5637              :         case RID_TYPEDEF:
    5638              :         case RID_SHORT:
    5639              :         case RID_INLINE:
    5640              :         case RID_NORETURN:
    5641              :         case RID_VOLATILE:
    5642              :         case RID_SIGNED:
    5643              :         case RID_AUTO:
    5644              :         case RID_RESTRICT:
    5645              :         case RID_COMPLEX:
    5646              :         case RID_THREAD:
    5647              :         case RID_INT:
    5648              :         case RID_CHAR:
    5649              :         case RID_FLOAT:
    5650              :         case RID_DOUBLE:
    5651              :         case RID_VOID:
    5652              :         case RID_DFLOAT32:
    5653              :         case RID_DFLOAT64:
    5654              :         case RID_DFLOAT128:
    5655              :         case RID_DFLOAT64X:
    5656              :         CASE_RID_FLOATN_NX:
    5657              :         case RID_BOOL:
    5658              :         case RID_BITINT:
    5659              :         case RID_FRACT:
    5660              :         case RID_ACCUM:
    5661              :         case RID_SAT:
    5662              :         case RID_TRANSACTION_ATOMIC:
    5663              :         case RID_TRANSACTION_CANCEL:
    5664              :         case RID_ATOMIC:
    5665              :         case RID_AUTO_TYPE:
    5666              :         case RID_CONSTEXPR:
    5667              :         case RID_INT_N_0:
    5668              :         case RID_INT_N_1:
    5669              :         case RID_INT_N_2:
    5670              :         case RID_INT_N_3:
    5671              :           ok = true;
    5672              :           break;
    5673              :         default:
    5674              :           ok = false;
    5675              :           break;
    5676              :         }
    5677       913575 :       if (!ok)
    5678              :         return NULL_TREE;
    5679              : 
    5680              :       /* Accept __attribute__((__const)) as __attribute__((const)) etc.  */
    5681       913575 :       attr_name = ridpointers[(int) c_parser_peek_token (parser)->keyword];
    5682              :     }
    5683    140204868 :   else if (c_parser_next_token_is (parser, CPP_NAME))
    5684    140204865 :     attr_name = c_parser_peek_token (parser)->value;
    5685              : 
    5686              :   return attr_name;
    5687              : }
    5688              : 
    5689              : /* Parse attribute arguments.  This is a common form of syntax
    5690              :    covering all currently valid GNU and standard attributes.
    5691              : 
    5692              :    gnu-attribute-arguments:
    5693              :      identifier
    5694              :      identifier , nonempty-expr-list
    5695              :      expr-list
    5696              : 
    5697              :    where the "identifier" must not be declared as a type.  ??? Why not
    5698              :    allow identifiers declared as types to start the arguments?  */
    5699              : 
    5700              : static tree
    5701      4737366 : c_parser_attribute_arguments (c_parser *parser, bool takes_identifier,
    5702              :                               bool require_string, bool assume_attr,
    5703              :                               bool allow_empty_args)
    5704              : {
    5705      4737366 :   vec<tree, va_gc> *expr_list;
    5706      4737366 :   tree attr_args;
    5707              :   /* Parse the attribute contents.  If they start with an
    5708              :      identifier which is followed by a comma or close
    5709              :      parenthesis, then the arguments start with that
    5710              :      identifier; otherwise they are an expression list.
    5711              :      In objective-c the identifier may be a classname.  */
    5712      4737366 :   if (c_parser_next_token_is (parser, CPP_NAME)
    5713       606744 :       && (c_parser_peek_token (parser)->id_kind == C_ID_ID
    5714            1 :           || (c_dialect_objc ()
    5715            0 :               && c_parser_peek_token (parser)->id_kind
    5716              :               == C_ID_CLASSNAME))
    5717       606743 :       && ((c_parser_peek_2nd_token (parser)->type == CPP_COMMA)
    5718        40985 :           || (c_parser_peek_2nd_token (parser)->type
    5719              :               == CPP_CLOSE_PAREN))
    5720      5344064 :       && (takes_identifier
    5721       146274 :           || (c_dialect_objc ()
    5722            0 :               && !assume_attr
    5723            0 :               && c_parser_peek_token (parser)->id_kind
    5724              :               == C_ID_CLASSNAME)))
    5725              :     {
    5726       460424 :       tree arg1 = c_parser_peek_token (parser)->value;
    5727       460424 :       c_parser_consume_token (parser);
    5728       460424 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5729        36428 :         attr_args = build_tree_list (NULL_TREE, arg1);
    5730              :       else
    5731              :         {
    5732       423996 :           tree tree_list;
    5733       423996 :           c_parser_consume_token (parser);
    5734       423996 :           expr_list = c_parser_expr_list (parser, false, true,
    5735              :                                           NULL, NULL, NULL, NULL);
    5736       423996 :           tree_list = build_tree_list_vec (expr_list);
    5737       423996 :           attr_args = tree_cons (NULL_TREE, arg1, tree_list);
    5738       423996 :           release_tree_vector (expr_list);
    5739              :         }
    5740              :     }
    5741              :   else
    5742              :     {
    5743      4276942 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5744              :         {
    5745           16 :           if (!allow_empty_args)
    5746            3 :             error_at (c_parser_peek_token (parser)->location,
    5747              :                       "parentheses must be omitted if "
    5748              :                       "attribute argument list is empty");
    5749              :           attr_args = NULL_TREE;
    5750              :         }
    5751      4276926 :       else if (require_string)
    5752              :         {
    5753              :           /* The only valid argument for this attribute is a string
    5754              :              literal.  Handle this specially here to avoid accepting
    5755              :              string literals with excess parentheses.  */
    5756           19 :           tree string = c_parser_string_literal (parser, false, true).value;
    5757           19 :           attr_args = build_tree_list (NULL_TREE, string);
    5758              :         }
    5759      4276907 :       else if (assume_attr)
    5760              :         {
    5761           51 :           tree cond
    5762           51 :             = c_parser_conditional_expression (parser, NULL, NULL_TREE).value;
    5763           51 :           if (!c_parser_next_token_is (parser, CPP_COMMA))
    5764           49 :             attr_args = build_tree_list (NULL_TREE, cond);
    5765              :           else
    5766              :             {
    5767            2 :               tree tree_list;
    5768            2 :               c_parser_consume_token (parser);
    5769            2 :               expr_list = c_parser_expr_list (parser, false, true,
    5770              :                                               NULL, NULL, NULL, NULL);
    5771            2 :               tree_list = build_tree_list_vec (expr_list);
    5772            2 :               attr_args = tree_cons (NULL_TREE, cond, tree_list);
    5773            2 :               release_tree_vector (expr_list);
    5774              :             }
    5775              :         }
    5776              :       else
    5777              :         {
    5778      4276856 :           expr_list = c_parser_expr_list (parser, false, true,
    5779              :                                           NULL, NULL, NULL, NULL);
    5780      4276856 :           attr_args = build_tree_list_vec (expr_list);
    5781      4276856 :           release_tree_vector (expr_list);
    5782              :         }
    5783              :     }
    5784      4737366 :   return attr_args;
    5785              : }
    5786              : 
    5787              : /* Parse (possibly empty) gnu-attributes.  This is a GNU extension.
    5788              : 
    5789              :    gnu-attributes:
    5790              :      empty
    5791              :      gnu-attributes gnu-attribute
    5792              : 
    5793              :    gnu-attribute:
    5794              :      __attribute__ ( ( gnu-attribute-list ) )
    5795              : 
    5796              :    gnu-attribute-list:
    5797              :      gnu-attrib
    5798              :      gnu-attribute_list , gnu-attrib
    5799              : 
    5800              :    gnu-attrib:
    5801              :      empty
    5802              :      any-word
    5803              :      any-word ( gnu-attribute-arguments )
    5804              : 
    5805              :    where "any-word" may be any identifier (including one declared as a
    5806              :    type), a reserved word storage class specifier, type specifier or
    5807              :    type qualifier.  ??? This still leaves out most reserved keywords
    5808              :    (following the old parser), shouldn't we include them?
    5809              :    When EXPECT_COMMA is true, expect the attribute to be preceded
    5810              :    by a comma and fail if it isn't.
    5811              :    When EMPTY_OK is true, allow and consume any number of consecutive
    5812              :    commas with no attributes in between.  */
    5813              : 
    5814              : static tree
    5815    196522221 : c_parser_gnu_attribute (c_parser *parser, tree attrs,
    5816              :                         bool expect_comma = false, bool empty_ok = true)
    5817              : {
    5818    196522221 :   bool comma_first = c_parser_next_token_is (parser, CPP_COMMA);
    5819    196522221 :   if (!comma_first
    5820    110808316 :       && !c_parser_next_token_is (parser, CPP_NAME)
    5821    252839467 :       && !c_parser_next_token_is (parser, CPP_KEYWORD))
    5822              :     return NULL_TREE;
    5823              : 
    5824    226832355 :   while (c_parser_next_token_is (parser, CPP_COMMA))
    5825              :     {
    5826     85713912 :       c_parser_consume_token (parser);
    5827     85713912 :       if (!empty_ok)
    5828              :         return attrs;
    5829              :     }
    5830              : 
    5831    141118443 :   tree attr_name = c_parser_gnu_attribute_any_word (parser);
    5832    141118443 :   if (attr_name == NULL_TREE)
    5833              :     return NULL_TREE;
    5834              : 
    5835    141118440 :   attr_name = canonicalize_attr_name (attr_name);
    5836    141118440 :   c_parser_consume_token (parser);
    5837              : 
    5838    141118440 :   tree attr;
    5839    141118440 :   if (c_parser_next_token_is_not (parser, CPP_OPEN_PAREN))
    5840              :     {
    5841    136381221 :       if (expect_comma && !comma_first)
    5842              :         {
    5843              :           /* A comma is missing between the last attribute on the chain
    5844              :              and this one.  */
    5845            7 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    5846              :                                      "expected %<)%>");
    5847            7 :           return error_mark_node;
    5848              :         }
    5849    136381214 :       attr = build_tree_list (attr_name, NULL_TREE);
    5850              :       /* Add this attribute to the list.  */
    5851    136381214 :       attrs = chainon (attrs, attr);
    5852    136381214 :       return attrs;
    5853              :     }
    5854      4737219 :   c_parser_consume_token (parser);
    5855              : 
    5856      4737219 :   tree attr_args
    5857      4737219 :     = c_parser_attribute_arguments (parser,
    5858              :                                     attribute_takes_identifier_p (attr_name),
    5859              :                                     false,
    5860              :                                     is_attribute_p ("assume", attr_name),
    5861              :                                     true);
    5862              : 
    5863      4737219 :   attr = build_tree_list (attr_name, attr_args);
    5864      4737219 :   if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5865      4737217 :     c_parser_consume_token (parser);
    5866              :   else
    5867              :     {
    5868            2 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    5869              :                                  "expected %<)%>");
    5870            2 :       return error_mark_node;
    5871              :     }
    5872              : 
    5873      4737217 :   if (expect_comma && !comma_first)
    5874              :     {
    5875              :       /* A comma is missing between the last attribute on the chain
    5876              :          and this one.  */
    5877            0 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    5878              :                                  "expected %<)%>");
    5879            0 :       return error_mark_node;
    5880              :     }
    5881              : 
    5882              :   /* Add this attribute to the list.  */
    5883      4737217 :   attrs = chainon (attrs, attr);
    5884      4737217 :   return attrs;
    5885              : }
    5886              : 
    5887              : static tree
    5888    113847815 : c_parser_gnu_attributes (c_parser *parser)
    5889              : {
    5890    113847815 :   tree attrs = NULL_TREE;
    5891    169251592 :   while (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
    5892              :     {
    5893     55403787 :       bool save_translate_strings_p = parser->translate_strings_p;
    5894     55403787 :       parser->translate_strings_p = false;
    5895              :       /* Consume the `__attribute__' keyword.  */
    5896     55403787 :       c_parser_consume_token (parser);
    5897              :       /* Look for the two `(' tokens.  */
    5898     55403787 :       if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
    5899              :         {
    5900            0 :           parser->translate_strings_p = save_translate_strings_p;
    5901            0 :           return attrs;
    5902              :         }
    5903     55403787 :       if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
    5904              :         {
    5905            0 :           parser->translate_strings_p = save_translate_strings_p;
    5906            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
    5907            0 :           return attrs;
    5908              :         }
    5909              :       /* Parse the attribute list.  Require a comma between successive
    5910              :          (possibly empty) attributes.  */
    5911              :       for (bool expect_comma = false; ; expect_comma = true)
    5912              :         {
    5913              :           /* Parse a single attribute.  */
    5914    196521460 :           tree attr = c_parser_gnu_attribute (parser, attrs, expect_comma);
    5915    196521460 :           if (attr == error_mark_node)
    5916              :             return attrs;
    5917    196521451 :           if (!attr)
    5918              :             break;
    5919              :           attrs = attr;
    5920              :       }
    5921              : 
    5922              :       /* Look for the two `)' tokens.  */
    5923     55403778 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5924     55403778 :         c_parser_consume_token (parser);
    5925              :       else
    5926              :         {
    5927            0 :           parser->translate_strings_p = save_translate_strings_p;
    5928            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    5929              :                                      "expected %<)%>");
    5930            0 :           return attrs;
    5931              :         }
    5932     55403778 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    5933     55403777 :         c_parser_consume_token (parser);
    5934              :       else
    5935              :         {
    5936            1 :           parser->translate_strings_p = save_translate_strings_p;
    5937            1 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
    5938              :                                      "expected %<)%>");
    5939            1 :           return attrs;
    5940              :         }
    5941     55403777 :       parser->translate_strings_p = save_translate_strings_p;
    5942              :     }
    5943              : 
    5944              :   return attrs;
    5945              : }
    5946              : 
    5947              : /* Parse an optional balanced token sequence.
    5948              : 
    5949              :    balanced-token-sequence:
    5950              :      balanced-token
    5951              :      balanced-token-sequence balanced-token
    5952              : 
    5953              :    balanced-token:
    5954              :      ( balanced-token-sequence[opt] )
    5955              :      [ balanced-token-sequence[opt] ]
    5956              :      { balanced-token-sequence[opt] }
    5957              :      any token other than ()[]{}
    5958              : */
    5959              : 
    5960              : static void
    5961          145 : c_parser_balanced_token_sequence (c_parser *parser)
    5962              : {
    5963          563 :   while (true)
    5964              :     {
    5965          563 :       c_token *token = c_parser_peek_token (parser);
    5966          563 :       switch (token->type)
    5967              :         {
    5968            4 :         case CPP_OPEN_BRACE:
    5969            4 :           {
    5970            4 :             matching_braces braces;
    5971            4 :             braces.consume_open (parser);
    5972            4 :             c_parser_balanced_token_sequence (parser);
    5973            4 :             braces.require_close (parser);
    5974            4 :             break;
    5975              :           }
    5976              : 
    5977           42 :         case CPP_OPEN_PAREN:
    5978           42 :           {
    5979           42 :             matching_parens parens;
    5980           42 :             parens.consume_open (parser);
    5981           42 :             c_parser_balanced_token_sequence (parser);
    5982           42 :             parens.require_close (parser);
    5983           42 :             break;
    5984              :           }
    5985              : 
    5986           33 :         case CPP_OPEN_SQUARE:
    5987           33 :           c_parser_consume_token (parser);
    5988           33 :           c_parser_balanced_token_sequence (parser);
    5989           33 :           c_parser_require (parser, CPP_CLOSE_SQUARE, "expected %<]%>");
    5990           33 :           break;
    5991              : 
    5992          145 :         case CPP_CLOSE_BRACE:
    5993          145 :         case CPP_CLOSE_PAREN:
    5994          145 :         case CPP_CLOSE_SQUARE:
    5995          145 :         case CPP_EOF:
    5996          145 :           return;
    5997              : 
    5998            1 :         case CPP_PRAGMA:
    5999            1 :           c_parser_consume_pragma (parser);
    6000            1 :           c_parser_skip_to_pragma_eol (parser, false);
    6001            1 :           break;
    6002              : 
    6003          338 :         default:
    6004          338 :           c_parser_consume_token (parser);
    6005          338 :           break;
    6006              :         }
    6007              :     }
    6008              : }
    6009              : 
    6010              : /* Parse arguments of omp::directive or omp::decl attribute.
    6011              : 
    6012              :    directive-name ,[opt] clause-list[opt]
    6013              : 
    6014              :    For directive just remember the tokens in a vector for subsequent
    6015              :    parsing.  */
    6016              : 
    6017              : static void
    6018          914 : c_parser_omp_directive_args (c_parser *parser, tree attribute, bool decl_p)
    6019              : {
    6020          914 :   unsigned int n = 1;
    6021          914 :   c_token *first = c_parser_peek_token (parser);
    6022          914 :   if (!c_parser_check_balanced_raw_token_sequence (parser, &n)
    6023          914 :       || (c_parser_peek_nth_token_raw (parser, n)->type
    6024              :           != CPP_CLOSE_PAREN))
    6025              :     {
    6026            1 :       c_parser_balanced_token_sequence (parser);
    6027            1 :       TREE_VALUE (attribute) = NULL_TREE;
    6028            3 :       return;
    6029              :     }
    6030          913 :   if (n == 1)
    6031              :     {
    6032            2 :       error_at (first->location, "expected OpenMP directive name");
    6033            2 :       TREE_VALUE (attribute) = NULL_TREE;
    6034            2 :       return;
    6035              :     }
    6036          911 :   vec<c_token, va_gc> *v;
    6037          911 :   vec_alloc (v, n - 1);
    6038        18777 :   for (--n; n; --n)
    6039              :     {
    6040        17866 :       c_token *tok = c_parser_peek_token (parser);
    6041        17866 :       v->quick_push (*tok);
    6042        17866 :       c_parser_consume_token (parser);
    6043              :     }
    6044          911 :   tree arg = make_node (C_TOKEN_VEC);
    6045          911 :   C_TOKEN_VEC_TOKENS (arg) = v;
    6046          911 :   if (decl_p)
    6047           58 :     TREE_PUBLIC (arg) = 1;
    6048          911 :   TREE_VALUE (attribute) = tree_cons (NULL_TREE, arg, TREE_VALUE (attribute));
    6049              : }
    6050              : 
    6051              : /* Parse arguments of omp::sequence attribute.
    6052              : 
    6053              :    omp::[opt] directive-attr [ , omp::[opt] directive-attr ]...  */
    6054              : 
    6055              : static void
    6056          157 : c_parser_omp_sequence_args (c_parser *parser, tree attribute)
    6057              : {
    6058          314 :   do
    6059              :     {
    6060          314 :       c_token *token = c_parser_peek_token (parser);
    6061          314 :       if (token->type == CPP_NAME
    6062          313 :           && strcmp (IDENTIFIER_POINTER (token->value), "omp") == 0
    6063          378 :           && c_parser_peek_2nd_token (parser)->type == CPP_SCOPE)
    6064              :         {
    6065           64 :           c_parser_consume_token (parser);
    6066           64 :           c_parser_consume_token (parser);
    6067           64 :           token = c_parser_peek_token (parser);
    6068              :         }
    6069          314 :       bool directive = false;
    6070          314 :       const char *p;
    6071          314 :       if (token->type != CPP_NAME)
    6072              :         p = "";
    6073              :       else
    6074          313 :         p = IDENTIFIER_POINTER (token->value);
    6075          314 :       if (strcmp (p, "directive") == 0)
    6076              :         directive = true;
    6077           12 :       else if (strcmp (p, "sequence") != 0)
    6078              :         {
    6079            7 :           error_at (token->location, "expected %<directive%> or %<sequence%>");
    6080            7 :           unsigned nesting_depth = 0;
    6081              : 
    6082           47 :           while (true)
    6083              :             {
    6084              :               /* Peek at the next token.  */
    6085           27 :               token = c_parser_peek_token (parser);
    6086              :               /* If we've reached the token we want, consume it and stop.  */
    6087           27 :               if ((token->type == CPP_CLOSE_PAREN || token->type == CPP_COMMA)
    6088           13 :                   && !nesting_depth)
    6089              :                 break;
    6090              :               /* If we've run out of tokens, stop.  */
    6091           20 :               if (token->type == CPP_EOF)
    6092              :                 break;
    6093           20 :               if (token->type == CPP_PRAGMA_EOL && parser->in_pragma)
    6094              :                 break;
    6095           20 :               if (token->type == CPP_OPEN_BRACE
    6096              :                   || token->type == CPP_OPEN_PAREN
    6097              :                   || token->type == CPP_OPEN_SQUARE)
    6098            6 :                 ++nesting_depth;
    6099              :               else if (token->type == CPP_CLOSE_BRACE
    6100              :                        || token->type == CPP_CLOSE_PAREN
    6101              :                        || token->type == CPP_CLOSE_SQUARE)
    6102              :                 {
    6103            6 :                   if (nesting_depth-- == 0)
    6104              :                     break;
    6105              :                 }
    6106              :               /* Consume this token.  */
    6107           20 :               c_parser_consume_token (parser);
    6108              :             }
    6109            7 :           if (c_parser_next_token_is_not (parser, CPP_COMMA))
    6110              :             break;
    6111            0 :           c_parser_consume_token (parser);
    6112            0 :           continue;
    6113            0 :         }
    6114          307 :       c_parser_consume_token (parser);
    6115          307 :       matching_parens parens;
    6116          307 :       if (parens.require_open (parser))
    6117              :         {
    6118          305 :           if (directive)
    6119          301 :             c_parser_omp_directive_args (parser, attribute, false);
    6120              :           else
    6121            4 :             c_parser_omp_sequence_args (parser, attribute);
    6122          305 :           parens.skip_until_found_close (parser);
    6123          305 :           if (c_parser_next_token_is_not (parser, CPP_COMMA))
    6124              :             break;
    6125          157 :           c_parser_consume_token (parser);
    6126              :         }
    6127            2 :       else if (c_parser_next_token_is_not (parser, CPP_COMMA))
    6128              :         break;
    6129              :       else
    6130            0 :         c_parser_consume_token (parser);
    6131              :     }
    6132              :   while (1);
    6133          157 : }
    6134              : 
    6135              : /* Parse standard (C23) attributes (including GNU attributes in the
    6136              :    gnu:: namespace).
    6137              : 
    6138              :    attribute-specifier-sequence:
    6139              :      attribute-specifier-sequence[opt] attribute-specifier
    6140              : 
    6141              :    attribute-specifier:
    6142              :      [ [ attribute-list ] ]
    6143              : 
    6144              :    attribute-list:
    6145              :      attribute[opt]
    6146              :      attribute-list, attribute[opt]
    6147              : 
    6148              :    attribute:
    6149              :      attribute-token attribute-argument-clause[opt]
    6150              : 
    6151              :    attribute-token:
    6152              :      standard-attribute
    6153              :      attribute-prefixed-token
    6154              : 
    6155              :    standard-attribute:
    6156              :      identifier
    6157              : 
    6158              :    attribute-prefixed-token:
    6159              :      attribute-prefix :: identifier
    6160              : 
    6161              :    attribute-prefix:
    6162              :      identifier
    6163              : 
    6164              :    attribute-argument-clause:
    6165              :      ( balanced-token-sequence[opt] )
    6166              : 
    6167              :    Keywords are accepted as identifiers for this purpose.
    6168              : 
    6169              :    As an extension, we permit an attribute-specifier to be:
    6170              : 
    6171              :      [ [ __extension__ attribute-list ] ]
    6172              : 
    6173              :    Two colons are then accepted as a synonym for ::.  No attempt is made
    6174              :    to check whether the colons are immediately adjacent.  LOOSE_SCOPE_P
    6175              :    indicates whether this relaxation is in effect.  */
    6176              : 
    6177              : static tree
    6178         3247 : c_parser_std_attribute (c_parser *parser, bool for_tm)
    6179              : {
    6180         3247 :   c_token *token = c_parser_peek_token (parser);
    6181         3247 :   tree ns, name, attribute;
    6182              : 
    6183              :   /* Parse the attribute-token.  */
    6184         3247 :   if (token->type != CPP_NAME && token->type != CPP_KEYWORD)
    6185              :     {
    6186            2 :       c_parser_error (parser, "expected identifier");
    6187            2 :       return error_mark_node;
    6188              :     }
    6189         3245 :   name = canonicalize_attr_name (token->value);
    6190         3245 :   c_parser_consume_token (parser);
    6191         3245 :   if (c_parser_next_token_is (parser, CPP_SCOPE)
    6192         3711 :       || (c_parser_next_token_is (parser, CPP_COLON)
    6193           39 :           && (c_parser_peek_token (parser)->flags & COLON_SCOPE) != 0
    6194           13 :           && c_parser_peek_2nd_token (parser)->type == CPP_COLON))
    6195              :     {
    6196         2792 :       ns = name;
    6197         2792 :       if (c_parser_next_token_is (parser, CPP_COLON))
    6198           13 :         c_parser_consume_token (parser);
    6199         2792 :       c_parser_consume_token (parser);
    6200         2792 :       token = c_parser_peek_token (parser);
    6201         2792 :       if (token->type != CPP_NAME && token->type != CPP_KEYWORD)
    6202              :         {
    6203            0 :           c_parser_error (parser, "expected identifier");
    6204            0 :           return error_mark_node;
    6205              :         }
    6206         2792 :       name = canonicalize_attr_name (token->value);
    6207         2792 :       c_parser_consume_token (parser);
    6208              :     }
    6209              :   else
    6210              :     ns = NULL_TREE;
    6211         3245 :   attribute = build_tree_list (build_tree_list (ns, name), NULL_TREE);
    6212              : 
    6213              :   /* Parse the arguments, if any.  */
    6214         3245 :   const attribute_spec *as = lookup_attribute_spec (TREE_PURPOSE (attribute));
    6215         3245 :   if (c_parser_next_token_is_not (parser, CPP_OPEN_PAREN))
    6216              :     {
    6217         2242 :       if ((flag_openmp || flag_openmp_simd)
    6218            9 :           && ns
    6219            7 :           && is_attribute_p ("omp", ns)
    6220         2254 :           && (is_attribute_p ("directive", name)
    6221            2 :               || is_attribute_p ("sequence", name)
    6222            1 :               || is_attribute_p ("decl", name)))
    6223              :         {
    6224            3 :           error ("%<omp::%E%> attribute requires argument", name);
    6225            3 :           return error_mark_node;
    6226              :         }
    6227         2248 :       goto out;
    6228              :     }
    6229          994 :   {
    6230          994 :     location_t open_loc = c_parser_peek_token (parser)->location;
    6231          994 :     matching_parens parens;
    6232          994 :     parens.consume_open (parser);
    6233          183 :     if ((as && as->max_length == 0)
    6234              :         /* Special-case the transactional-memory attribute "outer",
    6235              :            which is specially handled but not registered as an
    6236              :            attribute, to avoid allowing arbitrary balanced token
    6237              :            sequences as arguments.  */
    6238         1154 :         || is_attribute_p ("outer", name))
    6239              :       {
    6240           24 :         error_at (open_loc, "%qE attribute does not take any arguments", name);
    6241           24 :         parens.skip_until_found_close (parser);
    6242          790 :         return error_mark_node;
    6243              :       }
    6244              :     /* If this is a fake attribute created to handle -Wno-attributes,
    6245              :        we must skip parsing the arguments.  */
    6246          970 :     if (as && !attribute_ignored_p (as))
    6247              :       {
    6248          147 :         bool takes_identifier
    6249              :           = (ns != NULL_TREE
    6250          126 :              && strcmp (IDENTIFIER_POINTER (ns), "gnu") == 0
    6251          273 :              && attribute_takes_identifier_p (name));
    6252              :         bool require_string
    6253              :           = (ns == NULL_TREE
    6254           21 :              && (strcmp (IDENTIFIER_POINTER (name), "deprecated") == 0
    6255           11 :                  || strcmp (IDENTIFIER_POINTER (name), "nodiscard") == 0));
    6256              :         bool assume_attr
    6257              :           = (ns != NULL_TREE
    6258          126 :              && strcmp (IDENTIFIER_POINTER (ns), "gnu") == 0
    6259          126 :              && strcmp (IDENTIFIER_POINTER (name), "assume") == 0);
    6260          294 :         TREE_VALUE (attribute)
    6261          147 :           = c_parser_attribute_arguments (parser, takes_identifier,
    6262              :                                           require_string, assume_attr, false);
    6263              :       }
    6264              :     else
    6265              :       {
    6266           57 :         if ((flag_openmp || flag_openmp_simd)
    6267          766 :             && ns
    6268         1589 :             && is_attribute_p ("omp", ns))
    6269              :           {
    6270          766 :             if (is_attribute_p ("directive", name))
    6271              :               {
    6272          554 :                 c_parser_omp_directive_args (parser, attribute, false);
    6273          554 :                 parens.skip_until_found_close (parser);
    6274          554 :                 return attribute;
    6275              :               }
    6276          212 :             else if (is_attribute_p ("decl", name))
    6277              :               {
    6278           59 :                 TREE_VALUE (TREE_PURPOSE (attribute))
    6279           59 :                   = get_identifier ("directive");
    6280           59 :                 c_parser_omp_directive_args (parser, attribute, true);
    6281           59 :                 parens.skip_until_found_close (parser);
    6282           59 :                 return attribute;
    6283              :               }
    6284          153 :             else if (is_attribute_p ("sequence", name))
    6285              :               {
    6286          153 :                 TREE_VALUE (TREE_PURPOSE (attribute))
    6287          153 :                   = get_identifier ("directive");
    6288          153 :                 c_parser_omp_sequence_args (parser, attribute);
    6289          153 :                 parens.skip_until_found_close (parser);
    6290          153 :                 TREE_VALUE (attribute) = nreverse (TREE_VALUE (attribute));
    6291          153 :                 return attribute;
    6292              :               }
    6293              :           }
    6294           57 :         c_parser_balanced_token_sequence (parser);
    6295              :       }
    6296          204 :     parens.require_close (parser);
    6297              :   }
    6298         2452 :  out:
    6299         2452 :   if (ns == NULL_TREE && !for_tm && !as)
    6300              :     {
    6301              :       /* An attribute with standard syntax and no namespace specified
    6302              :          is a constraint violation if it is not one of the known
    6303              :          standard attributes.  Diagnose it here with a pedwarn and
    6304              :          then discard it to prevent a duplicate warning later.  */
    6305           73 :       pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored",
    6306              :                name);
    6307           73 :       return error_mark_node;
    6308              :     }
    6309              :   return attribute;
    6310              : }
    6311              : 
    6312              : static tree
    6313         3349 : c_parser_std_attribute_list (c_parser *parser, bool for_tm)
    6314              : {
    6315         3349 :   tree attributes = NULL_TREE;
    6316         3599 :   while (true)
    6317              :     {
    6318         3599 :       c_token *token = c_parser_peek_token (parser);
    6319         3599 :       if (token->type == CPP_CLOSE_SQUARE)
    6320              :         break;
    6321         3383 :       if (token->type == CPP_COMMA)
    6322              :         {
    6323          136 :           c_parser_consume_token (parser);
    6324          136 :           continue;
    6325              :         }
    6326         3247 :       tree attribute = c_parser_std_attribute (parser, for_tm);
    6327         3247 :       if (attribute != error_mark_node)
    6328              :         {
    6329         3145 :           TREE_CHAIN (attribute) = attributes;
    6330         3145 :           attributes = attribute;
    6331              :         }
    6332         3247 :       if (c_parser_next_token_is_not (parser, CPP_COMMA))
    6333              :         break;
    6334              :     }
    6335         3349 :   return attributes;
    6336              : }
    6337              : 
    6338              : static tree
    6339         3349 : c_parser_std_attribute_specifier (c_parser *parser, bool for_tm)
    6340              : {
    6341         3349 :   location_t loc = c_parser_peek_token (parser)->location;
    6342         3349 :   if (!c_parser_require (parser, CPP_OPEN_SQUARE, "expected %<[%>"))
    6343              :     return NULL_TREE;
    6344         3349 :   if (!c_parser_require (parser, CPP_OPEN_SQUARE, "expected %<[%>"))
    6345              :     {
    6346            0 :       c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, "expected %<]%>");
    6347            0 :       return NULL_TREE;
    6348              :     }
    6349         3349 :   tree attributes;
    6350         3349 :   if (c_parser_next_token_is_keyword (parser, RID_EXTENSION))
    6351              :     {
    6352           42 :       auto ext = disable_extension_diagnostics ();
    6353           42 :       c_parser_consume_token (parser);
    6354           42 :       attributes = c_parser_std_attribute_list (parser, for_tm);
    6355           42 :       restore_extension_diagnostics (ext);
    6356              :     }
    6357              :   else
    6358              :     {
    6359         3307 :       if (!for_tm)
    6360         3287 :         pedwarn_c11 (loc, OPT_Wpedantic,
    6361              :                      "ISO C does not support %<[[]]%> attributes before C23");
    6362         3307 :       attributes = c_parser_std_attribute_list (parser, for_tm);
    6363              :     }
    6364         3349 :   c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, "expected %<]%>");
    6365         3349 :   c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, "expected %<]%>");
    6366         3349 :   return nreverse (attributes);
    6367              : }
    6368              : 
    6369              : /* Look past an optional balanced token sequence of raw look-ahead
    6370              :    tokens starting with the *Nth token.  *N is updated to point to the
    6371              :    following token.  Return true if such a sequence was found, false
    6372              :    if the tokens parsed were not balanced.  */
    6373              : 
    6374              : static bool
    6375        13774 : c_parser_check_balanced_raw_token_sequence (c_parser *parser, unsigned int *n)
    6376              : {
    6377        61819 :   while (true)
    6378              :     {
    6379        61819 :       c_token *token = c_parser_peek_nth_token_raw (parser, *n);
    6380        61819 :       switch (token->type)
    6381              :         {
    6382           66 :         case CPP_OPEN_BRACE:
    6383           66 :           {
    6384           66 :             ++*n;
    6385           66 :             if (c_parser_check_balanced_raw_token_sequence (parser, n))
    6386              :               {
    6387           66 :                 token = c_parser_peek_nth_token_raw (parser, *n);
    6388           66 :                 if (token->type == CPP_CLOSE_BRACE)
    6389           66 :                   ++*n;
    6390              :                 else
    6391              :                   return false;
    6392              :               }
    6393              :             else
    6394              :               return false;
    6395           66 :             break;
    6396              :           }
    6397              : 
    6398        10934 :         case CPP_OPEN_PAREN:
    6399        10934 :           {
    6400        10934 :             ++*n;
    6401        10934 :             if (c_parser_check_balanced_raw_token_sequence (parser, n))
    6402              :               {
    6403        10934 :                 token = c_parser_peek_nth_token_raw (parser, *n);
    6404        10934 :                 if (token->type == CPP_CLOSE_PAREN)
    6405        10934 :                   ++*n;
    6406              :                 else
    6407              :                   return false;
    6408              :               }
    6409              :             else
    6410              :               return false;
    6411        10934 :             break;
    6412              :           }
    6413              : 
    6414           79 :         case CPP_OPEN_SQUARE:
    6415           79 :           {
    6416           79 :             ++*n;
    6417           79 :             if (c_parser_check_balanced_raw_token_sequence (parser, n))
    6418              :               {
    6419           79 :                 token = c_parser_peek_nth_token_raw (parser, *n);
    6420           79 :                 if (token->type == CPP_CLOSE_SQUARE)
    6421           79 :                   ++*n;
    6422              :                 else
    6423              :                   return false;
    6424              :               }
    6425              :             else
    6426              :               return false;
    6427           79 :             break;
    6428              :           }
    6429              : 
    6430              :         case CPP_CLOSE_BRACE:
    6431              :         case CPP_CLOSE_PAREN:
    6432              :         case CPP_CLOSE_SQUARE:
    6433              :         case CPP_EOF:
    6434              :           return true;
    6435              : 
    6436        36966 :         default:
    6437        36966 :           ++*n;
    6438        36966 :           break;
    6439              :         }
    6440              :     }
    6441              : }
    6442              : 
    6443              : /* Return whether standard attributes start with the Nth token.  */
    6444              : 
    6445              : static bool
    6446    925068427 : c_parser_nth_token_starts_std_attributes (c_parser *parser, unsigned int n)
    6447              : {
    6448    925068427 :   if (!(c_parser_peek_nth_token (parser, n)->type == CPP_OPEN_SQUARE
    6449      2339483 :         && c_parser_peek_nth_token (parser, n + 1)->type == CPP_OPEN_SQUARE))
    6450              :     return false;
    6451              :   /* In C, '[[' must start attributes.  In Objective-C, we need to
    6452              :      check whether '[[' is matched by ']]'.  */
    6453         5133 :   if (!c_dialect_objc ())
    6454              :     return true;
    6455            0 :   n += 2;
    6456            0 :   if (!c_parser_check_balanced_raw_token_sequence (parser, &n))
    6457              :     return false;
    6458            0 :   c_token *token = c_parser_peek_nth_token_raw (parser, n);
    6459            0 :   if (token->type != CPP_CLOSE_SQUARE)
    6460              :     return false;
    6461            0 :   token = c_parser_peek_nth_token_raw (parser, n + 1);
    6462            0 :   return token->type == CPP_CLOSE_SQUARE;
    6463              : }
    6464              : 
    6465              : /* Skip standard attribute tokens starting at Nth token (with 1 as the
    6466              :    next token), return index of the first token after the standard
    6467              :    attribute tokens, or N on failure.  */
    6468              : 
    6469              : static size_t
    6470          329 : c_parser_skip_std_attribute_spec_seq (c_parser *parser, size_t n)
    6471              : {
    6472          329 :   size_t orig_n = n;
    6473          361 :   while (true)
    6474              :     {
    6475          345 :       if (c_parser_peek_nth_token_raw (parser, n)->type == CPP_OPEN_SQUARE
    6476          345 :           && (c_parser_peek_nth_token_raw (parser, n + 1)->type
    6477              :               == CPP_OPEN_SQUARE))
    6478              :         {
    6479           16 :           unsigned int m = n + 2;
    6480           16 :           if (!c_parser_check_balanced_raw_token_sequence (parser, &m))
    6481            0 :             return orig_n;
    6482           16 :           c_token *token = c_parser_peek_nth_token_raw (parser, m);
    6483           16 :           if (token->type != CPP_CLOSE_SQUARE)
    6484              :             return orig_n;
    6485           16 :           token = c_parser_peek_nth_token_raw (parser, m + 1);
    6486           16 :           if (token->type != CPP_CLOSE_SQUARE)
    6487              :             return orig_n;
    6488           16 :           n = m + 2;
    6489              :         }
    6490              :       else
    6491              :         break;
    6492           16 :     }
    6493              :   return n;
    6494              : }
    6495              : 
    6496              : static tree
    6497         3268 : c_parser_std_attribute_specifier_sequence (c_parser *parser)
    6498              : {
    6499         3268 :   tree attributes = NULL_TREE;
    6500         3329 :   do
    6501              :     {
    6502         3329 :       tree attrs = c_parser_std_attribute_specifier (parser, false);
    6503         3329 :       attributes = chainon (attributes, attrs);
    6504              :     }
    6505         3329 :   while (c_parser_nth_token_starts_std_attributes (parser, 1));
    6506         3268 :   return attributes;
    6507              : }
    6508              : 
    6509              : /* Parse a type name (C90 6.5.5, C99 6.7.6, C11 6.7.7).  ALIGNAS_OK
    6510              :    says whether alignment specifiers are OK (only in cases that might
    6511              :    be the type name of a compound literal).
    6512              : 
    6513              :    type-name:
    6514              :      specifier-qualifier-list abstract-declarator[opt]
    6515              : */
    6516              : 
    6517              : struct c_type_name *
    6518    126566977 : c_parser_type_name (c_parser *parser, bool alignas_ok)
    6519              : {
    6520    126566977 :   struct c_declspecs *specs = build_null_declspecs ();
    6521    126566977 :   struct c_declarator *declarator;
    6522    126566977 :   struct c_type_name *ret;
    6523    126566977 :   bool dummy = false;
    6524    126566977 :   c_parser_declspecs (parser, specs, false, true, true, alignas_ok, false,
    6525              :                       false, true, cla_prefer_type);
    6526    126566977 :   if (!specs->declspecs_seen_p)
    6527              :     {
    6528            5 :       c_parser_error (parser, "expected specifier-qualifier-list");
    6529            5 :       return NULL;
    6530              :     }
    6531    126566972 :   if (specs->type != error_mark_node)
    6532              :     {
    6533    126566955 :       pending_xref_error ();
    6534    126566955 :       finish_declspecs (specs);
    6535              :       /* When the typename is declared, its type is a top level type, we should
    6536              :          call verify_counted_by_for_top_anonymous_type.  */
    6537    126566955 :       if (specs->typespec_kind == ctsk_tagdef)
    6538         1676 :         verify_counted_by_for_top_anonymous_type (specs->type);
    6539              :     }
    6540    253133944 :   declarator = c_parser_declarator (parser,
    6541    126566972 :                                     specs->typespec_kind != ctsk_none,
    6542              :                                     C_DTR_ABSTRACT, &dummy);
    6543    126566972 :   if (declarator == NULL)
    6544              :     return NULL;
    6545    126566967 :   ret = XOBNEW (&parser_obstack, struct c_type_name);
    6546    126566967 :   ret->specs = specs;
    6547    126566967 :   ret->declarator = declarator;
    6548    126566967 :   return ret;
    6549              : }
    6550              : 
    6551              : /* Parse an initializer (C90 6.5.7, C99 6.7.8, C11 6.7.9).
    6552              : 
    6553              :    initializer:
    6554              :      assignment-expression
    6555              :      { initializer-list }
    6556              :      { initializer-list , }
    6557              : 
    6558              :    initializer-list:
    6559              :      designation[opt] initializer
    6560              :      initializer-list , designation[opt] initializer
    6561              : 
    6562              :    designation:
    6563              :      designator-list =
    6564              : 
    6565              :    designator-list:
    6566              :      designator
    6567              :      designator-list designator
    6568              : 
    6569              :    designator:
    6570              :      array-designator
    6571              :      . identifier
    6572              : 
    6573              :    array-designator:
    6574              :      [ constant-expression ]
    6575              : 
    6576              :    GNU extensions:
    6577              : 
    6578              :    initializer:
    6579              :      { }
    6580              : 
    6581              :    designation:
    6582              :      array-designator
    6583              :      identifier :
    6584              : 
    6585              :    array-designator:
    6586              :      [ constant-expression ... constant-expression ]
    6587              : 
    6588              :    Any expression without commas is accepted in the syntax for the
    6589              :    constant-expressions, with non-constant expressions rejected later.
    6590              : 
    6591              :    DECL is the declaration we're parsing this initializer for.
    6592              : 
    6593              :    This function is only used for top-level initializers; for nested
    6594              :    ones, see c_parser_initval.  */
    6595              : 
    6596              : static struct c_expr
    6597      6430264 : c_parser_initializer (c_parser *parser, tree decl)
    6598              : {
    6599      6430264 :   if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
    6600       108261 :     return c_parser_braced_init (parser, NULL_TREE, false, NULL,
    6601       108261 :                                  decl != error_mark_node
    6602       216520 :                                  && C_DECL_VARIABLE_SIZE (decl));
    6603              :   else
    6604              :     {
    6605      6322003 :       struct c_expr ret;
    6606      6322003 :       location_t loc = c_parser_peek_token (parser)->location;
    6607      6322003 :       ret = c_parser_expr_no_commas (parser, NULL);
    6608      6322001 :       if (decl != error_mark_node && C_DECL_VARIABLE_SIZE (decl))
    6609              :         {
    6610            2 :           error_at (loc,
    6611              :                     "variable-sized object may not be initialized except "
    6612              :                     "with an empty initializer");
    6613            2 :           ret.set_error ();
    6614              :         }
    6615              :       /* This is handled mostly by gimplify.cc, but we have to deal with
    6616              :          not warning about int x = x; as it is a GCC extension to turn off
    6617              :          this warning but only if warn_init_self is zero.  */
    6618      6322001 :       if (VAR_P (decl)
    6619      6321953 :           && !DECL_EXTERNAL (decl)
    6620      6321953 :           && !TREE_STATIC (decl)
    6621      6201168 :           && ret.value == decl
    6622     12643954 :           && !warning_enabled_at (DECL_SOURCE_LOCATION (decl), OPT_Winit_self))
    6623        90338 :         suppress_warning (decl, OPT_Winit_self);
    6624      6322001 :       if (TREE_CODE (ret.value) != STRING_CST
    6625      6322001 :           && (TREE_CODE (ret.value) != COMPOUND_LITERAL_EXPR
    6626        96629 :               || C_DECL_DECLARED_CONSTEXPR (COMPOUND_LITERAL_EXPR_DECL
    6627              :                                             (ret.value))))
    6628      6211303 :         ret = convert_lvalue_to_rvalue (loc, ret, true, true, true);
    6629      6322001 :       return ret;
    6630              :     }
    6631              : }
    6632              : 
    6633              : /* The location of the last comma within the current initializer list,
    6634              :    or UNKNOWN_LOCATION if not within one.  */
    6635              : 
    6636              : location_t last_init_list_comma;
    6637              : 
    6638              : /* Parse a braced initializer list.  TYPE is the type specified for a
    6639              :    compound literal, and NULL_TREE for other initializers and for
    6640              :    nested braced lists.  NESTED_P is true for nested braced lists,
    6641              :    false for the list of a compound literal or the list that is the
    6642              :    top-level initializer in a declaration.  VARSIZE_P indicates
    6643              :    whether the object to be initialized has a variable size.  */
    6644              : 
    6645              : static struct c_expr
    6646      1378877 : c_parser_braced_init (c_parser *parser, tree type, bool nested_p,
    6647              :                       struct obstack *outer_obstack, bool varsize_p)
    6648              : {
    6649      1378877 :   struct c_expr ret;
    6650      1378877 :   struct obstack braced_init_obstack;
    6651      1378877 :   location_t brace_loc = c_parser_peek_token (parser)->location;
    6652      1378877 :   gcc_obstack_init (&braced_init_obstack);
    6653      1378877 :   gcc_assert (c_parser_next_token_is (parser, CPP_OPEN_BRACE));
    6654      1378877 :   bool save_c_omp_array_section_p = c_omp_array_section_p;
    6655      1378877 :   c_omp_array_section_p = false;
    6656      1378877 :   bool zero_init_padding_bits = false;
    6657      1378877 :   matching_braces braces;
    6658      1378877 :   braces.consume_open (parser);
    6659      1378877 :   if (nested_p)
    6660              :     {
    6661       340321 :       finish_implicit_inits (brace_loc, outer_obstack);
    6662       340321 :       push_init_level (brace_loc, 0, &braced_init_obstack);
    6663              :     }
    6664              :   else
    6665      1038556 :     really_start_incremental_init (type);
    6666      1378877 :   if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
    6667              :     {
    6668         3147 :       pedwarn_c11 (brace_loc, OPT_Wpedantic,
    6669              :                    "ISO C forbids empty initializer braces before C23");
    6670         3147 :       if (flag_isoc23)
    6671      1378877 :         zero_init_padding_bits = true;
    6672              :     }
    6673              :   else
    6674              :     {
    6675      1375730 :       if (varsize_p)
    6676           61 :         error_at (brace_loc,
    6677              :                   "variable-sized object may not be initialized except "
    6678              :                   "with an empty initializer");
    6679              :       /* Parse a non-empty initializer list, possibly with a trailing
    6680              :          comma.  */
    6681      9002662 :       while (true)
    6682              :         {
    6683      9002662 :           c_parser_initelt (parser, &braced_init_obstack);
    6684      9002662 :           if (parser->error)
    6685              :             break;
    6686      9002632 :           if (c_parser_next_token_is (parser, CPP_COMMA))
    6687              :             {
    6688      7629725 :               last_init_list_comma = c_parser_peek_token (parser)->location;
    6689      7629725 :               c_parser_consume_token (parser);
    6690              :               /* CPP_EMBED should be always in between two CPP_COMMA
    6691              :                  tokens.  */
    6692     15259553 :               while (c_parser_next_token_is (parser, CPP_EMBED))
    6693              :                 {
    6694          103 :                   c_token *embed = c_parser_peek_token (parser);
    6695          103 :                   c_parser_consume_token (parser);
    6696          103 :                   c_expr embed_val;
    6697          103 :                   embed_val.value = embed->value;
    6698          103 :                   embed_val.original_code = RAW_DATA_CST;
    6699          103 :                   embed_val.original_type = integer_type_node;
    6700          103 :                   set_c_expr_source_range (&embed_val, embed->get_range ());
    6701          103 :                   embed_val.m_decimal = 0;
    6702          103 :                   process_init_element (embed->location, embed_val, false,
    6703              :                                         &braced_init_obstack);
    6704          103 :                   gcc_checking_assert (c_parser_next_token_is (parser,
    6705              :                                                                CPP_COMMA));
    6706          103 :                   last_init_list_comma = c_parser_peek_token (parser)->location;
    6707          103 :                   c_parser_consume_token (parser);
    6708              :                 }
    6709              :             }
    6710              :           else
    6711              :             break;
    6712      7629725 :           if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
    6713              :             break;
    6714              :         }
    6715              :     }
    6716      1378877 :   c_omp_array_section_p = save_c_omp_array_section_p;
    6717      1378877 :   c_token *next_tok = c_parser_peek_token (parser);
    6718      1378877 :   if (next_tok->type != CPP_CLOSE_BRACE)
    6719              :     {
    6720           31 :       ret.set_error ();
    6721           31 :       ret.original_code = ERROR_MARK;
    6722           31 :       ret.original_type = NULL;
    6723           31 :       braces.skip_until_found_close (parser);
    6724           31 :       pop_init_level (brace_loc, 0, &braced_init_obstack, last_init_list_comma);
    6725           31 :       obstack_free (&braced_init_obstack, NULL);
    6726              :       return ret;
    6727              :     }
    6728      1378846 :   location_t close_loc = next_tok->location;
    6729      1378846 :   c_parser_consume_token (parser);
    6730      1378846 :   ret = pop_init_level (brace_loc, 0, &braced_init_obstack, close_loc);
    6731      1378846 :   if (zero_init_padding_bits
    6732         2830 :       && ret.value
    6733         2788 :       && TREE_CODE (ret.value) == CONSTRUCTOR)
    6734         2693 :     CONSTRUCTOR_ZERO_PADDING_BITS (ret.value) = 1;
    6735      1378846 :   obstack_free (&braced_init_obstack, NULL);
    6736      1378846 :   set_c_expr_source_range (&ret, brace_loc, close_loc);
    6737      1378846 :   return ret;
    6738              : }
    6739              : 
    6740              : /* Parse a nested initializer, including designators.  */
    6741              : 
    6742              : static void
    6743      9002662 : c_parser_initelt (c_parser *parser, struct obstack * braced_init_obstack)
    6744              : {
    6745              :   /* Parse any designator or designator list.  A single array
    6746              :      designator may have the subsequent "=" omitted in GNU C, but a
    6747              :      longer list or a structure member designator may not.  */
    6748      9002662 :   if (c_parser_next_token_is (parser, CPP_NAME)
    6749      9002662 :       && c_parser_peek_2nd_token (parser)->type == CPP_COLON)
    6750              :     {
    6751              :       /* Old-style structure member designator.  */
    6752          156 :       set_init_label (c_parser_peek_token (parser)->location,
    6753          156 :                       c_parser_peek_token (parser)->value,
    6754          156 :                       c_parser_peek_token (parser)->location,
    6755              :                       braced_init_obstack);
    6756              :       /* Use the colon as the error location.  */
    6757          156 :       pedwarn (c_parser_peek_2nd_token (parser)->location, OPT_Wpedantic,
    6758              :                "obsolete use of designated initializer with %<:%>");
    6759          156 :       c_parser_consume_token (parser);
    6760          156 :       c_parser_consume_token (parser);
    6761              :     }
    6762              :   else
    6763              :     {
    6764              :       /* des_seen is 0 if there have been no designators, 1 if there
    6765              :          has been a single array designator and 2 otherwise.  */
    6766              :       int des_seen = 0;
    6767              :       /* Location of a designator.  */
    6768              :       location_t des_loc = UNKNOWN_LOCATION;  /* Quiet warning.  */
    6769      9039666 :       while (c_parser_next_token_is (parser, CPP_OPEN_SQUARE)
    6770     18077392 :              || c_parser_next_token_is (parser, CPP_DOT))
    6771              :         {
    6772        37160 :           int des_prev = des_seen;
    6773        37160 :           if (!des_seen)
    6774        34874 :             des_loc = c_parser_peek_token (parser)->location;
    6775        37160 :           if (des_seen < 2)
    6776        34952 :             des_seen++;
    6777        37160 :           if (c_parser_next_token_is (parser, CPP_DOT))
    6778              :             {
    6779        35220 :               des_seen = 2;
    6780        35220 :               c_parser_consume_token (parser);
    6781        35220 :               if (c_parser_next_token_is (parser, CPP_NAME))
    6782              :                 {
    6783        35220 :                   set_init_label (des_loc, c_parser_peek_token (parser)->value,
    6784        35220 :                                   c_parser_peek_token (parser)->location,
    6785              :                                   braced_init_obstack);
    6786        35220 :                   c_parser_consume_token (parser);
    6787              :                 }
    6788              :               else
    6789              :                 {
    6790            0 :                   struct c_expr init;
    6791            0 :                   init.set_error ();
    6792            0 :                   init.original_code = ERROR_MARK;
    6793            0 :                   init.original_type = NULL;
    6794            0 :                   c_parser_error (parser, "expected identifier");
    6795            0 :                   c_parser_skip_until_found (parser, CPP_COMMA, NULL);
    6796            0 :                   process_init_element (input_location, init, false,
    6797              :                                         braced_init_obstack);
    6798            0 :                   return;
    6799              :                 }
    6800              :             }
    6801              :           else
    6802              :             {
    6803         1940 :               struct c_expr first_expr;
    6804         1940 :               tree first, second;
    6805         1940 :               location_t ellipsis_loc = UNKNOWN_LOCATION;  /* Quiet warning.  */
    6806         1940 :               location_t array_index_loc = UNKNOWN_LOCATION;
    6807              :               /* ??? Following the old parser, [ objc-receiver
    6808              :                  objc-message-args ] is accepted as an initializer,
    6809              :                  being distinguished from a designator by what follows
    6810              :                  the first assignment expression inside the square
    6811              :                  brackets, but after a first array designator a
    6812              :                  subsequent square bracket is for Objective-C taken to
    6813              :                  start an expression, using the obsolete form of
    6814              :                  designated initializer without '=', rather than
    6815              :                  possibly being a second level of designation: in LALR
    6816              :                  terms, the '[' is shifted rather than reducing
    6817              :                  designator to designator-list.  */
    6818         1940 :               if (des_prev == 1 && c_dialect_objc ())
    6819              :                 {
    6820            0 :                   des_seen = des_prev;
    6821            0 :                   break;
    6822              :                 }
    6823         1940 :               if (des_prev == 0 && c_dialect_objc ())
    6824              :                 {
    6825              :                   /* This might be an array designator or an
    6826              :                      Objective-C message expression.  If the former,
    6827              :                      continue parsing here; if the latter, parse the
    6828              :                      remainder of the initializer given the starting
    6829              :                      primary-expression.  ??? It might make sense to
    6830              :                      distinguish when des_prev == 1 as well; see
    6831              :                      previous comment.  */
    6832            0 :                   tree rec, args;
    6833            0 :                   struct c_expr mexpr;
    6834            0 :                   c_parser_consume_token (parser);
    6835            0 :                   if (c_parser_peek_token (parser)->type == CPP_NAME
    6836            0 :                       && ((c_parser_peek_token (parser)->id_kind
    6837              :                            == C_ID_TYPENAME)
    6838            0 :                           || (c_parser_peek_token (parser)->id_kind
    6839              :                               == C_ID_CLASSNAME)))
    6840              :                     {
    6841              :                       /* Type name receiver.  */
    6842            0 :                       tree id = c_parser_peek_token (parser)->value;
    6843            0 :                       c_parser_consume_token (parser);
    6844            0 :                       rec = objc_get_class_reference (id);
    6845            0 :                       goto parse_message_args;
    6846              :                     }
    6847            0 :                   array_index_loc = c_parser_peek_token (parser)->location;
    6848            0 :                   first_expr = c_parser_expr_no_commas (parser, NULL);
    6849            0 :                   mark_exp_read (first_expr.value);
    6850            0 :                   if (c_parser_next_token_is (parser, CPP_ELLIPSIS)
    6851            0 :                       || c_parser_next_token_is (parser, CPP_CLOSE_SQUARE))
    6852            0 :                     goto array_desig_after_first;
    6853            0 :                   first = first_expr.value;
    6854              :                   /* Expression receiver.  So far only one part
    6855              :                      without commas has been parsed; there might be
    6856              :                      more of the expression.  */
    6857            0 :                   rec = first;
    6858            0 :                   while (c_parser_next_token_is (parser, CPP_COMMA))
    6859              :                     {
    6860            0 :                       struct c_expr next;
    6861            0 :                       location_t comma_loc, exp_loc;
    6862            0 :                       comma_loc = c_parser_peek_token (parser)->location;
    6863            0 :                       c_parser_consume_token (parser);
    6864            0 :                       exp_loc = c_parser_peek_token (parser)->location;
    6865            0 :                       next = c_parser_expr_no_commas (parser, NULL);
    6866            0 :                       next = convert_lvalue_to_rvalue (exp_loc, next,
    6867              :                                                        true, true);
    6868            0 :                       rec = build_compound_expr (comma_loc, rec, next.value);
    6869              :                     }
    6870            0 :                 parse_message_args:
    6871              :                   /* Now parse the objc-message-args.  */
    6872            0 :                   args = c_parser_objc_message_args (parser);
    6873            0 :                   c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
    6874              :                                              "expected %<]%>");
    6875            0 :                   mexpr.value
    6876            0 :                     = objc_build_message_expr (rec, args);
    6877            0 :                   mexpr.original_code = ERROR_MARK;
    6878            0 :                   mexpr.original_type = NULL;
    6879            0 :                   mexpr.m_decimal = 0;
    6880              :                   /* Now parse and process the remainder of the
    6881              :                      initializer, starting with this message
    6882              :                      expression as a primary-expression.  */
    6883            0 :                   c_parser_initval (parser, &mexpr, braced_init_obstack);
    6884            0 :                   return;
    6885              :                 }
    6886         1940 :               c_parser_consume_token (parser);
    6887         1940 :               array_index_loc = c_parser_peek_token (parser)->location;
    6888         1940 :               first_expr = c_parser_expr_no_commas (parser, NULL);
    6889         1940 :               mark_exp_read (first_expr.value);
    6890         1940 :             array_desig_after_first:
    6891         1940 :               first_expr = convert_lvalue_to_rvalue (array_index_loc,
    6892              :                                                      first_expr,
    6893              :                                                      true, true);
    6894         1940 :               first = first_expr.value;
    6895         1940 :               if (c_parser_next_token_is (parser, CPP_ELLIPSIS))
    6896              :                 {
    6897          397 :                   ellipsis_loc = c_parser_peek_token (parser)->location;
    6898          397 :                   c_parser_consume_token (parser);
    6899          397 :                   second = convert_lvalue_to_rvalue (ellipsis_loc,
    6900              :                                                      (c_parser_expr_no_commas
    6901              :                                                       (parser, NULL)),
    6902              :                                                      true, true).value;
    6903          397 :                   mark_exp_read (second);
    6904              :                 }
    6905              :               else
    6906              :                 second = NULL_TREE;
    6907         1940 :               if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE))
    6908              :                 {
    6909         1940 :                   c_parser_consume_token (parser);
    6910         1940 :                   set_init_index (array_index_loc, first, second,
    6911              :                                   braced_init_obstack);
    6912         1940 :                   if (second)
    6913          397 :                     pedwarn (ellipsis_loc, OPT_Wpedantic,
    6914              :                              "ISO C forbids specifying range of elements to initialize");
    6915              :                 }
    6916              :               else
    6917            0 :                 c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
    6918              :                                            "expected %<]%>");
    6919              :             }
    6920              :         }
    6921      9002506 :       if (des_seen >= 1)
    6922              :         {
    6923        34874 :           if (c_parser_next_token_is (parser, CPP_EQ))
    6924              :             {
    6925        34853 :               pedwarn_c90 (des_loc, OPT_Wpedantic,
    6926              :                            "ISO C90 forbids specifying subobject "
    6927              :                            "to initialize");
    6928        34853 :               c_parser_consume_token (parser);
    6929              :             }
    6930              :           else
    6931              :             {
    6932           21 :               if (des_seen == 1)
    6933           19 :                 pedwarn (c_parser_peek_token (parser)->location, OPT_Wpedantic,
    6934              :                          "obsolete use of designated initializer without %<=%>");
    6935              :               else
    6936              :                 {
    6937            2 :                   struct c_expr init;
    6938            2 :                   init.set_error ();
    6939            2 :                   init.original_code = ERROR_MARK;
    6940            2 :                   init.original_type = NULL;
    6941            2 :                   c_parser_error (parser, "expected %<=%>");
    6942            2 :                   c_parser_skip_until_found (parser, CPP_COMMA, NULL);
    6943            2 :                   process_init_element (input_location, init, false,
    6944              :                                         braced_init_obstack);
    6945            2 :                   return;
    6946              :                 }
    6947              :             }
    6948              :         }
    6949              :     }
    6950      9002660 :   c_parser_initval (parser, NULL, braced_init_obstack);
    6951              : }
    6952              : 
    6953              : /* Parse a nested initializer; as c_parser_initializer but parses
    6954              :    initializers within braced lists, after any designators have been
    6955              :    applied.  If AFTER is not NULL then it is an Objective-C message
    6956              :    expression which is the primary-expression starting the
    6957              :    initializer.  */
    6958              : 
    6959              : static void
    6960      9002660 : c_parser_initval (c_parser *parser, struct c_expr *after,
    6961              :                   struct obstack * braced_init_obstack)
    6962              : {
    6963      9002660 :   struct c_expr init;
    6964      9002660 :   gcc_assert (!after || c_dialect_objc ());
    6965      9002660 :   location_t loc = c_parser_peek_token (parser)->location;
    6966              : 
    6967      9002660 :   if (c_parser_next_token_is (parser, CPP_OPEN_BRACE) && !after)
    6968       340321 :     init = c_parser_braced_init (parser, NULL_TREE, true,
    6969              :                                  braced_init_obstack, false);
    6970              :   else
    6971              :     {
    6972      8662339 :       init = c_parser_expr_no_commas (parser, after);
    6973      8662339 :       if (init.value != NULL_TREE
    6974      8662339 :           && TREE_CODE (init.value) != STRING_CST
    6975     17283115 :           && (TREE_CODE (init.value) != COMPOUND_LITERAL_EXPR
    6976          177 :               || C_DECL_DECLARED_CONSTEXPR (COMPOUND_LITERAL_EXPR_DECL
    6977              :                                             (init.value))))
    6978      8620604 :         init = convert_lvalue_to_rvalue (loc, init, true, true, true);
    6979              :     }
    6980      9002660 :   tree val = init.value;
    6981      9002660 :   process_init_element (loc, init, false, braced_init_obstack);
    6982              : 
    6983              :   /* Attempt to optimize large char array initializers into RAW_DATA_CST
    6984              :      to save compile time and memory even when not using #embed.  */
    6985      9002660 :   static unsigned vals_to_ignore;
    6986      9002660 :   if (vals_to_ignore)
    6987              :     /* If earlier call determined there is certain number of CPP_COMMA
    6988              :        CPP_NUMBER tokens with 0-255 int values, but not enough for
    6989              :        RAW_DATA_CST to be beneficial, don't try to check it again until
    6990              :        they are all parsed.  */
    6991         6875 :     --vals_to_ignore;
    6992      8995785 :   else if (val
    6993      8995689 :            && TREE_CODE (val) == INTEGER_CST
    6994      4252435 :            && TREE_TYPE (val) == integer_type_node
    6995     12698542 :            && c_parser_next_token_is (parser, CPP_COMMA))
    6996      3033828 :     if (unsigned int len = c_maybe_optimize_large_byte_initializer ())
    6997              :       {
    6998         8769 :         char buf1[64];
    6999         8769 :         unsigned int i;
    7000         8769 :         gcc_checking_assert (len >= 64);
    7001              :         location_t last_loc = UNKNOWN_LOCATION;
    7002        21724 :         for (i = 0; i < 64; ++i)
    7003              :           {
    7004        21623 :             c_token *tok = c_parser_peek_nth_token_raw (parser, 1 + 2 * i);
    7005        21623 :             if (tok->type != CPP_COMMA)
    7006              :               break;
    7007        20744 :             tok = c_parser_peek_nth_token_raw (parser, 2 + 2 * i);
    7008        20744 :             if (tok->type != CPP_NUMBER
    7009        12955 :                 || TREE_CODE (tok->value) != INTEGER_CST
    7010        12955 :                 || TREE_TYPE (tok->value) != integer_type_node
    7011        12955 :                 || wi::neg_p (wi::to_wide (tok->value))
    7012        33699 :                 || wi::to_widest (tok->value) > UCHAR_MAX)
    7013              :               break;
    7014        12955 :             buf1[i] = (char) tree_to_uhwi (tok->value);
    7015        12955 :             if (i == 0)
    7016         1214 :               loc = tok->location;
    7017        12955 :             last_loc = tok->location;
    7018              :           }
    7019         8769 :         if (i < 64)
    7020              :           {
    7021         8668 :             vals_to_ignore = i;
    7022         8674 :             return;
    7023              :           }
    7024          101 :         c_token *tok = c_parser_peek_nth_token_raw (parser, 1 + 2 * i);
    7025              :         /* If 64 CPP_COMMA CPP_NUMBER pairs are followed by CPP_CLOSE_BRACE,
    7026              :            punt if len is INT_MAX as that can mean this is a flexible array
    7027              :            member and in that case we need one CPP_NUMBER afterwards
    7028              :            (as guaranteed for CPP_EMBED).  */
    7029          101 :         if (tok->type == CPP_CLOSE_BRACE && len != INT_MAX)
    7030              :           len = i;
    7031           99 :         else if (tok->type != CPP_COMMA
    7032           99 :                  || (c_parser_peek_nth_token_raw (parser, 2 + 2 * i)->type
    7033              :                      != CPP_NUMBER))
    7034              :           {
    7035            6 :             vals_to_ignore = i;
    7036            6 :             return;
    7037              :           }
    7038              :         /* Ensure the STRING_CST fits into 128K.  */
    7039           95 :         unsigned int max_len = 131072 - offsetof (struct tree_string, str) - 1;
    7040           95 :         unsigned int orig_len = len;
    7041           95 :         unsigned int off = 0, last = 0;
    7042           95 :         if (!wi::neg_p (wi::to_wide (val)) && wi::to_widest (val) <= UCHAR_MAX)
    7043           87 :           off = 1;
    7044           95 :         len = MIN (len, max_len - off);
    7045           95 :         char *buf2 = XNEWVEC (char, len + off);
    7046           95 :         if (off)
    7047           87 :           buf2[0] = (char) tree_to_uhwi (val);
    7048           95 :         memcpy (buf2 + off, buf1, i);
    7049         6175 :         for (unsigned int j = 0; j < i; ++j)
    7050              :           {
    7051         6080 :             c_parser_peek_token (parser);
    7052         6080 :             c_parser_consume_token (parser);
    7053         6080 :             c_parser_peek_token (parser);
    7054         6080 :             c_parser_consume_token (parser);
    7055              :           }
    7056        20276 :         for (; i < len; ++i)
    7057              :           {
    7058        20233 :             if (!c_parser_next_token_is (parser, CPP_COMMA))
    7059              :               break;
    7060        20231 :             tok = c_parser_peek_2nd_token (parser);
    7061        20231 :             if (tok->type != CPP_NUMBER
    7062        20223 :                 || TREE_CODE (tok->value) != INTEGER_CST
    7063        20223 :                 || TREE_TYPE (tok->value) != integer_type_node
    7064        20223 :                 || wi::neg_p (wi::to_wide (tok->value))
    7065        40454 :                 || wi::to_widest (tok->value) > UCHAR_MAX)
    7066              :               break;
    7067        20223 :             c_token *tok2 = c_parser_peek_nth_token (parser, 3);
    7068        20223 :             if (tok2->type != CPP_COMMA && tok2->type != CPP_CLOSE_BRACE)
    7069              :               break;
    7070        20220 :             buf2[i + off] = (char) tree_to_uhwi (tok->value);
    7071              :             /* If orig_len is INT_MAX, this can be flexible array member and
    7072              :                in that case we need to ensure another element which
    7073              :                for CPP_EMBED is normally guaranteed after it.  Include
    7074              :                that byte in the RAW_DATA_OWNER though, so it can be optimized
    7075              :                later.  */
    7076        20220 :             if (orig_len == INT_MAX
    7077        20220 :                 && (tok2->type == CPP_CLOSE_BRACE
    7078        12859 :                     || (c_parser_peek_nth_token (parser, 4)->type
    7079              :                         != CPP_NUMBER)))
    7080              :               {
    7081              :                 last = 1;
    7082              :                 break;
    7083              :               }
    7084        20181 :             last_loc = tok->location;
    7085        20181 :             c_parser_consume_token (parser);
    7086        20181 :             c_parser_consume_token (parser);
    7087              :           }
    7088           95 :         val = make_node (RAW_DATA_CST);
    7089           95 :         TREE_TYPE (val) = integer_type_node;
    7090           95 :         RAW_DATA_LENGTH (val) = i;
    7091           95 :         tree owner = build_string (i + off + last, buf2);
    7092           95 :         XDELETEVEC (buf2);
    7093           95 :         TREE_TYPE (owner) = build_array_type_nelts (unsigned_char_type_node,
    7094           95 :                                                     i + off + last);
    7095           95 :         RAW_DATA_OWNER (val) = owner;
    7096           95 :         RAW_DATA_POINTER (val) = TREE_STRING_POINTER (owner) + off;
    7097           95 :         init.value = val;
    7098           95 :         set_c_expr_source_range (&init, loc, last_loc);
    7099           95 :         init.original_code = RAW_DATA_CST;
    7100           95 :         init.original_type = integer_type_node;
    7101           95 :         init.m_decimal = 0;
    7102           95 :         process_init_element (loc, init, false, braced_init_obstack);
    7103              :       }
    7104              : }
    7105              : 
    7106              : /* Parse a compound statement (possibly a function body) (C90 6.6.2,
    7107              :    C99 6.8.2, C11 6.8.2, C23 6.8.2).
    7108              : 
    7109              :    compound-statement:
    7110              :      { block-item-list[opt] }
    7111              :      { label-declarations block-item-list }
    7112              : 
    7113              :    block-item-list:
    7114              :      block-item
    7115              :      block-item-list block-item
    7116              : 
    7117              :    block-item:
    7118              :      label
    7119              :      nested-declaration
    7120              :      statement
    7121              : 
    7122              :    nested-declaration:
    7123              :      declaration
    7124              : 
    7125              :    GNU extensions:
    7126              : 
    7127              :    compound-statement:
    7128              :      { label-declarations block-item-list }
    7129              : 
    7130              :    nested-declaration:
    7131              :      __extension__ nested-declaration
    7132              :      nested-function-definition
    7133              : 
    7134              :    label-declarations:
    7135              :      label-declaration
    7136              :      label-declarations label-declaration
    7137              : 
    7138              :    label-declaration:
    7139              :      __label__ identifier-list ;
    7140              : 
    7141              :    Allowing the mixing of declarations and code is new in C99.  The
    7142              :    GNU syntax also permits (not shown above) labels at the end of
    7143              :    compound statements, which yield an error.  We don't allow labels
    7144              :    on declarations; this might seem like a natural extension, but
    7145              :    there would be a conflict between gnu-attributes on the label and
    7146              :    prefix gnu-attributes on the declaration.  ??? The syntax follows the
    7147              :    old parser in requiring something after label declarations.
    7148              :    Although they are erroneous if the labels declared aren't defined,
    7149              :    is it useful for the syntax to be this way?
    7150              : 
    7151              :    OpenACC:
    7152              : 
    7153              :    block-item:
    7154              :      openacc-directive
    7155              : 
    7156              :    openacc-directive:
    7157              :      update-directive
    7158              : 
    7159              :    OpenMP:
    7160              : 
    7161              :    block-item:
    7162              :      openmp-directive
    7163              : 
    7164              :    openmp-directive:
    7165              :      barrier-directive
    7166              :      flush-directive
    7167              :      taskwait-directive
    7168              :      taskyield-directive
    7169              :      cancel-directive
    7170              :      cancellation-point-directive  */
    7171              : 
    7172              : static tree
    7173     38637929 : c_parser_compound_statement (c_parser *parser, location_t *endlocp)
    7174              : {
    7175     38637929 :   tree stmt;
    7176     38637929 :   location_t brace_loc;
    7177     38637929 :   brace_loc = c_parser_peek_token (parser)->location;
    7178     38637929 :   if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
    7179              :     {
    7180              :       /* Ensure a scope is entered and left anyway to avoid confusion
    7181              :          if we have just prepared to enter a function body.  */
    7182           16 :       stmt = c_begin_compound_stmt (true);
    7183           16 :       c_end_compound_stmt (brace_loc, stmt, true);
    7184           16 :       return error_mark_node;
    7185              :     }
    7186     38637913 :   stmt = c_begin_compound_stmt (true);
    7187     38637913 :   location_t end_loc = c_parser_compound_statement_nostart (parser);
    7188     38637912 :   if (endlocp)
    7189     37712841 :     *endlocp = end_loc;
    7190              : 
    7191     38637912 :   return c_end_compound_stmt (brace_loc, stmt, true);
    7192              : }
    7193              : 
    7194              : /* Diagnose errors related to imperfectly nested loops in an OMP
    7195              :    loop construct.  This function is called when such code is seen.
    7196              :    Only issue one such diagnostic no matter how much invalid
    7197              :    intervening code there is in the loop.
    7198              :    FIXME: maybe the location associated with the diagnostic should
    7199              :    be the current parser token instead of the location of the outer loop
    7200              :    nest.  */
    7201              : 
    7202              : static void
    7203          299 : check_omp_intervening_code (c_parser *parser)
    7204              : {
    7205          299 :   struct omp_for_parse_data *omp_for_parse_state = parser->omp_for_parse_state;
    7206          299 :   gcc_assert (omp_for_parse_state);
    7207              : 
    7208          299 :   if (!omp_for_parse_state->in_intervening_code)
    7209              :     return;
    7210          278 :   omp_for_parse_state->saw_intervening_code = true;
    7211              : 
    7212              :   /* Only diagnose errors related to perfect nesting once.  */
    7213          278 :   if (!omp_for_parse_state->perfect_nesting_fail)
    7214              :     {
    7215              : 
    7216              :       /* OpenACC does not (yet) permit intervening code, in
    7217              :          addition to situations forbidden by the OpenMP spec.  */
    7218          256 :       if (omp_for_parse_state->code == OACC_LOOP)
    7219              :         {
    7220            3 :           error_at (omp_for_parse_state->for_loc,
    7221              :                     "inner loops must be perfectly nested in "
    7222              :                     "%<#pragma acc loop%>");
    7223            3 :           omp_for_parse_state->perfect_nesting_fail = true;
    7224              :         }
    7225          253 :       else if (omp_for_parse_state->ordered)
    7226              :         {
    7227           11 :           error_at (omp_for_parse_state->for_loc,
    7228              :                     "inner loops must be perfectly nested with "
    7229              :                     "%<ordered%> clause");
    7230           11 :           omp_for_parse_state->perfect_nesting_fail = true;
    7231              :         }
    7232          242 :       else if (omp_for_parse_state->inscan)
    7233              :         {
    7234            2 :           error_at (omp_for_parse_state->for_loc,
    7235              :                     "inner loops must be perfectly nested with "
    7236              :                     "%<reduction%> %<inscan%> clause");
    7237            2 :           omp_for_parse_state->perfect_nesting_fail = true;
    7238              :         }
    7239          240 :       else if (omp_for_parse_state->code == OMP_TILE)
    7240              :         {
    7241            9 :           error_at (omp_for_parse_state->for_loc,
    7242              :                     "inner loops must be perfectly nested in "
    7243              :                      "%<pragma omp tile%>");
    7244            9 :           omp_for_parse_state->perfect_nesting_fail = true;
    7245              :         }
    7246          256 :       if (omp_for_parse_state->perfect_nesting_fail)
    7247           25 :         omp_for_parse_state->fail = true;
    7248              :     }
    7249              : }
    7250              : 
    7251              : /* Helper function for below:  wrap an OMP_STRUCTURED_BLOCK around SL
    7252              :    and add the statement to the current list.  If SL is an empty statement
    7253              :    list, do nothing.  */
    7254              : static void
    7255          294 : add_structured_block_stmt (tree sl)
    7256              : {
    7257          294 :   if (TREE_CODE (sl) != STATEMENT_LIST
    7258          294 :       || !tsi_end_p (tsi_start (sl)))
    7259          152 :     add_stmt (build1 (OMP_STRUCTURED_BLOCK, void_type_node, sl));
    7260          294 : }
    7261              : 
    7262              : struct c_omp_attribute_data
    7263              : {
    7264              :   vec<c_token, va_gc> *tokens;
    7265              :   const c_omp_directive *dir;
    7266              :   c_omp_directive_kind kind;
    7267              : };
    7268              : 
    7269              : /* Handle omp::directive and omp::sequence attributes in ATTRS
    7270              :    (if any) at the start of a statement or in attribute-declaration.  */
    7271              : 
    7272              : static bool
    7273          878 : c_parser_handle_statement_omp_attributes (c_parser *parser, tree &attrs,
    7274              :                                           bool *have_std_attrs)
    7275              : {
    7276          878 :   if (!flag_openmp && !flag_openmp_simd)
    7277              :     return false;
    7278              : 
    7279          610 :   auto_vec<c_omp_attribute_data, 16> vd;
    7280          610 :   int cnt = 0;
    7281          610 :   int tokens = 0;
    7282          610 :   bool bad = false;
    7283         1220 :   for (tree *pa = &attrs; *pa; )
    7284          610 :     if (is_attribute_namespace_p ("omp", *pa)
    7285          610 :         && is_attribute_p ("directive", get_attribute_name (*pa)))
    7286              :       {
    7287          609 :         cnt++;
    7288         1358 :         for (tree a = TREE_VALUE (*pa); a; a = TREE_CHAIN (a))
    7289              :           {
    7290          749 :             tree d = TREE_VALUE (a);
    7291          749 :             gcc_assert (TREE_CODE (d) == C_TOKEN_VEC);
    7292          749 :             vec<c_token, va_gc> *toks = C_TOKEN_VEC_TOKENS (d);
    7293          749 :             c_token *first = toks->address ();
    7294          749 :             c_token *last = first + toks->length ();
    7295          749 :             if (parser->omp_attrs_forbidden_p)
    7296              :               {
    7297           14 :                 error_at (first->location,
    7298              :                           "mixing OpenMP directives with attribute and pragma "
    7299              :                           "syntax on the same statement");
    7300           14 :                 parser->omp_attrs_forbidden_p = false;
    7301           14 :                 bad = true;
    7302              :               }
    7303          735 :             else if (TREE_PUBLIC (d))
    7304              :               {
    7305            3 :                 error_at (first->location,
    7306              :                           "OpenMP %<omp::decl%> attribute on a statement");
    7307            3 :                 bad = true;
    7308              :               }
    7309          749 :             const char *directive[3] = {};
    7310         2208 :             for (int i = 0; i < 3; i++)
    7311              :               {
    7312         2026 :                 tree id = NULL_TREE;
    7313         2026 :                 if (first + i == last)
    7314              :                   break;
    7315         1781 :                 if (first[i].type == CPP_NAME)
    7316         1341 :                   id = first[i].value;
    7317          440 :                 else if (first[i].type == CPP_KEYWORD)
    7318          118 :                   id = ridpointers[(int) first[i].keyword];
    7319              :                 else
    7320              :                   break;
    7321         1459 :                 directive[i] = IDENTIFIER_POINTER (id);
    7322              :               }
    7323          749 :             const c_omp_directive *dir = NULL;
    7324          749 :             if (directive[0])
    7325          749 :               dir = c_omp_categorize_directive (directive[0], directive[1],
    7326              :                                                 directive[2]);
    7327          749 :             if (dir == NULL)
    7328              :               {
    7329            1 :                 error_at (first->location,
    7330              :                           "unknown OpenMP directive name in %qs attribute "
    7331              :                           "argument",
    7332            1 :                           TREE_PUBLIC (d) ? "omp::decl" : "omp::directive");
    7333            1 :                 continue;
    7334              :               }
    7335          748 :             c_omp_directive_kind kind = dir->kind;
    7336          748 :             if (dir->id == PRAGMA_OMP_ORDERED)
    7337              :               {
    7338              :                 /* ordered is C_OMP_DIR_CONSTRUCT only if it doesn't contain
    7339              :                    depend/doacross clause.  */
    7340            8 :                 if (directive[1]
    7341            4 :                     && (strcmp (directive[1], "depend") == 0
    7342            2 :                         || strcmp (directive[1], "doacross") == 0))
    7343              :                   kind = C_OMP_DIR_STANDALONE;
    7344            6 :                 else if (first + 2 < last
    7345            4 :                          && first[1].type == CPP_COMMA
    7346            4 :                          && first[2].type == CPP_NAME
    7347           10 :                          && (strcmp (IDENTIFIER_POINTER (first[2].value),
    7348              :                                      "depend") == 0
    7349            2 :                              || strcmp (IDENTIFIER_POINTER (first[2].value),
    7350              :                                         "doacross") == 0))
    7351              :                   kind = C_OMP_DIR_STANDALONE;
    7352              :               }
    7353          740 :             else if (dir->id == PRAGMA_OMP_ERROR)
    7354              :               {
    7355              :                 /* error with at(execution) clause is C_OMP_DIR_STANDALONE.  */
    7356              :                 int paren_depth = 0;
    7357           99 :                 for (int i = 1; first + i < last; i++)
    7358           84 :                   if (first[i].type == CPP_OPEN_PAREN)
    7359           18 :                     paren_depth++;
    7360           66 :                   else if (first[i].type == CPP_CLOSE_PAREN)
    7361           18 :                     paren_depth--;
    7362           48 :                   else if (paren_depth == 0
    7363           30 :                            && first + i + 2 < last
    7364           30 :                            && first[i].type == CPP_NAME
    7365           21 :                            && first[i + 1].type == CPP_OPEN_PAREN
    7366           21 :                            && first[i + 2].type == CPP_NAME
    7367           15 :                            && !strcmp (IDENTIFIER_POINTER (first[i].value),
    7368              :                                        "at")
    7369           57 :                            && !strcmp (IDENTIFIER_POINTER (first[i
    7370              :                                                                  + 2].value),
    7371              :                                        "execution"))
    7372              :                     {
    7373              :                       kind = C_OMP_DIR_STANDALONE;
    7374              :                       break;
    7375              :                     }
    7376              :               }
    7377          748 :             c_omp_attribute_data v = { toks, dir, kind };
    7378          748 :             vd.safe_push (v);
    7379          748 :             if (flag_openmp || dir->simd)
    7380          748 :               tokens += (last - first) + 1;
    7381              :           }
    7382          609 :         c_omp_attribute_data v = {};
    7383          609 :         vd.safe_push (v);
    7384          609 :         *pa = TREE_CHAIN (*pa);
    7385              :       }
    7386              :     else
    7387            1 :       pa = &TREE_CHAIN (*pa);
    7388              : 
    7389          610 :   if (bad)
    7390              :     {
    7391           17 :     fail:
    7392           29 :       if (have_std_attrs && attrs == NULL)
    7393           26 :         *have_std_attrs = false;
    7394              :       return false;
    7395              :     }
    7396              : 
    7397              :   unsigned int i;
    7398              :   c_omp_attribute_data *v;
    7399              :   c_omp_attribute_data *construct_seen = nullptr;
    7400              :   c_omp_attribute_data *standalone_seen = nullptr;
    7401              :   c_omp_attribute_data *prev_standalone_seen = nullptr;
    7402         1915 :   FOR_EACH_VEC_ELT (vd, i, v)
    7403         1322 :     if (v->tokens)
    7404              :       {
    7405          730 :         if (v->kind == C_OMP_DIR_CONSTRUCT && !construct_seen)
    7406              :           construct_seen = v;
    7407          359 :         else if (v->kind == C_OMP_DIR_STANDALONE && !standalone_seen)
    7408           71 :           standalone_seen = v;
    7409              :       }
    7410              :     else
    7411              :       {
    7412          592 :         if (standalone_seen && !prev_standalone_seen)
    7413              :           {
    7414         1322 :             prev_standalone_seen = standalone_seen;
    7415         1322 :             standalone_seen = nullptr;
    7416              :           }
    7417              :       }
    7418              : 
    7419          593 :   if (cnt > 1 && construct_seen)
    7420              :     {
    7421            4 :       error_at ((*construct_seen->tokens)[0].location,
    7422              :                 "OpenMP construct among %<omp::directive%> attributes"
    7423              :                 " requires all %<omp::directive%> attributes on the"
    7424              :                 " same statement to be in the same %<omp::sequence%>");
    7425            4 :       goto fail;
    7426              :     }
    7427          589 :   if (cnt > 1 && standalone_seen && prev_standalone_seen)
    7428              :     {
    7429            2 :       error_at ((*standalone_seen->tokens)[0].location,
    7430              :                 "multiple OpenMP standalone directives among"
    7431              :                 " %<omp::directive%> attributes must be all within the"
    7432              :                 " same %<omp::sequence%>");
    7433            2 :       goto fail;
    7434              :     }
    7435              : 
    7436          587 :   if (prev_standalone_seen)
    7437              :     standalone_seen = prev_standalone_seen;
    7438          520 :   if (standalone_seen
    7439          587 :       && !c_parser_next_token_is (parser, CPP_SEMICOLON))
    7440              :     {
    7441            2 :       error_at (standalone_seen->tokens->address ()->location,
    7442              :                 "standalone OpenMP directives in %<omp::directive%> attribute"
    7443              :                 " can only appear on an empty statement");
    7444            2 :       goto fail;
    7445              :     }
    7446         1162 :   if (cnt && c_parser_next_token_is (parser, CPP_PRAGMA))
    7447              :     {
    7448            4 :       c_token *token = c_parser_peek_token (parser);
    7449            4 :       enum pragma_kind kind = token->pragma_kind;
    7450            4 :       if (kind >= PRAGMA_OMP__START_ && kind <= PRAGMA_OMP__LAST_)
    7451              :         {
    7452            4 :           error_at (token->location,
    7453              :                     "mixing OpenMP directives with attribute and pragma "
    7454              :                     "syntax on the same statement");
    7455            4 :           goto fail;
    7456              :         }
    7457              :     }
    7458              : 
    7459          581 :   if (!tokens)
    7460              :     return false;
    7461              : 
    7462          565 :   unsigned int tokens_avail = parser->tokens_avail;
    7463              : 
    7464          565 :   tokens++;
    7465          565 :   vec<c_token, va_gc> *toks = NULL;
    7466          565 :   vec_safe_reserve (toks, tokens, true);
    7467         2408 :   FOR_EACH_VEC_ELT (vd, i, v)
    7468              :     {
    7469         1278 :       if (!v->tokens)
    7470          566 :         continue;
    7471          712 :       if (!flag_openmp && !v->dir->simd)
    7472            0 :         continue;
    7473          712 :       c_token *first = v->tokens->address ();
    7474          712 :       c_token *last = first + v->tokens->length ();
    7475          712 :       c_token tok = {};
    7476          712 :       tok.type = CPP_PRAGMA;
    7477          712 :       tok.keyword = RID_MAX;
    7478          712 :       tok.pragma_kind = pragma_kind (v->dir->id);
    7479          712 :       tok.location = first->location;
    7480          712 :       toks->quick_push (tok);
    7481        17475 :       while (++first < last)
    7482        16051 :         toks->quick_push (*first);
    7483          712 :       tok = {};
    7484          712 :       tok.type = CPP_PRAGMA_EOL;
    7485          712 :       tok.keyword = RID_MAX;
    7486          712 :       tok.location = last[-1].location;
    7487          712 :       toks->quick_push (tok);
    7488              :     }
    7489              : 
    7490          565 :   c_token tok = {};
    7491          565 :   tok.type = CPP_EOF;
    7492          565 :   tok.keyword = RID_MAX;
    7493          565 :   tok.location = toks->last ().location;
    7494          565 :   toks->quick_push (tok);
    7495              : 
    7496          565 :   gcc_assert (!parser->in_omp_attribute_pragma);
    7497          565 :   parser->in_omp_attribute_pragma = ggc_alloc<omp_attribute_pragma_state> ();
    7498          565 :   parser->in_omp_attribute_pragma->token_vec = toks;
    7499          565 :   parser->in_omp_attribute_pragma->save_tokens = parser->tokens;
    7500          565 :   parser->in_omp_attribute_pragma->save_tokens_avail = tokens_avail;
    7501          565 :   parser->tokens = toks->address ();
    7502          565 :   parser->tokens_avail = tokens;
    7503          565 :   return true;
    7504          610 : }
    7505              : 
    7506              : /* Handle omp::directive and omp::sequence attributes in ATTRS
    7507              :    (if any) at the start or after declaration-id of a declaration.  */
    7508              : 
    7509              : static void
    7510     66615456 : c_parser_handle_directive_omp_attributes (tree &attrs,
    7511              :                                           vec<c_token> *&pragma_clauses,
    7512              :                                           vec<c_token> *attr_clauses)
    7513              : {
    7514     66615456 :   if (!flag_openmp && !flag_openmp_simd)
    7515              :     return;
    7516              : 
    7517      1753948 :   for (tree *pa = &attrs; *pa; )
    7518       684233 :     if (is_attribute_namespace_p ("omp", *pa)
    7519       684233 :         && is_attribute_p ("directive", get_attribute_name (*pa)))
    7520              :       {
    7521          141 :         int cnt = 0;
    7522          281 :         for (tree *pa2 = &TREE_VALUE (*pa); *pa2; )
    7523              :           {
    7524          142 :             tree a = *pa2;
    7525          142 :             tree d = TREE_VALUE (a);
    7526          142 :             gcc_assert (TREE_CODE (d) == C_TOKEN_VEC);
    7527          142 :             vec<c_token, va_gc> *toks = C_TOKEN_VEC_TOKENS (d);
    7528          142 :             c_token *first = toks->address ();
    7529          142 :             c_token *last = first + toks->length ();
    7530          142 :             const char *directive[3] = {};
    7531          424 :             for (int i = 0; i < 3; i++)
    7532              :               {
    7533          390 :                 tree id = NULL_TREE;
    7534          390 :                 if (first + i == last)
    7535              :                   break;
    7536          335 :                 if (first[i].type == CPP_NAME)
    7537          282 :                   id = first[i].value;
    7538           53 :                 else if (first[i].type == CPP_KEYWORD)
    7539            0 :                   id = ridpointers[(int) first[i].keyword];
    7540              :                 else
    7541              :                   break;
    7542          282 :                 directive[i] = IDENTIFIER_POINTER (id);
    7543              :               }
    7544          142 :             const c_omp_directive *dir = NULL;
    7545          142 :             if (directive[0])
    7546          142 :               dir = c_omp_categorize_directive (directive[0], directive[1],
    7547              :                                                 directive[2]);
    7548          142 :             if (dir == NULL)
    7549              :               {
    7550            9 :                 error_at (first->location,
    7551              :                           "unknown OpenMP directive name in "
    7552              :                           "%qs attribute argument",
    7553            9 :                           TREE_PUBLIC (d) ? "omp::decl" : "omp::directive");
    7554            9 :                 *pa2 = TREE_CHAIN (a);
    7555              :               }
    7556          133 :             else if (dir->id == PRAGMA_OMP_DECLARE
    7557          105 :                      && (strcmp (directive[1], "simd") == 0
    7558           22 :                          || strcmp (directive[1], "variant") == 0))
    7559              :               {
    7560           92 :                 if (pragma_clauses)
    7561              :                   {
    7562            2 :                     error_at (first->location,
    7563              :                               "mixing OpenMP directives with attribute and "
    7564              :                               "pragma syntax on the same declaration");
    7565            6 :                     for (pa = &attrs; *pa; )
    7566            2 :                       if (is_attribute_namespace_p ("omp", *pa)
    7567            4 :                           && is_attribute_p ("directive",
    7568            2 :                                              get_attribute_name (*pa)))
    7569            2 :                         *pa = TREE_CHAIN (*pa);
    7570              :                       else
    7571            0 :                         pa = &TREE_CHAIN (*pa);
    7572            2 :                     return;
    7573              :                   }
    7574           90 :                 ++cnt;
    7575          110 :                 attr_clauses->reserve (attr_clauses->length ()
    7576           90 :                                        + toks->length () + 2);
    7577          834 :                 for (++first; first < last; ++first)
    7578          744 :                   attr_clauses->quick_push (*first);
    7579           90 :                 c_token tok = {};
    7580           90 :                 tok.type = CPP_PRAGMA_EOL;
    7581           90 :                 tok.keyword = RID_MAX;
    7582           90 :                 tok.location = last[-1].location;
    7583           90 :                 attr_clauses->quick_push (tok);
    7584           90 :                 *pa2 = TREE_CHAIN (a);
    7585           90 :               }
    7586              :             else
    7587           41 :               pa2 = &TREE_CHAIN (a);
    7588              :           }
    7589          139 :         if (cnt && TREE_VALUE (*pa) == NULL_TREE)
    7590           86 :           *pa = TREE_CHAIN (*pa);
    7591              :         else
    7592           53 :           pa = &TREE_CHAIN (*pa);
    7593              :       }
    7594              :     else
    7595       684092 :       pa = &TREE_CHAIN (*pa);
    7596      1069715 :   if (attr_clauses->length ())
    7597              :     {
    7598           70 :       c_token tok = {};
    7599           70 :       tok.type = CPP_EOF;
    7600           70 :       tok.keyword = RID_MAX;
    7601           70 :       tok.location = attr_clauses->last ().location;
    7602           70 :       attr_clauses->quick_push (tok);
    7603           70 :       attr_clauses->quick_push (tok);
    7604           70 :       pragma_clauses = attr_clauses;
    7605              :     }
    7606              : }
    7607              : 
    7608              : /* Check if STD_ATTR contains a musttail attribute and remove if it
    7609              :    precedes a return.  PARSER is the parser and ATTR is the output
    7610              :    attr_state.  */
    7611              : 
    7612              : static tree
    7613          978 : c_parser_handle_musttail (c_parser *parser, tree std_attrs, attr_state &attr)
    7614              : {
    7615          978 :   if (c_parser_next_token_is_keyword (parser, RID_RETURN))
    7616              :     {
    7617          229 :       if (tree a = lookup_attribute ("gnu", "musttail", std_attrs))
    7618              :         {
    7619          426 :           for (; a; a = lookup_attribute ("gnu", "musttail", TREE_CHAIN (a)))
    7620          214 :             if (TREE_VALUE (a))
    7621            2 :               error ("%qs attribute does not take any arguments",
    7622              :                      "musttail");
    7623          212 :           std_attrs = remove_attribute ("gnu", "musttail", std_attrs);
    7624          212 :           attr.musttail_p = true;
    7625              :         }
    7626          229 :       if (lookup_attribute ("clang", "musttail", std_attrs))
    7627              :         {
    7628           10 :           std_attrs = remove_attribute ("clang", "musttail", std_attrs);
    7629           10 :           attr.musttail_p = true;
    7630              :         }
    7631              :     }
    7632          978 :   return std_attrs;
    7633              : }
    7634              : 
    7635              : /* Return a statement before optional series of LABEL_EXPR/CASE_LABEL_EXPRs.
    7636              :    Instead of collecting vectors of labels before each stmt just in case
    7637              :    the statement would be iteration or switch statement for named loops,
    7638              :    we just remember last emitted statement and let the iteration/switch
    7639              :    statement search backwards in cur_stmt_list until that stmt for loop
    7640              :    names if any.  */
    7641              : 
    7642              : static tree
    7643     91944130 : get_before_labels ()
    7644              : {
    7645     91944130 :   if (!building_stmt_list_p ())
    7646              :     return NULL_TREE;
    7647     91944130 :   tree_stmt_iterator tsi = tsi_last (cur_stmt_list);
    7648     91944130 :   if (tsi_end_p (tsi))
    7649              :     return NULL_TREE;
    7650     50831276 :   return tsi_stmt (tsi);
    7651              : }
    7652              : 
    7653              : /* Parse a compound statement except for the opening brace.  This is
    7654              :    used for parsing both compound statements and statement expressions
    7655              :    (which follow different paths to handling the opening).  */
    7656              : 
    7657              : static location_t
    7658     38673357 : c_parser_compound_statement_nostart (c_parser *parser)
    7659              : {
    7660     38673357 :   bool last_stmt = false;
    7661     38673357 :   bool last_label = false;
    7662     38673357 :   bool save_valid_for_pragma = valid_location_for_stdc_pragma_p ();
    7663     38673357 :   location_t label_loc = UNKNOWN_LOCATION;  /* Quiet warning.  */
    7664     38673357 :   struct omp_for_parse_data *omp_for_parse_state
    7665              :     = parser->omp_for_parse_state;
    7666     77346714 :   bool in_omp_loop_block
    7667     38673357 :     = omp_for_parse_state ? omp_for_parse_state->want_nested_loop : false;
    7668     38673357 :   tree sl = NULL_TREE;
    7669     38673357 :   attr_state astate = {};
    7670              : 
    7671     38673357 :   if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
    7672              :     {
    7673        24260 :       location_t endloc = c_parser_peek_token (parser)->location;
    7674        24260 :       add_debug_begin_stmt (endloc);
    7675        24260 :       c_parser_consume_token (parser);
    7676        24260 :       return endloc;
    7677              :     }
    7678              : 
    7679              :   /* If we're parsing a {} sequence in an OMP_FOR body, start a
    7680              :      statement list for intervening code.  */
    7681     38649097 :   if (in_omp_loop_block)
    7682          178 :     sl = push_stmt_list ();
    7683              : 
    7684     38649097 :   mark_valid_location_for_stdc_pragma (true);
    7685     38649097 :   if (c_parser_next_token_is_keyword (parser, RID_LABEL))
    7686              :     {
    7687              :       /* Read zero or more forward-declarations for labels that nested
    7688              :          functions can jump to.  */
    7689          754 :       mark_valid_location_for_stdc_pragma (false);
    7690          754 :       if (in_omp_loop_block)
    7691            5 :         check_omp_intervening_code (parser);
    7692         1630 :       while (c_parser_next_token_is_keyword (parser, RID_LABEL))
    7693              :         {
    7694          876 :           label_loc = c_parser_peek_token (parser)->location;
    7695          876 :           c_parser_consume_token (parser);
    7696              :           /* Any identifiers, including those declared as type names,
    7697              :              are OK here.  */
    7698         1588 :           while (true)
    7699              :             {
    7700         1232 :               tree label;
    7701         1232 :               if (c_parser_next_token_is_not (parser, CPP_NAME))
    7702              :                 {
    7703            0 :                   c_parser_error (parser, "expected identifier");
    7704            0 :                   break;
    7705              :                 }
    7706         1232 :               label
    7707         1232 :                 = declare_label (c_parser_peek_token (parser)->value);
    7708         1232 :               C_DECLARED_LABEL_FLAG (label) = 1;
    7709         1232 :               add_stmt (build_stmt (label_loc, DECL_EXPR, label));
    7710         1232 :               c_parser_consume_token (parser);
    7711         1232 :               if (c_parser_next_token_is (parser, CPP_COMMA))
    7712          356 :                 c_parser_consume_token (parser);
    7713              :               else
    7714              :                 break;
    7715          356 :             }
    7716          876 :           c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
    7717              :         }
    7718          754 :       pedwarn (label_loc, OPT_Wpedantic, "ISO C forbids label declarations");
    7719              :     }
    7720              :   /* We must now have at least one statement, label or declaration.  */
    7721     38649097 :   if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
    7722              :     {
    7723            0 :       mark_valid_location_for_stdc_pragma (save_valid_for_pragma);
    7724            0 :       c_parser_error (parser, "expected declaration or statement");
    7725            0 :       location_t endloc = c_parser_peek_token (parser)->location;
    7726            0 :       c_parser_consume_token (parser);
    7727            0 :       return endloc;
    7728              :     }
    7729     38649097 :   tree before_labels = get_before_labels ();
    7730    129550191 :   while (c_parser_next_token_is_not (parser, CPP_CLOSE_BRACE))
    7731              :     {
    7732     52252056 :       location_t loc = c_parser_peek_token (parser)->location;
    7733     52252056 :       loc = expansion_point_location_if_in_system_header (loc);
    7734              : 
    7735    104504112 :       bool want_nested_loop = (omp_for_parse_state
    7736     52252056 :                                ? omp_for_parse_state->want_nested_loop
    7737              :                                : false);
    7738              : 
    7739              :       /* First take care of special cases for OpenMP "canonical loop
    7740              :          nest form", that do not allow standard attributes, labels, or
    7741              :          __extension__ before the nested statement.  */
    7742     52252056 :       if (in_omp_loop_block && !last_label)
    7743              :         {
    7744          397 :           tree_code code = omp_for_parse_state->code;
    7745          513 :           if (want_nested_loop
    7746          397 :               && c_parser_omp_next_tokens_can_be_canon_loop (parser, code,
    7747              :                                                              false))
    7748              :             {
    7749              :               /* Found the next nested loop.  If there were intervening
    7750              :                  code statements collected before now, wrap them in an
    7751              :                  OMP_STRUCTURED_BLOCK node, and start a new structured
    7752              :                  block to hold statements that may come after the FOR.  */
    7753          116 :               gcc_assert (sl);
    7754          116 :               add_structured_block_stmt (pop_stmt_list (sl));
    7755          116 :               omp_for_parse_state->depth++;
    7756          116 :               add_stmt (c_parser_omp_loop_nest (parser, NULL));
    7757          116 :               omp_for_parse_state->depth--;
    7758          116 :               sl = push_stmt_list ();
    7759          116 :               parser->error = false;
    7760          116 :               before_labels = get_before_labels ();
    7761          116 :               astate.reset ();
    7762          167 :               continue;
    7763              :             }
    7764          281 :           else if (want_nested_loop
    7765          468 :                    && c_parser_next_token_is (parser, CPP_OPEN_BRACE))
    7766              :             {
    7767              :               /* If this nested compound statement contains the nested loop,
    7768              :                  we need to separate the other statements in the current
    7769              :                  statement into separate blocks of intervening code.  If
    7770              :                  there's no nested loop, it's all part of the same
    7771              :                  chunk of intervening code.  */
    7772           44 :               tree pre_sl = pop_stmt_list (sl);
    7773           44 :               tree nested_sl = push_stmt_list ();
    7774           44 :               mark_valid_location_for_stdc_pragma (false);
    7775           44 :               c_parser_statement_after_labels (parser, NULL, NULL_TREE);
    7776           44 :               nested_sl = pop_stmt_list (nested_sl);
    7777           44 :               if (omp_for_parse_state->want_nested_loop)
    7778              :                 {
    7779              :                   /* This block didn't contain a loop-nest, so it's
    7780              :                      all part of the same chunk of intervening code.  */
    7781           13 :                   check_omp_intervening_code (parser);
    7782           13 :                   sl = push_stmt_list ();
    7783           13 :                   add_stmt (pre_sl);
    7784           13 :                   add_stmt (nested_sl);
    7785              :                 }
    7786              :               else
    7787              :                 {
    7788              :                   /* It contains the nested loop.  */
    7789           31 :                   add_structured_block_stmt (pre_sl);
    7790           31 :                   add_stmt (nested_sl);
    7791           31 :                   sl = push_stmt_list ();
    7792              :                 }
    7793           44 :               parser->error = false;
    7794           44 :               before_labels = get_before_labels ();
    7795           44 :               astate.reset ();
    7796           44 :               continue;
    7797           44 :             }
    7798          237 :           else if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    7799              :             {
    7800              :               /* Prior to implementing the OpenMP 5.1 syntax for canonical
    7801              :                  loop form, GCC used to accept an empty statements that
    7802              :                  would now be flagged as intervening code.  Continue to
    7803              :                  do that, as an extension.  */
    7804              :               /* FIXME:  Maybe issue a warning or something here?  */
    7805            4 :               c_parser_consume_token (parser);
    7806            4 :               before_labels = get_before_labels ();
    7807            4 :               astate.reset ();
    7808            4 :               continue;
    7809              :             }
    7810              :         }
    7811              : 
    7812              :       /* Standard attributes may start a label, statement or declaration.  */
    7813     52251892 :       bool have_std_attrs
    7814     52251892 :         = c_parser_nth_token_starts_std_attributes (parser, 1);
    7815     52251892 :       tree std_attrs = NULL_TREE;
    7816     52251892 :       if (have_std_attrs)
    7817              :         {
    7818          842 :           std_attrs = c_parser_std_attribute_specifier_sequence (parser);
    7819          842 :           std_attrs = c_parser_handle_musttail (parser, std_attrs, astate);
    7820              :         }
    7821     52251892 :       if (c_parser_next_token_is_keyword (parser, RID_CASE)
    7822     51247529 :           || c_parser_next_token_is_keyword (parser, RID_DEFAULT)
    7823    103464570 :           || (c_parser_next_token_is (parser, CPP_NAME)
    7824     10375534 :               && c_parser_peek_2nd_token (parser)->type == CPP_COLON))
    7825              :         {
    7826      1063440 :           if (c_parser_next_token_is_keyword (parser, RID_CASE))
    7827      1004363 :             label_loc = c_parser_peek_2nd_token (parser)->location;
    7828              :           else
    7829        59077 :             label_loc = c_parser_peek_token (parser)->location;
    7830      1063440 :           last_label = true;
    7831      1063440 :           last_stmt = false;
    7832      1063440 :           mark_valid_location_for_stdc_pragma (false);
    7833      1063440 :           if (in_omp_loop_block)
    7834           26 :             check_omp_intervening_code (parser);
    7835      1063440 :           c_parser_label (parser, std_attrs);
    7836              :         }
    7837     51188452 :       else if (c_parser_next_tokens_start_declaration (parser)
    7838     51188452 :                || (have_std_attrs
    7839          705 :                    && !c_parser_handle_statement_omp_attributes
    7840          705 :                                 (parser, std_attrs, &have_std_attrs)
    7841          271 :                    && c_parser_next_token_is (parser, CPP_SEMICOLON)
    7842           77 :                    && (have_std_attrs = true)))
    7843              :         {
    7844      7720998 :           if (last_label)
    7845           97 :             pedwarn_c11 (c_parser_peek_token (parser)->location, OPT_Wfree_labels,
    7846              :                          "a label can only be part of a statement and "
    7847              :                          "a declaration is not a statement");
    7848              :           /* It's unlikely we'll see a nested loop in a declaration in
    7849              :              intervening code in an OMP loop, but disallow it anyway.  */
    7850      7720998 :           if (in_omp_loop_block)
    7851              :             {
    7852           19 :               check_omp_intervening_code (parser);
    7853           19 :               omp_for_parse_state->want_nested_loop = false;
    7854              :             }
    7855      7720998 :           mark_valid_location_for_stdc_pragma (false);
    7856      7720998 :           bool fallthru_attr_p = false;
    7857      7720998 :           c_parser_declaration_or_fndef (parser, true, !have_std_attrs,
    7858              :                                          true, true, true, false, NULL,
    7859              :                                          NULL, have_std_attrs, std_attrs,
    7860              :                                          NULL, &fallthru_attr_p);
    7861              : 
    7862      7720998 :           if (in_omp_loop_block)
    7863           19 :               omp_for_parse_state->want_nested_loop = want_nested_loop;
    7864      7720998 :           if (last_stmt && !fallthru_attr_p)
    7865       314606 :             pedwarn_c90 (loc, OPT_Wdeclaration_after_statement,
    7866              :                          "ISO C90 forbids mixed declarations and code");
    7867      7720998 :           last_stmt = fallthru_attr_p;
    7868      7720998 :           last_label = false;
    7869      7720998 :           before_labels = get_before_labels ();
    7870              :         }
    7871     43467454 :       else if (c_parser_next_token_is_keyword (parser, RID_EXTENSION))
    7872              :         {
    7873              :           /* __extension__ can start a declaration, but is also an
    7874              :              unary operator that can start an expression.  Consume all
    7875              :              but the last of a possible series of __extension__ to
    7876              :              determine which.  If standard attributes have already
    7877              :              been seen, it must start a statement, not a declaration,
    7878              :              but standard attributes starting a declaration may appear
    7879              :              after __extension__.  */
    7880         1568 :           while (c_parser_peek_2nd_token (parser)->type == CPP_KEYWORD
    7881          784 :                  && (c_parser_peek_2nd_token (parser)->keyword
    7882              :                      == RID_EXTENSION))
    7883            0 :             c_parser_consume_token (parser);
    7884          784 :           if (!have_std_attrs
    7885          784 :               && (c_parser_next_tokens_start_declaration (parser, 2)
    7886          713 :                   || c_parser_nth_token_starts_std_attributes (parser, 2)))
    7887              :             {
    7888           74 :               int ext;
    7889           74 :               ext = disable_extension_diagnostics ();
    7890           74 :               c_parser_consume_token (parser);
    7891           74 :               last_label = false;
    7892              :               /* It's unlikely we'll see a nested loop in a declaration in
    7893              :                  intervening code in an OMP loop, but disallow it anyway.  */
    7894           74 :               if (in_omp_loop_block)
    7895              :                 {
    7896            0 :                   check_omp_intervening_code (parser);
    7897            0 :                   omp_for_parse_state->want_nested_loop = false;
    7898              :                 }
    7899           74 :               mark_valid_location_for_stdc_pragma (false);
    7900           74 :               c_parser_declaration_or_fndef (parser, true, true, true, true,
    7901              :                                              true, false);
    7902           74 :               if (in_omp_loop_block)
    7903            0 :                 omp_for_parse_state->want_nested_loop = want_nested_loop;
    7904              :               /* Following the old parser, __extension__ does not
    7905              :                  disable this diagnostic.  */
    7906           74 :               restore_extension_diagnostics (ext);
    7907           74 :               if (last_stmt)
    7908            7 :                 pedwarn_c90 (loc, OPT_Wdeclaration_after_statement,
    7909              :                              "ISO C90 forbids mixed declarations and code");
    7910           74 :               last_stmt = false;
    7911           74 :               before_labels = get_before_labels ();
    7912              :             }
    7913              :           else
    7914          710 :             goto statement;
    7915              :         }
    7916     43466670 :       else if (c_parser_next_token_is (parser, CPP_PRAGMA))
    7917              :         {
    7918       341073 :           if (have_std_attrs && !parser->in_omp_attribute_pragma)
    7919            0 :             c_parser_error (parser, "expected declaration or statement");
    7920       341073 :           else if (std_attrs)
    7921            0 :             c_warn_unused_attributes (std_attrs);
    7922              :           /* External pragmas, and some omp pragmas, are not associated
    7923              :              with regular c code, and so are not to be considered statements
    7924              :              syntactically.  This ensures that the user doesn't put them
    7925              :              places that would turn into syntax errors if the directive
    7926              :              were ignored.  */
    7927       341073 :           if (omp_for_parse_state)
    7928           13 :             omp_for_parse_state->want_nested_loop = false;
    7929       682063 :           if (c_parser_pragma (parser,
    7930              :                                last_label ? pragma_stmt : pragma_compound,
    7931              :                                NULL, before_labels))
    7932              :             {
    7933        24127 :               last_label = false;
    7934        24127 :               last_stmt = true;
    7935        24127 :               if (omp_for_parse_state)
    7936            5 :                 check_omp_intervening_code (parser);
    7937              :             }
    7938       316951 :           if (omp_for_parse_state)
    7939           13 :             omp_for_parse_state->want_nested_loop = want_nested_loop;
    7940       341073 :           before_labels = get_before_labels ();
    7941              :         }
    7942     43125597 :       else if (c_parser_next_token_is (parser, CPP_EOF))
    7943              :         {
    7944           56 :           mark_valid_location_for_stdc_pragma (save_valid_for_pragma);
    7945           56 :           c_parser_error (parser, "expected declaration or statement");
    7946           58 :           return c_parser_peek_token (parser)->location;
    7947              :         }
    7948     43125541 :       else if (c_parser_next_token_is_keyword (parser, RID_ELSE))
    7949              :         {
    7950            5 :           if (parser->in_if_block)
    7951              :             {
    7952            2 :               mark_valid_location_for_stdc_pragma (save_valid_for_pragma);
    7953            2 :               error_at (loc, "expected %<}%> before %<else%>");
    7954            2 :               return c_parser_peek_token (parser)->location;
    7955              :             }
    7956              :           else
    7957              :             {
    7958            3 :               error_at (loc, "%<else%> without a previous %<if%>");
    7959            3 :               c_parser_consume_token (parser);
    7960            3 :               before_labels = get_before_labels ();
    7961            3 :               astate.reset ();
    7962            3 :               continue;
    7963              :             }
    7964              :         }
    7965              :       else
    7966              :         {
    7967     43125536 :         statement:
    7968     43126246 :           c_warn_unused_attributes (std_attrs);
    7969     43126246 :           last_label = false;
    7970     43126246 :           last_stmt = true;
    7971     43126246 :           mark_valid_location_for_stdc_pragma (false);
    7972     43126246 :           if (!omp_for_parse_state)
    7973     43126015 :             c_parser_statement_after_labels (parser, NULL, before_labels,
    7974              :                                              NULL, astate);
    7975              :           else
    7976              :             {
    7977              :               /* In canonical loop nest form, nested loops can only appear
    7978              :                  directly, or in a directly nested compound statement.  We
    7979              :                  already took care of those cases above, so now we have
    7980              :                  something else.  This statement and everything inside
    7981              :                  it must be intervening code.  */
    7982          231 :               omp_for_parse_state->want_nested_loop = false;
    7983          231 :               check_omp_intervening_code (parser);
    7984          231 :               c_parser_statement_after_labels (parser, NULL, before_labels);
    7985          231 :               omp_for_parse_state->want_nested_loop = want_nested_loop;
    7986              :             }
    7987     43126245 :           before_labels = get_before_labels ();
    7988              :         }
    7989              : 
    7990     52251830 :       parser->error = false;
    7991     52251830 :       astate.reset ();
    7992              :     }
    7993     38649038 :   if (last_label)
    7994           51 :     pedwarn_c11 (label_loc, OPT_Wfree_labels,
    7995              :                  "label at end of compound statement");
    7996     38649038 :   location_t endloc = c_parser_peek_token (parser)->location;
    7997     38649038 :   c_parser_consume_token (parser);
    7998              : 
    7999              :   /* Restore the value we started with.  */
    8000     38649038 :   mark_valid_location_for_stdc_pragma (save_valid_for_pragma);
    8001              : 
    8002              :   /* Package leftover intervening code, or the whole contents of the
    8003              :      compound statement if we were looking for a nested loop in an OMP_FOR
    8004              :      construct and didn't find one.  */
    8005     38649038 :   if (sl)
    8006              :     {
    8007          178 :       sl = pop_stmt_list (sl);
    8008          178 :       if (omp_for_parse_state->want_nested_loop)
    8009           31 :         add_stmt (sl);
    8010              :       else
    8011          147 :         add_structured_block_stmt (sl);
    8012              :     }
    8013              :   return endloc;
    8014              : }
    8015              : 
    8016              : /* Parse all consecutive labels, possibly preceded by standard
    8017              :    attributes.  In this context, a statement is required, not a
    8018              :    declaration, so attributes must be followed by a statement that is
    8019              :    not just a semicolon.  Returns an attr_state.  */
    8020              : 
    8021              : static attr_state
    8022      2106476 : c_parser_all_labels (c_parser *parser)
    8023              : {
    8024      2106476 :   attr_state attr = {};
    8025      2106476 :   bool have_std_attrs;
    8026      2106476 :   tree std_attrs = NULL;
    8027      2106476 :   if ((have_std_attrs = c_parser_nth_token_starts_std_attributes (parser, 1)))
    8028              :     {
    8029          110 :       std_attrs = c_parser_std_attribute_specifier_sequence (parser);
    8030          110 :       std_attrs = c_parser_handle_musttail (parser, std_attrs, attr);
    8031              :     }
    8032              : 
    8033      2107552 :   while (c_parser_next_token_is_keyword (parser, RID_CASE)
    8034      2106978 :          || c_parser_next_token_is_keyword (parser, RID_DEFAULT)
    8035      4214519 :          || (c_parser_next_token_is (parser, CPP_NAME)
    8036       521746 :              && c_parser_peek_2nd_token (parser)->type == CPP_COLON))
    8037              :     {
    8038         1076 :       c_parser_label (parser, std_attrs);
    8039         1076 :       std_attrs = NULL;
    8040         1076 :       if ((have_std_attrs = c_parser_nth_token_starts_std_attributes (parser,
    8041              :                                                                       1)))
    8042              :         {
    8043            3 :           std_attrs = c_parser_std_attribute_specifier_sequence (parser);
    8044            3 :           std_attrs = c_parser_handle_musttail (parser, std_attrs, attr);
    8045              :         }
    8046              :     }
    8047      2106476 :   if (std_attrs
    8048      2106476 :       && (!c_parser_handle_statement_omp_attributes (parser, std_attrs, &have_std_attrs)
    8049           11 :           || std_attrs))
    8050              :     {
    8051           22 :       if (have_std_attrs && c_parser_next_token_is (parser, CPP_SEMICOLON))
    8052            0 :         c_parser_error (parser, "expected statement");
    8053           18 :       c_warn_unused_attributes (std_attrs);
    8054              :     }
    8055      2106551 :   else if (have_std_attrs && c_parser_next_token_is (parser, CPP_SEMICOLON))
    8056            1 :     c_parser_error (parser, "expected statement");
    8057      2106476 :   return attr;
    8058              : }
    8059              : 
    8060              : 
    8061              : /* Information used while parsing an OpenMP metadirective.  */
    8062              : struct omp_metadirective_parse_data {
    8063              :   /* These fields are used to unique-ify labels when reparsing the
    8064              :      code in a metadirective alternative.  */
    8065              :   vec<tree> * GTY((skip)) body_labels;
    8066              :   unsigned int region_num;
    8067              : };
    8068              : 
    8069              : /* Helper function for c_parser_label: mangle a metadirective region
    8070              :    label NAME.  */
    8071              : static tree
    8072            0 : mangle_metadirective_region_label (c_parser *parser, tree name)
    8073              : {
    8074            0 :   if (parser->omp_metadirective_state->body_labels->contains (name))
    8075              :     {
    8076            0 :       const char *old_name = IDENTIFIER_POINTER (name);
    8077            0 :       char *new_name = (char *) XALLOCAVEC (char, strlen (old_name) + 32);
    8078            0 :       sprintf (new_name, "%s_MDR%u", old_name,
    8079              :                parser->omp_metadirective_state->region_num);
    8080            0 :       return get_identifier (new_name);
    8081              :     }
    8082            0 :   return name;
    8083              : }
    8084              : 
    8085              : /* Parse a label (C90 6.6.1, C99 6.8.1, C11 6.8.1).
    8086              : 
    8087              :    label:
    8088              :      identifier : gnu-attributes[opt]
    8089              :      case constant-expression :
    8090              :      default :
    8091              : 
    8092              :    GNU extensions:
    8093              : 
    8094              :    label:
    8095              :      case constant-expression ... constant-expression :
    8096              : 
    8097              :    The use of gnu-attributes on labels is a GNU extension.  The syntax in
    8098              :    GNU C accepts any expressions without commas, non-constant
    8099              :    expressions being rejected later.  Any standard
    8100              :    attribute-specifier-sequence before the first label has been parsed
    8101              :    in the caller, to distinguish statements from declarations.  Any
    8102              :    attribute-specifier-sequence after the label is parsed in this
    8103              :    function.  */
    8104              : static void
    8105      1064516 : c_parser_label (c_parser *parser, tree std_attrs)
    8106              : {
    8107      1064516 :   location_t loc1 = c_parser_peek_token (parser)->location;
    8108      1064516 :   tree label = NULL_TREE;
    8109              : 
    8110              :   /* Remember whether this case or a user-defined label is allowed to fall
    8111              :      through to.  */
    8112      1064516 :   bool fallthrough_p = c_parser_peek_token (parser)->flags & PREV_FALLTHROUGH;
    8113              : 
    8114      1064516 :   if (c_parser_next_token_is_keyword (parser, RID_CASE))
    8115              :     {
    8116      1004937 :       tree exp1, exp2;
    8117      1004937 :       c_parser_consume_token (parser);
    8118      1004937 :       exp1 = convert_lvalue_to_rvalue (loc1,
    8119              :                                        c_parser_expr_no_commas (parser, NULL),
    8120              :                                        true, true).value;
    8121      1004937 :       if (c_parser_next_token_is (parser, CPP_COLON))
    8122              :         {
    8123      1004613 :           c_parser_consume_token (parser);
    8124      1004613 :           label = do_case (loc1, exp1, NULL_TREE, std_attrs);
    8125              :         }
    8126          324 :       else if (c_parser_next_token_is (parser, CPP_ELLIPSIS))
    8127              :         {
    8128          316 :           c_parser_consume_token (parser);
    8129          316 :           exp2 = convert_lvalue_to_rvalue (loc1,
    8130              :                                            c_parser_expr_no_commas (parser,
    8131              :                                                                     NULL),
    8132              :                                            true, true).value;
    8133          316 :           if (c_parser_require (parser, CPP_COLON, "expected %<:%>"))
    8134          316 :             label = do_case (loc1, exp1, exp2, std_attrs);
    8135              :         }
    8136              :       else
    8137            8 :         c_parser_error (parser, "expected %<:%> or %<...%>");
    8138              :     }
    8139        59579 :   else if (c_parser_next_token_is_keyword (parser, RID_DEFAULT))
    8140              :     {
    8141        34862 :       c_parser_consume_token (parser);
    8142        34862 :       if (c_parser_require (parser, CPP_COLON, "expected %<:%>"))
    8143        34862 :         label = do_case (loc1, NULL_TREE, NULL_TREE, std_attrs);
    8144              :     }
    8145              :   else
    8146              :     {
    8147        24717 :       tree name = c_parser_peek_token (parser)->value;
    8148        24717 :       tree tlab;
    8149        24717 :       tree attrs;
    8150        24717 :       location_t loc2 = c_parser_peek_token (parser)->location;
    8151        24717 :       gcc_assert (c_parser_next_token_is (parser, CPP_NAME));
    8152        24717 :       c_parser_consume_token (parser);
    8153        24717 :       gcc_assert (c_parser_next_token_is (parser, CPP_COLON));
    8154        24717 :       c_parser_consume_token (parser);
    8155        24717 :       attrs = c_parser_gnu_attributes (parser);
    8156        24717 :       if (parser->omp_metadirective_state)
    8157            0 :         name = mangle_metadirective_region_label (parser, name);
    8158        24717 :       tlab = define_label (loc2, name);
    8159        24717 :       if (tlab)
    8160              :         {
    8161        24689 :           decl_attributes (&tlab, attrs, 0);
    8162        24689 :           decl_attributes (&tlab, std_attrs, 0);
    8163        24689 :           label = add_stmt (build_stmt (loc1, LABEL_EXPR, tlab));
    8164              :         }
    8165        24717 :       if (attrs
    8166        24717 :           && c_parser_next_tokens_start_declaration (parser))
    8167            1 :           warning_at (loc2, OPT_Wattributes, "GNU-style attribute between"
    8168              :                       " label and declaration appertains to the label");
    8169              :     }
    8170      1064516 :   if (label)
    8171              :     {
    8172      1064336 :       if (TREE_CODE (label) == LABEL_EXPR)
    8173        24689 :         FALLTHROUGH_LABEL_P (LABEL_EXPR_LABEL (label)) = fallthrough_p;
    8174              :       else
    8175      1039647 :         FALLTHROUGH_LABEL_P (CASE_LABEL (label)) = fallthrough_p;
    8176              :     }
    8177      1064516 : }
    8178              : 
    8179              : /* Parse a statement (C90 6.6, C99 6.8, C11 6.8).
    8180              : 
    8181              :    statement:
    8182              :      labeled-statement
    8183              :      attribute-specifier-sequence[opt] compound-statement
    8184              :      expression-statement
    8185              :      attribute-specifier-sequence[opt] selection-statement
    8186              :      attribute-specifier-sequence[opt] iteration-statement
    8187              :      attribute-specifier-sequence[opt] jump-statement
    8188              : 
    8189              :    labeled-statement:
    8190              :      attribute-specifier-sequence[opt] label statement
    8191              : 
    8192              :    expression-statement:
    8193              :      expression[opt] ;
    8194              :      attribute-specifier-sequence expression ;
    8195              : 
    8196              :    selection-statement:
    8197              :      if-statement
    8198              :      switch-statement
    8199              : 
    8200              :    iteration-statement:
    8201              :      while-statement
    8202              :      do-statement
    8203              :      for-statement
    8204              : 
    8205              :    jump-statement:
    8206              :      goto identifier ;
    8207              :      continue ;
    8208              :      break ;
    8209              :      return expression[opt] ;
    8210              : 
    8211              :    GNU extensions:
    8212              : 
    8213              :    statement:
    8214              :      attribute-specifier-sequence[opt] asm-statement
    8215              : 
    8216              :    jump-statement:
    8217              :      goto * expression ;
    8218              : 
    8219              :    expression-statement:
    8220              :      gnu-attributes ;
    8221              : 
    8222              :    Objective-C:
    8223              : 
    8224              :    statement:
    8225              :      attribute-specifier-sequence[opt] objc-throw-statement
    8226              :      attribute-specifier-sequence[opt] objc-try-catch-statement
    8227              :      attribute-specifier-sequence[opt] objc-synchronized-statement
    8228              : 
    8229              :    objc-throw-statement:
    8230              :      @throw expression ;
    8231              :      @throw ;
    8232              : 
    8233              :    OpenACC:
    8234              : 
    8235              :    statement:
    8236              :      attribute-specifier-sequence[opt] openacc-construct
    8237              : 
    8238              :    openacc-construct:
    8239              :      parallel-construct
    8240              :      kernels-construct
    8241              :      data-construct
    8242              :      loop-construct
    8243              : 
    8244              :    parallel-construct:
    8245              :      parallel-directive structured-block
    8246              : 
    8247              :    kernels-construct:
    8248              :      kernels-directive structured-block
    8249              : 
    8250              :    data-construct:
    8251              :      data-directive structured-block
    8252              : 
    8253              :    loop-construct:
    8254              :      loop-directive structured-block
    8255              : 
    8256              :    OpenMP:
    8257              : 
    8258              :    statement:
    8259              :      attribute-specifier-sequence[opt] openmp-construct
    8260              : 
    8261              :    openmp-construct:
    8262              :      parallel-construct
    8263              :      for-construct
    8264              :      simd-construct
    8265              :      for-simd-construct
    8266              :      sections-construct
    8267              :      single-construct
    8268              :      parallel-for-construct
    8269              :      parallel-for-simd-construct
    8270              :      parallel-sections-construct
    8271              :      master-construct
    8272              :      critical-construct
    8273              :      atomic-construct
    8274              :      ordered-construct
    8275              : 
    8276              :    parallel-construct:
    8277              :      parallel-directive structured-block
    8278              : 
    8279              :    for-construct:
    8280              :      for-directive iteration-statement
    8281              : 
    8282              :    simd-construct:
    8283              :      simd-directive iteration-statements
    8284              : 
    8285              :    for-simd-construct:
    8286              :      for-simd-directive iteration-statements
    8287              : 
    8288              :    sections-construct:
    8289              :      sections-directive section-scope
    8290              : 
    8291              :    single-construct:
    8292              :      single-directive structured-block
    8293              : 
    8294              :    parallel-for-construct:
    8295              :      parallel-for-directive iteration-statement
    8296              : 
    8297              :    parallel-for-simd-construct:
    8298              :      parallel-for-simd-directive iteration-statement
    8299              : 
    8300              :    parallel-sections-construct:
    8301              :      parallel-sections-directive section-scope
    8302              : 
    8303              :    master-construct:
    8304              :      master-directive structured-block
    8305              : 
    8306              :    critical-construct:
    8307              :      critical-directive structured-block
    8308              : 
    8309              :    atomic-construct:
    8310              :      atomic-directive expression-statement
    8311              : 
    8312              :    ordered-construct:
    8313              :      ordered-directive structured-block
    8314              : 
    8315              :    Transactional Memory:
    8316              : 
    8317              :    statement:
    8318              :      attribute-specifier-sequence[opt] transaction-statement
    8319              :      attribute-specifier-sequence[opt] transaction-cancel-statement
    8320              : 
    8321              :    IF_P is used to track whether there's a (possibly labeled) if statement
    8322              :    which is not enclosed in braces and has an else clause.  This is used to
    8323              :    implement -Wparentheses.  */
    8324              : 
    8325              : static void
    8326       552466 : c_parser_statement (c_parser *parser, bool *if_p, location_t *loc_after_labels)
    8327              : {
    8328       552466 :   tree before_labels = get_before_labels ();
    8329       552466 :   attr_state a = c_parser_all_labels (parser);
    8330       552466 :   if (loc_after_labels)
    8331       381349 :     *loc_after_labels = c_parser_peek_token (parser)->location;
    8332       552466 :   parser->omp_attrs_forbidden_p = false;
    8333       552466 :   c_parser_statement_after_labels (parser, if_p, before_labels, NULL, a);
    8334       552466 : }
    8335              : 
    8336              : /* Parse and handle optional identifier after break or continue keywords.  */
    8337              : 
    8338              : static tree
    8339       192016 : c_parser_bc_name (c_parser *parser, bool is_break)
    8340              : {
    8341       192016 :   if (!c_parser_next_token_is (parser, CPP_NAME))
    8342              :     return NULL_TREE;
    8343              : 
    8344          316 :   c_token *tok = c_parser_peek_token (parser);
    8345          316 :   tree label = c_finish_bc_name (tok->location, tok->value, is_break);
    8346          316 :   c_parser_consume_token (parser);
    8347          316 :   return label;
    8348              : }
    8349              : 
    8350              : /* Parse a statement, other than a labeled statement.  CHAIN is a vector
    8351              :    of if-else-if conditions.  All labels and standard attributes have
    8352              :    been parsed in the caller.
    8353              : 
    8354              :    IF_P is used to track whether there's a (possibly labeled) if statement
    8355              :    which is not enclosed in braces and has an else clause.  This is used to
    8356              :    implement -Wparentheses.  ASTATE is an earlier parsed attribute state.
    8357              : 
    8358              :    BEFORE_LABELS is last statement before possible labels, see
    8359              :    get_before_labels description for details.  */
    8360              : 
    8361              : static void
    8362     44764987 : c_parser_statement_after_labels (c_parser *parser, bool *if_p,
    8363              :                                  tree before_labels,
    8364              :                                  vec<tree> *chain, attr_state astate)
    8365              : {
    8366     44764987 :   location_t loc = c_parser_peek_token (parser)->location;
    8367     44764987 :   tree stmt = NULL_TREE;
    8368     44764987 :   bool in_if_block = parser->in_if_block;
    8369     44764987 :   parser->in_if_block = false;
    8370     44764987 :   if (if_p != NULL)
    8371       829818 :     *if_p = false;
    8372              : 
    8373     44764987 :   if (c_parser_peek_token (parser)->type != CPP_OPEN_BRACE)
    8374     44301135 :     add_debug_begin_stmt (loc);
    8375              : 
    8376     44764987 :  restart:
    8377     44765044 :   switch (c_parser_peek_token (parser)->type)
    8378              :     {
    8379       463860 :     case CPP_OPEN_BRACE:
    8380       463860 :       add_stmt (c_parser_compound_statement (parser));
    8381       463860 :       break;
    8382     38188623 :     case CPP_KEYWORD:
    8383     38188623 :       switch (c_parser_peek_token (parser)->keyword)
    8384              :         {
    8385      1294459 :         case RID_IF:
    8386      1294459 :           c_parser_if_statement (parser, if_p, chain);
    8387      1294459 :           break;
    8388        38874 :         case RID_SWITCH:
    8389        38874 :           c_parser_switch_statement (parser, if_p, before_labels);
    8390        38874 :           break;
    8391        45291 :         case RID_WHILE:
    8392        45291 :           c_parser_while_statement (parser, false, 0, false, if_p, before_labels);
    8393        45291 :           break;
    8394       149838 :         case RID_DO:
    8395       149838 :           c_parser_do_statement (parser, false, 0, false, before_labels);
    8396       149838 :           break;
    8397       293778 :         case RID_FOR:
    8398       293778 :           c_parser_for_statement (parser, false, 0, false, if_p, before_labels);
    8399       293778 :           break;
    8400        84745 :         case RID_GOTO:
    8401        84745 :           c_parser_consume_token (parser);
    8402        84745 :           if (c_parser_next_token_is (parser, CPP_NAME))
    8403              :             {
    8404        83672 :               tree name = c_parser_peek_token (parser)->value;
    8405        83672 :               if (parser->omp_metadirective_state)
    8406            0 :                 name = mangle_metadirective_region_label (parser, name);
    8407        83672 :               stmt = c_finish_goto_label (loc, name);
    8408        83672 :               c_parser_consume_token (parser);
    8409              :             }
    8410         1073 :           else if (c_parser_next_token_is (parser, CPP_MULT))
    8411              :             {
    8412         1073 :               struct c_expr val;
    8413              : 
    8414         1073 :               c_parser_consume_token (parser);
    8415         1073 :               val = c_parser_expression (parser);
    8416         1073 :               val = convert_lvalue_to_rvalue (loc, val, false, true);
    8417         1073 :               stmt = c_finish_goto_ptr (loc, val);
    8418              :             }
    8419              :           else
    8420            0 :             c_parser_error (parser, "expected identifier or %<*%>");
    8421        84745 :           goto expect_semicolon;
    8422        13401 :         case RID_CONTINUE:
    8423        13401 :           c_parser_consume_token (parser);
    8424        13401 :           stmt = c_finish_bc_stmt (loc, objc_foreach_continue_label, false,
    8425              :                                    c_parser_bc_name (parser, false));
    8426        13401 :           goto expect_semicolon;
    8427       178615 :         case RID_BREAK:
    8428       178615 :           c_parser_consume_token (parser);
    8429       178615 :           stmt = c_finish_bc_stmt (loc, objc_foreach_break_label, true,
    8430              :                                    c_parser_bc_name (parser, true));
    8431       178615 :           goto expect_semicolon;
    8432     35874102 :         case RID_RETURN:
    8433     35874102 :           c_parser_consume_token (parser);
    8434     35874102 :           if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    8435              :             {
    8436        21790 :               stmt = c_finish_return (loc, NULL_TREE, NULL_TREE,
    8437              :                                       astate.musttail_p);
    8438        21790 :               c_parser_consume_token (parser);
    8439              :             }
    8440              :           else
    8441              :             {
    8442     35852312 :               location_t xloc = c_parser_peek_token (parser)->location;
    8443     35852312 :               struct c_expr expr = c_parser_expression_conv (parser);
    8444     35852312 :               mark_exp_read (expr.value);
    8445     35852312 :               stmt = c_finish_return (EXPR_LOC_OR_LOC (expr.value, xloc),
    8446              :                                       expr.value, expr.original_type,
    8447              :                                       astate.musttail_p);
    8448     35852312 :               goto expect_semicolon;
    8449              :             }
    8450        21790 :           break;
    8451       196694 :         case RID_ASM:
    8452       196694 :           stmt = c_parser_asm_statement (parser);
    8453       196694 :           break;
    8454          137 :         case RID_TRANSACTION_ATOMIC:
    8455          137 :         case RID_TRANSACTION_RELAXED:
    8456          274 :           stmt = c_parser_transaction (parser,
    8457          137 :               c_parser_peek_token (parser)->keyword);
    8458          137 :           break;
    8459           28 :         case RID_TRANSACTION_CANCEL:
    8460           28 :           stmt = c_parser_transaction_cancel (parser);
    8461           28 :           goto expect_semicolon;
    8462            0 :         case RID_AT_THROW:
    8463            0 :           gcc_assert (c_dialect_objc ());
    8464            0 :           c_parser_consume_token (parser);
    8465            0 :           if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    8466              :             {
    8467            0 :               stmt = objc_build_throw_stmt (loc, NULL_TREE);
    8468            0 :               c_parser_consume_token (parser);
    8469              :             }
    8470              :           else
    8471              :             {
    8472            0 :               struct c_expr expr = c_parser_expression (parser);
    8473            0 :               expr = convert_lvalue_to_rvalue (loc, expr, false, false);
    8474            0 :               expr.value = c_fully_fold (expr.value, false, NULL);
    8475            0 :               stmt = objc_build_throw_stmt (loc, expr.value);
    8476            0 :               goto expect_semicolon;
    8477              :             }
    8478            0 :           break;
    8479            0 :         case RID_AT_TRY:
    8480            0 :           gcc_assert (c_dialect_objc ());
    8481            0 :           c_parser_objc_try_catch_finally_statement (parser);
    8482            0 :           break;
    8483            0 :         case RID_AT_SYNCHRONIZED:
    8484            0 :           gcc_assert (c_dialect_objc ());
    8485            0 :           c_parser_objc_synchronized_statement (parser);
    8486            0 :           break;
    8487            9 :         case RID_ATTRIBUTE:
    8488            9 :           {
    8489              :             /* Allow '__attribute__((fallthrough));' or
    8490              :                '__attribute__((assume(cond)));' or
    8491              :                '__attribute__((musttail))) return'.  */
    8492            9 :             tree attrs = c_parser_gnu_attributes (parser);
    8493            9 :             bool has_assume = lookup_attribute ("assume", attrs);
    8494            9 :             if (has_assume)
    8495              :               {
    8496            0 :                 if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    8497            0 :                   attrs = handle_assume_attribute (loc, attrs, true);
    8498              :                 else
    8499              :                   {
    8500            0 :                     auto_urlify_attributes sentinel;
    8501            0 :                     warning_at (loc, OPT_Wattributes,
    8502              :                                 "%<assume%> attribute not followed by %<;%>");
    8503            0 :                     has_assume = false;
    8504            0 :                   }
    8505              :               }
    8506            9 :             gcc_assert (!astate.musttail_p);
    8507            9 :             attrs = c_parser_handle_musttail (parser, attrs, astate);
    8508            9 :             if (astate.musttail_p)
    8509              :               {
    8510            4 :                 if (attrs)
    8511              :                   {
    8512            1 :                     auto_urlify_attributes sentinel;
    8513            1 :                     warning_at (c_parser_peek_token (parser)->location,
    8514            1 :                                 OPT_Wattributes,
    8515              :                                 "attribute %<musttail%> mixed with other "
    8516              :                                 "attributes on %<return%> statement");
    8517            1 :                   }
    8518            4 :                 goto restart;
    8519              :               }
    8520            5 :             if (attribute_fallthrough_p (attrs))
    8521              :               {
    8522            5 :                 if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    8523              :                   {
    8524            5 :                     tree fn = build_call_expr_internal_loc (loc,
    8525              :                                                             IFN_FALLTHROUGH,
    8526              :                                                             void_type_node, 0);
    8527            5 :                     add_stmt (fn);
    8528              :                     /* Eat the ';'.  */
    8529            5 :                     c_parser_consume_token (parser);
    8530              :                   }
    8531              :                 else
    8532              :                   {
    8533            0 :                     auto_urlify_attributes sentinel;
    8534            0 :                     warning_at (loc, OPT_Wattributes,
    8535              :                                 "%<fallthrough%> attribute not followed "
    8536              :                                 "by %<;%>");
    8537            0 :                   }
    8538              :               }
    8539            0 :             else if (has_assume)
    8540              :               /* Eat the ';'.  */
    8541            0 :               c_parser_consume_token (parser);
    8542            0 :             else if (attrs != NULL_TREE)
    8543              :               {
    8544            0 :                 auto_urlify_attributes sentinel;
    8545            0 :                 warning_at (loc, OPT_Wattributes,
    8546              :                             "only attribute %<fallthrough%> or %<assume%> can "
    8547              :                             "be applied to a null statement");
    8548            0 :               }
    8549              :             break;
    8550              :           }
    8551        18652 :         default:
    8552        18652 :           goto expr_stmt;
    8553              :         }
    8554              :       break;
    8555       208647 :     case CPP_SEMICOLON:
    8556       208647 :       c_parser_consume_token (parser);
    8557       208647 :       break;
    8558            5 :     case CPP_CLOSE_PAREN:
    8559            5 :     case CPP_CLOSE_SQUARE:
    8560              :       /* Avoid infinite loop in error recovery:
    8561              :          c_parser_skip_until_found stops at a closing nesting
    8562              :          delimiter without consuming it, but here we need to consume
    8563              :          it to proceed further.  */
    8564            5 :       c_parser_error (parser, "expected statement");
    8565            5 :       c_parser_consume_token (parser);
    8566            5 :       break;
    8567         2916 :     case CPP_PRAGMA:
    8568         2916 :       if (!c_parser_pragma (parser, pragma_stmt, if_p, before_labels))
    8569           53 :         goto restart;
    8570              :       break;
    8571      5919645 :     default:
    8572      5919645 :     expr_stmt:
    8573      5919645 :       stmt = c_finish_expr_stmt (loc, c_parser_expression_conv (parser).value);
    8574     42048745 :     expect_semicolon:
    8575     42048745 :       c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
    8576     42048745 :       break;
    8577              :     }
    8578              :   /* Two cases cannot and do not have line numbers associated: If stmt
    8579              :      is degenerate, such as "2;", then stmt is an INTEGER_CST, which
    8580              :      cannot hold line numbers.  But that's OK because the statement
    8581              :      will either be changed to a MODIFY_EXPR during gimplification of
    8582              :      the statement expr, or discarded.  If stmt was compound, but
    8583              :      without new variables, we will have skipped the creation of a
    8584              :      BIND and will have a bare STATEMENT_LIST.  But that's OK because
    8585              :      (recursively) all of the component statements should already have
    8586              :      line numbers assigned.  ??? Can we discard no-op statements
    8587              :      earlier?  */
    8588     44764986 :   if (EXPR_LOCATION (stmt) == UNKNOWN_LOCATION)
    8589      2501213 :     protected_set_expr_location (stmt, loc);
    8590              : 
    8591     44764986 :   parser->in_if_block = in_if_block;
    8592     44764986 : }
    8593              : 
    8594              : /* Parse the condition from an if, do, while or for statements.  */
    8595              : 
    8596              : static tree
    8597       488966 : c_parser_condition (c_parser *parser)
    8598              : {
    8599       488966 :   location_t loc = c_parser_peek_token (parser)->location;
    8600       488966 :   tree cond;
    8601       488966 :   cond = c_parser_expression_conv (parser).value;
    8602       488966 :   cond = c_objc_common_truthvalue_conversion (loc, cond);
    8603       488966 :   cond = c_fully_fold (cond, false, NULL);
    8604       488966 :   if (warn_sequence_point)
    8605        85811 :     verify_sequence_points (cond);
    8606       488966 :   return cond;
    8607              : }
    8608              : 
    8609              : /* Parse a parenthesized condition from a do or while statement.
    8610              : 
    8611              :    condition:
    8612              :      ( expression )
    8613              : */
    8614              : 
    8615              : static tree
    8616       195203 : c_parser_paren_condition (c_parser *parser)
    8617              : {
    8618       195203 :   tree cond;
    8619       195203 :   matching_parens parens;
    8620       195203 :   if (!parens.require_open (parser))
    8621            0 :     return error_mark_node;
    8622       195203 :   cond = c_parser_condition (parser);
    8623       195203 :   parens.skip_until_found_close (parser);
    8624       195203 :   return cond;
    8625              : }
    8626              : 
    8627              : /* Parse a selection-header:
    8628              : 
    8629              :    selection-header:
    8630              :      expression
    8631              :      declaration expression
    8632              :      simple-declaration
    8633              : 
    8634              :    simple-declaration:
    8635              :      attribute-specifier-sequence[opt] declaration-specifiers declarator
    8636              :        = initializer
    8637              : 
    8638              :   SWITCH_P is true if we are called from c_parser_switch_statement; in
    8639              :   that case, don't perform the truthvalue conversion.  */
    8640              : 
    8641              : static c_expr
    8642      1333325 : c_parser_selection_header (c_parser *parser, bool switch_p)
    8643              : {
    8644      1333325 :   location_t loc = c_parser_peek_token (parser)->location;
    8645      1333325 :   c_expr expr;
    8646      1333325 :   bool parse_expr = true;
    8647      1333325 :   tree std_attrs;
    8648      1333325 :   bool have_std_attrs = c_parser_nth_token_starts_std_attributes (parser, 1);
    8649      1333325 :   if (have_std_attrs)
    8650           20 :     std_attrs = c_parser_std_attribute_specifier_sequence (parser);
    8651              :   else
    8652              :     std_attrs = NULL_TREE;
    8653      1333325 :   if (c_parser_next_tokens_start_declaration (parser))
    8654              :     {
    8655          239 :       pedwarn_c23 (loc, OPT_Wpedantic,
    8656              :                    "ISO C does not support if declarations before C2Y");
    8657          239 :       expr.value
    8658          239 :         = c_parser_declaration_or_fndef (parser,
    8659              :                                          /*fndef_ok=*/false,
    8660              :                                          /*static_assert_ok=*/false,
    8661              :                                          /*empty_ok=*/false,
    8662              :                                          /*nested=*/true,
    8663              :                                          /*start_attr_ok=*/true,
    8664              :                                          /*simple_ok=*/true,
    8665              :                                          /*objc_foreach_object_decl=*/nullptr,
    8666              :                                          /*omp_declare_simd_clauses=*/nullptr,
    8667              :                                          have_std_attrs,
    8668              :                                          std_attrs);
    8669          239 :       if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    8670           99 :         c_parser_consume_token (parser);
    8671              :       else
    8672              :         {
    8673              :           /* A simple-declaration is a declaration that can appear in
    8674              :              place of the controlling expression of a selection statement.
    8675              :              In that case, there shall be an initializer.  */
    8676          140 :           if (!expr.value)
    8677              :             {
    8678           48 :               error_at (loc, "declaration in the controlling expression must "
    8679              :                         "have an initializer");
    8680           48 :               expr.original_type = error_mark_node;
    8681           48 :               expr.set_error ();
    8682           48 :               return expr;
    8683              :             }
    8684              :           parse_expr = false;
    8685              :         }
    8686          191 :       if (expr.value)
    8687              :         {
    8688          175 :           expr.original_type = TREE_TYPE (expr.value);
    8689          175 :           expr = convert_lvalue_to_rvalue (loc, expr, /*convert_p=*/true,
    8690              :                                            /*read_p=*/true);
    8691              :         }
    8692              :     }
    8693      1333086 :   else if (have_std_attrs)
    8694              :     {
    8695            8 :       c_parser_error (parser, "expected declaration");
    8696            8 :       expr.original_type = error_mark_node;
    8697            8 :       expr.set_error ();
    8698            8 :       return expr;
    8699              :     }
    8700              : 
    8701          191 :   if (parse_expr)
    8702      1333177 :     expr = c_parser_expression_conv (parser);
    8703      1333269 :   if (!switch_p)
    8704              :     {
    8705      1294430 :       expr.value = c_objc_common_truthvalue_conversion (loc, expr.value);
    8706      1294430 :       expr.value = c_fully_fold (expr.value, false, NULL);
    8707      1294430 :       if (warn_sequence_point)
    8708       251730 :         verify_sequence_points (expr.value);
    8709              :     }
    8710              :   return expr;
    8711              : }
    8712              : 
    8713              : /* Parse a selection-header enclosed in parentheses:
    8714              : 
    8715              :    ( selection-header )
    8716              : */
    8717              : 
    8718              : static tree
    8719      1294459 : c_parser_paren_selection_header (c_parser *parser)
    8720              : {
    8721      1294459 :   matching_parens parens;
    8722      1294459 :   if (!parens.require_open (parser))
    8723            1 :     return error_mark_node;
    8724      1294458 :   tree cond = c_parser_selection_header (parser, /*switch_p=*/false).value;
    8725      1294458 :   parens.skip_until_found_close (parser);
    8726      1294458 :   return cond;
    8727              : }
    8728              : 
    8729              : /* Parse a statement which is a block in C99.
    8730              : 
    8731              :    IF_P is used to track whether there's a (possibly labeled) if statement
    8732              :    which is not enclosed in braces and has an else clause.  This is used to
    8733              :    implement -Wparentheses.  */
    8734              : 
    8735              : static tree
    8736       542438 : c_parser_c99_block_statement (c_parser *parser, bool *if_p,
    8737              :                               location_t *loc_after_labels)
    8738              : {
    8739       542438 :   tree block = c_begin_compound_stmt (flag_isoc99);
    8740       542438 :   location_t loc = c_parser_peek_token (parser)->location;
    8741       542438 :   c_parser_statement (parser, if_p, loc_after_labels);
    8742       542438 :   return c_end_compound_stmt (loc, block, flag_isoc99);
    8743              : }
    8744              : 
    8745              : /* Parse the body of an if statement.  This is just parsing a
    8746              :    statement but (a) it is a block in C99, (b) we track whether the
    8747              :    body is an if statement for the sake of -Wparentheses warnings, (c)
    8748              :    we handle an empty body specially for the sake of -Wempty-body
    8749              :    warnings, and (d) we call parser_compound_statement directly
    8750              :    because c_parser_statement_after_labels resets
    8751              :    parser->in_if_block.
    8752              : 
    8753              :    IF_P is used to track whether there's a (possibly labeled) if statement
    8754              :    which is not enclosed in braces and has an else clause.  This is used to
    8755              :    implement -Wparentheses.  */
    8756              : 
    8757              : static tree
    8758      1294459 : c_parser_if_body (c_parser *parser, bool *if_p,
    8759              :                   const token_indent_info &if_tinfo)
    8760              : {
    8761      1294459 :   tree block = c_begin_compound_stmt (flag_isoc99);
    8762      1294459 :   location_t body_loc = c_parser_peek_token (parser)->location;
    8763      1294459 :   location_t body_loc_after_labels = UNKNOWN_LOCATION;
    8764      1294459 :   token_indent_info body_tinfo
    8765      1294459 :     = get_token_indent_info (c_parser_peek_token (parser));
    8766      1294459 :   tree before_labels = get_before_labels ();
    8767      1294459 :   attr_state a = c_parser_all_labels (parser);
    8768              : 
    8769      1294459 :   if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    8770              :     {
    8771         6817 :       location_t loc = c_parser_peek_token (parser)->location;
    8772         6817 :       add_stmt (build_empty_stmt (loc));
    8773         6817 :       c_parser_consume_token (parser);
    8774         6817 :       if (!c_parser_next_token_is_keyword (parser, RID_ELSE))
    8775          466 :         warning_at (loc, OPT_Wempty_body,
    8776              :                     "suggest braces around empty body in an %<if%> statement");
    8777              :     }
    8778      1287642 :   else if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
    8779       460947 :     add_stmt (c_parser_compound_statement (parser));
    8780              :   else
    8781              :     {
    8782       826695 :       body_loc_after_labels = c_parser_peek_token (parser)->location;
    8783       826695 :       c_parser_statement_after_labels (parser, if_p, before_labels, NULL, a);
    8784              :     }
    8785              : 
    8786      1294459 :   token_indent_info next_tinfo
    8787      1294459 :     = get_token_indent_info (c_parser_peek_token (parser));
    8788      1294459 :   warn_for_misleading_indentation (if_tinfo, body_tinfo, next_tinfo);
    8789      1294459 :   if (body_loc_after_labels != UNKNOWN_LOCATION
    8790       826695 :       && next_tinfo.type != CPP_SEMICOLON)
    8791       821891 :     warn_for_multistatement_macros (body_loc_after_labels, next_tinfo.location,
    8792       821891 :                                     if_tinfo.location, RID_IF);
    8793              : 
    8794      1294459 :   return c_end_compound_stmt (body_loc, block, flag_isoc99);
    8795              : }
    8796              : 
    8797              : /* Parse the else body of an if statement.  This is just parsing a
    8798              :    statement but (a) it is a block in C99, (b) we handle an empty body
    8799              :    specially for the sake of -Wempty-body warnings.  CHAIN is a vector
    8800              :    of if-else-if conditions.  */
    8801              : 
    8802              : static tree
    8803       259551 : c_parser_else_body (c_parser *parser, const token_indent_info &else_tinfo,
    8804              :                     vec<tree> *chain)
    8805              : {
    8806       259551 :   location_t body_loc = c_parser_peek_token (parser)->location;
    8807       259551 :   tree block = c_begin_compound_stmt (flag_isoc99);
    8808       259551 :   token_indent_info body_tinfo
    8809       259551 :     = get_token_indent_info (c_parser_peek_token (parser));
    8810       259551 :   location_t body_loc_after_labels = UNKNOWN_LOCATION;
    8811       259551 :   tree before_labels = get_before_labels ();
    8812       259551 :   attr_state a = c_parser_all_labels (parser);
    8813              : 
    8814       259551 :   if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    8815              :     {
    8816           29 :       location_t loc = c_parser_peek_token (parser)->location;
    8817           29 :       warning_at (loc,
    8818           29 :                   OPT_Wempty_body,
    8819              :                  "suggest braces around empty body in an %<else%> statement");
    8820           29 :       add_stmt (build_empty_stmt (loc));
    8821           29 :       c_parser_consume_token (parser);
    8822              :     }
    8823              :   else
    8824              :     {
    8825       259522 :       if (!c_parser_next_token_is (parser, CPP_OPEN_BRACE))
    8826       222152 :         body_loc_after_labels = c_parser_peek_token (parser)->location;
    8827       259522 :       c_parser_statement_after_labels (parser, NULL, before_labels, chain, a);
    8828              :     }
    8829              : 
    8830       259551 :   token_indent_info next_tinfo
    8831       259551 :     = get_token_indent_info (c_parser_peek_token (parser));
    8832       259551 :   warn_for_misleading_indentation (else_tinfo, body_tinfo, next_tinfo);
    8833       259551 :   if (body_loc_after_labels != UNKNOWN_LOCATION
    8834       222152 :       && next_tinfo.type != CPP_SEMICOLON)
    8835       222138 :     warn_for_multistatement_macros (body_loc_after_labels, next_tinfo.location,
    8836       222138 :                                     else_tinfo.location, RID_ELSE);
    8837              : 
    8838       259551 :   return c_end_compound_stmt (body_loc, block, flag_isoc99);
    8839              : }
    8840              : 
    8841              : /* Parse an if statement (C90 6.6.4, C99 6.8.4, C11 6.8.4).
    8842              : 
    8843              :    if-statement:
    8844              :      if ( selection-header ) statement
    8845              :      if ( selection-header ) statement else statement
    8846              : 
    8847              :    CHAIN is a vector of if-else-if conditions.
    8848              :    IF_P is used to track whether there's a (possibly labeled) if statement
    8849              :    which is not enclosed in braces and has an else clause.  This is used to
    8850              :    implement -Wparentheses.  */
    8851              : 
    8852              : static void
    8853      1294459 : c_parser_if_statement (c_parser *parser, bool *if_p, vec<tree> *chain)
    8854              : {
    8855      1294459 :   tree block;
    8856      1294459 :   location_t loc;
    8857      1294459 :   tree cond;
    8858      1294459 :   bool nested_if = false;
    8859      1294459 :   tree first_body, second_body;
    8860      1294459 :   bool in_if_block;
    8861              : 
    8862      1294459 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_IF));
    8863      1294459 :   token_indent_info if_tinfo
    8864      1294459 :     = get_token_indent_info (c_parser_peek_token (parser));
    8865      1294459 :   c_parser_consume_token (parser);
    8866      1294459 :   block = c_begin_compound_stmt (flag_isoc99);
    8867      1294459 :   loc = c_parser_peek_token (parser)->location;
    8868      1294459 :   cond = c_parser_paren_selection_header (parser);
    8869      1294459 :   in_if_block = parser->in_if_block;
    8870      1294459 :   parser->in_if_block = true;
    8871      1294459 :   first_body = c_parser_if_body (parser, &nested_if, if_tinfo);
    8872      1294459 :   parser->in_if_block = in_if_block;
    8873              : 
    8874      1294459 :   if (warn_duplicated_cond)
    8875           62 :     warn_duplicated_cond_add_or_warn (EXPR_LOCATION (cond), cond, &chain);
    8876              : 
    8877      1294459 :   if (c_parser_next_token_is_keyword (parser, RID_ELSE))
    8878              :     {
    8879       259551 :       token_indent_info else_tinfo
    8880       259551 :         = get_token_indent_info (c_parser_peek_token (parser));
    8881       259551 :       c_parser_consume_token (parser);
    8882       259551 :       if (warn_duplicated_cond)
    8883              :         {
    8884           43 :           if (c_parser_next_token_is_keyword (parser, RID_IF)
    8885           43 :               && chain == NULL)
    8886              :             {
    8887              :               /* We've got "if (COND) else if (COND2)".  Start the
    8888              :                  condition chain and add COND as the first element.  */
    8889           18 :               chain = new vec<tree> ();
    8890           18 :               if (!CONSTANT_CLASS_P (cond) && !TREE_SIDE_EFFECTS (cond))
    8891           12 :                 chain->safe_push (cond);
    8892              :             }
    8893           25 :           else if (!c_parser_next_token_is_keyword (parser, RID_IF))
    8894              :             /* This is if-else without subsequent if.  Zap the condition
    8895              :                chain; we would have already warned at this point.  */
    8896            4 :             vec_free (chain);
    8897              :         }
    8898       259551 :       second_body = c_parser_else_body (parser, else_tinfo, chain);
    8899              :       /* Set IF_P to true to indicate that this if statement has an
    8900              :          else clause.  This may trigger the Wparentheses warning
    8901              :          below when we get back up to the parent if statement.  */
    8902       259551 :       if (if_p != NULL)
    8903          284 :         *if_p = true;
    8904              :     }
    8905              :   else
    8906              :     {
    8907      1034908 :       second_body = NULL_TREE;
    8908              : 
    8909              :       /* Diagnose an ambiguous else if if-then-else is nested inside
    8910              :          if-then.  */
    8911      1034908 :       if (nested_if)
    8912          209 :         warning_at (loc, OPT_Wdangling_else,
    8913              :                     "suggest explicit braces to avoid ambiguous %<else%>");
    8914              : 
    8915      1034908 :       if (warn_duplicated_cond)
    8916              :         /* This if statement does not have an else clause.  We don't
    8917              :            need the condition chain anymore.  */
    8918           19 :         vec_free (chain);
    8919              :     }
    8920      1294459 :   c_finish_if_stmt (loc, cond, first_body, second_body);
    8921      1294459 :   add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
    8922              : 
    8923      1294459 :   c_parser_maybe_reclassify_token (parser);
    8924      1294459 : }
    8925              : 
    8926              : /* Parse a switch statement (C90 6.6.4, C99 6.8.4, C11 6.8.4).
    8927              : 
    8928              :    switch-statement:
    8929              :      switch (expression) statement
    8930              : 
    8931              :    BEFORE_LABELS is last statement before possible labels, see
    8932              :    get_before_labels description for details.  */
    8933              : 
    8934              : static void
    8935        38874 : c_parser_switch_statement (c_parser *parser, bool *if_p, tree before_labels)
    8936              : {
    8937        38874 :   struct c_expr ce;
    8938        38874 :   tree block, expr, body;
    8939        38874 :   unsigned char save_in_statement;
    8940        38874 :   location_t switch_loc = c_parser_peek_token (parser)->location;
    8941        38874 :   location_t switch_cond_loc;
    8942        38874 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_SWITCH));
    8943        38874 :   c_parser_consume_token (parser);
    8944        38874 :   tree switch_name;
    8945        38874 :   int num_names = c_get_loop_names (before_labels, true, &switch_name);
    8946        38874 :   block = c_begin_compound_stmt (flag_isoc99);
    8947        38874 :   bool explicit_cast_p = false;
    8948        38874 :   matching_parens parens;
    8949        38874 :   if (parens.require_open (parser))
    8950              :     {
    8951        38867 :       switch_cond_loc = c_parser_peek_token (parser)->location;
    8952        38867 :       if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
    8953        38867 :           && c_token_starts_typename (c_parser_peek_2nd_token (parser)))
    8954              :         explicit_cast_p = true;
    8955        38867 :       ce = c_parser_selection_header (parser, /*switch_p=*/true);
    8956              :       /* The call above already performed convert_lvalue_to_rvalue, but
    8957              :          if it parsed an expression, read_p was false.  Make sure we mark
    8958              :          the expression as read.  */
    8959        38867 :       ce = convert_lvalue_to_rvalue (switch_cond_loc, ce, true, true);
    8960        38867 :       expr = ce.value;
    8961              :       /* ??? expr has no valid location?  */
    8962        38867 :       parens.skip_until_found_close (parser);
    8963              :     }
    8964              :   else
    8965              :     {
    8966            7 :       switch_cond_loc = UNKNOWN_LOCATION;
    8967            7 :       expr = error_mark_node;
    8968            7 :       ce.original_type = error_mark_node;
    8969              :     }
    8970        38874 :   tree stmt
    8971        38874 :     = c_start_switch (switch_loc, switch_cond_loc, expr, explicit_cast_p,
    8972              :                       switch_name);
    8973        38874 :   save_in_statement = in_statement;
    8974        38874 :   in_statement |= IN_SWITCH_STMT;
    8975        38874 :   if (switch_name)
    8976              :     {
    8977          163 :       C_DECL_LOOP_SWITCH_NAME_VALID (switch_name) = 1;
    8978          163 :       in_statement |= IN_NAMED_STMT;
    8979              :     }
    8980              :   else
    8981        38711 :     in_statement &= ~IN_NAMED_STMT;
    8982        38874 :   location_t loc_after_labels;
    8983        38874 :   bool open_brace_p = c_parser_peek_token (parser)->type == CPP_OPEN_BRACE;
    8984        38874 :   body = c_parser_c99_block_statement (parser, if_p, &loc_after_labels);
    8985        38874 :   location_t next_loc = c_parser_peek_token (parser)->location;
    8986        38874 :   if (!open_brace_p && c_parser_peek_token (parser)->type != CPP_SEMICOLON)
    8987          429 :     warn_for_multistatement_macros (loc_after_labels, next_loc, switch_loc,
    8988              :                                     RID_SWITCH);
    8989        38874 :   c_finish_switch (body, ce.original_type);
    8990        38874 :   in_statement = save_in_statement;
    8991        38874 :   if (num_names)
    8992              :     {
    8993          163 :       if (!C_DECL_LOOP_SWITCH_NAME_USED (switch_name))
    8994          151 :         SWITCH_STMT_NAME (stmt) = NULL_TREE;
    8995              :       else
    8996           12 :         SWITCH_STMT_NO_BREAK_P (stmt) = 0;
    8997          163 :       c_release_loop_names (num_names);
    8998              :     }
    8999        38874 :   add_stmt (c_end_compound_stmt (switch_loc, block, flag_isoc99));
    9000        38874 :   c_parser_maybe_reclassify_token (parser);
    9001        38874 : }
    9002              : 
    9003              : /* Parse a while statement (C90 6.6.5, C99 6.8.5, C11 6.8.5).
    9004              : 
    9005              :    while-statement:
    9006              :       while (expression) statement
    9007              : 
    9008              :    IF_P is used to track whether there's a (possibly labeled) if statement
    9009              :    which is not enclosed in braces and has an else clause.  This is used to
    9010              :    implement -Wparentheses.
    9011              : 
    9012              :    BEFORE_LABELS is last statement before possible labels, see
    9013              :    get_before_labels description for details.  */
    9014              : 
    9015              : static void
    9016        45306 : c_parser_while_statement (c_parser *parser, bool ivdep, unsigned short unroll,
    9017              :                           bool novector, bool *if_p, tree before_labels)
    9018              : {
    9019        45306 :   tree block, cond, body;
    9020        45306 :   unsigned char save_in_statement;
    9021        45306 :   location_t loc;
    9022        45306 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_WHILE));
    9023        45306 :   token_indent_info while_tinfo
    9024        45306 :     = get_token_indent_info (c_parser_peek_token (parser));
    9025        45306 :   tree loop_name;
    9026        45306 :   int num_names = c_get_loop_names (before_labels, false, &loop_name);
    9027              : 
    9028        45306 :   if (parser->omp_for_parse_state)
    9029              :     {
    9030            1 :       error_at (c_parser_peek_token (parser)->location,
    9031              :                 "loop not permitted in intervening code in OpenMP loop body");
    9032            1 :       parser->omp_for_parse_state->fail = true;
    9033              :     }
    9034              : 
    9035        45306 :   c_parser_consume_token (parser);
    9036        45306 :   block = c_begin_compound_stmt (flag_isoc99);
    9037        45306 :   loc = c_parser_peek_token (parser)->location;
    9038        45306 :   cond = c_parser_paren_condition (parser);
    9039        45306 :   if (ivdep && cond != error_mark_node)
    9040            3 :     cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
    9041              :                    build_int_cst (integer_type_node,
    9042              :                                   annot_expr_ivdep_kind),
    9043              :                    integer_zero_node);
    9044        45306 :   if (unroll && cond != error_mark_node)
    9045            6 :     cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
    9046              :                    build_int_cst (integer_type_node,
    9047              :                                   annot_expr_unroll_kind),
    9048            6 :                    build_int_cst (integer_type_node, unroll));
    9049        45306 :   if (novector && cond != error_mark_node)
    9050            6 :     cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
    9051              :                    build_int_cst (integer_type_node,
    9052              :                                   annot_expr_no_vector_kind),
    9053              :                    integer_zero_node);
    9054        45306 :   save_in_statement = in_statement;
    9055        45306 :   in_statement = IN_ITERATION_STMT;
    9056        45306 :   if (loop_name)
    9057              :     {
    9058          135 :       C_DECL_LOOP_SWITCH_NAME_VALID (loop_name) = 1;
    9059          135 :       in_statement |= IN_NAMED_STMT;
    9060              :     }
    9061              : 
    9062        45306 :   token_indent_info body_tinfo
    9063        45306 :     = get_token_indent_info (c_parser_peek_token (parser));
    9064              : 
    9065        45306 :   location_t loc_after_labels;
    9066        45306 :   bool open_brace = c_parser_next_token_is (parser, CPP_OPEN_BRACE);
    9067        45306 :   body = c_parser_c99_block_statement (parser, if_p, &loc_after_labels);
    9068        45306 :   if (loop_name && !C_DECL_LOOP_SWITCH_NAME_USED (loop_name))
    9069          133 :     loop_name = NULL_TREE;
    9070        45306 :   add_stmt (build_stmt (loc, WHILE_STMT, cond, body, loop_name, NULL_TREE,
    9071              :                         NULL_TREE));
    9072        45306 :   add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
    9073        45306 :   c_parser_maybe_reclassify_token (parser);
    9074        45306 :   if (num_names)
    9075          135 :     c_release_loop_names (num_names);
    9076              : 
    9077        45306 :   token_indent_info next_tinfo
    9078        45306 :     = get_token_indent_info (c_parser_peek_token (parser));
    9079        45306 :   warn_for_misleading_indentation (while_tinfo, body_tinfo, next_tinfo);
    9080              : 
    9081        45306 :   if (next_tinfo.type != CPP_SEMICOLON && !open_brace)
    9082        10832 :     warn_for_multistatement_macros (loc_after_labels, next_tinfo.location,
    9083              :                                     while_tinfo.location, RID_WHILE);
    9084              : 
    9085        45306 :   in_statement = save_in_statement;
    9086        45306 : }
    9087              : 
    9088              : /* Parse a do statement (C90 6.6.5, C99 6.8.5, C11 6.8.5).
    9089              : 
    9090              :    do-statement:
    9091              :      do statement while ( expression ) ;
    9092              : 
    9093              :    BEFORE_LABELS is last statement before possible labels, see
    9094              :    get_before_labels description for details.  */
    9095              : 
    9096              : static void
    9097       149897 : c_parser_do_statement (c_parser *parser, bool ivdep, unsigned short unroll,
    9098              :                        bool novector, tree before_labels)
    9099              : {
    9100       149897 :   tree block, cond, body;
    9101       149897 :   unsigned char save_in_statement;
    9102       149897 :   location_t loc;
    9103       149897 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_DO));
    9104       149897 :   tree loop_name;
    9105       149897 :   int num_names = c_get_loop_names (before_labels, false, &loop_name);
    9106              : 
    9107       149897 :   if (parser->omp_for_parse_state)
    9108              :     {
    9109            1 :       error_at (c_parser_peek_token (parser)->location,
    9110              :                 "loop not permitted in intervening code in OpenMP loop body");
    9111            1 :       parser->omp_for_parse_state->fail = true;
    9112              :     }
    9113              : 
    9114       149897 :   c_parser_consume_token (parser);
    9115       149897 :   if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    9116           50 :     warning_at (c_parser_peek_token (parser)->location,
    9117           50 :                 OPT_Wempty_body,
    9118              :                 "suggest braces around empty body in %<do%> statement");
    9119       149897 :   block = c_begin_compound_stmt (flag_isoc99);
    9120       149897 :   loc = c_parser_peek_token (parser)->location;
    9121       149897 :   save_in_statement = in_statement;
    9122       149897 :   in_statement = IN_ITERATION_STMT;
    9123       149897 :   if (loop_name)
    9124              :     {
    9125          184 :       C_DECL_LOOP_SWITCH_NAME_VALID (loop_name) = 1;
    9126          184 :       in_statement |= IN_NAMED_STMT;
    9127              :     }
    9128       149897 :   body = c_parser_c99_block_statement (parser, NULL);
    9129       149897 :   c_parser_require_keyword (parser, RID_WHILE, "expected %<while%>");
    9130       149897 :   in_statement = save_in_statement;
    9131       149897 :   if (num_names)
    9132              :     {
    9133          184 :       if (!C_DECL_LOOP_SWITCH_NAME_USED (loop_name))
    9134          182 :         loop_name = NULL_TREE;
    9135          184 :       c_release_loop_names (num_names);
    9136              :     }
    9137       149897 :   cond = c_parser_paren_condition (parser);
    9138       149897 :   if (ivdep && cond != error_mark_node)
    9139            2 :     cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
    9140              :                    build_int_cst (integer_type_node,
    9141              :                                   annot_expr_ivdep_kind),
    9142              :                    integer_zero_node);
    9143       149897 :   if (unroll && cond != error_mark_node)
    9144            3 :     cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
    9145              :                    build_int_cst (integer_type_node,
    9146              :                                   annot_expr_unroll_kind),
    9147            3 :                    build_int_cst (integer_type_node, unroll));
    9148       149897 :   if (novector && cond != error_mark_node)
    9149           54 :     cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
    9150              :                    build_int_cst (integer_type_node,
    9151              :                                   annot_expr_no_vector_kind),
    9152              :                    integer_zero_node);
    9153       149897 :   if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
    9154            0 :     c_parser_skip_to_end_of_block_or_statement (parser);
    9155              : 
    9156       149897 :   add_stmt (build_stmt (loc, DO_STMT, cond, body, loop_name));
    9157       149897 :   add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
    9158       149897 : }
    9159              : 
    9160              : /* Parse a for statement (C90 6.6.5, C99 6.8.5, C11 6.8.5).
    9161              : 
    9162              :    for-statement:
    9163              :      for ( expression[opt] ; expression[opt] ; expression[opt] ) statement
    9164              :      for ( nested-declaration expression[opt] ; expression[opt] ) statement
    9165              : 
    9166              :    The form with a declaration is new in C99.
    9167              : 
    9168              :    ??? In accordance with the old parser, the declaration may be a
    9169              :    nested function, which is then rejected in check_for_loop_decls,
    9170              :    but does it make any sense for this to be included in the grammar?
    9171              :    Note in particular that the nested function does not include a
    9172              :    trailing ';', whereas the "declaration" production includes one.
    9173              :    Also, can we reject bad declarations earlier and cheaper than
    9174              :    check_for_loop_decls?
    9175              : 
    9176              :    In Objective-C, there are two additional variants:
    9177              : 
    9178              :    foreach-statement:
    9179              :      for ( expression in expression ) statement
    9180              :      for ( declaration in expression ) statement
    9181              : 
    9182              :    This is inconsistent with C, because the second variant is allowed
    9183              :    even if c99 is not enabled.
    9184              : 
    9185              :    The rest of the comment documents these Objective-C foreach-statement.
    9186              : 
    9187              :    Here is the canonical example of the first variant:
    9188              :     for (object in array)    { do something with object }
    9189              :    we call the first expression ("object") the "object_expression" and
    9190              :    the second expression ("array") the "collection_expression".
    9191              :    object_expression must be an lvalue of type "id" (a generic Objective-C
    9192              :    object) because the loop works by assigning to object_expression the
    9193              :    various objects from the collection_expression.  collection_expression
    9194              :    must evaluate to something of type "id" which responds to the method
    9195              :    countByEnumeratingWithState:objects:count:.
    9196              : 
    9197              :    The canonical example of the second variant is:
    9198              :     for (id object in array)    { do something with object }
    9199              :    which is completely equivalent to
    9200              :     {
    9201              :       id object;
    9202              :       for (object in array) { do something with object }
    9203              :     }
    9204              :    Note that initizializing 'object' in some way (eg, "for ((object =
    9205              :    xxx) in array) { do something with object }") is possibly
    9206              :    technically valid, but completely pointless as 'object' will be
    9207              :    assigned to something else as soon as the loop starts.  We should
    9208              :    most likely reject it (TODO).
    9209              : 
    9210              :    The beginning of the Objective-C foreach-statement looks exactly
    9211              :    like the beginning of the for-statement, and we can tell it is a
    9212              :    foreach-statement only because the initial declaration or
    9213              :    expression is terminated by 'in' instead of ';'.
    9214              : 
    9215              :    IF_P is used to track whether there's a (possibly labeled) if statement
    9216              :    which is not enclosed in braces and has an else clause.  This is used to
    9217              :    implement -Wparentheses.
    9218              : 
    9219              :    BEFORE_LABELS is last statement before possible labels, see
    9220              :    get_before_labels description for details.  */
    9221              : 
    9222              : static void
    9223       297169 : c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll,
    9224              :                         bool novector, bool *if_p, tree before_labels)
    9225              : {
    9226       297169 :   tree block, cond, incr, body;
    9227       297169 :   unsigned char save_in_statement;
    9228       297169 :   tree save_objc_foreach_break_label, save_objc_foreach_continue_label;
    9229              :   /* The following are only used when parsing an ObjC foreach statement.  */
    9230       297169 :   tree object_expression;
    9231              :   /* Silence the bogus uninitialized warning.  */
    9232       297169 :   tree collection_expression = NULL;
    9233       297169 :   location_t loc = c_parser_peek_token (parser)->location;
    9234       297169 :   location_t for_loc = loc;
    9235       297169 :   bool is_foreach_statement = false;
    9236       297169 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_FOR));
    9237       297169 :   token_indent_info for_tinfo
    9238       297169 :     = get_token_indent_info (c_parser_peek_token (parser));
    9239       297169 :   tree loop_name;
    9240       297169 :   int num_names = c_get_loop_names (before_labels, false, &loop_name);
    9241              : 
    9242       297169 :   if (parser->omp_for_parse_state)
    9243              :     {
    9244           13 :       error_at (for_loc,
    9245              :                 "loop not permitted in intervening code in OpenMP loop body");
    9246           13 :       parser->omp_for_parse_state->fail = true;
    9247              :     }
    9248              : 
    9249       297169 :   c_parser_consume_token (parser);
    9250              :   /* Open a compound statement in Objective-C as well, just in case this is
    9251              :      as foreach expression.  */
    9252       593446 :   block = c_begin_compound_stmt (flag_isoc99 || c_dialect_objc ());
    9253       297169 :   cond = error_mark_node;
    9254       297169 :   incr = error_mark_node;
    9255       297169 :   matching_parens parens;
    9256       297169 :   if (parens.require_open (parser))
    9257              :     {
    9258              :       /* Parse the initialization declaration or expression.  */
    9259       297168 :       object_expression = error_mark_node;
    9260       297168 :       parser->objc_could_be_foreach_context = c_dialect_objc ();
    9261       297168 :       if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    9262              :         {
    9263        14463 :           parser->objc_could_be_foreach_context = false;
    9264        14463 :           c_parser_consume_token (parser);
    9265        14463 :           c_finish_expr_stmt (loc, NULL_TREE);
    9266              :         }
    9267       282705 :       else if (c_parser_next_tokens_start_declaration (parser)
    9268       282705 :                || c_parser_nth_token_starts_std_attributes (parser, 1))
    9269              :         {
    9270        25492 :           c_parser_declaration_or_fndef (parser, true, true, true, true, true,
    9271              :                                          false, &object_expression);
    9272        25492 :           parser->objc_could_be_foreach_context = false;
    9273              : 
    9274        25492 :           if (c_parser_next_token_is_keyword (parser, RID_IN))
    9275              :             {
    9276            0 :               c_parser_consume_token (parser);
    9277            0 :               is_foreach_statement = true;
    9278            0 :               if (check_for_loop_decls (for_loc, true) == NULL_TREE)
    9279            0 :                 c_parser_error (parser, "multiple iterating variables in "
    9280              :                                         "fast enumeration");
    9281              :             }
    9282              :           else
    9283        25492 :             check_for_loop_decls (for_loc, flag_isoc99);
    9284              :         }
    9285       257213 :       else if (c_parser_next_token_is_keyword (parser, RID_EXTENSION))
    9286              :         {
    9287              :           /* __extension__ can start a declaration, but is also an
    9288              :              unary operator that can start an expression.  Consume all
    9289              :              but the last of a possible series of __extension__ to
    9290              :              determine which.  */
    9291            0 :           while (c_parser_peek_2nd_token (parser)->type == CPP_KEYWORD
    9292            0 :                  && (c_parser_peek_2nd_token (parser)->keyword
    9293              :                      == RID_EXTENSION))
    9294            0 :             c_parser_consume_token (parser);
    9295            0 :           if (c_parser_next_tokens_start_declaration (parser, 2)
    9296            0 :               || c_parser_nth_token_starts_std_attributes (parser, 2))
    9297              :             {
    9298            0 :               int ext;
    9299            0 :               ext = disable_extension_diagnostics ();
    9300            0 :               c_parser_consume_token (parser);
    9301            0 :               c_parser_declaration_or_fndef (parser, true, true, true, true,
    9302              :                                              true, false, &object_expression);
    9303            0 :               parser->objc_could_be_foreach_context = false;
    9304              : 
    9305            0 :               restore_extension_diagnostics (ext);
    9306            0 :               if (c_parser_next_token_is_keyword (parser, RID_IN))
    9307              :                 {
    9308            0 :                   c_parser_consume_token (parser);
    9309            0 :                   is_foreach_statement = true;
    9310            0 :                   if (check_for_loop_decls (for_loc, true) == NULL_TREE)
    9311            0 :                     c_parser_error (parser, "multiple iterating variables in "
    9312              :                                             "fast enumeration");
    9313              :                 }
    9314              :               else
    9315            0 :                 check_for_loop_decls (for_loc, flag_isoc99);
    9316              :             }
    9317              :           else
    9318            0 :             goto init_expr;
    9319              :         }
    9320              :       else
    9321              :         {
    9322       257213 :         init_expr:
    9323       257213 :           {
    9324       257213 :             struct c_expr ce;
    9325       257213 :             tree init_expression;
    9326       257213 :             ce = c_parser_expression (parser);
    9327       257213 :             init_expression = ce.value;
    9328       257213 :             parser->objc_could_be_foreach_context = false;
    9329       257213 :             if (c_parser_next_token_is_keyword (parser, RID_IN))
    9330              :               {
    9331            0 :                 c_parser_consume_token (parser);
    9332            0 :                 is_foreach_statement = true;
    9333            0 :                 if (! lvalue_p (init_expression))
    9334            0 :                   c_parser_error (parser, "invalid iterating variable in "
    9335              :                                           "fast enumeration");
    9336            0 :                 object_expression
    9337            0 :                   = c_fully_fold (init_expression, false, NULL);
    9338              :               }
    9339              :             else
    9340              :               {
    9341       257213 :                 ce = convert_lvalue_to_rvalue (loc, ce, true, false);
    9342       257213 :                 init_expression = ce.value;
    9343       257213 :                 c_finish_expr_stmt (loc, init_expression);
    9344       257213 :                 c_parser_skip_until_found (parser, CPP_SEMICOLON,
    9345              :                                            "expected %<;%>");
    9346              :               }
    9347              :           }
    9348              :         }
    9349              :       /* Parse the loop condition.  In the case of a foreach
    9350              :          statement, there is no loop condition.  */
    9351       297168 :       gcc_assert (!parser->objc_could_be_foreach_context);
    9352       297168 :       if (!is_foreach_statement)
    9353              :         {
    9354       297168 :           if (c_parser_next_token_is (parser, CPP_SEMICOLON))
    9355              :             {
    9356         3405 :               if (ivdep)
    9357              :                 {
    9358            1 :                   c_parser_error (parser, "missing loop condition in loop "
    9359              :                                           "with %<GCC ivdep%> pragma");
    9360            1 :                   cond = error_mark_node;
    9361              :                 }
    9362         3404 :               else if (unroll)
    9363              :                 {
    9364            0 :                   c_parser_error (parser, "missing loop condition in loop "
    9365              :                                           "with %<GCC unroll%> pragma");
    9366            0 :                   cond = error_mark_node;
    9367              :                 }
    9368              :               else
    9369              :                 {
    9370         3404 :                   c_parser_consume_token (parser);
    9371         3404 :                   cond = NULL_TREE;
    9372              :                 }
    9373              :             }
    9374              :           else
    9375              :             {
    9376       293763 :               cond = c_parser_condition (parser);
    9377       293763 :               c_parser_skip_until_found (parser, CPP_SEMICOLON,
    9378              :                                          "expected %<;%>");
    9379              :             }
    9380       297168 :           if (ivdep && cond != error_mark_node)
    9381          122 :             cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
    9382              :                            build_int_cst (integer_type_node,
    9383              :                                           annot_expr_ivdep_kind),
    9384              :                            integer_zero_node);
    9385       297168 :           if (unroll && cond != error_mark_node)
    9386          285 :             cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
    9387              :                            build_int_cst (integer_type_node,
    9388              :                                           annot_expr_unroll_kind),
    9389          285 :                            build_int_cst (integer_type_node, unroll));
    9390       297168 :           if (novector && cond && cond != error_mark_node)
    9391         2995 :             cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
    9392              :                            build_int_cst (integer_type_node,
    9393              :                                           annot_expr_no_vector_kind),
    9394              :                            integer_zero_node);
    9395              :         }
    9396              :       /* Parse the increment expression (the third expression in a
    9397              :          for-statement).  In the case of a foreach-statement, this is
    9398              :          the expression that follows the 'in'.  */
    9399       297168 :       loc = c_parser_peek_token (parser)->location;
    9400       297168 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    9401              :         {
    9402         4600 :           if (is_foreach_statement)
    9403              :             {
    9404            0 :               c_parser_error (parser,
    9405              :                               "missing collection in fast enumeration");
    9406            0 :               collection_expression = error_mark_node;
    9407              :             }
    9408              :           else
    9409         4600 :             incr = c_process_expr_stmt (loc, NULL_TREE);
    9410              :         }
    9411              :       else
    9412              :         {
    9413       292568 :           if (is_foreach_statement)
    9414            0 :             collection_expression
    9415            0 :               = c_fully_fold (c_parser_expression (parser).value, false, NULL);
    9416              :           else
    9417              :             {
    9418       292568 :               struct c_expr ce = c_parser_expression (parser);
    9419       292568 :               ce = convert_lvalue_to_rvalue (loc, ce, true, false);
    9420       292568 :               incr = c_process_expr_stmt (loc, ce.value);
    9421              :             }
    9422              :         }
    9423       297168 :       parens.skip_until_found_close (parser);
    9424              :     }
    9425       297169 :   save_in_statement = in_statement;
    9426       297169 :   if (is_foreach_statement)
    9427              :     {
    9428            0 :       in_statement = IN_OBJC_FOREACH;
    9429            0 :       save_objc_foreach_break_label = objc_foreach_break_label;
    9430            0 :       save_objc_foreach_continue_label = objc_foreach_continue_label;
    9431            0 :       objc_foreach_break_label = create_artificial_label (loc);
    9432            0 :       objc_foreach_continue_label = create_artificial_label (loc);
    9433            0 :       if (loop_name)
    9434              :         {
    9435            0 :           gcc_checking_assert (!DECL_CHAIN (loop_name)
    9436              :                                && !DECL_CHAIN (objc_foreach_break_label));
    9437            0 :           C_DECL_SWITCH_NAME (loop_name) = 1;
    9438            0 :           DECL_CHAIN (loop_name) = objc_foreach_break_label;
    9439            0 :           DECL_CHAIN (objc_foreach_break_label) = objc_foreach_continue_label;
    9440              :         }
    9441              :     }
    9442              :   else
    9443       297169 :     in_statement = IN_ITERATION_STMT;
    9444       297169 :   if (loop_name)
    9445              :     {
    9446          505 :       C_DECL_LOOP_SWITCH_NAME_VALID (loop_name) = 1;
    9447          505 :       in_statement |= IN_NAMED_STMT;
    9448              :     }
    9449              : 
    9450       297169 :   token_indent_info body_tinfo
    9451       297169 :     = get_token_indent_info (c_parser_peek_token (parser));
    9452              : 
    9453       297169 :   location_t loc_after_labels;
    9454       297169 :   bool open_brace = c_parser_next_token_is (parser, CPP_OPEN_BRACE);
    9455       297169 :   body = c_parser_c99_block_statement (parser, if_p, &loc_after_labels);
    9456              : 
    9457       297169 :   if (loop_name && is_foreach_statement)
    9458              :     {
    9459            0 :       gcc_checking_assert (DECL_CHAIN (loop_name) == objc_foreach_break_label
    9460              :                            && (DECL_CHAIN (objc_foreach_break_label)
    9461              :                                == objc_foreach_continue_label));
    9462            0 :       C_DECL_SWITCH_NAME (loop_name) = 0;
    9463            0 :       DECL_CHAIN (loop_name) = NULL_TREE;
    9464            0 :       DECL_CHAIN (objc_foreach_break_label) = NULL_TREE;
    9465              :     }
    9466              : 
    9467       296664 :   if (is_foreach_statement)
    9468            0 :     objc_finish_foreach_loop (for_loc, object_expression,
    9469              :                               collection_expression, body,
    9470              :                               objc_foreach_break_label,
    9471              :                               objc_foreach_continue_label);
    9472              :   else
    9473       594338 :     add_stmt (build_stmt (for_loc, FOR_STMT, NULL_TREE, cond, incr,
    9474              :                           body, NULL_TREE,
    9475          505 :                           loop_name && C_DECL_LOOP_SWITCH_NAME_USED (loop_name)
    9476              :                           ? loop_name : NULL_TREE, NULL_TREE, NULL_TREE));
    9477       297169 :   add_stmt (c_end_compound_stmt (for_loc, block,
    9478       297169 :                                  flag_isoc99 || c_dialect_objc ()));
    9479       297169 :   c_parser_maybe_reclassify_token (parser);
    9480              : 
    9481       297169 :   token_indent_info next_tinfo
    9482       297169 :     = get_token_indent_info (c_parser_peek_token (parser));
    9483       297169 :   warn_for_misleading_indentation (for_tinfo, body_tinfo, next_tinfo);
    9484              : 
    9485       297169 :   if (next_tinfo.type != CPP_SEMICOLON && !open_brace)
    9486       177282 :     warn_for_multistatement_macros (loc_after_labels, next_tinfo.location,
    9487              :                                     for_tinfo.location, RID_FOR);
    9488              : 
    9489       297169 :   in_statement = save_in_statement;
    9490       297169 :   if (num_names)
    9491          505 :     c_release_loop_names (num_names);
    9492       297169 :   if (is_foreach_statement)
    9493              :     {
    9494            0 :       objc_foreach_break_label = save_objc_foreach_break_label;
    9495            0 :       objc_foreach_continue_label = save_objc_foreach_continue_label;
    9496              :     }
    9497       297169 : }
    9498              : 
    9499              : /* Parse an asm statement, a GNU extension.  This is a full-blown asm
    9500              :    statement with inputs, outputs, clobbers, and volatile, inline, and goto
    9501              :    tags allowed.
    9502              : 
    9503              :    asm-qualifier:
    9504              :      volatile
    9505              :      inline
    9506              :      goto
    9507              : 
    9508              :    asm-qualifier-list:
    9509              :      asm-qualifier-list asm-qualifier
    9510              :      asm-qualifier
    9511              : 
    9512              :    asm-statement:
    9513              :      asm asm-qualifier-list[opt] ( asm-argument ) ;
    9514              : 
    9515              :    asm-argument:
    9516              :      asm-string-literal
    9517              :      asm-string-literal : asm-operands[opt]
    9518              :      asm-string-literal : asm-operands[opt] : asm-operands[opt]
    9519              :      asm-string-literal : asm-operands[opt] : asm-operands[opt] \
    9520              :        : asm-clobbers[opt]
    9521              :      asm-string-literal : : asm-operands[opt] : asm-clobbers[opt] \
    9522              :        : asm-goto-operands
    9523              : 
    9524              :    The form with asm-goto-operands is valid if and only if the
    9525              :    asm-qualifier-list contains goto, and is the only allowed form in that case.
    9526              :    Duplicate asm-qualifiers are not allowed.
    9527              : 
    9528              :    The :: token is considered equivalent to two consecutive : tokens.  */
    9529              : 
    9530              : static tree
    9531       196694 : c_parser_asm_statement (c_parser *parser)
    9532              : {
    9533       196694 :   tree str, outputs, inputs, clobbers, labels, ret;
    9534       196694 :   bool simple;
    9535       196694 :   location_t asm_loc = c_parser_peek_token (parser)->location;
    9536       196694 :   int section, nsections;
    9537              : 
    9538       196694 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_ASM));
    9539       196694 :   c_parser_consume_token (parser);
    9540              : 
    9541              :   /* Handle the asm-qualifier-list.  */
    9542       196694 :   location_t volatile_loc = UNKNOWN_LOCATION;
    9543       196694 :   location_t inline_loc = UNKNOWN_LOCATION;
    9544       196694 :   location_t goto_loc = UNKNOWN_LOCATION;
    9545       354080 :   for (;;)
    9546              :     {
    9547       354080 :       c_token *token = c_parser_peek_token (parser);
    9548       354080 :       location_t loc = token->location;
    9549       354080 :       switch (token->keyword)
    9550              :         {
    9551       156785 :         case RID_VOLATILE:
    9552       156785 :           if (volatile_loc)
    9553              :             {
    9554            6 :               error_at (loc, "duplicate %<asm%> qualifier %qE", token->value);
    9555            6 :               inform (volatile_loc, "first seen here");
    9556              :             }
    9557              :           else
    9558              :             volatile_loc = loc;
    9559       156785 :           c_parser_consume_token (parser);
    9560       156785 :           continue;
    9561              : 
    9562           38 :         case RID_INLINE:
    9563           38 :           if (inline_loc)
    9564              :             {
    9565            6 :               error_at (loc, "duplicate %<asm%> qualifier %qE", token->value);
    9566            6 :               inform (inline_loc, "first seen here");
    9567              :             }
    9568              :           else
    9569              :             inline_loc = loc;
    9570           38 :           c_parser_consume_token (parser);
    9571           38 :           continue;
    9572              : 
    9573          561 :         case RID_GOTO:
    9574          561 :           if (goto_loc)
    9575              :             {
    9576            6 :               error_at (loc, "duplicate %<asm%> qualifier %qE", token->value);
    9577            6 :               inform (goto_loc, "first seen here");
    9578              :             }
    9579              :           else
    9580              :             goto_loc = loc;
    9581          561 :           c_parser_consume_token (parser);
    9582          561 :           continue;
    9583              : 
    9584            2 :         case RID_CONST:
    9585            2 :         case RID_RESTRICT:
    9586            2 :           error_at (loc, "%qE is not a valid %<asm%> qualifier", token->value);
    9587            2 :           c_parser_consume_token (parser);
    9588            2 :           continue;
    9589              : 
    9590       196694 :         default:
    9591       196694 :           break;
    9592              :         }
    9593       196694 :       break;
    9594              :     }
    9595              : 
    9596       196694 :   bool is_volatile = (volatile_loc != UNKNOWN_LOCATION);
    9597       196694 :   bool is_inline = (inline_loc != UNKNOWN_LOCATION);
    9598       196694 :   bool is_goto = (goto_loc != UNKNOWN_LOCATION);
    9599              : 
    9600       196694 :   ret = NULL;
    9601              : 
    9602       196694 :   matching_parens parens;
    9603       196694 :   if (!parens.require_open (parser))
    9604            0 :     goto error;
    9605              : 
    9606       196694 :   str = c_parser_asm_string_literal (parser);
    9607       196694 :   if (str == NULL_TREE)
    9608           12 :     goto error_close_paren;
    9609              : 
    9610       196682 :   simple = true;
    9611       196682 :   outputs = NULL_TREE;
    9612       196682 :   inputs = NULL_TREE;
    9613       196682 :   clobbers = NULL_TREE;
    9614       196682 :   labels = NULL_TREE;
    9615              : 
    9616       196682 :   if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN) && !is_goto)
    9617         1920 :     goto done_asm;
    9618              : 
    9619              :   /* Parse each colon-delimited section of operands.  */
    9620       194762 :   nsections = 3 + is_goto;
    9621       503165 :   for (section = 0; section < nsections; ++section)
    9622              :     {
    9623       502620 :       if (c_parser_next_token_is (parser, CPP_SCOPE))
    9624              :         {
    9625        25195 :           ++section;
    9626        25195 :           if (section == nsections)
    9627              :             {
    9628            5 :               c_parser_error (parser, "expected %<)%>");
    9629            5 :               goto error_close_paren;
    9630              :             }
    9631        25190 :           c_parser_consume_token (parser);
    9632              :         }
    9633       952970 :       else if (!c_parser_require (parser, CPP_COLON,
    9634              :                                   is_goto
    9635              :                                   ? G_("expected %<:%>")
    9636              :                                   : G_("expected %<:%> or %<)%>"),
    9637              :                                   UNKNOWN_LOCATION, is_goto))
    9638            7 :         goto error_close_paren;
    9639              : 
    9640              :       /* Once past any colon, we're no longer a simple asm.  */
    9641       502608 :       simple = false;
    9642              : 
    9643       502608 :       if ((!c_parser_next_token_is (parser, CPP_COLON)
    9644       421241 :            && !c_parser_next_token_is (parser, CPP_SCOPE)
    9645       421163 :            && !c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
    9646       512484 :           || section == 3)
    9647       411366 :         switch (section)
    9648              :           {
    9649       134509 :           case 0:
    9650       134509 :             outputs = c_parser_asm_operands (parser);
    9651       134509 :             break;
    9652       133894 :           case 1:
    9653       133894 :             inputs = c_parser_asm_operands (parser);
    9654       133894 :             break;
    9655       142418 :           case 2:
    9656       142418 :             clobbers = c_parser_asm_clobbers (parser);
    9657       142418 :             break;
    9658          545 :           case 3:
    9659          545 :             labels = c_parser_asm_goto_operands (parser);
    9660          545 :             break;
    9661            0 :           default:
    9662            0 :             gcc_unreachable ();
    9663              :           }
    9664              : 
    9665       502608 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN) && !is_goto)
    9666       194205 :         goto done_asm;
    9667              :     }
    9668              : 
    9669          545 :  done_asm:
    9670       196670 :   if (!parens.require_close (parser))
    9671              :     {
    9672            0 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
    9673            0 :       goto error;
    9674              :     }
    9675              : 
    9676       196670 :   if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
    9677            0 :     c_parser_skip_to_end_of_block_or_statement (parser);
    9678              : 
    9679       196670 :   ret = build_asm_stmt (is_volatile,
    9680              :                         build_asm_expr (asm_loc, str, outputs, inputs,
    9681              :                                         clobbers, labels, simple, is_inline));
    9682              : 
    9683       196694 :  error:
    9684       196694 :   return ret;
    9685              : 
    9686           24 :  error_close_paren:
    9687           24 :   c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
    9688           24 :   goto error;
    9689              : }
    9690              : 
    9691              : /* Parse asm operands, a GNU extension.
    9692              : 
    9693              :    asm-operands:
    9694              :      asm-operand
    9695              :      asm-operands , asm-operand
    9696              : 
    9697              :    asm-operand:
    9698              :      asm-string-literal ( expression )
    9699              :      [ identifier ] asm-string-literal ( expression )
    9700              : */
    9701              : 
    9702              : static tree
    9703       268459 : c_parser_asm_operands (c_parser *parser)
    9704              : {
    9705       268459 :   tree list = NULL_TREE;
    9706      1180761 :   while (true)
    9707              :     {
    9708       724610 :       tree name, str;
    9709       724610 :       struct c_expr expr;
    9710       724610 :       if (c_parser_next_token_is (parser, CPP_OPEN_SQUARE))
    9711              :         {
    9712          717 :           c_parser_consume_token (parser);
    9713          717 :           if (c_parser_next_token_is (parser, CPP_NAME))
    9714              :             {
    9715          717 :               tree id = c_parser_peek_token (parser)->value;
    9716          717 :               c_parser_consume_token (parser);
    9717          717 :               name = build_string (IDENTIFIER_LENGTH (id),
    9718          717 :                                    IDENTIFIER_POINTER (id));
    9719              :             }
    9720              :           else
    9721              :             {
    9722            0 :               c_parser_error (parser, "expected identifier");
    9723            0 :               c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL);
    9724            0 :               return NULL_TREE;
    9725              :             }
    9726          717 :           c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
    9727              :                                      "expected %<]%>");
    9728              :         }
    9729              :       else
    9730              :         name = NULL_TREE;
    9731       724610 :       str = c_parser_asm_string_literal (parser);
    9732       724610 :       if (str == NULL_TREE)
    9733              :         return NULL_TREE;
    9734       724610 :       matching_parens parens;
    9735       724610 :       if (!parens.require_open (parser))
    9736              :         return NULL_TREE;
    9737       724610 :       expr = c_parser_expression (parser);
    9738       724610 :       mark_exp_read (expr.value);
    9739       724610 :       if (!parens.require_close (parser))
    9740              :         {
    9741            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
    9742            0 :           return NULL_TREE;
    9743              :         }
    9744       724610 :       list = chainon (list, build_tree_list (build_tree_list (name, str),
    9745              :                                              expr.value));
    9746       724610 :       if (c_parser_next_token_is (parser, CPP_COMMA))
    9747       456151 :         c_parser_consume_token (parser);
    9748              :       else
    9749              :         break;
    9750       456151 :     }
    9751       268459 :   return list;
    9752              : }
    9753              : 
    9754              : /* Parse asm clobbers, a GNU extension.
    9755              : 
    9756              :    asm-clobbers:
    9757              :      asm-string-literal
    9758              :      asm-clobbers , asm-string-literal
    9759              : */
    9760              : 
    9761              : static tree
    9762       142418 : c_parser_asm_clobbers (c_parser *parser)
    9763              : {
    9764       142418 :   tree list = NULL_TREE;
    9765       383864 :   while (true)
    9766              :     {
    9767       263141 :       tree str = c_parser_asm_string_literal (parser);
    9768       263141 :       if (str)
    9769       263141 :         list = tree_cons (NULL_TREE, str, list);
    9770              :       else
    9771              :         return NULL_TREE;
    9772       263141 :       if (c_parser_next_token_is (parser, CPP_COMMA))
    9773       120723 :         c_parser_consume_token (parser);
    9774              :       else
    9775              :         break;
    9776       120723 :     }
    9777              :   return list;
    9778              : }
    9779              : 
    9780              : /* Parse asm goto labels, a GNU extension.
    9781              : 
    9782              :    asm-goto-operands:
    9783              :      identifier
    9784              :      asm-goto-operands , identifier
    9785              : */
    9786              : 
    9787              : static tree
    9788          545 : c_parser_asm_goto_operands (c_parser *parser)
    9789              : {
    9790          545 :   tree list = NULL_TREE;
    9791         1181 :   while (true)
    9792              :     {
    9793          863 :       tree name, label;
    9794              : 
    9795          863 :       if (c_parser_next_token_is (parser, CPP_NAME))
    9796              :         {
    9797          862 :           c_token *tok = c_parser_peek_token (parser);
    9798          862 :           name = tok->value;
    9799          862 :           label = lookup_label_for_goto (tok->location, name);
    9800          862 :           c_parser_consume_token (parser);
    9801          862 :           TREE_USED (label) = 1;
    9802              :         }
    9803              :       else
    9804              :         {
    9805            1 :           c_parser_error (parser, "expected identifier");
    9806            1 :           return NULL_TREE;
    9807              :         }
    9808              : 
    9809          862 :       name = build_string (IDENTIFIER_LENGTH (name),
    9810          862 :                            IDENTIFIER_POINTER (name));
    9811          862 :       list = tree_cons (name, label, list);
    9812          862 :       if (c_parser_next_token_is (parser, CPP_COMMA))
    9813          318 :         c_parser_consume_token (parser);
    9814              :       else
    9815          544 :         return nreverse (list);
    9816          318 :     }
    9817              : }
    9818              : 
    9819              : /* Parse a possibly concatenated sequence of string literals.
    9820              :    TRANSLATE says whether to translate them to the execution character
    9821              :    set; WIDE_OK says whether any kind of prefixed string literal is
    9822              :    permitted in this context.  This code is based on that in
    9823              :    lex_string.  */
    9824              : 
    9825              : struct c_expr
    9826      3894963 : c_parser_string_literal (c_parser *parser, bool translate, bool wide_ok)
    9827              : {
    9828      3894963 :   struct c_expr ret;
    9829      3894963 :   size_t count;
    9830      3894963 :   struct obstack str_ob;
    9831      3894963 :   struct obstack loc_ob;
    9832      3894963 :   cpp_string str, istr, *strs;
    9833      3894963 :   c_token *tok;
    9834      3894963 :   location_t loc, last_tok_loc;
    9835      3894963 :   enum cpp_ttype type;
    9836      3894963 :   tree value, string_tree;
    9837              : 
    9838      3894963 :   tok = c_parser_peek_token (parser);
    9839      3894963 :   loc = tok->location;
    9840      3894963 :   last_tok_loc = linemap_resolve_location (line_table, loc,
    9841              :                                            LRK_MACRO_DEFINITION_LOCATION,
    9842              :                                            NULL);
    9843      3894963 :   type = tok->type;
    9844      3894963 :   switch (type)
    9845              :     {
    9846      3894946 :     case CPP_STRING:
    9847      3894946 :     case CPP_WSTRING:
    9848      3894946 :     case CPP_STRING16:
    9849      3894946 :     case CPP_STRING32:
    9850      3894946 :     case CPP_UTF8STRING:
    9851      3894946 :       string_tree = tok->value;
    9852      3894946 :       break;
    9853              : 
    9854           17 :     default:
    9855           17 :       c_parser_error (parser, "expected string literal");
    9856           17 :       ret.set_error ();
    9857           17 :       ret.value = NULL_TREE;
    9858           17 :       ret.original_code = ERROR_MARK;
    9859           17 :       ret.original_type = NULL_TREE;
    9860           17 :       return ret;
    9861              :     }
    9862              : 
    9863              :   /* Try to avoid the overhead of creating and destroying an obstack
    9864              :      for the common case of just one string.  */
    9865      3894946 :   switch (c_parser_peek_2nd_token (parser)->type)
    9866              :     {
    9867      3004051 :     default:
    9868      3004051 :       c_parser_consume_token (parser);
    9869      3004051 :       str.text = (const unsigned char *) TREE_STRING_POINTER (string_tree);
    9870      3004051 :       str.len = TREE_STRING_LENGTH (string_tree);
    9871      3004051 :       count = 1;
    9872      3004051 :       strs = &str;
    9873      3004051 :       break;
    9874              : 
    9875       890895 :     case CPP_STRING:
    9876       890895 :     case CPP_WSTRING:
    9877       890895 :     case CPP_STRING16:
    9878       890895 :     case CPP_STRING32:
    9879       890895 :     case CPP_UTF8STRING:
    9880       890895 :       gcc_obstack_init (&str_ob);
    9881       890895 :       gcc_obstack_init (&loc_ob);
    9882       890895 :       count = 0;
    9883     27892456 :       do
    9884              :         {
    9885     27892456 :           c_parser_consume_token (parser);
    9886     27892456 :           count++;
    9887     27892456 :           str.text = (const unsigned char *) TREE_STRING_POINTER (string_tree);
    9888     27892456 :           str.len = TREE_STRING_LENGTH (string_tree);
    9889     27892456 :           if (type != tok->type)
    9890              :             {
    9891          669 :               if (type == CPP_STRING)
    9892           29 :                 type = tok->type;
    9893          640 :               else if (tok->type != CPP_STRING)
    9894           66 :                 error ("unsupported non-standard concatenation "
    9895              :                        "of string literals");
    9896              :             }
    9897     27892456 :           obstack_grow (&str_ob, &str, sizeof (cpp_string));
    9898     27892456 :           obstack_grow (&loc_ob, &last_tok_loc, sizeof (location_t));
    9899     27892456 :           tok = c_parser_peek_token (parser);
    9900     27892456 :           string_tree = tok->value;
    9901     27892456 :           last_tok_loc
    9902     27892456 :             = linemap_resolve_location (line_table, tok->location,
    9903              :                                         LRK_MACRO_DEFINITION_LOCATION, NULL);
    9904              :         }
    9905     27892456 :       while (tok->type == CPP_STRING
    9906              :              || tok->type == CPP_WSTRING
    9907              :              || tok->type == CPP_STRING16
    9908              :              || tok->type == CPP_STRING32
    9909     27892456 :              || tok->type == CPP_UTF8STRING);
    9910       890895 :       strs = (cpp_string *) obstack_finish (&str_ob);
    9911              :     }
    9912              : 
    9913      3894946 :   if (count > 1 && !in_system_header_at (input_location))
    9914       659274 :     warning (OPT_Wtraditional,
    9915              :              "traditional C rejects string constant concatenation");
    9916              : 
    9917      3894946 :   if ((type == CPP_STRING || wide_ok)
    9918      7789882 :       && ((translate
    9919      3894936 :           ? cpp_interpret_string : cpp_interpret_string_notranslate)
    9920      3894936 :           (parse_in, strs, count, &istr, type)))
    9921              :     {
    9922      3894936 :       value = build_string (istr.len, (const char *) istr.text);
    9923      3894936 :       free (const_cast<unsigned char *> (istr.text));
    9924      3894936 :       if (count > 1)
    9925              :         {
    9926       890895 :           location_t *locs = (location_t *) obstack_finish (&loc_ob);
    9927       890895 :           gcc_assert (g_string_concat_db);
    9928       890895 :           g_string_concat_db->record_string_concatenation (count, locs);
    9929              :         }
    9930              :     }
    9931              :   else
    9932              :     {
    9933           10 :       if (type != CPP_STRING && !wide_ok)
    9934              :         {
    9935           10 :           error_at (loc, "a wide string is invalid in this context");
    9936           10 :           type = CPP_STRING;
    9937              :         }
    9938              :       /* Callers cannot generally handle error_mark_node in this
    9939              :          context, so return the empty string instead.  An error has
    9940              :          been issued, either above or from cpp_interpret_string.  */
    9941           10 :       switch (type)
    9942              :         {
    9943           10 :         default:
    9944           10 :         case CPP_STRING:
    9945           10 :         case CPP_UTF8STRING:
    9946           10 :           if (type == CPP_UTF8STRING && flag_char8_t)
    9947              :             {
    9948            0 :               value = build_string (TYPE_PRECISION (char8_type_node)
    9949            0 :                                     / TYPE_PRECISION (char_type_node),
    9950              :                                     "");  /* char8_t is 8 bits */
    9951              :             }
    9952              :           else
    9953           10 :             value = build_string (1, "");
    9954              :           break;
    9955            0 :         case CPP_STRING16:
    9956            0 :           value = build_string (TYPE_PRECISION (char16_type_node)
    9957            0 :                                 / TYPE_PRECISION (char_type_node),
    9958              :                                 "\0");  /* char16_t is 16 bits */
    9959            0 :           break;
    9960            0 :         case CPP_STRING32:
    9961            0 :           value = build_string (TYPE_PRECISION (char32_type_node)
    9962            0 :                                 / TYPE_PRECISION (char_type_node),
    9963              :                                 "\0\0\0");  /* char32_t is 32 bits */
    9964            0 :           break;
    9965            0 :         case CPP_WSTRING:
    9966            0 :           value = build_string (TYPE_PRECISION (wchar_type_node)
    9967            0 :                                 / TYPE_PRECISION (char_type_node),
    9968              :                                 "\0\0\0");  /* widest supported wchar_t
    9969              :                                                is 32 bits */
    9970            0 :           break;
    9971              :         }
    9972              :     }
    9973              : 
    9974      3894946 :   switch (type)
    9975              :     {
    9976      3891630 :     default:
    9977      3891630 :     case CPP_STRING:
    9978      3891630 :       TREE_TYPE (value) = char_array_type_node;
    9979      3891630 :       break;
    9980          264 :     case CPP_UTF8STRING:
    9981          264 :       if (flag_char8_t)
    9982           82 :         TREE_TYPE (value) = char8_array_type_node;
    9983              :       else
    9984          182 :         TREE_TYPE (value) = char_array_type_node;
    9985              :       break;
    9986          232 :     case CPP_STRING16:
    9987          232 :       TREE_TYPE (value) = char16_array_type_node;
    9988          232 :       break;
    9989         2294 :     case CPP_STRING32:
    9990         2294 :       TREE_TYPE (value) = char32_array_type_node;
    9991         2294 :       break;
    9992          526 :     case CPP_WSTRING:
    9993          526 :       TREE_TYPE (value) = wchar_array_type_node;
    9994              :     }
    9995      3894946 :   value = fix_string_type (value);
    9996              : 
    9997      3894946 :   if (count > 1)
    9998              :     {
    9999       890895 :       obstack_free (&str_ob, 0);
   10000       890895 :       obstack_free (&loc_ob, 0);
   10001              :     }
   10002              : 
   10003      3894946 :   ret.value = value;
   10004      3894946 :   ret.original_code = STRING_CST;
   10005      3894946 :   ret.original_type = NULL_TREE;
   10006      3894946 :   set_c_expr_source_range (&ret, get_range_from_loc (line_table, loc));
   10007      3894946 :   ret.m_decimal = 0;
   10008      3894946 :   parser->seen_string_literal = true;
   10009      3894946 :   return ret;
   10010              : }
   10011              : 
   10012              : /* Parse an expression other than a compound expression; that is, an
   10013              :    assignment expression (C90 6.3.16, C99 6.5.16, C11 6.5.16).  If
   10014              :    AFTER is not NULL then it is an Objective-C message expression which
   10015              :    is the primary-expression starting the expression as an initializer.
   10016              : 
   10017              :    assignment-expression:
   10018              :      conditional-expression
   10019              :      unary-expression assignment-operator assignment-expression
   10020              : 
   10021              :    assignment-operator: one of
   10022              :      = *= /= %= += -= <<= >>= &= ^= |=
   10023              : 
   10024              :    In GNU C we accept any conditional expression on the LHS and
   10025              :    diagnose the invalid lvalue rather than producing a syntax
   10026              :    error.  */
   10027              : 
   10028              : static struct c_expr
   10029    235498380 : c_parser_expr_no_commas (c_parser *parser, struct c_expr *after,
   10030              :                          tree omp_atomic_lhs)
   10031              : {
   10032    235498380 :   struct c_expr lhs, rhs, ret;
   10033    235498380 :   enum tree_code code;
   10034    235498380 :   location_t op_location, exp_location;
   10035    235498380 :   bool save_in_omp_for = c_in_omp_for;
   10036    235498380 :   c_in_omp_for = false;
   10037    235498380 :   gcc_assert (!after || c_dialect_objc ());
   10038    235498380 :   lhs = c_parser_conditional_expression (parser, after, omp_atomic_lhs);
   10039    235498378 :   op_location = c_parser_peek_token (parser)->location;
   10040    235498378 :   switch (c_parser_peek_token (parser)->type)
   10041              :     {
   10042              :     case CPP_EQ:
   10043              :       code = NOP_EXPR;
   10044              :       break;
   10045        12664 :     case CPP_MULT_EQ:
   10046        12664 :       code = MULT_EXPR;
   10047        12664 :       break;
   10048         8848 :     case CPP_DIV_EQ:
   10049         8848 :       code = TRUNC_DIV_EXPR;
   10050         8848 :       break;
   10051         2249 :     case CPP_MOD_EQ:
   10052         2249 :       code = TRUNC_MOD_EXPR;
   10053         2249 :       break;
   10054        93041 :     case CPP_PLUS_EQ:
   10055        93041 :       code = PLUS_EXPR;
   10056        93041 :       break;
   10057        29799 :     case CPP_MINUS_EQ:
   10058        29799 :       code = MINUS_EXPR;
   10059        29799 :       break;
   10060         4221 :     case CPP_LSHIFT_EQ:
   10061         4221 :       code = LSHIFT_EXPR;
   10062         4221 :       break;
   10063        17296 :     case CPP_RSHIFT_EQ:
   10064        17296 :       code = RSHIFT_EXPR;
   10065        17296 :       break;
   10066        25749 :     case CPP_AND_EQ:
   10067        25749 :       code = BIT_AND_EXPR;
   10068        25749 :       break;
   10069         3561 :     case CPP_XOR_EQ:
   10070         3561 :       code = BIT_XOR_EXPR;
   10071         3561 :       break;
   10072        21210 :     case CPP_OR_EQ:
   10073        21210 :       code = BIT_IOR_EXPR;
   10074        21210 :       break;
   10075    232505647 :     default:
   10076    232505647 :       c_in_omp_for = save_in_omp_for;
   10077    232505647 :       return lhs;
   10078              :     }
   10079      2992731 :   c_parser_consume_token (parser);
   10080      2992731 :   exp_location = c_parser_peek_token (parser)->location;
   10081      2992731 :   rhs = c_parser_expr_no_commas (parser, NULL);
   10082      2992731 :   rhs = convert_lvalue_to_rvalue (exp_location, rhs, true, true);
   10083              : 
   10084      2992731 :   ret.value = build_modify_expr (op_location, lhs.value, lhs.original_type,
   10085              :                                  code, exp_location, rhs.value,
   10086              :                                  rhs.original_type);
   10087      2992731 :   ret.m_decimal = 0;
   10088      2992731 :   set_c_expr_source_range (&ret, lhs.get_start (), rhs.get_finish ());
   10089      2992731 :   if (code == NOP_EXPR)
   10090      2774093 :     ret.original_code = MODIFY_EXPR;
   10091              :   else
   10092              :     {
   10093       218638 :       suppress_warning (ret.value, OPT_Wparentheses);
   10094       218638 :       ret.original_code = ERROR_MARK;
   10095              :     }
   10096      2992731 :   ret.original_type = NULL;
   10097      2992731 :   c_in_omp_for = save_in_omp_for;
   10098      2992731 :   return ret;
   10099              : }
   10100              : 
   10101              : /* Parse a conditional expression (C90 6.3.15, C99 6.5.15, C11 6.5.15).  If
   10102              :    AFTER is not NULL then it is an Objective-C message expression which is
   10103              :    the primary-expression starting the expression as an initializer.
   10104              : 
   10105              :    conditional-expression:
   10106              :      logical-OR-expression
   10107              :      logical-OR-expression ? expression : conditional-expression
   10108              : 
   10109              :    GNU extensions:
   10110              : 
   10111              :    conditional-expression:
   10112              :      logical-OR-expression ? : conditional-expression
   10113              : */
   10114              : 
   10115              : static struct c_expr
   10116    235908681 : c_parser_conditional_expression (c_parser *parser, struct c_expr *after,
   10117              :                                  tree omp_atomic_lhs)
   10118              : {
   10119    235908681 :   struct c_expr cond, exp1, exp2, ret;
   10120    235908681 :   location_t start, cond_loc, colon_loc;
   10121    235908681 :   bool save_c_omp_array_section_p = c_omp_array_section_p;
   10122              : 
   10123    235908681 :   gcc_assert (!after || c_dialect_objc ());
   10124              : 
   10125    235908681 :   cond = c_parser_binary_expression (parser, after, omp_atomic_lhs);
   10126              : 
   10127    235908679 :   if (c_parser_next_token_is_not (parser, CPP_QUERY))
   10128    235498575 :     return cond;
   10129       410104 :   c_omp_array_section_p = false;
   10130       410104 :   if (cond.value != error_mark_node)
   10131       410093 :     start = cond.get_start ();
   10132              :   else
   10133              :     start = UNKNOWN_LOCATION;
   10134       410104 :   cond_loc = c_parser_peek_token (parser)->location;
   10135       410104 :   cond = convert_lvalue_to_rvalue (cond_loc, cond, true, true);
   10136       410104 :   c_parser_consume_token (parser);
   10137       410104 :   if (c_parser_next_token_is (parser, CPP_COLON))
   10138              :     {
   10139          784 :       tree eptype = NULL_TREE;
   10140              : 
   10141          784 :       location_t middle_loc = c_parser_peek_token (parser)->location;
   10142          784 :       pedwarn (middle_loc, OPT_Wpedantic,
   10143              :                "ISO C forbids omitting the middle term of a %<?:%> expression");
   10144          784 :       if (TREE_CODE (cond.value) == EXCESS_PRECISION_EXPR)
   10145              :         {
   10146            1 :           eptype = TREE_TYPE (cond.value);
   10147            1 :           cond.value = TREE_OPERAND (cond.value, 0);
   10148              :         }
   10149          784 :       tree e = cond.value;
   10150          787 :       while (TREE_CODE (e) == COMPOUND_EXPR)
   10151            3 :         e = TREE_OPERAND (e, 1);
   10152          784 :       warn_for_omitted_condop (middle_loc, e);
   10153              :       /* Make sure first operand is calculated only once.  */
   10154          784 :       exp1.value = save_expr (default_conversion (cond.value));
   10155          784 :       if (eptype)
   10156            1 :         exp1.value = build1 (EXCESS_PRECISION_EXPR, eptype, exp1.value);
   10157          784 :       exp1.original_type = NULL;
   10158          784 :       exp1.src_range = cond.src_range;
   10159          784 :       cond.value = c_objc_common_truthvalue_conversion (cond_loc, exp1.value);
   10160          784 :       c_inhibit_evaluation_warnings += cond.value == truthvalue_true_node;
   10161              :     }
   10162              :   else
   10163              :     {
   10164       409320 :       cond.value
   10165       409320 :         = c_objc_common_truthvalue_conversion
   10166       409320 :         (cond_loc, default_conversion (cond.value));
   10167       409320 :       c_inhibit_evaluation_warnings += cond.value == truthvalue_false_node;
   10168       409320 :       exp1 = c_parser_expression_conv (parser);
   10169       409320 :       mark_exp_read (exp1.value);
   10170       409320 :       c_inhibit_evaluation_warnings +=
   10171       409320 :         ((cond.value == truthvalue_true_node)
   10172       409320 :          - (cond.value == truthvalue_false_node));
   10173              :     }
   10174              : 
   10175       410104 :   colon_loc = c_parser_peek_token (parser)->location;
   10176       410104 :   if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   10177              :     {
   10178            9 :       c_inhibit_evaluation_warnings -= cond.value == truthvalue_true_node;
   10179            9 :       ret.set_error ();
   10180            9 :       ret.original_code = ERROR_MARK;
   10181            9 :       ret.original_type = NULL;
   10182            9 :       c_omp_array_section_p = save_c_omp_array_section_p;
   10183            9 :       return ret;
   10184              :     }
   10185       410095 :   {
   10186       410095 :     location_t exp2_loc = c_parser_peek_token (parser)->location;
   10187       410095 :     exp2 = c_parser_conditional_expression (parser, NULL, NULL_TREE);
   10188       410095 :     exp2 = convert_lvalue_to_rvalue (exp2_loc, exp2, true, true);
   10189              :   }
   10190       410095 :   c_inhibit_evaluation_warnings -= cond.value == truthvalue_true_node;
   10191       410095 :   location_t loc1 = make_location (exp1.get_start (), exp1.src_range);
   10192       410095 :   location_t loc2 = make_location (exp2.get_start (), exp2.src_range);
   10193       410095 :   if (UNLIKELY (omp_atomic_lhs != NULL)
   10194           69 :       && (TREE_CODE (cond.value) == GT_EXPR
   10195              :           || TREE_CODE (cond.value) == LT_EXPR
   10196              :           || TREE_CODE (cond.value) == EQ_EXPR)
   10197           63 :       && c_tree_equal (exp2.value, omp_atomic_lhs)
   10198       410153 :       && (c_tree_equal (TREE_OPERAND (cond.value, 0), omp_atomic_lhs)
   10199           19 :           || c_tree_equal (TREE_OPERAND (cond.value, 1), omp_atomic_lhs)))
   10200           55 :     ret.value = build3_loc (colon_loc, COND_EXPR, TREE_TYPE (omp_atomic_lhs),
   10201              :                             cond.value, exp1.value, exp2.value);
   10202              :   else
   10203       410040 :     ret.value
   10204       410040 :       = build_conditional_expr (colon_loc, cond.value,
   10205       410040 :                                 cond.original_code == C_MAYBE_CONST_EXPR,
   10206              :                                 exp1.value, exp1.original_type, loc1,
   10207              :                                 exp2.value, exp2.original_type, loc2);
   10208       410095 :   ret.original_code = ERROR_MARK;
   10209       410095 :   if (exp1.value == error_mark_node || exp2.value == error_mark_node)
   10210           15 :     ret.original_type = NULL;
   10211              :   else
   10212              :     {
   10213       410080 :       tree t1, t2;
   10214              : 
   10215              :       /* If both sides are enum type, the default conversion will have
   10216              :          made the type of the result be an integer type.  We want to
   10217              :          remember the enum types we started with.  */
   10218       410080 :       t1 = exp1.original_type ? exp1.original_type : TREE_TYPE (exp1.value);
   10219       410080 :       t2 = exp2.original_type ? exp2.original_type : TREE_TYPE (exp2.value);
   10220       410080 :       ret.original_type = ((t1 != error_mark_node
   10221       410080 :                             && t2 != error_mark_node
   10222       410080 :                             && (TYPE_MAIN_VARIANT (t1)
   10223       410080 :                                 == TYPE_MAIN_VARIANT (t2)))
   10224       410080 :                            ? t1
   10225              :                            : NULL);
   10226              :     }
   10227       410095 :   set_c_expr_source_range (&ret, start, exp2.get_finish ());
   10228       410095 :   ret.m_decimal = 0;
   10229       410095 :   c_omp_array_section_p = save_c_omp_array_section_p;
   10230       410095 :   return ret;
   10231              : }
   10232              : 
   10233              : /* Parse a binary expression; that is, a logical-OR-expression (C90
   10234              :    6.3.5-6.3.14, C99 6.5.5-6.5.14, C11 6.5.5-6.5.14).  If AFTER is not
   10235              :    NULL then it is an Objective-C message expression which is the
   10236              :    primary-expression starting the expression as an initializer.
   10237              : 
   10238              :    OMP_ATOMIC_LHS is NULL, unless parsing OpenMP #pragma omp atomic,
   10239              :    when it should be the unfolded lhs.  In a valid OpenMP source,
   10240              :    one of the operands of the toplevel binary expression must be equal
   10241              :    to it.  In that case, just return a build2 created binary operation
   10242              :    rather than result of parser_build_binary_op.
   10243              : 
   10244              :    multiplicative-expression:
   10245              :      cast-expression
   10246              :      multiplicative-expression * cast-expression
   10247              :      multiplicative-expression / cast-expression
   10248              :      multiplicative-expression % cast-expression
   10249              : 
   10250              :    additive-expression:
   10251              :      multiplicative-expression
   10252              :      additive-expression + multiplicative-expression
   10253              :      additive-expression - multiplicative-expression
   10254              : 
   10255              :    shift-expression:
   10256              :      additive-expression
   10257              :      shift-expression << additive-expression
   10258              :      shift-expression >> additive-expression
   10259              : 
   10260              :    relational-expression:
   10261              :      shift-expression
   10262              :      relational-expression < shift-expression
   10263              :      relational-expression > shift-expression
   10264              :      relational-expression <= shift-expression
   10265              :      relational-expression >= shift-expression
   10266              : 
   10267              :    equality-expression:
   10268              :      relational-expression
   10269              :      equality-expression == relational-expression
   10270              :      equality-expression != relational-expression
   10271              : 
   10272              :    AND-expression:
   10273              :      equality-expression
   10274              :      AND-expression & equality-expression
   10275              : 
   10276              :    exclusive-OR-expression:
   10277              :      AND-expression
   10278              :      exclusive-OR-expression ^ AND-expression
   10279              : 
   10280              :    inclusive-OR-expression:
   10281              :      exclusive-OR-expression
   10282              :      inclusive-OR-expression | exclusive-OR-expression
   10283              : 
   10284              :    logical-AND-expression:
   10285              :      inclusive-OR-expression
   10286              :      logical-AND-expression && inclusive-OR-expression
   10287              : 
   10288              :    logical-OR-expression:
   10289              :      logical-AND-expression
   10290              :      logical-OR-expression || logical-AND-expression
   10291              : */
   10292              : 
   10293              : static struct c_expr
   10294    235926133 : c_parser_binary_expression (c_parser *parser, struct c_expr *after,
   10295              :                             tree omp_atomic_lhs)
   10296              : {
   10297              :   /* A binary expression is parsed using operator-precedence parsing,
   10298              :      with the operands being cast expressions.  All the binary
   10299              :      operators are left-associative.  Thus a binary expression is of
   10300              :      form:
   10301              : 
   10302              :      E0 op1 E1 op2 E2 ...
   10303              : 
   10304              :      which we represent on a stack.  On the stack, the precedence
   10305              :      levels are strictly increasing.  When a new operator is
   10306              :      encountered of higher precedence than that at the top of the
   10307              :      stack, it is pushed; its LHS is the top expression, and its RHS
   10308              :      is everything parsed until it is popped.  When a new operator is
   10309              :      encountered with precedence less than or equal to that at the top
   10310              :      of the stack, triples E[i-1] op[i] E[i] are popped and replaced
   10311              :      by the result of the operation until the operator at the top of
   10312              :      the stack has lower precedence than the new operator or there is
   10313              :      only one element on the stack; then the top expression is the LHS
   10314              :      of the new operator.  In the case of logical AND and OR
   10315              :      expressions, we also need to adjust c_inhibit_evaluation_warnings
   10316              :      as appropriate when the operators are pushed and popped.  */
   10317              : 
   10318    235926133 :   struct {
   10319              :     /* The expression at this stack level.  */
   10320              :     struct c_expr expr;
   10321              :     /* The precedence of the operator on its left, PREC_NONE at the
   10322              :        bottom of the stack.  */
   10323              :     enum c_parser_prec prec;
   10324              :     /* The operation on its left.  */
   10325              :     enum tree_code op;
   10326              :     /* The source location of this operation.  */
   10327              :     location_t loc;
   10328              :     /* The sizeof argument if expr.original_code == {PAREN_,}SIZEOF_EXPR.  */
   10329              :     tree sizeof_arg;
   10330              :     /* The original expr.value before c_objc_common_truthvalue_conversion
   10331              :        for TRUTH_{AND,OR}*_EXPR lhs operands.  */
   10332              :     tree orig_expr;
   10333              :   } stack[NUM_PRECS];
   10334    235926133 :   int sp;
   10335              :   /* Location of the binary operator.  */
   10336    235926133 :   location_t binary_loc = UNKNOWN_LOCATION;  /* Quiet warning.  */
   10337              : #define POP                                                                   \
   10338              :   do {                                                                        \
   10339              :     switch (stack[sp].op)                                                     \
   10340              :       {                                                                       \
   10341              :       case TRUTH_ANDIF_EXPR:                                                  \
   10342              :         c_inhibit_evaluation_warnings -= (stack[sp - 1].expr.value            \
   10343              :                                           == truthvalue_false_node);          \
   10344              :         break;                                                                \
   10345              :       case TRUTH_ORIF_EXPR:                                                   \
   10346              :         c_inhibit_evaluation_warnings -= (stack[sp - 1].expr.value            \
   10347              :                                           == truthvalue_true_node);           \
   10348              :         break;                                                                \
   10349              :       case TRUNC_DIV_EXPR:                                                    \
   10350              :         if ((stack[sp - 1].expr.original_code == SIZEOF_EXPR                  \
   10351              :              || stack[sp - 1].expr.original_code == PAREN_SIZEOF_EXPR)        \
   10352              :             && (stack[sp].expr.original_code == SIZEOF_EXPR                   \
   10353              :                 || stack[sp].expr.original_code == PAREN_SIZEOF_EXPR))        \
   10354              :           {                                                                   \
   10355              :             tree type0 = stack[sp - 1].sizeof_arg;                            \
   10356              :             tree type1 = stack[sp].sizeof_arg;                                \
   10357              :             tree first_arg = type0;                                           \
   10358              :             if (!TYPE_P (type0))                                              \
   10359              :               type0 = TREE_TYPE (type0);                                      \
   10360              :             if (!TYPE_P (type1))                                              \
   10361              :               type1 = TREE_TYPE (type1);                                      \
   10362              :             if (POINTER_TYPE_P (type0)                                        \
   10363              :                 && comptypes (TREE_TYPE (type0), type1)                       \
   10364              :                 && !(TREE_CODE (first_arg) == PARM_DECL                       \
   10365              :                      && C_ARRAY_PARAMETER (first_arg)                         \
   10366              :                      && warn_sizeof_array_argument))                          \
   10367              :               {                                                               \
   10368              :                 auto_diagnostic_group d;                                      \
   10369              :                 if (warning_at (stack[sp].loc, OPT_Wsizeof_pointer_div,       \
   10370              :                                   "division %<sizeof (%T) / sizeof (%T)%> "   \
   10371              :                                   "does not compute the number of array "     \
   10372              :                                   "elements",                               \
   10373              :                                   type0, type1))                              \
   10374              :                   if (DECL_P (first_arg))                                     \
   10375              :                     inform (DECL_SOURCE_LOCATION (first_arg),                 \
   10376              :                               "first %<sizeof%> operand was declared here");  \
   10377              :               }                                                               \
   10378              :             else if (TREE_CODE (type0) == ARRAY_TYPE                          \
   10379              :                      && !char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type0)))  \
   10380              :                      && stack[sp].expr.original_code != PAREN_SIZEOF_EXPR)    \
   10381              :               maybe_warn_sizeof_array_div (stack[sp].loc, first_arg, type0,   \
   10382              :                                            stack[sp].sizeof_arg, type1);      \
   10383              :           }                                                                   \
   10384              :         break;                                                                \
   10385              :       default:                                                                \
   10386              :         break;                                                                \
   10387              :       }                                                                       \
   10388              :     stack[sp - 1].expr                                                        \
   10389              :       = convert_lvalue_to_rvalue (stack[sp - 1].loc,                          \
   10390              :                                   stack[sp - 1].expr, true, true);            \
   10391              :     stack[sp].expr                                                            \
   10392              :       = convert_lvalue_to_rvalue (stack[sp].loc,                              \
   10393              :                                   stack[sp].expr, true, true);                \
   10394              :     if (UNLIKELY (omp_atomic_lhs != NULL_TREE) && sp == 1                     \
   10395              :         && ((c_parser_next_token_is (parser, CPP_SEMICOLON)                   \
   10396              :              && ((1 << stack[sp].prec)                                          \
   10397              :                  & ((1 << PREC_BITOR) | (1 << PREC_BITXOR)                    \
   10398              :                      | (1 << PREC_BITAND) | (1 << PREC_SHIFT)                     \
   10399              :                      | (1 << PREC_ADD) | (1 << PREC_MULT)                 \
   10400              :                      | (1 << PREC_EQ))))                                \
   10401              :             || ((c_parser_next_token_is (parser, CPP_QUERY)                   \
   10402              :                  || (omp_atomic_lhs == void_list_node                         \
   10403              :                      && c_parser_next_token_is (parser, CPP_CLOSE_PAREN)))    \
   10404              :                 && (stack[sp].prec == PREC_REL || stack[sp].prec == PREC_EQ)))\
   10405              :         && stack[sp].op != TRUNC_MOD_EXPR                                     \
   10406              :         && stack[sp].op != GE_EXPR                                            \
   10407              :         && stack[sp].op != LE_EXPR                                            \
   10408              :         && stack[sp].op != NE_EXPR                                            \
   10409              :         && stack[0].expr.value != error_mark_node                             \
   10410              :         && stack[1].expr.value != error_mark_node                             \
   10411              :         && (omp_atomic_lhs == void_list_node                                  \
   10412              :             || c_tree_equal (stack[0].expr.value, omp_atomic_lhs)             \
   10413              :             || c_tree_equal (stack[1].expr.value, omp_atomic_lhs)             \
   10414              :             || (stack[sp].op == EQ_EXPR                                       \
   10415              :                 && c_parser_peek_2nd_token (parser)->keyword == RID_IF)))     \
   10416              :       {                                                                       \
   10417              :         tree t = make_node (stack[1].op);                                     \
   10418              :         TREE_TYPE (t) = TREE_TYPE (stack[0].expr.value);                      \
   10419              :         TREE_OPERAND (t, 0) = stack[0].expr.value;                            \
   10420              :         TREE_OPERAND (t, 1) = stack[1].expr.value;                            \
   10421              :         stack[0].expr.value = t;                                              \
   10422              :         stack[0].expr.m_decimal = 0;                                          \
   10423              :       }                                                                       \
   10424              :     else                                                                      \
   10425              :       stack[sp - 1].expr = parser_build_binary_op (stack[sp].loc,             \
   10426              :                                                    stack[sp].op,              \
   10427              :                                                    stack[sp - 1].expr,        \
   10428              :                                                    stack[sp].expr,            \
   10429              :                                                    stack[sp - 1].orig_expr);  \
   10430              :     stack[sp - 1].orig_expr = NULL_TREE;                                      \
   10431              :     sp--;                                                                     \
   10432              :   } while (0)
   10433    235926133 :   gcc_assert (!after || c_dialect_objc ());
   10434    235926133 :   stack[0].loc = c_parser_peek_token (parser)->location;
   10435    235926133 :   stack[0].expr = c_parser_cast_expression (parser, after);
   10436    235926133 :   stack[0].prec = PREC_NONE;
   10437    235926133 :   stack[0].sizeof_arg = c_last_sizeof_arg;
   10438    235926133 :   stack[0].orig_expr = NULL_TREE;
   10439    235926133 :   sp = 0;
   10440    256030891 :   while (true)
   10441              :     {
   10442    245978512 :       enum c_parser_prec oprec;
   10443    245978512 :       enum tree_code ocode;
   10444    245978512 :       source_range src_range;
   10445    245978512 :       if (parser->error)
   10446         1072 :         goto out;
   10447    245977440 :       switch (c_parser_peek_token (parser)->type)
   10448              :         {
   10449              :         case CPP_MULT:
   10450              :           oprec = PREC_MULT;
   10451              :           ocode = MULT_EXPR;
   10452              :           break;
   10453       269689 :         case CPP_DIV:
   10454       269689 :           oprec = PREC_MULT;
   10455       269689 :           ocode = TRUNC_DIV_EXPR;
   10456       269689 :           break;
   10457        57278 :         case CPP_MOD:
   10458        57278 :           oprec = PREC_MULT;
   10459        57278 :           ocode = TRUNC_MOD_EXPR;
   10460        57278 :           break;
   10461      2308668 :         case CPP_PLUS:
   10462      2308668 :           oprec = PREC_ADD;
   10463      2308668 :           ocode = PLUS_EXPR;
   10464      2308668 :           break;
   10465       765039 :         case CPP_MINUS:
   10466       765039 :           oprec = PREC_ADD;
   10467       765039 :           ocode = MINUS_EXPR;
   10468       765039 :           break;
   10469       807852 :         case CPP_LSHIFT:
   10470       807852 :           oprec = PREC_SHIFT;
   10471       807852 :           ocode = LSHIFT_EXPR;
   10472       807852 :           break;
   10473       218182 :         case CPP_RSHIFT:
   10474       218182 :           oprec = PREC_SHIFT;
   10475       218182 :           ocode = RSHIFT_EXPR;
   10476       218182 :           break;
   10477       486731 :         case CPP_LESS:
   10478       486731 :           oprec = PREC_REL;
   10479       486731 :           ocode = LT_EXPR;
   10480       486731 :           break;
   10481       199995 :         case CPP_GREATER:
   10482       199995 :           oprec = PREC_REL;
   10483       199995 :           ocode = GT_EXPR;
   10484       199995 :           break;
   10485       164345 :         case CPP_LESS_EQ:
   10486       164345 :           oprec = PREC_REL;
   10487       164345 :           ocode = LE_EXPR;
   10488       164345 :           break;
   10489       169080 :         case CPP_GREATER_EQ:
   10490       169080 :           oprec = PREC_REL;
   10491       169080 :           ocode = GE_EXPR;
   10492       169080 :           break;
   10493       406893 :         case CPP_EQ_EQ:
   10494       406893 :           oprec = PREC_EQ;
   10495       406893 :           ocode = EQ_EXPR;
   10496       406893 :           break;
   10497       787330 :         case CPP_NOT_EQ:
   10498       787330 :           oprec = PREC_EQ;
   10499       787330 :           ocode = NE_EXPR;
   10500       787330 :           break;
   10501       657219 :         case CPP_AND:
   10502       657219 :           oprec = PREC_BITAND;
   10503       657219 :           ocode = BIT_AND_EXPR;
   10504       657219 :           break;
   10505        85132 :         case CPP_XOR:
   10506        85132 :           oprec = PREC_BITXOR;
   10507        85132 :           ocode = BIT_XOR_EXPR;
   10508        85132 :           break;
   10509       878304 :         case CPP_OR:
   10510       878304 :           oprec = PREC_BITOR;
   10511       878304 :           ocode = BIT_IOR_EXPR;
   10512       878304 :           break;
   10513       188352 :         case CPP_AND_AND:
   10514       188352 :           oprec = PREC_LOGAND;
   10515       188352 :           ocode = TRUTH_ANDIF_EXPR;
   10516       188352 :           break;
   10517       327678 :         case CPP_OR_OR:
   10518       327678 :           oprec = PREC_LOGOR;
   10519       327678 :           ocode = TRUTH_ORIF_EXPR;
   10520       327678 :           break;
   10521    235925061 :         default:
   10522              :           /* Not a binary operator, so end of the binary
   10523              :              expression.  */
   10524    235925061 :           goto out;
   10525              :         }
   10526     10052379 :       binary_loc = c_parser_peek_token (parser)->location;
   10527     10052379 :       while (oprec <= stack[sp].prec)
   10528     11525482 :         POP;
   10529     10052379 :       c_parser_consume_token (parser);
   10530     10052379 :       switch (ocode)
   10531              :         {
   10532       188352 :         case TRUTH_ANDIF_EXPR:
   10533       188352 :           src_range = stack[sp].expr.src_range;
   10534       188352 :           stack[sp].expr
   10535       188352 :             = convert_lvalue_to_rvalue (stack[sp].loc,
   10536              :                                         stack[sp].expr, true, true);
   10537       188352 :           stack[sp].orig_expr = stack[sp].expr.value;
   10538       376704 :           stack[sp].expr.value = c_objc_common_truthvalue_conversion
   10539       188352 :             (stack[sp].loc, default_conversion (stack[sp].expr.value));
   10540       188352 :           c_inhibit_evaluation_warnings += (stack[sp].expr.value
   10541       188352 :                                             == truthvalue_false_node);
   10542       188352 :           set_c_expr_source_range (&stack[sp].expr, src_range);
   10543       188352 :           break;
   10544       327678 :         case TRUTH_ORIF_EXPR:
   10545       327678 :           src_range = stack[sp].expr.src_range;
   10546       327678 :           stack[sp].expr
   10547       327678 :             = convert_lvalue_to_rvalue (stack[sp].loc,
   10548              :                                         stack[sp].expr, true, true);
   10549       327678 :           stack[sp].orig_expr = stack[sp].expr.value;
   10550       655356 :           stack[sp].expr.value = c_objc_common_truthvalue_conversion
   10551       327678 :             (stack[sp].loc, default_conversion (stack[sp].expr.value));
   10552       327678 :           c_inhibit_evaluation_warnings += (stack[sp].expr.value
   10553       327678 :                                             == truthvalue_true_node);
   10554       327678 :           set_c_expr_source_range (&stack[sp].expr, src_range);
   10555       327678 :           break;
   10556              :         default:
   10557              :           break;
   10558              :         }
   10559     10052379 :       sp++;
   10560     10052379 :       stack[sp].loc = binary_loc;
   10561     10052379 :       stack[sp].expr = c_parser_cast_expression (parser, NULL);
   10562     10052379 :       stack[sp].prec = oprec;
   10563     10052379 :       stack[sp].op = ocode;
   10564     10052379 :       stack[sp].sizeof_arg = c_last_sizeof_arg;
   10565     10052379 :       stack[sp].orig_expr = NULL_TREE;
   10566     10052379 :     }
   10567    235926133 :  out:
   10568    235926133 :   while (sp > 0)
   10569    244505648 :     POP;
   10570    235926131 :   return stack[0].expr;
   10571              : #undef POP
   10572              : }
   10573              : 
   10574              : /* Parse any storage class specifiers after an open parenthesis in a
   10575              :    context where a compound literal is permitted.  */
   10576              : 
   10577              : static struct c_declspecs *
   10578    126522948 : c_parser_compound_literal_scspecs (c_parser *parser)
   10579              : {
   10580    126522948 :   bool seen_scspec = false;
   10581    126522948 :   struct c_declspecs *specs = build_null_declspecs ();
   10582    253046239 :   while (c_parser_next_token_is (parser, CPP_KEYWORD))
   10583              :     {
   10584      4393491 :       switch (c_parser_peek_token (parser)->keyword)
   10585              :         {
   10586          343 :         case RID_CONSTEXPR:
   10587          343 :         case RID_REGISTER:
   10588          343 :         case RID_STATIC:
   10589          343 :         case RID_THREAD:
   10590          343 :           seen_scspec = true;
   10591          343 :           declspecs_add_scspec (c_parser_peek_token (parser)->location,
   10592          343 :                                 specs, c_parser_peek_token (parser)->value);
   10593          343 :           c_parser_consume_token (parser);
   10594          343 :           break;
   10595      4393148 :         default:
   10596      4393148 :           goto out;
   10597              :         }
   10598              :     }
   10599    122129800 :  out:
   10600    126522948 :   return seen_scspec ? specs : NULL;
   10601              : }
   10602              : 
   10603              : /* Parse a cast expression (C90 6.3.4, C99 6.5.4, C11 6.5.4).  If AFTER
   10604              :    is not NULL then it is an Objective-C message expression which is the
   10605              :    primary-expression starting the expression as an initializer.
   10606              : 
   10607              :    cast-expression:
   10608              :      unary-expression
   10609              :      ( type-name ) unary-expression
   10610              : */
   10611              : 
   10612              : static struct c_expr
   10613    381410773 : c_parser_cast_expression (c_parser *parser, struct c_expr *after)
   10614              : {
   10615    381410773 :   location_t cast_loc = c_parser_peek_token (parser)->location;
   10616    381410773 :   gcc_assert (!after || c_dialect_objc ());
   10617            0 :   if (after)
   10618            0 :     return c_parser_postfix_expression_after_primary (parser,
   10619            0 :                                                       cast_loc, *after);
   10620              :   /* If the expression begins with a parenthesized type name, it may
   10621              :      be either a cast or a compound literal; we need to see whether
   10622              :      the next character is '{' to tell the difference.  If not, it is
   10623              :      an unary expression.  Full detection of unknown typenames here
   10624              :      would require a 3-token lookahead.  */
   10625    381410773 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
   10626    381410773 :       && c_token_starts_compound_literal (c_parser_peek_2nd_token (parser)))
   10627              :     {
   10628    126156643 :       struct c_declspecs *scspecs;
   10629    126156643 :       struct c_type_name *type_name;
   10630    126156643 :       struct c_expr ret;
   10631    126156643 :       struct c_expr expr;
   10632    126156643 :       matching_parens parens;
   10633    126156643 :       parens.consume_open (parser);
   10634    126156643 :       scspecs = c_parser_compound_literal_scspecs (parser);
   10635    126156643 :       type_name = c_parser_type_name (parser, true);
   10636    126156643 :       parens.skip_until_found_close (parser);
   10637    126156643 :       if (type_name == NULL)
   10638              :         {
   10639            1 :           ret.set_error ();
   10640            1 :           ret.original_code = ERROR_MARK;
   10641            1 :           ret.original_type = NULL;
   10642            1 :           return ret;
   10643              :         }
   10644              : 
   10645              :       /* Save casted types in the function's used types hash table.  */
   10646    126156642 :       used_types_insert (type_name->specs->type);
   10647              : 
   10648    126156642 :       if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
   10649       930267 :         return c_parser_postfix_expression_after_paren_type (parser, scspecs,
   10650              :                                                              type_name,
   10651       930267 :                                                              cast_loc);
   10652    125226375 :       if (scspecs)
   10653            1 :         error_at (cast_loc, "storage class specifier in cast");
   10654    125226375 :       if (type_name->specs->alignas_p)
   10655            1 :         error_at (type_name->specs->locations[cdw_alignas],
   10656              :                   "alignment specified for type name in cast");
   10657    125226375 :       {
   10658    125226375 :         location_t expr_loc = c_parser_peek_token (parser)->location;
   10659    125226375 :         expr = c_parser_cast_expression (parser, NULL);
   10660    125226375 :         expr = convert_lvalue_to_rvalue (expr_loc, expr, true, true);
   10661              :       }
   10662    125226375 :       ret.value = c_cast_expr (cast_loc, type_name, expr.value);
   10663    125226375 :       if (ret.value && expr.value)
   10664    125226375 :         set_c_expr_source_range (&ret, cast_loc, expr.get_finish ());
   10665    125226375 :       ret.original_code = ERROR_MARK;
   10666    125226375 :       ret.original_type = NULL;
   10667    125226375 :       ret.m_decimal = 0;
   10668    125226375 :       return ret;
   10669              :     }
   10670              :   else
   10671    255254130 :     return c_parser_unary_expression (parser);
   10672              : }
   10673              : 
   10674              : 
   10675              : /* Like mark_exp_read but skip marking VAR_DECLs and PARM_DECLs
   10676              :    depending on the warning mode.  This helper function is
   10677              :    used in c_parser_unary_expression and
   10678              :    and c_parser_postfix_expression_after_primary for
   10679              :    pre/post-increment/decrement operations.
   10680              :  */
   10681              : 
   10682              : static void
   10683       954300 : mark_exp_read_cond (tree exp)
   10684              : {
   10685       954300 :   if ((VAR_P (exp) || TREE_CODE (exp) == PARM_DECL)
   10686       874804 :       && (VAR_P (exp) ? warn_unused_but_set_variable
   10687              :                       : warn_unused_but_set_parameter) > 1)
   10688              :     return;
   10689              : 
   10690       756147 :   mark_exp_read (exp);
   10691              : }
   10692              : 
   10693              : 
   10694              : /* Parse an unary expression (C90 6.3.3, C99 6.5.3, C11 6.5.3).
   10695              : 
   10696              :    unary-expression:
   10697              :      postfix-expression
   10698              :      ++ unary-expression
   10699              :      -- unary-expression
   10700              :      unary-operator cast-expression
   10701              :      _Countof unary-expression
   10702              :      _Countof ( type-name )
   10703              :      sizeof unary-expression
   10704              :      sizeof ( type-name )
   10705              :      static-assert-declaration-no-semi
   10706              : 
   10707              :    (_Countof and the use of static assertions in expressions are new in C2y.)
   10708              : 
   10709              :    unary-operator: one of
   10710              :      & * + - ~ !
   10711              : 
   10712              :    GNU extensions:
   10713              : 
   10714              :    unary-expression:
   10715              :      __alignof__ unary-expression
   10716              :      __alignof__ ( type-name )
   10717              :      _Maxof ( type-name )
   10718              :      _Minof ( type-name )
   10719              :      && identifier
   10720              : 
   10721              :    (C11 permits _Alignof with type names only.)
   10722              : 
   10723              :    unary-operator: one of
   10724              :      __extension__ __real__ __imag__
   10725              : 
   10726              :    Transactional Memory:
   10727              : 
   10728              :    unary-expression:
   10729              :      transaction-expression
   10730              : 
   10731              :    In addition, the GNU syntax treats ++ and -- as unary operators, so
   10732              :    they may be applied to cast expressions with errors for non-lvalues
   10733              :    given later.  */
   10734              : 
   10735              : static struct c_expr
   10736    255611191 : c_parser_unary_expression (c_parser *parser)
   10737              : {
   10738    255611191 :   int ext;
   10739    255611191 :   struct c_expr ret, op;
   10740    255611191 :   location_t op_loc = c_parser_peek_token (parser)->location;
   10741    255611191 :   location_t exp_loc;
   10742    255611191 :   location_t finish;
   10743    255611191 :   ret.original_code = ERROR_MARK;
   10744    255611191 :   ret.original_type = NULL;
   10745    255611191 :   switch (c_parser_peek_token (parser)->type)
   10746              :     {
   10747       221721 :     case CPP_PLUS_PLUS:
   10748       221721 :       c_parser_consume_token (parser);
   10749       221721 :       exp_loc = c_parser_peek_token (parser)->location;
   10750       221721 :       op = c_parser_cast_expression (parser, NULL);
   10751       221721 :       mark_exp_read_cond (op.value);
   10752       221721 :       op = default_function_array_conversion (exp_loc, op);
   10753       221721 :       return parser_build_unary_op (op_loc, PREINCREMENT_EXPR, op);
   10754        20489 :     case CPP_MINUS_MINUS:
   10755        20489 :       c_parser_consume_token (parser);
   10756        20489 :       exp_loc = c_parser_peek_token (parser)->location;
   10757        20489 :       op = c_parser_cast_expression (parser, NULL);
   10758        20489 :       mark_exp_read_cond (op.value);
   10759        20489 :       op = default_function_array_conversion (exp_loc, op);
   10760        20489 :       return parser_build_unary_op (op_loc, PREDECREMENT_EXPR, op);
   10761       454405 :     case CPP_AND:
   10762       454405 :       c_parser_consume_token (parser);
   10763       454405 :       op = c_parser_cast_expression (parser, NULL);
   10764       454405 :       mark_exp_read (op.value);
   10765       454405 :       return parser_build_unary_op (op_loc, ADDR_EXPR, op);
   10766      1226363 :     case CPP_MULT:
   10767      1226363 :       {
   10768      1226363 :         c_parser_consume_token (parser);
   10769      1226363 :         exp_loc = c_parser_peek_token (parser)->location;
   10770      1226363 :         op = c_parser_cast_expression (parser, NULL);
   10771      1226363 :         finish = op.get_finish ();
   10772      1226363 :         op = convert_lvalue_to_rvalue (exp_loc, op, true, true);
   10773      1226363 :         location_t combined_loc = make_location (op_loc, op_loc, finish);
   10774      1226363 :         ret.value = build_indirect_ref (combined_loc, op.value, RO_UNARY_STAR);
   10775      1226363 :         ret.src_range.m_start = op_loc;
   10776      1226363 :         ret.src_range.m_finish = finish;
   10777      1226363 :         ret.m_decimal = 0;
   10778      1226363 :         return ret;
   10779              :       }
   10780        28812 :     case CPP_PLUS:
   10781        28812 :       if (!c_dialect_objc () && !in_system_header_at (input_location))
   10782        28810 :         warning_at (op_loc,
   10783        28810 :                     OPT_Wtraditional,
   10784              :                     "traditional C rejects the unary plus operator");
   10785        28812 :       c_parser_consume_token (parser);
   10786        28812 :       exp_loc = c_parser_peek_token (parser)->location;
   10787        28812 :       op = c_parser_cast_expression (parser, NULL);
   10788        28812 :       op = convert_lvalue_to_rvalue (exp_loc, op, true, true);
   10789        28812 :       return parser_build_unary_op (op_loc, CONVERT_EXPR, op);
   10790      7026099 :     case CPP_MINUS:
   10791      7026099 :       c_parser_consume_token (parser);
   10792      7026099 :       exp_loc = c_parser_peek_token (parser)->location;
   10793      7026099 :       op = c_parser_cast_expression (parser, NULL);
   10794      7026099 :       op = convert_lvalue_to_rvalue (exp_loc, op, true, true);
   10795      7026099 :       return parser_build_unary_op (op_loc, NEGATE_EXPR, op);
   10796       300000 :     case CPP_COMPL:
   10797       300000 :       c_parser_consume_token (parser);
   10798       300000 :       exp_loc = c_parser_peek_token (parser)->location;
   10799       300000 :       op = c_parser_cast_expression (parser, NULL);
   10800       300000 :       op = convert_lvalue_to_rvalue (exp_loc, op, true, true);
   10801       300000 :       return parser_build_unary_op (op_loc, BIT_NOT_EXPR, op);
   10802       379727 :     case CPP_NOT:
   10803       379727 :       c_parser_consume_token (parser);
   10804       379727 :       exp_loc = c_parser_peek_token (parser)->location;
   10805       379727 :       op = c_parser_cast_expression (parser, NULL);
   10806       379727 :       op = convert_lvalue_to_rvalue (exp_loc, op, true, true);
   10807       379727 :       return parser_build_unary_op (op_loc, TRUTH_NOT_EXPR, op);
   10808         2021 :     case CPP_AND_AND:
   10809              :       /* Refer to the address of a label as a pointer.  */
   10810         2021 :       c_parser_consume_token (parser);
   10811         2021 :       if (c_parser_next_token_is (parser, CPP_NAME))
   10812              :         {
   10813         4028 :           ret.value = finish_label_address_expr
   10814         2014 :             (c_parser_peek_token (parser)->value, op_loc);
   10815         2014 :           set_c_expr_source_range (&ret, op_loc,
   10816              :                                    c_parser_peek_token (parser)->get_finish ());
   10817         2014 :           c_parser_consume_token (parser);
   10818              :         }
   10819              :       else
   10820              :         {
   10821            7 :           c_parser_error (parser, "expected identifier");
   10822            7 :           ret.set_error ();
   10823              :         }
   10824         2021 :       return ret;
   10825      2931040 :     case CPP_KEYWORD:
   10826      2931040 :       {
   10827      2931040 :         enum rid rid = c_parser_peek_token (parser)->keyword;
   10828      2931040 :         switch (rid)
   10829              :           {
   10830       651050 :           case RID_COUNTOF:
   10831       651050 :           case RID_SIZEOF:
   10832       651050 :             return c_parser_sizeof_or_countof_expression (parser, rid);
   10833        72316 :           case RID_ALIGNOF:
   10834        72316 :             return c_parser_alignof_expression (parser);
   10835          102 :           case RID_MAXOF:
   10836          102 :           case RID_MINOF:
   10837          102 :             return c_parser_maxof_or_minof_expression (parser, rid);
   10838          765 :           case RID_BUILTIN_HAS_ATTRIBUTE:
   10839          765 :             return c_parser_has_attribute_expression (parser);
   10840       466942 :           case RID_EXTENSION:
   10841       466942 :             c_parser_consume_token (parser);
   10842       466942 :             ext = disable_extension_diagnostics ();
   10843       466942 :             ret = c_parser_cast_expression (parser, NULL);
   10844       466942 :             restore_extension_diagnostics (ext);
   10845       466942 :             return ret;
   10846        38407 :           case RID_REALPART:
   10847        38407 :             c_parser_consume_token (parser);
   10848        38407 :             exp_loc = c_parser_peek_token (parser)->location;
   10849        38407 :             op = c_parser_cast_expression (parser, NULL);
   10850        38407 :             op = default_function_array_conversion (exp_loc, op);
   10851        38407 :             return parser_build_unary_op (op_loc, REALPART_EXPR, op);
   10852        40269 :           case RID_IMAGPART:
   10853        40269 :             c_parser_consume_token (parser);
   10854        40269 :             exp_loc = c_parser_peek_token (parser)->location;
   10855        40269 :             op = c_parser_cast_expression (parser, NULL);
   10856        40269 :             op = default_function_array_conversion (exp_loc, op);
   10857        40269 :             return parser_build_unary_op (op_loc, IMAGPART_EXPR, op);
   10858            7 :           case RID_TRANSACTION_ATOMIC:
   10859            7 :           case RID_TRANSACTION_RELAXED:
   10860            7 :             return c_parser_transaction_expression (parser, rid);
   10861          168 :           case RID_STATIC_ASSERT:
   10862          168 :             c_parser_static_assert_declaration_no_semi (parser);
   10863          168 :             pedwarn_c23 (op_loc, OPT_Wpedantic,
   10864              :                          "ISO C does not support static assertions in "
   10865              :                          "expressions before C2Y");
   10866          168 :             ret.value = void_node;
   10867          168 :             set_c_expr_source_range (&ret, op_loc, op_loc);
   10868          168 :             ret.m_decimal = 0;
   10869          168 :             return ret;
   10870      1661014 :           default:
   10871      1661014 :             return c_parser_postfix_expression (parser);
   10872              :           }
   10873              :       }
   10874    243020514 :     default:
   10875    243020514 :       return c_parser_postfix_expression (parser);
   10876              :     }
   10877              : }
   10878              : 
   10879              : /* Parse a sizeof or _Countof expression.  */
   10880              : 
   10881              : static struct c_expr
   10882       651050 : c_parser_sizeof_or_countof_expression (c_parser *parser, enum rid rid)
   10883              : {
   10884       651050 :   const char *op_name = (rid == RID_COUNTOF) ? "_Countof" : "sizeof";
   10885       651050 :   struct c_expr expr;
   10886       651050 :   struct c_expr result;
   10887       651050 :   location_t expr_loc;
   10888       651050 :   gcc_assert (c_parser_next_token_is_keyword (parser, rid));
   10889              : 
   10890       651050 :   location_t start;
   10891       651050 :   location_t finish = UNKNOWN_LOCATION;
   10892              : 
   10893       651050 :   start = c_parser_peek_token (parser)->location;
   10894              : 
   10895       651050 :   if (rid == RID_COUNTOF)
   10896           72 :     pedwarn_c23 (start, OPT_Wpedantic,
   10897              :                  "ISO C does not support %qs before C2Y", op_name);
   10898              : 
   10899       651050 :   c_parser_consume_token (parser);
   10900       651050 :   c_inhibit_evaluation_warnings++;
   10901       651050 :   if (rid == RID_COUNTOF)
   10902           72 :     in_countof++;
   10903              :   else
   10904       650978 :     in_sizeof++;
   10905       651050 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
   10906       651050 :       && c_token_starts_compound_literal (c_parser_peek_2nd_token (parser)))
   10907              :     {
   10908              :       /* Either sizeof ( type-name ) or sizeof unary-expression
   10909              :          starting with a compound literal.  */
   10910       334788 :       struct c_declspecs *scspecs;
   10911       334788 :       struct c_type_name *type_name;
   10912       334788 :       matching_parens parens;
   10913       334788 :       parens.consume_open (parser);
   10914       334788 :       expr_loc = c_parser_peek_token (parser)->location;
   10915       334788 :       scspecs = c_parser_compound_literal_scspecs (parser);
   10916       334788 :       type_name = c_parser_type_name (parser, true);
   10917       334788 :       parens.skip_until_found_close (parser);
   10918       334788 :       finish = parser->tokens_buf[0].location;
   10919       334788 :       if (type_name == NULL)
   10920              :         {
   10921              :           /* Let c_expr_sizeof_expr call pop_maybe_used and fill in c_expr
   10922              :              for parsing error; the parsing of the expression could have
   10923              :              called record_maybe_used_decl.  */
   10924            1 :           expr.set_error ();
   10925           27 :           goto Xof_expr;
   10926              :         }
   10927       334787 :       if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
   10928              :         {
   10929           26 :           expr = c_parser_postfix_expression_after_paren_type (parser, scspecs,
   10930              :                                                                type_name,
   10931              :                                                                expr_loc);
   10932           26 :           finish = expr.get_finish ();
   10933           26 :           goto Xof_expr;
   10934              :         }
   10935              :       /* sizeof ( type-name ).  */
   10936       334761 :       if (scspecs)
   10937            1 :         error_at (expr_loc, "storage class specifier in %qs", op_name);
   10938       334761 :       if (type_name->specs->alignas_p)
   10939            2 :         error_at (type_name->specs->locations[cdw_alignas],
   10940              :                   "alignment specified for type name in %qs", op_name);
   10941       334761 :       c_inhibit_evaluation_warnings--;
   10942       334761 :       if (rid == RID_COUNTOF)
   10943              :         {
   10944           18 :           in_countof--;
   10945           18 :           result = c_expr_countof_type (expr_loc, type_name);
   10946              :         }
   10947              :       else
   10948              :         {
   10949       334743 :           in_sizeof--;
   10950       334743 :           result = c_expr_sizeof_type (expr_loc, type_name);
   10951              :         }
   10952              :     }
   10953              :   else
   10954              :     {
   10955       316262 :       expr_loc = c_parser_peek_token (parser)->location;
   10956       316262 :       expr = c_parser_unary_expression (parser);
   10957       316262 :       finish = expr.get_finish ();
   10958       316289 :     Xof_expr:
   10959       316289 :       c_inhibit_evaluation_warnings--;
   10960       316289 :       if (rid == RID_COUNTOF)
   10961           54 :         in_countof--;
   10962              :       else
   10963       316235 :         in_sizeof--;
   10964       316289 :       mark_exp_read (expr.value);
   10965       316289 :       if (TREE_CODE (expr.value) == COMPONENT_REF
   10966       316289 :           && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
   10967            1 :         error_at (expr_loc, "%qs applied to a bit-field", op_name);
   10968       316289 :       if (rid == RID_COUNTOF)
   10969           54 :         result = c_expr_countof_expr (expr_loc, expr);
   10970              :       else
   10971       316235 :         result = c_expr_sizeof_expr (expr_loc, expr);
   10972              :     }
   10973       651050 :   if (finish == UNKNOWN_LOCATION)
   10974            1 :     finish = start;
   10975       651050 :   set_c_expr_source_range (&result, start, finish);
   10976       651050 :   return result;
   10977              : }
   10978              : 
   10979              : /* Parse an alignof expression.  */
   10980              : 
   10981              : static struct c_expr
   10982        72316 : c_parser_alignof_expression (c_parser *parser)
   10983              : {
   10984        72316 :   struct c_expr expr;
   10985        72316 :   location_t start_loc = c_parser_peek_token (parser)->location;
   10986        72316 :   location_t end_loc;
   10987        72316 :   tree alignof_spelling = c_parser_peek_token (parser)->value;
   10988        72316 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_ALIGNOF));
   10989        72316 :   bool is_c11_alignof = (strcmp (IDENTIFIER_POINTER (alignof_spelling),
   10990              :                                 "_Alignof") == 0
   10991        72316 :                          || strcmp (IDENTIFIER_POINTER (alignof_spelling),
   10992              :                                     "alignof") == 0);
   10993              :   /* A diagnostic is not required for the use of this identifier in
   10994              :      the implementation namespace; only diagnose it for the C11 or C23
   10995              :      spelling because of existing code using the other spellings.  */
   10996              :   if (is_c11_alignof)
   10997              :     {
   10998          234 :       if (flag_isoc99)
   10999          230 :         pedwarn_c99 (start_loc, OPT_Wpedantic, "ISO C99 does not support %qE",
   11000              :                      alignof_spelling);
   11001              :       else
   11002            4 :         pedwarn_c99 (start_loc, OPT_Wpedantic, "ISO C90 does not support %qE",
   11003              :                      alignof_spelling);
   11004              :     }
   11005        72316 :   c_parser_consume_token (parser);
   11006        72316 :   c_inhibit_evaluation_warnings++;
   11007        72316 :   in_alignof++;
   11008        72316 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
   11009        72316 :       && c_token_starts_compound_literal (c_parser_peek_2nd_token (parser)))
   11010              :     {
   11011              :       /* Either __alignof__ ( type-name ) or __alignof__
   11012              :          unary-expression starting with a compound literal.  */
   11013        31517 :       location_t loc;
   11014        31517 :       struct c_declspecs *scspecs;
   11015        31517 :       struct c_type_name *type_name;
   11016        31517 :       struct c_expr ret;
   11017        31517 :       matching_parens parens;
   11018        31517 :       parens.consume_open (parser);
   11019        31517 :       loc = c_parser_peek_token (parser)->location;
   11020        31517 :       scspecs = c_parser_compound_literal_scspecs (parser);
   11021        31517 :       type_name = c_parser_type_name (parser, true);
   11022        31517 :       end_loc = c_parser_peek_token (parser)->location;
   11023        31517 :       parens.skip_until_found_close (parser);
   11024        31517 :       if (type_name == NULL)
   11025              :         {
   11026            0 :           struct c_expr ret;
   11027            0 :           c_inhibit_evaluation_warnings--;
   11028            0 :           in_alignof--;
   11029            0 :           ret.set_error ();
   11030            0 :           ret.original_code = ERROR_MARK;
   11031            0 :           ret.original_type = NULL;
   11032        31515 :           return ret;
   11033              :         }
   11034        31517 :       if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
   11035              :         {
   11036            2 :           expr = c_parser_postfix_expression_after_paren_type (parser, scspecs,
   11037              :                                                                type_name,
   11038              :                                                                loc);
   11039            2 :           goto alignof_expr;
   11040              :         }
   11041              :       /* alignof ( type-name ).  */
   11042        31515 :       if (scspecs)
   11043            1 :         error_at (loc, "storage class specifier in %qE", alignof_spelling);
   11044        31515 :       if (type_name->specs->alignas_p)
   11045            1 :         error_at (type_name->specs->locations[cdw_alignas],
   11046              :                   "alignment specified for type name in %qE",
   11047              :                   alignof_spelling);
   11048        31515 :       c_inhibit_evaluation_warnings--;
   11049        31515 :       in_alignof--;
   11050        31515 :       ret.value = c_sizeof_or_alignof_type (loc, groktypename (type_name,
   11051              :                                                                NULL, NULL),
   11052              :                                             false, is_c11_alignof, 1);
   11053        31515 :       ret.original_code = ERROR_MARK;
   11054        31515 :       ret.original_type = NULL;
   11055        31515 :       set_c_expr_source_range (&ret, start_loc, end_loc);
   11056        31515 :       ret.m_decimal = 0;
   11057        31515 :       return ret;
   11058              :     }
   11059              :   else
   11060              :     {
   11061        40799 :       struct c_expr ret;
   11062        40799 :       expr = c_parser_unary_expression (parser);
   11063        40799 :       end_loc = expr.src_range.m_finish;
   11064        40801 :     alignof_expr:
   11065        40801 :       mark_exp_read (expr.value);
   11066        40801 :       c_inhibit_evaluation_warnings--;
   11067        40801 :       in_alignof--;
   11068        40801 :       if (is_c11_alignof)
   11069           36 :         pedwarn (start_loc,
   11070           36 :                  OPT_Wpedantic, "ISO C does not allow %<%E (expression)%>",
   11071              :                  alignof_spelling);
   11072        40801 :       ret.value = c_alignof_expr (start_loc, expr.value);
   11073        40801 :       ret.original_code = ERROR_MARK;
   11074        40801 :       ret.original_type = NULL;
   11075        40801 :       set_c_expr_source_range (&ret, start_loc, end_loc);
   11076        40801 :       ret.m_decimal = 0;
   11077        40801 :       return ret;
   11078              :     }
   11079              : }
   11080              : 
   11081              : /* Parse a _Maxof or _Minof expression.  */
   11082              : 
   11083              : static struct c_expr
   11084          102 : c_parser_maxof_or_minof_expression (c_parser *parser, enum rid rid)
   11085              : {
   11086          102 :   const char *op_name = (rid == RID_MAXOF) ? "_Maxof" : "_Minof";
   11087          102 :   struct c_expr result;
   11088          102 :   location_t expr_loc;
   11089          102 :   struct c_type_name *type_name;
   11090          102 :   matching_parens parens;
   11091          102 :   gcc_assert (c_parser_next_token_is_keyword (parser, rid));
   11092              : 
   11093          102 :   location_t start;
   11094          102 :   location_t finish = UNKNOWN_LOCATION;
   11095              : 
   11096          102 :   start = c_parser_peek_token (parser)->location;
   11097              : 
   11098          102 :   pedwarn (start, OPT_Wpedantic, "ISO C does not support %qs", op_name);
   11099              : 
   11100          102 :   c_parser_consume_token (parser);
   11101          102 :   c_inhibit_evaluation_warnings++;
   11102          102 :   if (!c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   11103              :     {
   11104            2 :       c_parser_error (parser, "expected %<(%>");
   11105            2 :       goto fail;
   11106              :     }
   11107          100 :   parens.consume_open (parser);
   11108          100 :   expr_loc = c_parser_peek_token (parser)->location;
   11109          100 :   if (!c_token_starts_typename (c_parser_peek_token (parser)))
   11110              :     {
   11111            6 :       error_at (expr_loc, "invalid application of %qs to something not a type", op_name);
   11112            6 :       parens.skip_until_found_close (parser);
   11113            6 :       goto fail;
   11114              :     }
   11115           94 :   type_name = c_parser_type_name (parser, true);
   11116           94 :   if (type_name == NULL)
   11117              :     {
   11118              :       // c_parser_type_name() has already diagnosed the error.
   11119            2 :       parens.skip_until_found_close (parser);
   11120            2 :       goto fail;
   11121              :     }
   11122           92 :   parens.skip_until_found_close (parser);
   11123           92 :   finish = parser->tokens_buf[0].location;
   11124           92 :   if (type_name->specs->alignas_p)
   11125            2 :     error_at (type_name->specs->locations[cdw_alignas],
   11126              :               "alignment specified for type name in %qs", op_name);
   11127           92 :   c_inhibit_evaluation_warnings--;
   11128           92 :   if (rid == RID_MAXOF)
   11129           46 :     result = c_expr_maxof_type (expr_loc, type_name);
   11130              :   else
   11131           46 :     result = c_expr_minof_type (expr_loc, type_name);
   11132           92 :   set_c_expr_source_range (&result, start, finish);
   11133           92 :   return result;
   11134           10 : fail:
   11135           10 :   c_inhibit_evaluation_warnings--;
   11136           10 :   result.set_error ();
   11137           10 :   result.original_code = ERROR_MARK;
   11138           10 :   result.original_type = NULL;
   11139           10 :   return result;
   11140              : }
   11141              : 
   11142              : /* Parse the __builtin_has_attribute ([expr|type], attribute-spec)
   11143              :    expression.  */
   11144              : 
   11145              : static struct c_expr
   11146          765 : c_parser_has_attribute_expression (c_parser *parser)
   11147              : {
   11148          765 :   gcc_assert (c_parser_next_token_is_keyword (parser,
   11149              :                                               RID_BUILTIN_HAS_ATTRIBUTE));
   11150          765 :   location_t start = c_parser_peek_token (parser)->location;
   11151          765 :   c_parser_consume_token (parser);
   11152              : 
   11153          765 :   c_inhibit_evaluation_warnings++;
   11154              : 
   11155          765 :   matching_parens parens;
   11156          765 :   if (!parens.require_open (parser))
   11157              :     {
   11158            0 :       c_inhibit_evaluation_warnings--;
   11159            0 :       in_typeof--;
   11160              : 
   11161            0 :       struct c_expr result;
   11162            0 :       result.set_error ();
   11163            0 :       result.original_code = ERROR_MARK;
   11164            0 :       result.original_type = NULL;
   11165            0 :       return result;
   11166              :     }
   11167              : 
   11168              :   /* Treat the type argument the same way as in typeof for the purposes
   11169              :      of warnings.  FIXME: Generalize this so the warning refers to
   11170              :      __builtin_has_attribute rather than typeof.  */
   11171          765 :   in_typeof++;
   11172              : 
   11173              :   /* The first operand: one of DECL, EXPR, or TYPE.  */
   11174          765 :   tree oper = NULL_TREE;
   11175          765 :   if (c_parser_next_tokens_start_typename (parser, cla_prefer_id))
   11176              :     {
   11177          148 :       struct c_type_name *tname = c_parser_type_name (parser);
   11178          148 :       in_typeof--;
   11179          148 :       if (tname)
   11180              :         {
   11181          148 :           oper = groktypename (tname, NULL, NULL);
   11182          148 :           pop_maybe_used (c_type_variably_modified_p (oper));
   11183              :         }
   11184              :     }
   11185              :   else
   11186              :     {
   11187          617 :       struct c_expr cexpr = c_parser_expr_no_commas (parser, NULL);
   11188          617 :       c_inhibit_evaluation_warnings--;
   11189          617 :       in_typeof--;
   11190          617 :       if (cexpr.value != error_mark_node)
   11191              :         {
   11192          614 :           mark_exp_read (cexpr.value);
   11193          614 :           oper = cexpr.value;
   11194          614 :           tree etype = TREE_TYPE (oper);
   11195          614 :           bool was_vm = c_type_variably_modified_p (etype);
   11196              :           /* This is returned with the type so that when the type is
   11197              :              evaluated, this can be evaluated.  */
   11198          614 :           if (was_vm)
   11199            0 :             oper = c_fully_fold (oper, false, NULL);
   11200          614 :           pop_maybe_used (was_vm);
   11201              :         }
   11202              :     }
   11203              : 
   11204          765 :   struct c_expr result;
   11205          765 :   result.original_code = ERROR_MARK;
   11206          765 :   result.original_type = NULL;
   11207              : 
   11208          765 :   if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>"))
   11209              :     {
   11210              :       /* Consume the closing parenthesis if that's the next token
   11211              :          in the likely case the built-in was invoked with fewer
   11212              :          than two arguments.  */
   11213            4 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   11214            4 :         c_parser_consume_token (parser);
   11215            4 :       c_inhibit_evaluation_warnings--;
   11216            4 :       result.set_error ();
   11217            4 :       return result;
   11218              :     }
   11219              : 
   11220          761 :   bool save_translate_strings_p = parser->translate_strings_p;
   11221              : 
   11222          761 :   location_t atloc = c_parser_peek_token (parser)->location;
   11223              :   /* Parse a single attribute.  Require no leading comma and do not
   11224              :      allow empty attributes.  */
   11225          761 :   tree attr = c_parser_gnu_attribute (parser, NULL_TREE, false, false);
   11226              : 
   11227          761 :   parser->translate_strings_p = save_translate_strings_p;
   11228              : 
   11229          761 :   location_t finish = c_parser_peek_token (parser)->location;
   11230          761 :   if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   11231          758 :     c_parser_consume_token (parser);
   11232              :   else
   11233              :     {
   11234            3 :       c_parser_error (parser, "expected identifier");
   11235            3 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   11236              : 
   11237            3 :       result.set_error ();
   11238            3 :       return result;
   11239              :     }
   11240              : 
   11241          758 :   if (!attr)
   11242              :     {
   11243            0 :       error_at (atloc, "expected identifier");
   11244            0 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   11245              :                                  "expected %<)%>");
   11246            0 :       result.set_error ();
   11247            0 :       return result;
   11248              :     }
   11249              : 
   11250          758 :   result.original_code = INTEGER_CST;
   11251          758 :   result.original_type = boolean_type_node;
   11252              : 
   11253          758 :   if (has_attribute (atloc, oper, attr, default_conversion))
   11254          296 :     result.value = boolean_true_node;
   11255              :   else
   11256          462 :     result.value =  boolean_false_node;
   11257              : 
   11258          758 :   set_c_expr_source_range (&result, start, finish);
   11259          758 :   result.m_decimal = 0;
   11260          758 :   return result;
   11261              : }
   11262              : 
   11263              : /* Helper function to read arguments of builtins which are interfaces
   11264              :    for the middle-end nodes like COMPLEX_EXPR, VEC_PERM_EXPR and
   11265              :    others.  The name of the builtin is passed using BNAME parameter.
   11266              :    Function returns true if there were no errors while parsing and
   11267              :    stores the arguments in CEXPR_LIST.  If it returns true,
   11268              :    *OUT_CLOSE_PAREN_LOC is written to with the location of the closing
   11269              :    parenthesis.  */
   11270              : static bool
   11271      1583232 : c_parser_get_builtin_args (c_parser *parser, const char *bname,
   11272              :                            vec<c_expr_t, va_gc> **ret_cexpr_list,
   11273              :                            bool choose_expr_p,
   11274              :                            location_t *out_close_paren_loc)
   11275              : {
   11276      1583232 :   location_t loc = c_parser_peek_token (parser)->location;
   11277      1583232 :   vec<c_expr_t, va_gc> *cexpr_list;
   11278      1583232 :   c_expr_t expr;
   11279      1583232 :   bool saved_force_folding_builtin_constant_p;
   11280              : 
   11281      1583232 :   *ret_cexpr_list = NULL;
   11282      1583232 :   if (c_parser_next_token_is_not (parser, CPP_OPEN_PAREN))
   11283              :     {
   11284            1 :       error_at (loc, "cannot take address of %qs", bname);
   11285            1 :       return false;
   11286              :     }
   11287              : 
   11288      1583231 :   c_parser_consume_token (parser);
   11289              : 
   11290      1583231 :   if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   11291              :     {
   11292           26 :       *out_close_paren_loc = c_parser_peek_token (parser)->location;
   11293           26 :       c_parser_consume_token (parser);
   11294           26 :       return true;
   11295              :     }
   11296              : 
   11297      1583205 :   saved_force_folding_builtin_constant_p
   11298      1583205 :     = force_folding_builtin_constant_p;
   11299      1583205 :   force_folding_builtin_constant_p |= choose_expr_p;
   11300      1583205 :   expr = c_parser_expr_no_commas (parser, NULL);
   11301      1583205 :   force_folding_builtin_constant_p
   11302      1583205 :     = saved_force_folding_builtin_constant_p;
   11303      1583205 :   vec_alloc (cexpr_list, 1);
   11304      1583205 :   vec_safe_push (cexpr_list, expr);
   11305     18518887 :   while (c_parser_next_token_is (parser, CPP_COMMA))
   11306              :     {
   11307     15352477 :       c_parser_consume_token (parser);
   11308     15352477 :       if (c_parser_next_token_is (parser, CPP_EMBED))
   11309              :         {
   11310            2 :           c_token *embed = c_parser_peek_token (parser);
   11311            2 :           tree value = embed->value;
   11312            2 :           expr.original_code = INTEGER_CST;
   11313            2 :           expr.original_type = integer_type_node;
   11314            2 :           expr.value = NULL_TREE;
   11315            2 :           set_c_expr_source_range (&expr, embed->get_range ());
   11316            2 :           expr.m_decimal = 0;
   11317          510 :           for (unsigned int i = 0; i < (unsigned) RAW_DATA_LENGTH (value); i++)
   11318              :             {
   11319         1016 :               expr.value = build_int_cst (integer_type_node,
   11320          508 :                                           RAW_DATA_UCHAR_ELT (value, i));
   11321          508 :               vec_safe_push (cexpr_list, expr);
   11322              :             }
   11323            2 :           c_parser_consume_token (parser);
   11324            2 :           continue;
   11325            2 :         }
   11326     15352475 :       expr = c_parser_expr_no_commas (parser, NULL);
   11327     15352475 :       vec_safe_push (cexpr_list, expr);
   11328              :     }
   11329              : 
   11330      1583205 :   *out_close_paren_loc = c_parser_peek_token (parser)->location;
   11331      1583205 :   if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
   11332              :     return false;
   11333              : 
   11334      1583205 :   *ret_cexpr_list = cexpr_list;
   11335      1583205 :   return true;
   11336              : }
   11337              : 
   11338              : /* This represents a single generic-association.  */
   11339              : 
   11340              : struct c_generic_association
   11341              : {
   11342              :   /* The location of the starting token of the type.  */
   11343              :   location_t type_location;
   11344              :   /* The association's type, or NULL_TREE for 'default'.  */
   11345              :   tree type;
   11346              :   /* The association's expression.  */
   11347              :   struct c_expr expression;
   11348              : };
   11349              : 
   11350              : /* Parse a generic-selection.  (C11 6.5.1.1).
   11351              : 
   11352              :    generic-selection:
   11353              :      _Generic ( generic-controlling-operand , generic-assoc-list )
   11354              : 
   11355              :   generic-controlling-operand:
   11356              :     assignment-expression
   11357              :     type-name
   11358              : 
   11359              :   (The use of a type-name is new in C2Y.)
   11360              : 
   11361              :    generic-assoc-list:
   11362              :      generic-association
   11363              :      generic-assoc-list , generic-association
   11364              : 
   11365              :    generic-association:
   11366              :      type-name : assignment-expression
   11367              :      default : assignment-expression
   11368              : */
   11369              : 
   11370              : static struct c_expr
   11371         1427 : c_parser_generic_selection (c_parser *parser)
   11372              : {
   11373         1427 :   struct c_expr selector, error_expr;
   11374         1427 :   tree selector_type;
   11375         1427 :   struct c_generic_association matched_assoc;
   11376         1427 :   int match_found = -1;
   11377         1427 :   location_t generic_loc, selector_loc;
   11378              : 
   11379         1427 :   error_expr.original_code = ERROR_MARK;
   11380         1427 :   error_expr.original_type = NULL;
   11381         1427 :   error_expr.set_error ();
   11382         1427 :   matched_assoc.type_location = UNKNOWN_LOCATION;
   11383         1427 :   matched_assoc.type = NULL_TREE;
   11384         1427 :   matched_assoc.expression = error_expr;
   11385              : 
   11386         1427 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_GENERIC));
   11387         1427 :   generic_loc = c_parser_peek_token (parser)->location;
   11388         1427 :   c_parser_consume_token (parser);
   11389         1427 :   if (flag_isoc99)
   11390         1425 :     pedwarn_c99 (generic_loc, OPT_Wpedantic,
   11391              :                  "ISO C99 does not support %<_Generic%>");
   11392              :   else
   11393            2 :     pedwarn_c99 (generic_loc, OPT_Wpedantic,
   11394              :                  "ISO C90 does not support %<_Generic%>");
   11395              : 
   11396         1427 :   matching_parens parens;
   11397         1427 :   if (!parens.require_open (parser))
   11398            0 :     return error_expr;
   11399              : 
   11400         1427 :   selector_loc = c_parser_peek_token (parser)->location;
   11401         1427 :   if (c_parser_next_tokens_start_typename (parser, cla_prefer_id))
   11402              :     {
   11403           38 :       c_inhibit_evaluation_warnings++;
   11404           38 :       pedwarn_c23 (selector_loc, OPT_Wpedantic,
   11405              :                    "ISO C does not support use of type name as %<_Generic%> "
   11406              :                    "controlling operand before C2Y");
   11407           38 :       struct c_type_name *type = c_parser_type_name (parser);
   11408           38 :       if (type)
   11409           37 :         selector_type = groktypename (type, NULL, NULL);
   11410           38 :       c_inhibit_evaluation_warnings--;
   11411           38 :       if (!type)
   11412              :         {
   11413            1 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   11414            1 :           return error_expr;
   11415              :         }
   11416              :     }
   11417              :   else
   11418              :     {
   11419         1389 :       c_inhibit_evaluation_warnings++;
   11420         1389 :       in_generic++;
   11421         1389 :       selector = c_parser_expr_no_commas (parser, NULL);
   11422         1389 :       selector = default_function_array_conversion (selector_loc, selector);
   11423         1389 :       c_inhibit_evaluation_warnings--;
   11424         1389 :       in_generic--;
   11425         1389 :       pop_maybe_used (!flag_isoc23);
   11426              : 
   11427         1389 :       if (selector.value == error_mark_node)
   11428              :         {
   11429            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   11430            0 :           return selector;
   11431              :         }
   11432         1389 :       mark_exp_read (selector.value);
   11433         1389 :       selector_type = TREE_TYPE (selector.value);
   11434              :       /* In ISO C terms, rvalues (including the controlling expression
   11435              :          of _Generic) do not have qualified types.  */
   11436         1389 :       if (TREE_CODE (selector_type) != ARRAY_TYPE)
   11437         1389 :         selector_type = TYPE_MAIN_VARIANT (selector_type);
   11438              :       /* In ISO C terms, _Noreturn is not part of the type of expressions
   11439              :          such as &abort, but in GCC it is represented internally as a type
   11440              :          qualifier.  */
   11441          578 :       if (FUNCTION_POINTER_TYPE_P (selector_type)
   11442         1393 :           && TYPE_QUALS (TREE_TYPE (selector_type)) != TYPE_UNQUALIFIED)
   11443            1 :         selector_type
   11444            1 :           = c_build_pointer_type (TYPE_MAIN_VARIANT (TREE_TYPE (selector_type)));
   11445              :     }
   11446              : 
   11447         1426 :   if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>"))
   11448              :     {
   11449            0 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   11450            0 :       return error_expr;
   11451              :     }
   11452              : 
   11453         1426 :   auto_vec<c_generic_association> associations;
   11454         1426 :   struct maybe_used_decl *maybe_used_default = NULL;
   11455         4094 :   while (1)
   11456              :     {
   11457         2760 :       struct c_generic_association assoc, *iter;
   11458         2760 :       unsigned int ix;
   11459         2760 :       c_token *token = c_parser_peek_token (parser);
   11460              : 
   11461         2760 :       assoc.type_location = token->location;
   11462         2760 :       if (token->type == CPP_KEYWORD && token->keyword == RID_DEFAULT)
   11463              :         {
   11464         1217 :           c_parser_consume_token (parser);
   11465         1217 :           assoc.type = NULL_TREE;
   11466              :         }
   11467              :       else
   11468              :         {
   11469         1543 :           struct c_type_name *type_name;
   11470              : 
   11471         1543 :           type_name = c_parser_type_name (parser);
   11472         1543 :           if (type_name == NULL)
   11473              :             {
   11474            1 :               c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   11475            1 :               return error_expr;
   11476              :             }
   11477         1542 :           assoc.type = grokgenassoc (type_name);
   11478         1542 :           if (assoc.type == error_mark_node)
   11479              :             {
   11480            0 :               c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   11481            0 :               return error_expr;
   11482              :             }
   11483              : 
   11484         1542 :           if (TREE_CODE (assoc.type) == FUNCTION_TYPE)
   11485            9 :             pedwarn_c23 (assoc.type_location, OPT_Wpedantic,
   11486              :                          "ISO C does not support %<_Generic%> association with "
   11487              :                          "function type before C2Y");
   11488         1533 :           else if (!COMPLETE_TYPE_P (assoc.type))
   11489           13 :             pedwarn_c23 (assoc.type_location, OPT_Wpedantic,
   11490              :                          "ISO C does not support %<_Generic%> association with "
   11491              :                          "incomplete type before C2Y");
   11492              : 
   11493         1542 :           if (c_type_variably_modified_p (assoc.type))
   11494            9 :             pedwarn_c23 (assoc.type_location, OPT_Wpedantic,
   11495              :                          "ISO C does not support %<_Generic%> association with "
   11496              :                          "variably-modified type before C2Y");
   11497              :         }
   11498              : 
   11499         2759 :       if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   11500              :         {
   11501            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   11502            0 :           return error_expr;
   11503              :         }
   11504              : 
   11505         2759 :       bool match = assoc.type == NULL_TREE
   11506         2759 :                    || comptypes (assoc.type, selector_type);
   11507              : 
   11508         2364 :       if (!match || matched_assoc.type != NULL_TREE)
   11509          844 :         c_inhibit_evaluation_warnings++;
   11510         2759 :       in_generic++;
   11511              : 
   11512         2759 :       assoc.expression = c_parser_expr_no_commas (parser, NULL);
   11513              : 
   11514         2759 :       if (!match || matched_assoc.type != NULL_TREE)
   11515          844 :         c_inhibit_evaluation_warnings--;
   11516         2759 :       in_generic--;
   11517         2759 :       if (!match)
   11518          395 :         pop_maybe_used (!flag_isoc23);
   11519         2364 :       else if (assoc.type == NULL_TREE)
   11520         1217 :         maybe_used_default = save_maybe_used ();
   11521              :       else
   11522         1147 :         pop_maybe_used (true);
   11523              : 
   11524         2759 :       if (assoc.expression.value == error_mark_node)
   11525              :         {
   11526            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   11527            0 :           return error_expr;
   11528              :         }
   11529              : 
   11530         4208 :       for (ix = 0; associations.iterate (ix, &iter); ++ix)
   11531              :         {
   11532         1449 :           if (assoc.type == NULL_TREE)
   11533              :             {
   11534          726 :               if (iter->type == NULL_TREE)
   11535              :                 {
   11536            1 :                   error_at (assoc.type_location,
   11537              :                             "duplicate %<default%> case in %<_Generic%>");
   11538            1 :                   inform (iter->type_location, "original %<default%> is here");
   11539              :                 }
   11540              :             }
   11541          723 :           else if (iter->type != NULL_TREE)
   11542              :             {
   11543          184 :               if (comptypes (assoc.type, iter->type))
   11544              :                 {
   11545            1 :                   error_at (assoc.type_location,
   11546              :                             "%<_Generic%> specifies two compatible types");
   11547            1 :                   inform (iter->type_location, "compatible type is here");
   11548              :                 }
   11549              :             }
   11550              :         }
   11551              : 
   11552         2759 :       if (assoc.type == NULL_TREE)
   11553              :         {
   11554         1217 :           if (match_found < 0)
   11555              :             {
   11556          767 :               matched_assoc = assoc;
   11557         1027 :               match_found = associations.length ();
   11558              :             }
   11559              :         }
   11560         1542 :       else if (match)
   11561              :         {
   11562         1147 :           if (match_found < 0 || matched_assoc.type == NULL_TREE)
   11563              :             {
   11564         1147 :               matched_assoc = assoc;
   11565         1681 :               match_found = associations.length ();
   11566              :             }
   11567              :           else
   11568              :             {
   11569            0 :               error_at (assoc.type_location,
   11570              :                         "%<_Generic%> selector matches multiple associations");
   11571            0 :               inform (matched_assoc.type_location,
   11572              :                       "other match is here");
   11573              :             }
   11574              :         }
   11575              : 
   11576         2759 :       associations.safe_push (assoc);
   11577              : 
   11578         2759 :       if (c_parser_peek_token (parser)->type != CPP_COMMA)
   11579              :         break;
   11580         1334 :       c_parser_consume_token (parser);
   11581         1334 :     }
   11582              : 
   11583         1425 :   if (match_found >= 0 && matched_assoc.type == NULL_TREE)
   11584              :     {
   11585              :       /* Declarations referenced in the default association are used.  */
   11586          275 :       restore_maybe_used (maybe_used_default);
   11587          275 :       pop_maybe_used (true);
   11588              :     }
   11589         1150 :   else if (maybe_used_default)
   11590              :     {
   11591              :       /* Declarations referenced in the default association are not used, but
   11592              :          are treated as used before C23.  */
   11593            8 :       restore_maybe_used (maybe_used_default);
   11594            8 :       pop_maybe_used (!flag_isoc23);
   11595              :     }
   11596              : 
   11597         1425 :   unsigned int ix;
   11598         1425 :   struct c_generic_association *iter;
   11599         4183 :   FOR_EACH_VEC_ELT (associations, ix, iter)
   11600         2758 :     if (ix != (unsigned) match_found)
   11601         1337 :       mark_exp_read (iter->expression.value);
   11602              : 
   11603         1425 :   if (!parens.require_close (parser))
   11604              :     {
   11605            0 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   11606            0 :       return error_expr;
   11607              :     }
   11608              : 
   11609         1425 :   if (match_found < 0)
   11610              :     {
   11611            4 :       error_at (selector_loc, "%<_Generic%> selector of type %qT is not "
   11612              :                 "compatible with any association",
   11613              :                 selector_type);
   11614            4 :       return error_expr;
   11615              :     }
   11616              : 
   11617         1421 :   return matched_assoc.expression;
   11618         1426 : }
   11619              : 
   11620              : /* Check the validity of a function pointer argument *EXPR (argument
   11621              :    position POS) to __builtin_tgmath.  Return the number of function
   11622              :    arguments if possibly valid; return 0 having reported an error if
   11623              :    not valid.  */
   11624              : 
   11625              : static unsigned int
   11626         1755 : check_tgmath_function (c_expr *expr, unsigned int pos)
   11627              : {
   11628         1755 :   tree type = TREE_TYPE (expr->value);
   11629         1755 :   if (!FUNCTION_POINTER_TYPE_P (type))
   11630              :     {
   11631            2 :       error_at (expr->get_location (),
   11632              :                 "argument %u of %<__builtin_tgmath%> is not a function pointer",
   11633              :                 pos);
   11634            2 :       return 0;
   11635              :     }
   11636         1753 :   type = TREE_TYPE (type);
   11637         1753 :   if (!prototype_p (type))
   11638              :     {
   11639            2 :       error_at (expr->get_location (),
   11640              :                 "argument %u of %<__builtin_tgmath%> is unprototyped", pos);
   11641            2 :       return 0;
   11642              :     }
   11643         1751 :   if (stdarg_p (type))
   11644              :     {
   11645            2 :       error_at (expr->get_location (),
   11646              :                 "argument %u of %<__builtin_tgmath%> has variable arguments",
   11647              :                 pos);
   11648            2 :       return 0;
   11649              :     }
   11650         1749 :   unsigned int nargs = 0;
   11651         1749 :   function_args_iterator iter;
   11652         1749 :   tree t;
   11653         4176 :   FOREACH_FUNCTION_ARGS (type, t, iter)
   11654              :     {
   11655         4176 :       if (t == void_type_node)
   11656              :         break;
   11657         2427 :       nargs++;
   11658              :     }
   11659         1749 :   if (nargs == 0)
   11660              :     {
   11661            2 :       error_at (expr->get_location (),
   11662              :                 "argument %u of %<__builtin_tgmath%> has no arguments", pos);
   11663            2 :       return 0;
   11664              :     }
   11665              :   return nargs;
   11666              : }
   11667              : 
   11668              : /* Ways in which a parameter or return value of a type-generic macro
   11669              :    may vary between the different functions the macro may call.  */
   11670              : enum tgmath_parm_kind
   11671              :   {
   11672              :     tgmath_fixed, tgmath_real, tgmath_complex
   11673              :   };
   11674              : 
   11675              : /* Helper function for c_parser_postfix_expression.  Parse predefined
   11676              :    identifiers.  */
   11677              : 
   11678              : static struct c_expr
   11679        13565 : c_parser_predefined_identifier (c_parser *parser)
   11680              : {
   11681        13565 :   location_t loc = c_parser_peek_token (parser)->location;
   11682        13565 :   switch (c_parser_peek_token (parser)->keyword)
   11683              :     {
   11684          717 :     case RID_FUNCTION_NAME:
   11685          717 :       pedwarn (loc, OPT_Wpedantic, "ISO C does not support %qs predefined "
   11686              :                "identifier", "__FUNCTION__");
   11687          717 :       break;
   11688         6258 :     case RID_PRETTY_FUNCTION_NAME:
   11689         6258 :       pedwarn (loc, OPT_Wpedantic, "ISO C does not support %qs predefined "
   11690              :                "identifier", "__PRETTY_FUNCTION__");
   11691         6258 :       break;
   11692         6590 :     case RID_C99_FUNCTION_NAME:
   11693         6590 :       pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not support "
   11694              :                    "%<__func__%> predefined identifier");
   11695         6590 :       break;
   11696            0 :     default:
   11697            0 :       gcc_unreachable ();
   11698              :     }
   11699              : 
   11700        13565 :   struct c_expr expr;
   11701        13565 :   expr.original_code = ERROR_MARK;
   11702        13565 :   expr.original_type = NULL;
   11703        13565 :   expr.value = fname_decl (loc, c_parser_peek_token (parser)->keyword,
   11704        13565 :                            c_parser_peek_token (parser)->value);
   11705        13565 :   set_c_expr_source_range (&expr, loc, loc);
   11706        13565 :   expr.m_decimal = 0;
   11707        13565 :   c_parser_consume_token (parser);
   11708        13565 :   return expr;
   11709              : }
   11710              : 
   11711              : /* Check whether the REF has an counted-by object associated with it
   11712              :    through the "counted_by" attribute.  */
   11713              : 
   11714              : static bool
   11715           80 : has_counted_by_object (tree ref)
   11716              : {
   11717              :   /* Currently, there are two cases are valid:
   11718              :      A. when the ref is an indirect_ref to a call to the
   11719              :         .ACCESS_WITH_SIZE, return true. (this is for FAM)
   11720              :      B. when the ref is a call to .ACCESS_WITH_SIZE, return true.
   11721              :         (this is for pointer field inside a structure)
   11722              :      More cases can be included later when the counted_by attribute is
   11723              :      extended to other situations.  */
   11724           80 :   if ((TREE_CODE (ref) == INDIRECT_REF
   11725           25 :        && is_access_with_size_p (TREE_OPERAND (ref, 0)))
   11726           80 :       || is_access_with_size_p (ref))
   11727           50 :     return true;
   11728              :   return false;
   11729              : }
   11730              : 
   11731              : /* Get the reference to the counted-by object associated with the REF.  */
   11732              : 
   11733              : static tree
   11734           50 : get_counted_by_ref (tree ref)
   11735              : {
   11736              :   /* Currently, there are two cases are valid:
   11737              :      A. when the ref is an indirect_ref to a call to the
   11738              :         .ACCESS_WITH_SIZE, return true. (this is for FAM)
   11739              :      B. when the ref is a call to .ACCESS_WITH_SIZE, return true.
   11740              :         (this is for pointer field inside a structure)
   11741              :      More cases can be included later when the counted_by attribute is
   11742              :      extended to other situations.  */
   11743           50 :   if (TREE_CODE (ref) == INDIRECT_REF
   11744           50 :       && is_access_with_size_p (TREE_OPERAND (ref, 0)))
   11745           25 :     return CALL_EXPR_ARG (TREE_OPERAND (ref, 0), 1);
   11746           25 :   else if (is_access_with_size_p (ref))
   11747           25 :     return CALL_EXPR_ARG (ref, 1);
   11748              : 
   11749              :   return NULL_TREE;
   11750              : }
   11751              : 
   11752              : /* Parse a postfix expression (C90 6.3.1-6.3.2, C99 6.5.1-6.5.2,
   11753              :    C11 6.5.1-6.5.2).  Compound literals aren't handled here; callers have to
   11754              :    call c_parser_postfix_expression_after_paren_type on encountering them.
   11755              : 
   11756              :    postfix-expression:
   11757              :      primary-expression
   11758              :      postfix-expression [ expression ]
   11759              :      postfix-expression ( argument-expression-list[opt] )
   11760              :      postfix-expression . identifier
   11761              :      postfix-expression -> identifier
   11762              :      postfix-expression ++
   11763              :      postfix-expression --
   11764              :      ( storage-class-specifiers[opt] type-name ) { initializer-list[opt] }
   11765              :      ( storage-class-specifiers[opt] type-name ) { initializer-list , }
   11766              : 
   11767              :    argument-expression-list:
   11768              :      argument-expression
   11769              :      argument-expression-list , argument-expression
   11770              : 
   11771              :    primary-expression:
   11772              :      identifier
   11773              :      constant
   11774              :      string-literal
   11775              :      ( expression )
   11776              :      generic-selection
   11777              : 
   11778              :    GNU extensions:
   11779              : 
   11780              :    primary-expression:
   11781              :      __func__
   11782              :        (treated as a keyword in GNU C)
   11783              :      __FUNCTION__
   11784              :      __PRETTY_FUNCTION__
   11785              :      ( compound-statement )
   11786              :      __builtin_va_arg ( assignment-expression , type-name )
   11787              :      __builtin_offsetof ( type-name , offsetof-member-designator )
   11788              :      __builtin_choose_expr ( assignment-expression ,
   11789              :                              assignment-expression ,
   11790              :                              assignment-expression )
   11791              :      __builtin_types_compatible_p ( type-name , type-name )
   11792              :      __builtin_tgmath ( expr-list )
   11793              :      __builtin_complex ( assignment-expression , assignment-expression )
   11794              :      __builtin_shuffle ( assignment-expression , assignment-expression )
   11795              :      __builtin_shuffle ( assignment-expression ,
   11796              :                          assignment-expression ,
   11797              :                          assignment-expression, )
   11798              :      __builtin_convertvector ( assignment-expression , type-name )
   11799              :      __builtin_assoc_barrier ( assignment-expression )
   11800              : 
   11801              :    offsetof-member-designator:
   11802              :      identifier
   11803              :      offsetof-member-designator . identifier
   11804              :      offsetof-member-designator [ expression ]
   11805              : 
   11806              :    Objective-C:
   11807              : 
   11808              :    primary-expression:
   11809              :      [ objc-receiver objc-message-args ]
   11810              :      @selector ( objc-selector-arg )
   11811              :      @protocol ( identifier )
   11812              :      @encode ( type-name )
   11813              :      objc-string-literal
   11814              :      Classname . identifier
   11815              : */
   11816              : 
   11817              : static struct c_expr
   11818    244693465 : c_parser_postfix_expression (c_parser *parser)
   11819              : {
   11820    244693465 :   struct c_expr expr, e1;
   11821    244693465 :   struct c_type_name *t1, *t2;
   11822    244693465 :   location_t loc = c_parser_peek_token (parser)->location;
   11823    244693465 :   source_range tok_range = c_parser_peek_token (parser)->get_range ();
   11824    244693465 :   expr.original_code = ERROR_MARK;
   11825    244693465 :   expr.original_type = NULL;
   11826    244693465 :   expr.m_decimal = 0;
   11827    244693465 :   switch (c_parser_peek_token (parser)->type)
   11828              :     {
   11829     52879590 :     case CPP_NUMBER:
   11830     52879590 :       expr.value = c_parser_peek_token (parser)->value;
   11831     52879590 :       set_c_expr_source_range (&expr, tok_range);
   11832     52879590 :       loc = c_parser_peek_token (parser)->location;
   11833     52879590 :       expr.m_decimal = c_parser_peek_token (parser)->flags & DECIMAL_INT;
   11834     52879590 :       c_parser_consume_token (parser);
   11835     52879590 :       if (TREE_CODE (expr.value) == FIXED_CST
   11836     52879590 :           && !targetm.fixed_point_supported_p ())
   11837              :         {
   11838            6 :           error_at (loc, "fixed-point types not supported for this target");
   11839            6 :           expr.set_error ();
   11840              :         }
   11841              :       break;
   11842       119089 :     case CPP_CHAR:
   11843       119089 :     case CPP_CHAR16:
   11844       119089 :     case CPP_CHAR32:
   11845       119089 :     case CPP_UTF8CHAR:
   11846       119089 :     case CPP_WCHAR:
   11847       119089 :       expr.value = c_parser_peek_token (parser)->value;
   11848              :       /* For the purpose of warning when a pointer is compared with
   11849              :          a zero character constant.  */
   11850       119089 :       expr.original_type = char_type_node;
   11851       119089 :       set_c_expr_source_range (&expr, tok_range);
   11852       119089 :       c_parser_consume_token (parser);
   11853       119089 :       break;
   11854      1173460 :     case CPP_STRING:
   11855      1173460 :     case CPP_STRING16:
   11856      1173460 :     case CPP_STRING32:
   11857      1173460 :     case CPP_WSTRING:
   11858      1173460 :     case CPP_UTF8STRING:
   11859      1173460 :       expr = c_parser_string_literal (parser, parser->translate_strings_p,
   11860              :                                       true);
   11861      1173460 :       break;
   11862            0 :     case CPP_OBJC_STRING:
   11863            0 :       gcc_assert (c_dialect_objc ());
   11864            0 :       expr.value
   11865            0 :         = objc_build_string_object (c_parser_peek_token (parser)->value);
   11866            0 :       set_c_expr_source_range (&expr, tok_range);
   11867            0 :       c_parser_consume_token (parser);
   11868            0 :       break;
   11869    180639808 :     case CPP_NAME:
   11870    180639808 :       switch (c_parser_peek_token (parser)->id_kind)
   11871              :         {
   11872    180639806 :         case C_ID_ID:
   11873    180639806 :           {
   11874    180639806 :             tree id = c_parser_peek_token (parser)->value;
   11875    180639806 :             c_parser_consume_token (parser);
   11876    541919418 :             expr.value = build_external_ref (loc, id,
   11877    180639806 :                                              (c_parser_peek_token (parser)->type
   11878              :                                               == CPP_OPEN_PAREN),
   11879              :                                              &expr.original_type);
   11880    180639806 :             set_c_expr_source_range (&expr, tok_range);
   11881    180639806 :             break;
   11882              :           }
   11883            0 :         case C_ID_CLASSNAME:
   11884            0 :           {
   11885              :             /* Here we parse the Objective-C 2.0 Class.name dot
   11886              :                syntax.  */
   11887            0 :             tree class_name = c_parser_peek_token (parser)->value;
   11888            0 :             tree component;
   11889            0 :             c_parser_consume_token (parser);
   11890            0 :             gcc_assert (c_dialect_objc ());
   11891            0 :             if (!c_parser_require (parser, CPP_DOT, "expected %<.%>"))
   11892              :               {
   11893            0 :                 expr.set_error ();
   11894            0 :                 break;
   11895              :               }
   11896            0 :             if (c_parser_next_token_is_not (parser, CPP_NAME))
   11897              :               {
   11898            0 :                 c_parser_error (parser, "expected identifier");
   11899            0 :                 expr.set_error ();
   11900            0 :                 break;
   11901              :               }
   11902            0 :             c_token *component_tok = c_parser_peek_token (parser);
   11903            0 :             component = component_tok->value;
   11904            0 :             location_t end_loc = component_tok->get_finish ();
   11905            0 :             c_parser_consume_token (parser);
   11906            0 :             expr.value = objc_build_class_component_ref (class_name,
   11907              :                                                          component);
   11908            0 :             set_c_expr_source_range (&expr, loc, end_loc);
   11909            0 :             break;
   11910              :           }
   11911            2 :         default:
   11912            2 :           c_parser_error (parser, "expected expression");
   11913            2 :           expr.set_error ();
   11914            2 :           break;
   11915              :         }
   11916              :       break;
   11917      8219711 :     case CPP_OPEN_PAREN:
   11918              :       /* A parenthesized expression, statement expression or compound
   11919              :          literal.  */
   11920      8219711 :       if (c_parser_peek_2nd_token (parser)->type == CPP_OPEN_BRACE)
   11921              :         {
   11922              :           /* A statement expression.  */
   11923        35468 :           tree stmt;
   11924        35468 :           location_t brace_loc;
   11925        35468 :           bool save_c_omp_array_section_p = c_omp_array_section_p;
   11926        35468 :           c_parser_consume_token (parser);
   11927        35468 :           brace_loc = c_parser_peek_token (parser)->location;
   11928        35468 :           c_parser_consume_token (parser);
   11929              :           /* If we've not yet started the current function's statement list,
   11930              :              or we're in the parameter scope of an old-style function
   11931              :              declaration, statement expressions are not allowed.  */
   11932        35468 :           if (!building_stmt_list_p () || old_style_parameter_scope ())
   11933              :             {
   11934           24 :               error_at (loc, "braced-group within expression allowed "
   11935              :                         "only inside a function");
   11936           24 :               parser->error = true;
   11937           24 :               c_parser_skip_until_found (parser, CPP_CLOSE_BRACE, NULL);
   11938           24 :               c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   11939           24 :               expr.set_error ();
   11940           24 :               break;
   11941              :             }
   11942        35444 :           c_omp_array_section_p = false;
   11943        35444 :           stmt = c_begin_stmt_expr ();
   11944        35444 :           c_parser_compound_statement_nostart (parser);
   11945        35444 :           location_t close_loc = c_parser_peek_token (parser)->location;
   11946        35444 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   11947              :                                      "expected %<)%>");
   11948        35444 :           pedwarn (loc, OPT_Wpedantic,
   11949              :                    "ISO C forbids braced-groups within expressions");
   11950        35444 :           expr.value = c_finish_stmt_expr (brace_loc, stmt);
   11951        35444 :           set_c_expr_source_range (&expr, loc, close_loc);
   11952        35444 :           mark_exp_read (expr.value);
   11953        35444 :           c_omp_array_section_p = save_c_omp_array_section_p;
   11954              :         }
   11955              :       else
   11956              :         {
   11957              :           /* A parenthesized expression.  */
   11958      8184243 :           location_t loc_open_paren = c_parser_peek_token (parser)->location;
   11959      8184243 :           c_parser_consume_token (parser);
   11960      8184243 :           expr = c_parser_expression (parser);
   11961      8184243 :           if (TREE_CODE (expr.value) == MODIFY_EXPR)
   11962        38284 :             suppress_warning (expr.value, OPT_Wparentheses);
   11963      8184243 :           if (expr.original_code != C_MAYBE_CONST_EXPR
   11964      8184231 :               && expr.original_code != SIZEOF_EXPR)
   11965      8179317 :             expr.original_code = ERROR_MARK;
   11966              :           /* Remember that we saw ( ) around the sizeof.  */
   11967      8184243 :           if (expr.original_code == SIZEOF_EXPR)
   11968         4914 :             expr.original_code = PAREN_SIZEOF_EXPR;
   11969              :           /* Don't change EXPR.ORIGINAL_TYPE.  */
   11970      8184243 :           location_t loc_close_paren = c_parser_peek_token (parser)->location;
   11971      8184243 :           set_c_expr_source_range (&expr, loc_open_paren, loc_close_paren);
   11972      8184243 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   11973              :                                      "expected %<)%>", loc_open_paren);
   11974              :         }
   11975              :       break;
   11976      1661014 :     case CPP_KEYWORD:
   11977      1661014 :       switch (c_parser_peek_token (parser)->keyword)
   11978              :         {
   11979        13545 :         case RID_FUNCTION_NAME:
   11980        13545 :         case RID_PRETTY_FUNCTION_NAME:
   11981        13545 :         case RID_C99_FUNCTION_NAME:
   11982        13545 :           expr = c_parser_predefined_identifier (parser);
   11983        13545 :           break;
   11984        20024 :         case RID_VA_ARG:
   11985        20024 :           {
   11986        20024 :             location_t start_loc = loc;
   11987        20024 :             c_parser_consume_token (parser);
   11988        20024 :             matching_parens parens;
   11989        20024 :             if (!parens.require_open (parser))
   11990              :               {
   11991            0 :                 expr.set_error ();
   11992            0 :                 break;
   11993              :               }
   11994        20024 :             e1 = c_parser_expr_no_commas (parser, NULL);
   11995        20024 :             mark_exp_read (e1.value);
   11996        20024 :             e1.value = c_fully_fold (e1.value, false, NULL);
   11997        20024 :             if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>"))
   11998              :               {
   11999            0 :                 c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   12000            0 :                 expr.set_error ();
   12001            0 :                 break;
   12002              :               }
   12003        20024 :             loc = c_parser_peek_token (parser)->location;
   12004        20024 :             t1 = c_parser_type_name (parser);
   12005        20024 :             location_t end_loc = c_parser_peek_token (parser)->get_finish ();
   12006        20024 :             c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   12007              :                                        "expected %<)%>");
   12008        20024 :             if (t1 == NULL)
   12009              :               {
   12010            0 :                 expr.set_error ();
   12011              :               }
   12012              :             else
   12013              :               {
   12014        20024 :                 tree type_expr = NULL_TREE;
   12015        20024 :                 tree type = groktypename (t1, &type_expr, NULL);
   12016        20024 :                 expr.value = c_build_va_arg (start_loc, e1.value, loc,
   12017              :                                              type, type_expr);
   12018        20024 :                 set_c_expr_source_range (&expr, start_loc, end_loc);
   12019              :               }
   12020              :           }
   12021        20024 :           break;
   12022        13690 :         case RID_C23_VA_START:
   12023        13690 :           {
   12024        13690 :             c_parser_consume_token (parser);
   12025        13690 :             matching_parens parens;
   12026        13690 :             if (!parens.require_open (parser))
   12027              :               {
   12028            0 :                 expr.set_error ();
   12029            0 :                 break;
   12030              :               }
   12031        13690 :             e1 = c_parser_expr_no_commas (parser, NULL);
   12032        13690 :             e1 = convert_lvalue_to_rvalue (e1.get_location (), e1, true, true);
   12033        13690 :             if (!c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   12034              :               {
   12035        13512 :                 location_t cloc = c_parser_peek_token (parser)->location;
   12036        13512 :                 if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>"))
   12037              :                   {
   12038            0 :                     c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   12039            0 :                     expr.set_error ();
   12040            0 :                     break;
   12041              :                   }
   12042        13512 :                 if (c_parser_next_token_is (parser, CPP_NAME)
   12043        13507 :                     && c_parser_peek_token (parser)->id_kind == C_ID_ID
   12044        27019 :                     && (c_parser_peek_2nd_token (parser)->type
   12045              :                         == CPP_CLOSE_PAREN))
   12046              :                   {
   12047        13486 :                     tree name = c_parser_peek_token (parser)->value;
   12048        13486 :                     location_t nloc = c_parser_peek_token (parser)->location;
   12049        13486 :                     tree decl = lookup_name (name);
   12050        13486 :                     tree last_parm
   12051        13486 :                       = tree_last (DECL_ARGUMENTS (current_function_decl));
   12052        13486 :                     if (!last_parm || decl != last_parm)
   12053            4 :                       warning_at (nloc, OPT_Wvarargs,
   12054              :                                   "optional second parameter of %<va_start%> "
   12055              :                                   "not last named argument");
   12056        13482 :                     else if (DECL_REGISTER (decl))
   12057            2 :                       warning_at (nloc, OPT_Wvarargs,
   12058              :                                   "undefined behavior when second parameter "
   12059              :                                   "of %<va_start%> is declared with "
   12060              :                                   "%<register%> storage");
   12061        13486 :                     c_parser_consume_token (parser);
   12062              :                   }
   12063              :                 else
   12064              :                   {
   12065           26 :                     unsigned nesting_depth = 0;
   12066           26 :                     location_t sloc = c_parser_peek_token (parser)->location;
   12067           26 :                     location_t eloc = sloc;
   12068              : 
   12069              :                     /* For va_start (ap,) the ) comes from stdarg.h.
   12070              :                        Use location of , in that case, otherwise without
   12071              :                        -Wsystem-headers nothing is reported.  After all,
   12072              :                        the problematic token is the comma in that case.  */
   12073           26 :                     if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   12074            1 :                       sloc = eloc = cloc;
   12075          492 :                     while (true)
   12076              :                       {
   12077          259 :                         c_token *token = c_parser_peek_token (parser);
   12078          259 :                         if (token->type == CPP_CLOSE_PAREN && !nesting_depth)
   12079              :                           break;
   12080              : 
   12081          233 :                         if (token->type == CPP_EOF)
   12082              :                           break;
   12083          233 :                         if (token->type == CPP_OPEN_PAREN)
   12084            8 :                           ++nesting_depth;
   12085          225 :                         else if (token->type == CPP_CLOSE_PAREN)
   12086            8 :                           --nesting_depth;
   12087          233 :                         eloc = token->location;
   12088          233 :                         c_parser_consume_token (parser);
   12089          233 :                       }
   12090           26 :                     if (sloc != eloc)
   12091           25 :                       sloc = make_location (sloc, sloc, eloc);
   12092           26 :                     warning_at (sloc, OPT_Wvarargs,
   12093              :                                 "%<va_start%> macro used with additional "
   12094              :                                 "arguments other than identifier of the "
   12095              :                                 "last named argument");
   12096              :                   }
   12097              :               }
   12098        13690 :             parens.skip_until_found_close (parser);
   12099        13690 :             tree fndecl = builtin_decl_explicit (BUILT_IN_VA_START);
   12100        13690 :             vec<tree, va_gc> *params;
   12101        13690 :             vec_alloc (params, 2);
   12102        13690 :             params->quick_push (e1.value);
   12103        13690 :             params->quick_push (integer_zero_node);
   12104        13690 :             auto_vec<location_t> arg_loc (2);
   12105        13690 :             arg_loc.quick_push (e1.get_location ());
   12106        13690 :             arg_loc.quick_push (UNKNOWN_LOCATION);
   12107        13690 :             expr.value = c_build_function_call_vec (loc, arg_loc, fndecl,
   12108              :                                                     params, NULL);
   12109        13690 :             set_c_expr_source_range (&expr, loc,
   12110              :                                      parser->tokens_buf[0].get_finish ());
   12111        13690 :             expr.m_decimal = 0;
   12112        13690 :             expr.original_code = ERROR_MARK;
   12113        13690 :             expr.original_type = NULL;
   12114        13690 :             release_tree_vector (params);
   12115        13690 :             break;
   12116        13690 :           }
   12117         3687 :         case RID_OFFSETOF:
   12118         3687 :           {
   12119         3687 :             c_parser_consume_token (parser);
   12120         3687 :             matching_parens parens;
   12121         3687 :             if (!parens.require_open (parser))
   12122              :               {
   12123            0 :                 expr.set_error ();
   12124            1 :                 break;
   12125              :               }
   12126         3687 :             t1 = c_parser_type_name (parser);
   12127         3687 :             if (t1 == NULL)
   12128            0 :               parser->error = true;
   12129         3687 :             if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>"))
   12130            1 :               gcc_assert (parser->error);
   12131         3687 :             if (parser->error)
   12132              :               {
   12133            1 :                 c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   12134            1 :                 expr.set_error ();
   12135            1 :                 break;
   12136              :               }
   12137         3686 :             tree type = groktypename (t1, NULL, NULL);
   12138         3686 :             tree offsetof_ref;
   12139         3686 :             if (type == error_mark_node)
   12140              :               offsetof_ref = error_mark_node;
   12141              :             else
   12142              :               {
   12143         3685 :                 offsetof_ref = build1 (INDIRECT_REF, type, null_pointer_node);
   12144         3685 :                 SET_EXPR_LOCATION (offsetof_ref, loc);
   12145              :               }
   12146              :             /* Parse the second argument to __builtin_offsetof.  We
   12147              :                must have one identifier, and beyond that we want to
   12148              :                accept sub structure and sub array references.  */
   12149         3686 :             if (c_parser_next_token_is (parser, CPP_NAME))
   12150              :               {
   12151         3686 :                 c_token *comp_tok = c_parser_peek_token (parser);
   12152         3686 :                 offsetof_ref
   12153         3686 :                   = build_component_ref (loc, offsetof_ref, comp_tok->value,
   12154              :                                          comp_tok->location, UNKNOWN_LOCATION);
   12155         3686 :                 c_parser_consume_token (parser);
   12156         3686 :                 while (c_parser_next_token_is (parser, CPP_DOT)
   12157         4156 :                        || c_parser_next_token_is (parser,
   12158              :                                                   CPP_OPEN_SQUARE)
   12159         8088 :                        || c_parser_next_token_is (parser,
   12160              :                                                   CPP_DEREF))
   12161              :                   {
   12162          715 :                     if (c_parser_next_token_is (parser, CPP_DEREF))
   12163              :                       {
   12164            1 :                         loc = c_parser_peek_token (parser)->location;
   12165            1 :                         offsetof_ref = build_array_ref (loc,
   12166              :                                                         offsetof_ref,
   12167              :                                                         integer_zero_node);
   12168            1 :                         goto do_dot;
   12169              :                       }
   12170          714 :                     else if (c_parser_next_token_is (parser, CPP_DOT))
   12171              :                       {
   12172          245 :                       do_dot:
   12173          246 :                         c_parser_consume_token (parser);
   12174          246 :                         if (c_parser_next_token_is_not (parser,
   12175              :                                                         CPP_NAME))
   12176              :                           {
   12177            0 :                             c_parser_error (parser, "expected identifier");
   12178            0 :                             break;
   12179              :                           }
   12180          246 :                         c_token *comp_tok = c_parser_peek_token (parser);
   12181          246 :                         offsetof_ref
   12182          246 :                           = build_component_ref (loc, offsetof_ref,
   12183              :                                                  comp_tok->value,
   12184              :                                                  comp_tok->location,
   12185              :                                                  UNKNOWN_LOCATION);
   12186          246 :                         c_parser_consume_token (parser);
   12187              :                       }
   12188              :                     else
   12189              :                       {
   12190          469 :                         struct c_expr ce;
   12191          469 :                         tree idx;
   12192          469 :                         loc = c_parser_peek_token (parser)->location;
   12193          469 :                         c_parser_consume_token (parser);
   12194          469 :                         ce = c_parser_expression (parser);
   12195          469 :                         ce = convert_lvalue_to_rvalue (loc, ce, false, false);
   12196          469 :                         idx = ce.value;
   12197          469 :                         idx = c_fully_fold (idx, false, NULL);
   12198          469 :                         c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
   12199              :                                                    "expected %<]%>");
   12200          469 :                         offsetof_ref = build_array_ref (loc, offsetof_ref, idx);
   12201              :                       }
   12202              :                   }
   12203              :               }
   12204              :             else
   12205            0 :               c_parser_error (parser, "expected identifier");
   12206         3686 :             location_t end_loc = c_parser_peek_token (parser)->get_finish ();
   12207         3686 :             c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   12208              :                                        "expected %<)%>");
   12209         3686 :             expr.value = fold_offsetof (offsetof_ref);
   12210         3686 :             set_c_expr_source_range (&expr, loc, end_loc);
   12211              :           }
   12212         3686 :           break;
   12213         1183 :         case RID_CHOOSE_EXPR:
   12214         1183 :           {
   12215         1183 :             vec<c_expr_t, va_gc> *cexpr_list;
   12216         1183 :             c_expr_t *e1_p, *e2_p, *e3_p;
   12217         1183 :             tree c;
   12218         1183 :             location_t close_paren_loc;
   12219              : 
   12220         1183 :             c_parser_consume_token (parser);
   12221         1183 :             if (!c_parser_get_builtin_args (parser,
   12222              :                                             "__builtin_choose_expr",
   12223              :                                             &cexpr_list, true,
   12224              :                                             &close_paren_loc))
   12225              :               {
   12226            0 :                 expr.set_error ();
   12227            0 :                 break;
   12228              :               }
   12229              : 
   12230         1183 :             if (vec_safe_length (cexpr_list) != 3)
   12231              :               {
   12232            0 :                 error_at (loc, "wrong number of arguments to "
   12233              :                                "%<__builtin_choose_expr%>");
   12234            0 :                 expr.set_error ();
   12235            0 :                 break;
   12236              :               }
   12237              : 
   12238         1183 :             e1_p = &(*cexpr_list)[0];
   12239         1183 :             e2_p = &(*cexpr_list)[1];
   12240         1183 :             e3_p = &(*cexpr_list)[2];
   12241              : 
   12242         1183 :             c = e1_p->value;
   12243         1183 :             mark_exp_read (e2_p->value);
   12244         1183 :             mark_exp_read (e3_p->value);
   12245         1183 :             if (TREE_CODE (c) != INTEGER_CST
   12246         1183 :                 || !INTEGRAL_TYPE_P (TREE_TYPE (c)))
   12247            7 :               error_at (loc,
   12248              :                         "first argument to %<__builtin_choose_expr%> not"
   12249              :                         " a constant");
   12250         1183 :             constant_expression_warning (c);
   12251         1183 :             expr = integer_zerop (c) ? *e3_p : *e2_p;
   12252         1183 :             set_c_expr_source_range (&expr, loc, close_paren_loc);
   12253         1183 :             break;
   12254              :           }
   12255          681 :         case RID_TYPES_COMPATIBLE_P:
   12256          681 :           {
   12257          681 :             c_parser_consume_token (parser);
   12258          681 :             matching_parens parens;
   12259          681 :             if (!parens.require_open (parser))
   12260              :               {
   12261            0 :                 expr.set_error ();
   12262            2 :                 break;
   12263              :               }
   12264          681 :             t1 = c_parser_type_name (parser);
   12265          681 :             if (t1 == NULL)
   12266              :               {
   12267            0 :                 expr.set_error ();
   12268            0 :                 break;
   12269              :               }
   12270          681 :             if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>"))
   12271              :               {
   12272            1 :                 c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   12273            1 :                 expr.set_error ();
   12274            1 :                 break;
   12275              :               }
   12276          680 :             t2 = c_parser_type_name (parser);
   12277          680 :             if (t2 == NULL)
   12278              :               {
   12279            0 :                 expr.set_error ();
   12280            0 :                 break;
   12281              :               }
   12282          680 :             location_t close_paren_loc = c_parser_peek_token (parser)->location;
   12283          680 :             parens.skip_until_found_close (parser);
   12284          680 :             tree e1, e2;
   12285          680 :             e1 = groktypename (t1, NULL, NULL);
   12286          680 :             e2 = groktypename (t2, NULL, NULL);
   12287          680 :             if (e1 == error_mark_node || e2 == error_mark_node)
   12288              :               {
   12289            1 :                 expr.set_error ();
   12290            1 :                 break;
   12291              :               }
   12292              : 
   12293          679 :             e1 = TYPE_MAIN_VARIANT (e1);
   12294          679 :             e2 = TYPE_MAIN_VARIANT (e2);
   12295              : 
   12296          679 :             expr.value
   12297          679 :               = comptypes (e1, e2) ? integer_one_node : integer_zero_node;
   12298          679 :             set_c_expr_source_range (&expr, loc, close_paren_loc);
   12299              :           }
   12300          679 :           break;
   12301          356 :         case RID_BUILTIN_TGMATH:
   12302          356 :           {
   12303          356 :             vec<c_expr_t, va_gc> *cexpr_list;
   12304          356 :             location_t close_paren_loc;
   12305              : 
   12306          356 :             c_parser_consume_token (parser);
   12307          356 :             if (!c_parser_get_builtin_args (parser,
   12308              :                                             "__builtin_tgmath",
   12309              :                                             &cexpr_list, false,
   12310              :                                             &close_paren_loc))
   12311              :               {
   12312            0 :                 expr.set_error ();
   12313          327 :                 break;
   12314              :               }
   12315              : 
   12316          356 :             if (vec_safe_length (cexpr_list) < 3)
   12317              :               {
   12318            3 :                 error_at (loc, "too few arguments to %<__builtin_tgmath%>");
   12319            3 :                 expr.set_error ();
   12320            3 :                 break;
   12321              :               }
   12322              : 
   12323              :             unsigned int i;
   12324              :             c_expr_t *p;
   12325         2587 :             FOR_EACH_VEC_ELT (*cexpr_list, i, p)
   12326         2234 :               *p = convert_lvalue_to_rvalue (loc, *p, true, true);
   12327          353 :             unsigned int nargs = check_tgmath_function (&(*cexpr_list)[0], 1);
   12328          353 :             if (nargs == 0)
   12329              :               {
   12330            4 :                 expr.set_error ();
   12331            4 :                 break;
   12332              :               }
   12333          698 :             if (vec_safe_length (cexpr_list) < nargs)
   12334              :               {
   12335            1 :                 error_at (loc, "too few arguments to %<__builtin_tgmath%>");
   12336            1 :                 expr.set_error ();
   12337            1 :                 break;
   12338              :               }
   12339          348 :             unsigned int num_functions = vec_safe_length (cexpr_list) - nargs;
   12340          348 :             if (num_functions < 2)
   12341              :               {
   12342            1 :                 error_at (loc, "too few arguments to %<__builtin_tgmath%>");
   12343            1 :                 expr.set_error ();
   12344            1 :                 break;
   12345              :               }
   12346              : 
   12347              :             /* The first NUM_FUNCTIONS expressions are the function
   12348              :                pointers.  The remaining NARGS expressions are the
   12349              :                arguments that are to be passed to one of those
   12350              :                functions, chosen following <tgmath.h> rules.  */
   12351         1744 :             for (unsigned int j = 1; j < num_functions; j++)
   12352              :               {
   12353         1402 :                 unsigned int this_nargs
   12354         1402 :                   = check_tgmath_function (&(*cexpr_list)[j], j + 1);
   12355         1402 :                 if (this_nargs == 0)
   12356              :                   {
   12357            4 :                     expr.set_error ();
   12358           29 :                     goto out;
   12359              :                   }
   12360         1398 :                 if (this_nargs != nargs)
   12361              :                   {
   12362            1 :                     error_at ((*cexpr_list)[j].get_location (),
   12363              :                               "argument %u of %<__builtin_tgmath%> has "
   12364              :                               "wrong number of arguments", j + 1);
   12365            1 :                     expr.set_error ();
   12366            1 :                     goto out;
   12367              :                   }
   12368              :               }
   12369              : 
   12370              :             /* The functions all have the same number of arguments.
   12371              :                Determine whether arguments and return types vary in
   12372              :                ways permitted for <tgmath.h> functions.  */
   12373              :             /* The first entry in each of these vectors is for the
   12374              :                return type, subsequent entries for parameter
   12375              :                types.  */
   12376          342 :             auto_vec<enum tgmath_parm_kind> parm_kind (nargs + 1);
   12377          342 :             auto_vec<tree> parm_first (nargs + 1);
   12378          342 :             auto_vec<bool> parm_complex (nargs + 1);
   12379          342 :             auto_vec<bool> parm_varies (nargs + 1);
   12380          342 :             tree first_type = TREE_TYPE (TREE_TYPE ((*cexpr_list)[0].value));
   12381          342 :             tree first_ret = TYPE_MAIN_VARIANT (TREE_TYPE (first_type));
   12382          342 :             parm_first.quick_push (first_ret);
   12383          342 :             parm_complex.quick_push (TREE_CODE (first_ret) == COMPLEX_TYPE);
   12384          342 :             parm_varies.quick_push (false);
   12385          342 :             function_args_iterator iter;
   12386          342 :             tree t;
   12387          342 :             unsigned int argpos;
   12388          802 :             FOREACH_FUNCTION_ARGS (first_type, t, iter)
   12389              :               {
   12390          802 :                 if (t == void_type_node)
   12391              :                   break;
   12392          460 :                 parm_first.quick_push (TYPE_MAIN_VARIANT (t));
   12393          460 :                 parm_complex.quick_push (TREE_CODE (t) == COMPLEX_TYPE);
   12394          460 :                 parm_varies.quick_push (false);
   12395              :               }
   12396         1727 :             for (unsigned int j = 1; j < num_functions; j++)
   12397              :               {
   12398         1397 :                 tree type = TREE_TYPE (TREE_TYPE ((*cexpr_list)[j].value));
   12399         1397 :                 tree ret = TYPE_MAIN_VARIANT (TREE_TYPE (type));
   12400         1397 :                 if (ret != parm_first[0])
   12401              :                   {
   12402         1294 :                     parm_varies[0] = true;
   12403         1294 :                     if (!SCALAR_FLOAT_TYPE_P (parm_first[0])
   12404         1294 :                         && !COMPLEX_FLOAT_TYPE_P (parm_first[0]))
   12405              :                       {
   12406            3 :                         error_at ((*cexpr_list)[0].get_location (),
   12407              :                                   "invalid type-generic return type for "
   12408              :                                   "argument %u of %<__builtin_tgmath%>",
   12409              :                                   1);
   12410            3 :                         expr.set_error ();
   12411            3 :                         goto out;
   12412              :                       }
   12413         1291 :                     if (!SCALAR_FLOAT_TYPE_P (ret)
   12414         1291 :                         && !COMPLEX_FLOAT_TYPE_P (ret))
   12415              :                       {
   12416            3 :                         error_at ((*cexpr_list)[j].get_location (),
   12417              :                                   "invalid type-generic return type for "
   12418              :                                   "argument %u of %<__builtin_tgmath%>",
   12419              :                                   j + 1);
   12420            3 :                         expr.set_error ();
   12421            3 :                         goto out;
   12422              :                       }
   12423              :                   }
   12424         1391 :                 if (TREE_CODE (ret) == COMPLEX_TYPE)
   12425          342 :                   parm_complex[0] = true;
   12426         1391 :                 argpos = 1;
   12427         3329 :                 FOREACH_FUNCTION_ARGS (type, t, iter)
   12428              :                   {
   12429         3329 :                     if (t == void_type_node)
   12430              :                       break;
   12431         1944 :                     t = TYPE_MAIN_VARIANT (t);
   12432         1944 :                     if (t != parm_first[argpos])
   12433              :                       {
   12434         1919 :                         parm_varies[argpos] = true;
   12435         1919 :                         if (!SCALAR_FLOAT_TYPE_P (parm_first[argpos])
   12436         1919 :                             && !COMPLEX_FLOAT_TYPE_P (parm_first[argpos]))
   12437              :                           {
   12438            3 :                             error_at ((*cexpr_list)[0].get_location (),
   12439              :                                       "invalid type-generic type for "
   12440              :                                       "argument %u of argument %u of "
   12441              :                                       "%<__builtin_tgmath%>", argpos, 1);
   12442            3 :                             expr.set_error ();
   12443            3 :                             goto out;
   12444              :                           }
   12445         1916 :                         if (!SCALAR_FLOAT_TYPE_P (t)
   12446         1916 :                             && !COMPLEX_FLOAT_TYPE_P (t))
   12447              :                           {
   12448            3 :                             error_at ((*cexpr_list)[j].get_location (),
   12449              :                                       "invalid type-generic type for "
   12450              :                                       "argument %u of argument %u of "
   12451              :                                       "%<__builtin_tgmath%>", argpos, j + 1);
   12452            3 :                             expr.set_error ();
   12453            3 :                             goto out;
   12454              :                           }
   12455              :                       }
   12456         1938 :                     if (TREE_CODE (t) == COMPLEX_TYPE)
   12457          674 :                       parm_complex[argpos] = true;
   12458         1938 :                     argpos++;
   12459              :                   }
   12460              :               }
   12461              :             enum tgmath_parm_kind max_variation = tgmath_fixed;
   12462         1108 :             for (unsigned int j = 0; j <= nargs; j++)
   12463              :               {
   12464          778 :                 enum tgmath_parm_kind this_kind;
   12465          778 :                 if (parm_varies[j])
   12466              :                   {
   12467          731 :                     if (parm_complex[j])
   12468          394 :                       max_variation = this_kind = tgmath_complex;
   12469              :                     else
   12470              :                       {
   12471          337 :                         this_kind = tgmath_real;
   12472          337 :                         if (max_variation != tgmath_complex)
   12473          778 :                           max_variation = tgmath_real;
   12474              :                       }
   12475              :                   }
   12476              :                 else
   12477           47 :                   this_kind = tgmath_fixed;
   12478          778 :                 parm_kind.quick_push (this_kind);
   12479              :               }
   12480          330 :             if (max_variation == tgmath_fixed)
   12481              :               {
   12482            1 :                 error_at (loc, "function arguments of %<__builtin_tgmath%> "
   12483              :                           "all have the same type");
   12484            1 :                 expr.set_error ();
   12485            1 :                 break;
   12486              :               }
   12487              : 
   12488              :             /* Identify a parameter (not the return type) that varies,
   12489              :                including with complex types if any variation includes
   12490              :                complex types; there must be at least one such
   12491              :                parameter.  */
   12492          341 :             unsigned int tgarg = 0;
   12493          341 :             for (unsigned int j = 1; j <= nargs; j++)
   12494          339 :               if (parm_kind[j] == max_variation)
   12495              :                 {
   12496              :                   tgarg = j;
   12497              :                   break;
   12498              :                 }
   12499          329 :             if (tgarg == 0)
   12500              :               {
   12501            2 :                 error_at (loc, "function arguments of %<__builtin_tgmath%> "
   12502              :                           "lack type-generic parameter");
   12503            2 :                 expr.set_error ();
   12504            2 :                 break;
   12505              :               }
   12506              : 
   12507              :             /* Determine the type of the relevant parameter for each
   12508              :                function.  */
   12509          327 :             auto_vec<tree> tg_type (num_functions);
   12510         2362 :             for (unsigned int j = 0; j < num_functions; j++)
   12511              :               {
   12512         1708 :                 tree type = TREE_TYPE (TREE_TYPE ((*cexpr_list)[j].value));
   12513         1708 :                 argpos = 1;
   12514         1738 :                 FOREACH_FUNCTION_ARGS (type, t, iter)
   12515              :                   {
   12516         1738 :                     if (argpos == tgarg)
   12517              :                       {
   12518         1708 :                         tg_type.quick_push (TYPE_MAIN_VARIANT (t));
   12519         1708 :                         break;
   12520              :                       }
   12521           30 :                     argpos++;
   12522              :                   }
   12523              :               }
   12524              : 
   12525              :             /* Verify that the corresponding types are different for
   12526              :                all the listed functions.  Also determine whether all
   12527              :                the types are complex, whether all the types are
   12528              :                standard or binary, and whether all the types are
   12529              :                decimal.  */
   12530          327 :             bool all_complex = true;
   12531          327 :             bool all_binary = true;
   12532          327 :             bool all_decimal = true;
   12533          327 :             hash_set<tree> tg_types;
   12534         2687 :             FOR_EACH_VEC_ELT (tg_type, i, t)
   12535              :               {
   12536         1708 :                 if (TREE_CODE (t) == COMPLEX_TYPE)
   12537              :                   all_decimal = false;
   12538              :                 else
   12539              :                   {
   12540         1186 :                     all_complex = false;
   12541         1186 :                     if (DECIMAL_FLOAT_TYPE_P (t))
   12542              :                       all_binary = false;
   12543              :                     else
   12544              :                       all_decimal = false;
   12545              :                   }
   12546         1708 :                 if (tg_types.add (t))
   12547              :                   {
   12548            1 :                     error_at ((*cexpr_list)[i].get_location (),
   12549              :                               "duplicate type-generic parameter type for "
   12550              :                               "function argument %u of %<__builtin_tgmath%>",
   12551              :                               i + 1);
   12552            1 :                     expr.set_error ();
   12553            1 :                     goto out;
   12554              :                   }
   12555              :               }
   12556              : 
   12557              :             /* Verify that other parameters and the return type whose
   12558              :                types vary have their types varying in the correct
   12559              :                way.  */
   12560         2029 :             for (unsigned int j = 0; j < num_functions; j++)
   12561              :               {
   12562         1705 :                 tree exp_type = tg_type[j];
   12563         1705 :                 tree exp_real_type = exp_type;
   12564         1705 :                 if (TREE_CODE (exp_type) == COMPLEX_TYPE)
   12565          522 :                   exp_real_type = TREE_TYPE (exp_type);
   12566         1705 :                 tree type = TREE_TYPE (TREE_TYPE ((*cexpr_list)[j].value));
   12567         1705 :                 tree ret = TYPE_MAIN_VARIANT (TREE_TYPE (type));
   12568         2606 :                 if ((parm_kind[0] == tgmath_complex && ret != exp_type)
   12569         2606 :                     || (parm_kind[0] == tgmath_real && ret != exp_real_type))
   12570              :                   {
   12571            1 :                     error_at ((*cexpr_list)[j].get_location (),
   12572              :                               "bad return type for function argument %u "
   12573              :                               "of %<__builtin_tgmath%>", j + 1);
   12574            1 :                     expr.set_error ();
   12575            1 :                     goto out;
   12576              :                   }
   12577         1704 :                 argpos = 1;
   12578         4078 :                 FOREACH_FUNCTION_ARGS (type, t, iter)
   12579              :                   {
   12580         4078 :                     if (t == void_type_node)
   12581              :                       break;
   12582         2375 :                     t = TYPE_MAIN_VARIANT (t);
   12583         2375 :                     if ((parm_kind[argpos] == tgmath_complex
   12584         1787 :                          && t != exp_type)
   12585         4162 :                         || (parm_kind[argpos] == tgmath_real
   12586          558 :                             && t != exp_real_type))
   12587              :                       {
   12588            1 :                         error_at ((*cexpr_list)[j].get_location (),
   12589              :                                   "bad type for argument %u of "
   12590              :                                   "function argument %u of "
   12591              :                                   "%<__builtin_tgmath%>", argpos, j + 1);
   12592            1 :                         expr.set_error ();
   12593            1 :                         goto out;
   12594              :                       }
   12595         2374 :                     argpos++;
   12596              :                   }
   12597              :               }
   12598              : 
   12599              :             /* The functions listed are a valid set of functions for a
   12600              :                <tgmath.h> macro to select between.  Identify the
   12601              :                matching function, if any.  First, the argument types
   12602              :                must be combined following <tgmath.h> rules.  Integer
   12603              :                types are treated as _Decimal64 if any type-generic
   12604              :                argument is decimal, or if the only alternatives for
   12605              :                type-generic arguments are of decimal types, and are
   12606              :                otherwise treated as _Float32x (or _Complex _Float32x
   12607              :                for complex integer types) if any type-generic argument
   12608              :                has _FloatNx type, otherwise as double (or _Complex
   12609              :                double for complex integer types).  After that
   12610              :                adjustment, types are combined following the usual
   12611              :                arithmetic conversions.  If the function only accepts
   12612              :                complex arguments, a complex type is produced.  */
   12613              :             bool arg_complex = all_complex;
   12614              :             bool arg_binary = all_binary;
   12615              :             bool arg_int_decimal = all_decimal;
   12616              :             bool arg_int_floatnx = false;
   12617              :             bool arg_int_decimalx = false;
   12618          756 :             for (unsigned int j = 1; j <= nargs; j++)
   12619              :               {
   12620          441 :                 if (parm_kind[j] == tgmath_fixed)
   12621           10 :                   continue;
   12622          431 :                 c_expr_t *ce = &(*cexpr_list)[num_functions + j - 1];
   12623          431 :                 tree type = TREE_TYPE (ce->value);
   12624          431 :                 if (!INTEGRAL_TYPE_P (type)
   12625          431 :                     && !SCALAR_FLOAT_TYPE_P (type)
   12626           89 :                     && TREE_CODE (type) != COMPLEX_TYPE)
   12627              :                   {
   12628            1 :                     error_at (ce->get_location (),
   12629              :                               "invalid type of argument %u of type-generic "
   12630              :                               "function", j);
   12631            1 :                     expr.set_error ();
   12632            1 :                     goto out;
   12633              :                   }
   12634          430 :                 if (DECIMAL_FLOAT_TYPE_P (type))
   12635              :                   {
   12636           68 :                     arg_int_decimal = true;
   12637           68 :                     if (all_complex)
   12638              :                       {
   12639            1 :                         error_at (ce->get_location (),
   12640              :                                   "decimal floating-point argument %u to "
   12641              :                                   "complex-only type-generic function", j);
   12642            1 :                         expr.set_error ();
   12643            1 :                         goto out;
   12644              :                       }
   12645           67 :                     else if (all_binary)
   12646              :                       {
   12647            1 :                         error_at (ce->get_location (),
   12648              :                                   "decimal floating-point argument %u to "
   12649              :                                   "binary-only type-generic function", j);
   12650            1 :                         expr.set_error ();
   12651            1 :                         goto out;
   12652              :                       }
   12653           66 :                     else if (arg_complex)
   12654              :                       {
   12655            1 :                         error_at (ce->get_location (),
   12656              :                                   "both complex and decimal floating-point "
   12657              :                                   "arguments to type-generic function");
   12658            1 :                         expr.set_error ();
   12659            1 :                         goto out;
   12660              :                       }
   12661           65 :                     else if (arg_binary)
   12662              :                       {
   12663            1 :                         error_at (ce->get_location (),
   12664              :                                   "both binary and decimal floating-point "
   12665              :                                   "arguments to type-generic function");
   12666            1 :                         expr.set_error ();
   12667            1 :                         goto out;
   12668              :                       }
   12669              :                   }
   12670          362 :                 else if (TREE_CODE (type) == COMPLEX_TYPE)
   12671              :                   {
   12672           88 :                     arg_complex = true;
   12673           88 :                     if (COMPLEX_FLOAT_TYPE_P (type))
   12674              :                       arg_binary = true;
   12675           88 :                     if (all_decimal)
   12676              :                       {
   12677            1 :                         error_at (ce->get_location (),
   12678              :                                   "complex argument %u to "
   12679              :                                   "decimal-only type-generic function", j);
   12680            1 :                         expr.set_error ();
   12681            1 :                         goto out;
   12682              :                       }
   12683           87 :                     else if (arg_int_decimal)
   12684              :                       {
   12685            1 :                         error_at (ce->get_location (),
   12686              :                                   "both complex and decimal floating-point "
   12687              :                                   "arguments to type-generic function");
   12688            1 :                         expr.set_error ();
   12689            1 :                         goto out;
   12690              :                       }
   12691              :                   }
   12692          274 :                 else if (SCALAR_FLOAT_TYPE_P (type))
   12693              :                   {
   12694          180 :                     arg_binary = true;
   12695          180 :                     if (all_decimal)
   12696              :                       {
   12697            1 :                         error_at (ce->get_location (),
   12698              :                                   "binary argument %u to "
   12699              :                                   "decimal-only type-generic function", j);
   12700            1 :                         expr.set_error ();
   12701            1 :                         goto out;
   12702              :                       }
   12703          179 :                     else if (arg_int_decimal)
   12704              :                       {
   12705            1 :                         error_at (ce->get_location (),
   12706              :                                   "both binary and decimal floating-point "
   12707              :                                   "arguments to type-generic function");
   12708            1 :                         expr.set_error ();
   12709            1 :                         goto out;
   12710              :                       }
   12711              :                   }
   12712          422 :                 tree rtype = TYPE_MAIN_VARIANT (type);
   12713          422 :                 if (TREE_CODE (rtype) == COMPLEX_TYPE)
   12714           86 :                   rtype = TREE_TYPE (rtype);
   12715          422 :                 if (SCALAR_FLOAT_TYPE_P (rtype))
   12716         1208 :                   for (unsigned int j = 0; j < NUM_FLOATNX_TYPES; j++)
   12717          908 :                     if (rtype == FLOATNX_TYPE_NODE (j))
   12718              :                       {
   12719              :                         arg_int_floatnx = true;
   12720              :                         break;
   12721              :                       }
   12722          422 :                 if (rtype == dfloat64x_type_node)
   12723            0 :                   arg_int_decimalx = true;
   12724              :               }
   12725              :             tree arg_real = NULL_TREE;
   12726          743 :             for (unsigned int j = 1; j <= nargs; j++)
   12727              :               {
   12728          428 :                 if (parm_kind[j] == tgmath_fixed)
   12729           10 :                   continue;
   12730          418 :                 c_expr_t *ce = &(*cexpr_list)[num_functions + j - 1];
   12731          418 :                 tree type = TYPE_MAIN_VARIANT (TREE_TYPE (ce->value));
   12732          418 :                 if (TREE_CODE (type) == COMPLEX_TYPE)
   12733           85 :                   type = TREE_TYPE (type);
   12734          418 :                 if (INTEGRAL_TYPE_P (type))
   12735          114 :                   type = (arg_int_decimalx
   12736          114 :                           ? dfloat64x_type_node
   12737              :                           : arg_int_floatnx
   12738          114 :                           ? float32x_type_node
   12739              :                           : arg_int_decimal
   12740          106 :                           ? dfloat64_type_node
   12741              :                           : double_type_node);
   12742          418 :                 if (arg_real == NULL_TREE)
   12743              :                   arg_real = type;
   12744              :                 else
   12745          103 :                   arg_real = common_type (arg_real, type);
   12746          418 :                 if (arg_real == error_mark_node)
   12747              :                   {
   12748            0 :                     expr.set_error ();
   12749            0 :                     goto out;
   12750              :                   }
   12751              :               }
   12752          315 :             tree arg_type = (arg_complex
   12753          315 :                              ? build_complex_type (arg_real)
   12754              :                              : arg_real);
   12755              : 
   12756              :             /* Look for a function to call with type-generic parameter
   12757              :                type ARG_TYPE.  */
   12758          315 :             c_expr_t *fn = NULL;
   12759          976 :             for (unsigned int j = 0; j < num_functions; j++)
   12760              :               {
   12761          970 :                 if (tg_type[j] == arg_type)
   12762              :                   {
   12763          309 :                     fn = &(*cexpr_list)[j];
   12764          309 :                     break;
   12765              :                   }
   12766              :               }
   12767          315 :             if (fn == NULL
   12768            6 :                 && parm_kind[0] == tgmath_fixed
   12769            4 :                 && SCALAR_FLOAT_TYPE_P (parm_first[0]))
   12770              :               {
   12771              :                 /* Presume this is a macro that rounds its result to a
   12772              :                    narrower type, and look for the first function with
   12773              :                    at least the range and precision of the argument
   12774              :                    type.  */
   12775            4 :                 for (unsigned int j = 0; j < num_functions; j++)
   12776              :                   {
   12777            8 :                     if (arg_complex
   12778            4 :                         != (TREE_CODE (tg_type[j]) == COMPLEX_TYPE))
   12779            0 :                       continue;
   12780            4 :                     tree real_tg_type = (arg_complex
   12781            4 :                                          ? TREE_TYPE (tg_type[j])
   12782            0 :                                          : tg_type[j]);
   12783            8 :                     if (DECIMAL_FLOAT_TYPE_P (arg_real)
   12784            4 :                         != DECIMAL_FLOAT_TYPE_P (real_tg_type))
   12785            0 :                       continue;
   12786            4 :                     scalar_float_mode arg_mode
   12787            4 :                       = SCALAR_FLOAT_TYPE_MODE (arg_real);
   12788            4 :                     scalar_float_mode tg_mode
   12789            4 :                       = SCALAR_FLOAT_TYPE_MODE (real_tg_type);
   12790            4 :                     const real_format *arg_fmt = REAL_MODE_FORMAT (arg_mode);
   12791            4 :                     const real_format *tg_fmt = REAL_MODE_FORMAT (tg_mode);
   12792            4 :                     if (arg_fmt->b == tg_fmt->b
   12793            4 :                         && arg_fmt->p <= tg_fmt->p
   12794            4 :                         && arg_fmt->emax <= tg_fmt->emax
   12795            4 :                         && (arg_fmt->emin - arg_fmt->p
   12796            4 :                             >= tg_fmt->emin - tg_fmt->p))
   12797              :                       {
   12798            4 :                         fn = &(*cexpr_list)[j];
   12799            4 :                         break;
   12800              :                       }
   12801              :                   }
   12802              :               }
   12803          315 :             if (fn == NULL)
   12804              :               {
   12805            2 :                 error_at (loc, "no matching function for type-generic call");
   12806            2 :                 expr.set_error ();
   12807            2 :                 break;
   12808              :               }
   12809              : 
   12810              :             /* Construct a call to FN.  */
   12811          313 :             vec<tree, va_gc> *args;
   12812          313 :             vec_alloc (args, nargs);
   12813          313 :             vec<tree, va_gc> *origtypes;
   12814          313 :             vec_alloc (origtypes, nargs);
   12815          313 :             auto_vec<location_t> arg_loc (nargs);
   12816         1052 :             for (unsigned int j = 0; j < nargs; j++)
   12817              :               {
   12818          426 :                 c_expr_t *ce = &(*cexpr_list)[num_functions + j];
   12819          426 :                 args->quick_push (ce->value);
   12820          426 :                 arg_loc.quick_push (ce->get_location ());
   12821          426 :                 origtypes->quick_push (ce->original_type);
   12822              :               }
   12823          313 :             expr.value = c_build_function_call_vec (loc, arg_loc, fn->value,
   12824              :                                                     args, origtypes);
   12825          313 :             set_c_expr_source_range (&expr, loc, close_paren_loc);
   12826          313 :             break;
   12827          982 :           }
   12828           23 :         case RID_BUILTIN_CALL_WITH_STATIC_CHAIN:
   12829           23 :           {
   12830           23 :             vec<c_expr_t, va_gc> *cexpr_list;
   12831           23 :             c_expr_t *e2_p;
   12832           23 :             tree chain_value;
   12833           23 :             location_t close_paren_loc;
   12834              : 
   12835           23 :             c_parser_consume_token (parser);
   12836           23 :             if (!c_parser_get_builtin_args (parser,
   12837              :                                             "__builtin_call_with_static_chain",
   12838              :                                             &cexpr_list, false,
   12839              :                                             &close_paren_loc))
   12840              :               {
   12841            0 :                 expr.set_error ();
   12842            0 :                 break;
   12843              :               }
   12844           23 :             if (vec_safe_length (cexpr_list) != 2)
   12845              :               {
   12846            0 :                 error_at (loc, "wrong number of arguments to "
   12847              :                                "%<__builtin_call_with_static_chain%>");
   12848            0 :                 expr.set_error ();
   12849            0 :                 break;
   12850              :               }
   12851              : 
   12852           23 :             expr = (*cexpr_list)[0];
   12853           23 :             e2_p = &(*cexpr_list)[1];
   12854           23 :             *e2_p = convert_lvalue_to_rvalue (loc, *e2_p, true, true);
   12855           23 :             chain_value = e2_p->value;
   12856           23 :             mark_exp_read (chain_value);
   12857              : 
   12858           23 :             if (TREE_CODE (expr.value) != CALL_EXPR)
   12859            3 :               error_at (loc, "first argument to "
   12860              :                         "%<__builtin_call_with_static_chain%> "
   12861              :                         "must be a call expression");
   12862           20 :             else if (TREE_CODE (TREE_TYPE (chain_value)) != POINTER_TYPE)
   12863            1 :               error_at (loc, "second argument to "
   12864              :                         "%<__builtin_call_with_static_chain%> "
   12865              :                         "must be a pointer type");
   12866              :             else
   12867           19 :               CALL_EXPR_STATIC_CHAIN (expr.value) = chain_value;
   12868           23 :             set_c_expr_source_range (&expr, loc, close_paren_loc);
   12869           23 :             break;
   12870              :           }
   12871        12079 :         case RID_BUILTIN_COMPLEX:
   12872        12079 :           {
   12873        12079 :             vec<c_expr_t, va_gc> *cexpr_list;
   12874        12079 :             c_expr_t *e1_p, *e2_p;
   12875        12079 :             location_t close_paren_loc;
   12876              : 
   12877        12079 :             c_parser_consume_token (parser);
   12878        12079 :             if (!c_parser_get_builtin_args (parser,
   12879              :                                             "__builtin_complex",
   12880              :                                             &cexpr_list, false,
   12881              :                                             &close_paren_loc))
   12882              :               {
   12883            1 :                 expr.set_error ();
   12884            1 :                 break;
   12885              :               }
   12886              : 
   12887        12078 :             if (vec_safe_length (cexpr_list) != 2)
   12888              :               {
   12889            2 :                 error_at (loc, "wrong number of arguments to "
   12890              :                                "%<__builtin_complex%>");
   12891            2 :                 expr.set_error ();
   12892            2 :                 break;
   12893              :               }
   12894              : 
   12895        12076 :             e1_p = &(*cexpr_list)[0];
   12896        12076 :             e2_p = &(*cexpr_list)[1];
   12897              : 
   12898        12076 :             *e1_p = convert_lvalue_to_rvalue (loc, *e1_p, true, true);
   12899        12076 :             if (TREE_CODE (e1_p->value) == EXCESS_PRECISION_EXPR)
   12900           56 :               e1_p->value = convert (TREE_TYPE (e1_p->value),
   12901           56 :                                      TREE_OPERAND (e1_p->value, 0));
   12902        12076 :             *e2_p = convert_lvalue_to_rvalue (loc, *e2_p, true, true);
   12903        12076 :             if (TREE_CODE (e2_p->value) == EXCESS_PRECISION_EXPR)
   12904           56 :               e2_p->value = convert (TREE_TYPE (e2_p->value),
   12905           56 :                                      TREE_OPERAND (e2_p->value, 0));
   12906        12076 :             if (!SCALAR_FLOAT_TYPE_P (TREE_TYPE (e1_p->value))
   12907        12075 :                 || DECIMAL_FLOAT_TYPE_P (TREE_TYPE (e1_p->value))
   12908        12074 :                 || !SCALAR_FLOAT_TYPE_P (TREE_TYPE (e2_p->value))
   12909        24149 :                 || DECIMAL_FLOAT_TYPE_P (TREE_TYPE (e2_p->value)))
   12910              :               {
   12911            3 :                 error_at (loc, "%<__builtin_complex%> operand "
   12912              :                           "not of real binary floating-point type");
   12913            3 :                 expr.set_error ();
   12914            3 :                 break;
   12915              :               }
   12916        12073 :             if (TYPE_MAIN_VARIANT (TREE_TYPE (e1_p->value))
   12917        12073 :                 != TYPE_MAIN_VARIANT (TREE_TYPE (e2_p->value)))
   12918              :               {
   12919            1 :                 error_at (loc,
   12920              :                           "%<__builtin_complex%> operands of different types");
   12921            1 :                 expr.set_error ();
   12922            1 :                 break;
   12923              :               }
   12924        12072 :             pedwarn_c90 (loc, OPT_Wpedantic,
   12925              :                          "ISO C90 does not support complex types");
   12926        12072 :             expr.value = build2_loc (loc, COMPLEX_EXPR,
   12927              :                                      build_complex_type
   12928        12072 :                                      (TYPE_MAIN_VARIANT
   12929              :                                       (TREE_TYPE (e1_p->value))),
   12930              :                                      e1_p->value, e2_p->value);
   12931        12072 :             set_c_expr_source_range (&expr, loc, close_paren_loc);
   12932        12072 :             break;
   12933              :           }
   12934           88 :         case RID_BUILTIN_COUNTED_BY_REF:
   12935           88 :           {
   12936           88 :             vec<c_expr_t, va_gc> *cexpr_list;
   12937           88 :             c_expr_t *e_p;
   12938           88 :             location_t close_paren_loc;
   12939              : 
   12940           88 :             c_parser_consume_token (parser);
   12941           88 :             if (!c_parser_get_builtin_args (parser,
   12942              :                                             "__builtin_counted_by_ref",
   12943              :                                             &cexpr_list, false,
   12944              :                                             &close_paren_loc))
   12945              :               {
   12946            0 :                 expr.set_error ();
   12947            0 :                 break;
   12948              :               }
   12949           88 :             if (vec_safe_length (cexpr_list) != 1)
   12950              :               {
   12951            4 :                 error_at (loc, "wrong number of arguments to "
   12952              :                                "%<__builtin_counted_by_ref%>");
   12953            4 :                 expr.set_error ();
   12954            4 :                 break;
   12955              :               }
   12956              : 
   12957           84 :             e_p = &(*cexpr_list)[0];
   12958           84 :             tree ref = e_p->value;
   12959              : 
   12960           84 :             if (TREE_CODE (TREE_TYPE (ref)) != ARRAY_TYPE
   12961           84 :                  && TREE_CODE (TREE_TYPE (ref)) != POINTER_TYPE)
   12962              :               {
   12963            2 :                 error_at (loc, "the argument to %<__builtin_counted_by_ref%>"
   12964              :                                 " must be an array or pointer");
   12965            2 :                 expr.set_error ();
   12966            2 :                 break;
   12967              :               }
   12968              : 
   12969           82 :             if (TREE_CODE (ref) != COMPONENT_REF)
   12970              :               {
   12971            2 :                 error_at (loc, "the argument to %<__builtin_counted_by_ref%>"
   12972              :                                 " must be a field of a structure");
   12973            2 :                 expr.set_error ();
   12974            2 :                 break;
   12975              :               }
   12976              : 
   12977              :             /* If the ref is inside TYPEOF or ALIGNOF, the call to
   12978              :                .ACCESS_WITH_SIZE was not generated by the routine
   12979              :                build_component_ref by default, we should generate it here.  */
   12980           80 :             if (TREE_CODE (ref) == COMPONENT_REF)
   12981           80 :               ref = handle_counted_by_for_component_ref (loc, ref);
   12982              : 
   12983           80 :             if (has_counted_by_object (ref))
   12984           50 :               expr.value = get_counted_by_ref (ref);
   12985              :             else
   12986           30 :               expr.value = null_pointer_node;
   12987              : 
   12988           80 :             set_c_expr_source_range (&expr, loc, close_paren_loc);
   12989           80 :             break;
   12990              :           }
   12991       475399 :         case RID_BUILTIN_SHUFFLE:
   12992       475399 :           {
   12993       475399 :             vec<c_expr_t, va_gc> *cexpr_list;
   12994       475399 :             unsigned int i;
   12995       475399 :             c_expr_t *p;
   12996       475399 :             location_t close_paren_loc;
   12997              : 
   12998       475399 :             c_parser_consume_token (parser);
   12999       475399 :             if (!c_parser_get_builtin_args (parser,
   13000              :                                             "__builtin_shuffle",
   13001              :                                             &cexpr_list, false,
   13002              :                                             &close_paren_loc))
   13003              :               {
   13004            0 :                 expr.set_error ();
   13005            0 :                 break;
   13006              :               }
   13007              : 
   13008      1467841 :             FOR_EACH_VEC_SAFE_ELT (cexpr_list, i, p)
   13009       992442 :               *p = convert_lvalue_to_rvalue (loc, *p, true, true);
   13010              : 
   13011       475399 :             if (vec_safe_length (cexpr_list) == 2)
   13012       433755 :               expr.value = c_build_vec_perm_expr (loc, (*cexpr_list)[0].value,
   13013              :                                                   NULL_TREE,
   13014       433755 :                                                   (*cexpr_list)[1].value);
   13015              : 
   13016        41644 :             else if (vec_safe_length (cexpr_list) == 3)
   13017        41644 :               expr.value = c_build_vec_perm_expr (loc, (*cexpr_list)[0].value,
   13018        41644 :                                                   (*cexpr_list)[1].value,
   13019        41644 :                                                   (*cexpr_list)[2].value);
   13020              :             else
   13021              :               {
   13022            0 :                 error_at (loc, "wrong number of arguments to "
   13023              :                                "%<__builtin_shuffle%>");
   13024            0 :                 expr.set_error ();
   13025              :               }
   13026       475399 :             set_c_expr_source_range (&expr, loc, close_paren_loc);
   13027       475399 :             break;
   13028              :           }
   13029      1091555 :         case RID_BUILTIN_SHUFFLEVECTOR:
   13030      1091555 :           {
   13031      1091555 :             vec<c_expr_t, va_gc> *cexpr_list;
   13032      1091555 :             unsigned int i;
   13033      1091555 :             c_expr_t *p;
   13034      1091555 :             location_t close_paren_loc;
   13035              : 
   13036      1091555 :             c_parser_consume_token (parser);
   13037      1091555 :             if (!c_parser_get_builtin_args (parser,
   13038              :                                             "__builtin_shufflevector",
   13039              :                                             &cexpr_list, false,
   13040              :                                             &close_paren_loc))
   13041              :               {
   13042            0 :                 expr.set_error ();
   13043            0 :                 break;
   13044              :               }
   13045              : 
   13046     17000949 :             FOR_EACH_VEC_SAFE_ELT (cexpr_list, i, p)
   13047     15909394 :               *p = convert_lvalue_to_rvalue (loc, *p, true, true);
   13048              : 
   13049      1091555 :             if (vec_safe_length (cexpr_list) < 3)
   13050              :               {
   13051            0 :                 error_at (loc, "wrong number of arguments to "
   13052              :                                "%<__builtin_shuffle%>");
   13053            0 :                 expr.set_error ();
   13054              :               }
   13055              :             else
   13056              :               {
   13057      1091555 :                 auto_vec<tree, 16> mask;
   13058     14817839 :                 for (i = 2; i < cexpr_list->length (); ++i)
   13059     13726284 :                   mask.safe_push ((*cexpr_list)[i].value);
   13060      1091555 :                 expr.value = c_build_shufflevector (loc, (*cexpr_list)[0].value,
   13061      1091555 :                                                     (*cexpr_list)[1].value,
   13062              :                                                     mask);
   13063      1091555 :               }
   13064      1091555 :             set_c_expr_source_range (&expr, loc, close_paren_loc);
   13065      1091555 :             break;
   13066              :           }
   13067          444 :         case RID_BUILTIN_CONVERTVECTOR:
   13068          444 :           {
   13069          444 :             location_t start_loc = loc;
   13070          444 :             c_parser_consume_token (parser);
   13071          444 :             matching_parens parens;
   13072          444 :             if (!parens.require_open (parser))
   13073              :               {
   13074            0 :                 expr.set_error ();
   13075            2 :                 break;
   13076              :               }
   13077          444 :             e1 = c_parser_expr_no_commas (parser, NULL);
   13078          444 :             mark_exp_read (e1.value);
   13079          444 :             if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>"))
   13080              :               {
   13081            2 :                 c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   13082            2 :                 expr.set_error ();
   13083            2 :                 break;
   13084              :               }
   13085          442 :             loc = c_parser_peek_token (parser)->location;
   13086          442 :             t1 = c_parser_type_name (parser);
   13087          442 :             location_t end_loc = c_parser_peek_token (parser)->get_finish ();
   13088          442 :             c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   13089              :                                        "expected %<)%>");
   13090          442 :             if (t1 == NULL)
   13091            1 :               expr.set_error ();
   13092              :             else
   13093              :               {
   13094          441 :                 tree type_expr = NULL_TREE;
   13095          441 :                 expr.value = c_build_vec_convert (start_loc, e1.value, loc,
   13096              :                                                   groktypename (t1, &type_expr,
   13097              :                                                                 NULL));
   13098          441 :                 set_c_expr_source_range (&expr, start_loc, end_loc);
   13099              :               }
   13100              :           }
   13101          442 :           break;
   13102           12 :         case RID_BUILTIN_ASSOC_BARRIER:
   13103           12 :           {
   13104           12 :             location_t start_loc = loc;
   13105           12 :             c_parser_consume_token (parser);
   13106           12 :             matching_parens parens;
   13107           12 :             if (!parens.require_open (parser))
   13108              :               {
   13109            0 :                 expr.set_error ();
   13110            0 :                 break;
   13111              :               }
   13112           12 :             e1 = c_parser_expr_no_commas (parser, NULL);
   13113           12 :             mark_exp_read (e1.value);
   13114           12 :             location_t end_loc = c_parser_peek_token (parser)->get_finish ();
   13115           12 :             parens.skip_until_found_close (parser);
   13116           12 :             expr = parser_build_unary_op (loc, PAREN_EXPR, e1);
   13117           12 :             set_c_expr_source_range (&expr, start_loc, end_loc);
   13118              :           }
   13119           12 :           break;
   13120         1078 :         case RID_BUILTIN_STDC:
   13121         1078 :           {
   13122         1078 :             vec<c_expr_t, va_gc> *cexpr_list;
   13123         1078 :             c_expr_t *arg_p;
   13124         1078 :             location_t close_paren_loc;
   13125         1078 :             enum c_builtin_stdc {
   13126              :               C_BUILTIN_STDC_BIT_CEIL,
   13127              :               C_BUILTIN_STDC_BIT_FLOOR,
   13128              :               C_BUILTIN_STDC_BIT_WIDTH,
   13129              :               C_BUILTIN_STDC_COUNT_ONES,
   13130              :               C_BUILTIN_STDC_COUNT_ZEROS,
   13131              :               C_BUILTIN_STDC_FIRST_LEADING_ONE,
   13132              :               C_BUILTIN_STDC_FIRST_LEADING_ZERO,
   13133              :               C_BUILTIN_STDC_FIRST_TRAILING_ONE,
   13134              :               C_BUILTIN_STDC_FIRST_TRAILING_ZERO,
   13135              :               C_BUILTIN_STDC_HAS_SINGLE_BIT,
   13136              :               C_BUILTIN_STDC_LEADING_ONES,
   13137              :               C_BUILTIN_STDC_LEADING_ZEROS,
   13138              :               C_BUILTIN_STDC_ROTATE_LEFT,
   13139              :               C_BUILTIN_STDC_ROTATE_RIGHT,
   13140              :               C_BUILTIN_STDC_TRAILING_ONES,
   13141              :               C_BUILTIN_STDC_TRAILING_ZEROS,
   13142              :               C_BUILTIN_STDC_MAX
   13143         1078 :             } stdc_rid = C_BUILTIN_STDC_MAX;
   13144         1078 :             const char *name
   13145         1078 :               = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   13146         1078 :             unsigned num_args = 1;
   13147         1078 :             switch (name[sizeof ("__builtin_stdc_") - 1])
   13148              :               {
   13149          204 :               case 'b':
   13150          204 :                 switch (name[sizeof ("__builtin_stdc_bit_") - 1])
   13151              :                   {
   13152              :                   case 'c':
   13153              :                     stdc_rid = C_BUILTIN_STDC_BIT_CEIL;
   13154              :                     break;
   13155           65 :                   case 'f':
   13156           65 :                     stdc_rid = C_BUILTIN_STDC_BIT_FLOOR;
   13157           65 :                     break;
   13158              :                   default:
   13159              :                     stdc_rid = C_BUILTIN_STDC_BIT_WIDTH;
   13160              :                     break;
   13161              :                   }
   13162              :                 break;
   13163          106 :               case 'c':
   13164          106 :                 if (name[sizeof ("__builtin_stdc_count_") - 1] == 'o')
   13165              :                   stdc_rid = C_BUILTIN_STDC_COUNT_ONES;
   13166              :                 else
   13167           53 :                   stdc_rid = C_BUILTIN_STDC_COUNT_ZEROS;
   13168              :                 break;
   13169          215 :               case 'f':
   13170          215 :                 switch (name[sizeof ("__builtin_stdc_first_trailing_") - 1])
   13171              :                   {
   13172              :                   case 'n':
   13173              :                     stdc_rid = C_BUILTIN_STDC_FIRST_LEADING_ONE;
   13174              :                     break;
   13175              :                   case 'e':
   13176              :                     stdc_rid = C_BUILTIN_STDC_FIRST_LEADING_ZERO;
   13177              :                     break;
   13178              :                   case 'o':
   13179              :                     stdc_rid = C_BUILTIN_STDC_FIRST_TRAILING_ONE;
   13180              :                     break;
   13181              :                   default:
   13182              :                     stdc_rid = C_BUILTIN_STDC_FIRST_TRAILING_ZERO;
   13183              :                     break;
   13184              :                   }
   13185              :                 break;
   13186              :               case 'h':
   13187              :                 stdc_rid = C_BUILTIN_STDC_HAS_SINGLE_BIT;
   13188              :                 break;
   13189          106 :               case 'l':
   13190          106 :                 if (name[sizeof ("__builtin_stdc_leading_") - 1] == 'o')
   13191              :                   stdc_rid = C_BUILTIN_STDC_LEADING_ONES;
   13192              :                 else
   13193           53 :                   stdc_rid = C_BUILTIN_STDC_LEADING_ZEROS;
   13194              :                 break;
   13195          288 :               case 'r':
   13196          288 :                 if (name[sizeof ("__builtin_stdc_rotate_") - 1] == 'l')
   13197              :                   stdc_rid = C_BUILTIN_STDC_ROTATE_LEFT;
   13198              :                 else
   13199          138 :                   stdc_rid = C_BUILTIN_STDC_ROTATE_RIGHT;
   13200              :                 num_args = 2;
   13201              :                 break;
   13202          106 :               case 't':
   13203          106 :                 if (name[sizeof ("__builtin_stdc_trailing_") - 1] == 'o')
   13204              :                   stdc_rid = C_BUILTIN_STDC_TRAILING_ONES;
   13205              :                 else
   13206           53 :                   stdc_rid = C_BUILTIN_STDC_TRAILING_ZEROS;
   13207              :                 break;
   13208              :               }
   13209          443 :             gcc_checking_assert (stdc_rid != C_BUILTIN_STDC_MAX);
   13210              : 
   13211         1078 :             c_parser_consume_token (parser);
   13212         1078 :             if (!c_parser_get_builtin_args (parser, name,
   13213              :                                             &cexpr_list, false,
   13214              :                                             &close_paren_loc))
   13215              :               {
   13216            0 :                 expr.set_error ();
   13217            0 :                 break;
   13218              :               }
   13219              : 
   13220         2140 :             if (vec_safe_length (cexpr_list) != num_args)
   13221              :               {
   13222           34 :                 error_at (loc, "wrong number of arguments to %qs", name);
   13223           34 :                 expr.set_error ();
   13224           34 :                 break;
   13225              :               }
   13226              : 
   13227         1044 :             arg_p = &(*cexpr_list)[0];
   13228         1044 :             *arg_p = convert_lvalue_to_rvalue (loc, *arg_p, true, true);
   13229         1044 :             if (!INTEGRAL_TYPE_P (TREE_TYPE (arg_p->value)))
   13230              :               {
   13231           80 :                 error_at (loc, "%qs operand not an integral type", name);
   13232           80 :                 expr.set_error ();
   13233           80 :                 break;
   13234              :               }
   13235          964 :             if (TREE_CODE (TREE_TYPE (arg_p->value)) == ENUMERAL_TYPE)
   13236              :               {
   13237           16 :                 error_at (loc, "argument %u in call to function "
   13238              :                           "%qs has enumerated type", 1, name);
   13239           16 :                 expr.set_error ();
   13240           16 :                 break;
   13241              :               }
   13242          948 :             if (TREE_CODE (TREE_TYPE (arg_p->value)) == BOOLEAN_TYPE)
   13243              :               {
   13244           16 :                 error_at (loc, "argument %u in call to function "
   13245              :                           "%qs has boolean type", 1, name);
   13246           16 :                 expr.set_error ();
   13247           16 :                 break;
   13248              :               }
   13249          932 :             if (!TYPE_UNSIGNED (TREE_TYPE (arg_p->value)))
   13250              :               {
   13251           16 :                 error_at (loc, "argument 1 in call to function "
   13252              :                           "%qs has signed type", name);
   13253           16 :                 expr.set_error ();
   13254           16 :                 break;
   13255              :               }
   13256          916 :             if (TYPE_MAIN_VARIANT (TREE_TYPE (arg_p->value))
   13257          916 :                 == char_type_node)
   13258              :               {
   13259           16 :                 error_at (loc, "argument 1 in call to function "
   13260              :                           "%qs has %<char%> type", name);
   13261           16 :                 expr.set_error ();
   13262           16 :                 break;
   13263              :               }
   13264          900 :             tree arg = arg_p->value;
   13265          900 :             tree type = TYPE_MAIN_VARIANT (TREE_TYPE (arg));
   13266              :             /* Expand:
   13267              :                __builtin_stdc_leading_zeros (arg) as
   13268              :                  (unsigned int) __builtin_clzg (arg, prec)
   13269              :                __builtin_stdc_leading_ones (arg) as
   13270              :                  (unsigned int) __builtin_clzg ((type) ~arg, prec)
   13271              :                __builtin_stdc_trailing_zeros (arg) as
   13272              :                  (unsigned int) __builtin_ctzg (arg, prec)
   13273              :                __builtin_stdc_trailing_ones (arg) as
   13274              :                  (unsigned int) __builtin_ctzg ((type) ~arg, prec)
   13275              :                __builtin_stdc_first_leading_zero (arg) as
   13276              :                  __builtin_clzg ((type) ~arg, -1) + 1U
   13277              :                __builtin_stdc_first_leading_one (arg) as
   13278              :                  __builtin_clzg (arg, -1) + 1U
   13279              :                __builtin_stdc_first_trailing_zero (arg) as
   13280              :                  __builtin_ctzg ((type) ~arg, -1) + 1U
   13281              :                __builtin_stdc_first_trailing_one (arg) as
   13282              :                  __builtin_ctzg (arg, -1) + 1U
   13283              :                __builtin_stdc_count_zeros (arg) as
   13284              :                  (unsigned int) __builtin_popcountg ((type) ~arg)
   13285              :                __builtin_stdc_count_ones (arg) as
   13286              :                  (unsigned int) __builtin_popcountg (arg)
   13287              :                __builtin_stdc_has_single_bit (arg) as
   13288              :                  (_Bool) (__builtin_popcountg (arg) == 1)
   13289              :                __builtin_stdc_bit_width (arg) as
   13290              :                  (unsigned int) (prec - __builtin_clzg (arg, prec))
   13291              :                __builtin_stdc_bit_floor (arg) as
   13292              :                  arg == 0 ? (type) 0
   13293              :                           : (type) 1 << (prec - 1 - __builtin_clzg (arg))
   13294              :                __builtin_stdc_bit_ceil (arg) as
   13295              :                  arg <= 1 ? (type) 1
   13296              :                           : (type) 2 << (prec - 1 - __builtin_clzg (arg - 1))
   13297              :                without evaluating arg multiple times, type being
   13298              :                __typeof (arg) and prec __builtin_popcountg ((type) ~0)).  */
   13299          900 :             int prec = TYPE_PRECISION (type);
   13300          900 :             if (num_args == 2)
   13301              :               {
   13302              :                 /* Expand:
   13303              :                    __builtin_stdc_rotate_left (arg1, arg2) as
   13304              :                    arg1 r<< (arg2 % prec)
   13305              :                    __builtin_stdc_rotate_right (arg1, arg2) as
   13306              :                    arg1 r>> (arg2 % prec).  */
   13307          264 :                 arg_p = &(*cexpr_list)[1];
   13308          264 :                 *arg_p = convert_lvalue_to_rvalue (loc, *arg_p, true, true);
   13309          264 :                 if (!INTEGRAL_TYPE_P (TREE_TYPE (arg_p->value)))
   13310              :                   {
   13311           10 :                     error_at (loc, "%qs operand not an integral type", name);
   13312           10 :                     expr.set_error ();
   13313           10 :                     break;
   13314              :                   }
   13315          254 :                 if (TREE_CODE (TREE_TYPE (arg_p->value)) == ENUMERAL_TYPE)
   13316              :                   {
   13317            2 :                     error_at (loc, "argument %u in call to function "
   13318              :                                    "%qs has enumerated type", 2, name);
   13319            2 :                     expr.set_error ();
   13320            2 :                     break;
   13321              :                   }
   13322          252 :                 tree arg1 = save_expr (arg);
   13323          252 :                 tree arg2 = save_expr (arg_p->value);
   13324          252 :                 tree_code code;
   13325          252 :                 if (stdc_rid == C_BUILTIN_STDC_ROTATE_LEFT)
   13326              :                   code = LROTATE_EXPR;
   13327              :                 else
   13328          120 :                   code = RROTATE_EXPR;
   13329              : 
   13330          252 :                 if (TREE_CODE (arg2) == INTEGER_CST
   13331          252 :                     && tree_int_cst_sgn (arg2) < 0)
   13332           20 :                   warning_at (loc, OPT_Wshift_count_negative,
   13333              :                               "rotate count is negative");
   13334              : 
   13335          252 :                 tree instrument_expr = NULL_TREE;
   13336          252 :                 if (sanitize_flags_p (SANITIZE_SHIFT))
   13337           28 :                   instrument_expr = ubsan_instrument_shift (loc, code,
   13338              :                                                             arg1, arg2);
   13339              : 
   13340              :                 /* Promote arg2 to unsigned just so that we don't
   13341              :                    need to deal with arg2 type not being able to represent
   13342              :                    prec.  In the end gimplification uses unsigned int
   13343              :                    for all shifts/rotates anyway.  */
   13344          252 :                 if (TYPE_PRECISION (TREE_TYPE (arg2))
   13345          252 :                     < TYPE_PRECISION (integer_type_node))
   13346           13 :                   arg2 = fold_convert (unsigned_type_node, arg2);
   13347              : 
   13348          252 :                 if (TYPE_UNSIGNED (TREE_TYPE (arg2)))
   13349           26 :                   arg2 = build2_loc (loc, TRUNC_MOD_EXPR, TREE_TYPE (arg2),
   13350           26 :                                      arg2, build_int_cst (TREE_TYPE (arg2),
   13351           26 :                                                           prec));
   13352              :                 else
   13353              :                   {
   13354              :                     /* When second argument is signed, just do the modulo in
   13355              :                        unsigned type, that results in better generated code
   13356              :                        (for power of 2 precisions bitwise AND).  */
   13357          226 :                     tree utype = c_common_unsigned_type (TREE_TYPE (arg2));
   13358          226 :                     arg2 = build2_loc (loc, TRUNC_MOD_EXPR, utype,
   13359              :                                        fold_convert (utype, arg2),
   13360          226 :                                        build_int_cst (utype, prec));
   13361              :                   }
   13362              : 
   13363              :                 /* The middle-end isn't prepared to handle {L,R}ROTATE_EXPR
   13364              :                    on types without mode precision, except for large/huge
   13365              :                    _BitInt types.  */
   13366          252 :                 if (type_has_mode_precision_p (TREE_TYPE (arg1))
   13367          252 :                     || (TREE_CODE (TREE_TYPE (arg1)) == BITINT_TYPE
   13368          154 :                         && prec > MAX_FIXED_MODE_SIZE))
   13369          193 :                   expr.value = build2_loc (loc, code, TREE_TYPE (arg1), arg1,
   13370              :                                            arg2);
   13371              :                 else
   13372              :                   {
   13373           59 :                     arg2 = save_expr (arg2);
   13374           84 :                     tree t1 = build2_loc (loc, (code == LROTATE_EXPR
   13375              :                                                 ? LSHIFT_EXPR : RSHIFT_EXPR),
   13376           59 :                                           TREE_TYPE (arg1), arg1, arg2);
   13377          118 :                     tree t2 = build2_loc (loc, MINUS_EXPR,
   13378           59 :                                           TREE_TYPE (arg2),
   13379           59 :                                           build_int_cst (TREE_TYPE (arg2),
   13380           59 :                                                          prec), arg2);
   13381           84 :                     t2 = build2_loc (loc, (code == LROTATE_EXPR
   13382              :                                            ? RSHIFT_EXPR : LSHIFT_EXPR),
   13383           59 :                                      TREE_TYPE (arg1), arg1, t2);
   13384           59 :                     suppress_warning (t2, OPT_Wshift_count_overflow);
   13385           59 :                     tree t3 = build2_loc (loc, BIT_IOR_EXPR,
   13386           59 :                                           TREE_TYPE (arg1), t1, t2);
   13387           59 :                     tree t4 = build2_loc (loc, NE_EXPR, boolean_type_node,
   13388              :                                           arg2,
   13389           59 :                                           build_zero_cst (TREE_TYPE (arg2)));
   13390           59 :                     t4 = build2_loc (loc, COMPOUND_EXPR, boolean_type_node,
   13391              :                                      arg1, t4);
   13392           59 :                     expr.value = build3_loc (loc, COND_EXPR,
   13393           59 :                                              TREE_TYPE (arg1), t4, t3, arg1);
   13394              :                   }
   13395          252 :                 if (instrument_expr)
   13396           28 :                   expr.value = build2_loc (loc, COMPOUND_EXPR,
   13397           28 :                                            TREE_TYPE (expr.value),
   13398              :                                            instrument_expr, expr.value);
   13399          252 :                 set_c_expr_source_range (&expr, loc, close_paren_loc);
   13400          252 :                 break;
   13401              :               }
   13402          636 :             tree barg1 = arg;
   13403          636 :             switch (stdc_rid)
   13404              :               {
   13405           70 :               case C_BUILTIN_STDC_BIT_CEIL:
   13406           70 :                 arg = save_expr (arg);
   13407           70 :                 barg1 = build2_loc (loc, PLUS_EXPR, type, arg,
   13408              :                                     build_int_cst (type, -1));
   13409           70 :                 break;
   13410           54 :               case C_BUILTIN_STDC_BIT_FLOOR:
   13411           54 :                 barg1 = arg = save_expr (arg);
   13412           54 :                 break;
   13413          211 :               case C_BUILTIN_STDC_COUNT_ZEROS:
   13414          211 :               case C_BUILTIN_STDC_FIRST_LEADING_ZERO:
   13415          211 :               case C_BUILTIN_STDC_FIRST_TRAILING_ZERO:
   13416          211 :               case C_BUILTIN_STDC_LEADING_ONES:
   13417          211 :               case C_BUILTIN_STDC_TRAILING_ONES:
   13418          211 :                 barg1 = build1_loc (loc, BIT_NOT_EXPR, type, arg);
   13419          211 :                 break;
   13420              :               default:
   13421              :                 break;
   13422              :               }
   13423          636 :             tree barg2 = NULL_TREE;
   13424          636 :             switch (stdc_rid)
   13425              :               {
   13426          215 :               case C_BUILTIN_STDC_BIT_WIDTH:
   13427          215 :               case C_BUILTIN_STDC_LEADING_ONES:
   13428          215 :               case C_BUILTIN_STDC_LEADING_ZEROS:
   13429          215 :               case C_BUILTIN_STDC_TRAILING_ONES:
   13430          215 :               case C_BUILTIN_STDC_TRAILING_ZEROS:
   13431          215 :                 barg2 = build_int_cst (integer_type_node, prec);
   13432          215 :                 break;
   13433          171 :               case C_BUILTIN_STDC_FIRST_LEADING_ONE:
   13434          171 :               case C_BUILTIN_STDC_FIRST_LEADING_ZERO:
   13435          171 :               case C_BUILTIN_STDC_FIRST_TRAILING_ONE:
   13436          171 :               case C_BUILTIN_STDC_FIRST_TRAILING_ZERO:
   13437          171 :                 barg2 = integer_minus_one_node;
   13438          171 :                 break;
   13439              :               default:
   13440              :                 break;
   13441              :               }
   13442          636 :             tree fndecl = NULL_TREE;
   13443          636 :             switch (stdc_rid)
   13444              :               {
   13445          342 :               case C_BUILTIN_STDC_BIT_CEIL:
   13446          342 :               case C_BUILTIN_STDC_BIT_FLOOR:
   13447          342 :               case C_BUILTIN_STDC_BIT_WIDTH:
   13448          342 :               case C_BUILTIN_STDC_FIRST_LEADING_ONE:
   13449          342 :               case C_BUILTIN_STDC_FIRST_LEADING_ZERO:
   13450          342 :               case C_BUILTIN_STDC_LEADING_ONES:
   13451          342 :               case C_BUILTIN_STDC_LEADING_ZEROS:
   13452          342 :                 fndecl = builtin_decl_explicit (BUILT_IN_CLZG);
   13453          342 :                 break;
   13454          168 :               case C_BUILTIN_STDC_FIRST_TRAILING_ONE:
   13455          168 :               case C_BUILTIN_STDC_FIRST_TRAILING_ZERO:
   13456          168 :               case C_BUILTIN_STDC_TRAILING_ONES:
   13457          168 :               case C_BUILTIN_STDC_TRAILING_ZEROS:
   13458          168 :                 fndecl = builtin_decl_explicit (BUILT_IN_CTZG);
   13459          168 :                 break;
   13460          126 :               case C_BUILTIN_STDC_COUNT_ONES:
   13461          126 :               case C_BUILTIN_STDC_COUNT_ZEROS:
   13462          126 :               case C_BUILTIN_STDC_HAS_SINGLE_BIT:
   13463          126 :                 fndecl = builtin_decl_explicit (BUILT_IN_POPCOUNTG);
   13464          126 :                 break;
   13465            0 :               default:
   13466            0 :                 gcc_unreachable ();
   13467              :               }
   13468              :             /* Construct a call to __builtin_{clz,ctz,popcount}g.  */
   13469          636 :             int nargs = barg2 != NULL_TREE ? 2 : 1;
   13470          636 :             vec<tree, va_gc> *args;
   13471          636 :             vec_alloc (args, nargs);
   13472          636 :             vec<tree, va_gc> *origtypes;
   13473          636 :             vec_alloc (origtypes, nargs);
   13474         1272 :             auto_vec<location_t> arg_loc (nargs);
   13475          636 :             args->quick_push (barg1);
   13476          636 :             arg_loc.quick_push (arg_p->get_location ());
   13477          636 :             origtypes->quick_push (arg_p->original_type);
   13478          636 :             if (nargs == 2)
   13479              :               {
   13480          386 :                 args->quick_push (barg2);
   13481          386 :                 arg_loc.quick_push (loc);
   13482          386 :                 origtypes->quick_push (integer_type_node);
   13483              :               }
   13484          636 :             expr.value = c_build_function_call_vec (loc, arg_loc, fndecl,
   13485              :                                                     args, origtypes);
   13486          636 :             set_c_expr_source_range (&expr, loc, close_paren_loc);
   13487          636 :             if (expr.value == error_mark_node)
   13488              :               break;
   13489          636 :             switch (stdc_rid)
   13490              :               {
   13491          124 :               case C_BUILTIN_STDC_BIT_CEIL:
   13492          124 :               case C_BUILTIN_STDC_BIT_FLOOR:
   13493          124 :                 --prec;
   13494              :                 /* FALLTHRU */
   13495          171 :               case C_BUILTIN_STDC_BIT_WIDTH:
   13496          171 :                 expr.value = build2_loc (loc, MINUS_EXPR, integer_type_node,
   13497              :                                          build_int_cst (integer_type_node,
   13498          171 :                                                         prec), expr.value);
   13499          171 :                 break;
   13500          171 :               case C_BUILTIN_STDC_FIRST_LEADING_ONE:
   13501          171 :               case C_BUILTIN_STDC_FIRST_LEADING_ZERO:
   13502          171 :               case C_BUILTIN_STDC_FIRST_TRAILING_ONE:
   13503          171 :               case C_BUILTIN_STDC_FIRST_TRAILING_ZERO:
   13504          171 :                 expr.value = build2_loc (loc, PLUS_EXPR, integer_type_node,
   13505              :                                          expr.value, integer_one_node);
   13506          171 :                 break;
   13507           42 :               case C_BUILTIN_STDC_HAS_SINGLE_BIT:
   13508           42 :                 expr.value = build2_loc (loc, EQ_EXPR, boolean_type_node,
   13509              :                                          expr.value, integer_one_node);
   13510           42 :                 break;
   13511              :               default:
   13512              :                 break;
   13513              :               }
   13514              : 
   13515          384 :             if (stdc_rid != C_BUILTIN_STDC_BIT_CEIL
   13516              :                 && stdc_rid != C_BUILTIN_STDC_BIT_FLOOR)
   13517              :               {
   13518          512 :                 if (stdc_rid != C_BUILTIN_STDC_HAS_SINGLE_BIT)
   13519          470 :                   expr.value = fold_convert_loc (loc, unsigned_type_node,
   13520              :                                                  expr.value);
   13521              :                 break;
   13522              :               }
   13523              :             /* For __builtin_stdc_bit_ceil (0U) or __builtin_stdc_bit_ceil (1U)
   13524              :                or __builtin_stdc_bit_floor (0U) avoid bogus -Wshift-count-*
   13525              :                warnings.  The LSHIFT_EXPR is in dead code in that case.  */
   13526          124 :             if (integer_zerop (arg)
   13527          124 :                 || (stdc_rid == C_BUILTIN_STDC_BIT_CEIL && integer_onep (arg)))
   13528           42 :               expr.value = build_int_cst (type, 0);
   13529              :             else
   13530              :               {
   13531           82 :                 expr.value
   13532           82 :                   = build2_loc (loc, LSHIFT_EXPR, type,
   13533              :                                 build_int_cst (type,
   13534              :                                                (stdc_rid
   13535              :                                                 == C_BUILTIN_STDC_BIT_CEIL
   13536          117 :                                                 ? 2 : 1)), expr.value);
   13537           82 :                 suppress_warning (expr.value, OPT_Wshift_count_negative);
   13538              :               }
   13539          124 :             if (stdc_rid == C_BUILTIN_STDC_BIT_CEIL)
   13540           70 :               expr.value = build3_loc (loc, COND_EXPR, type,
   13541              :                                        build2_loc (loc, LE_EXPR,
   13542              :                                                    boolean_type_node, arg,
   13543              :                                                    build_int_cst (type, 1)),
   13544              :                                        build_int_cst (type, 1),
   13545              :                                        expr.value);
   13546              :             else
   13547           54 :               expr.value = build3_loc (loc, COND_EXPR, type,
   13548              :                                        build2_loc (loc, EQ_EXPR,
   13549              :                                                    boolean_type_node, arg,
   13550              :                                                    build_int_cst (type, 0)),
   13551              :                                        build_int_cst (type, 0),
   13552              :                                        expr.value);
   13553              :             break;
   13554              :           }
   13555         1471 :         case RID_BUILTIN_BSWAPG:
   13556         1471 :         case RID_BUILTIN_BITCOMPRESSG:
   13557         1471 :         case RID_BUILTIN_BITEXPANDG:
   13558         1471 :         case RID_BUILTIN_BITREVERSEG:
   13559         1471 :         case RID_BUILTIN_CLMULG:
   13560         1471 :           {
   13561         1471 :             vec<c_expr_t, va_gc> *cexpr_list;
   13562         1471 :             location_t close_paren_loc;
   13563         1471 :             internal_fn ifn;
   13564         1471 :             const char *name;
   13565         1471 :             unsigned minarg = 1, maxarg = 1;
   13566         1471 :             switch (c_parser_peek_token (parser)->keyword)
   13567              :               {
   13568              :               case RID_BUILTIN_BSWAPG:
   13569              :                 ifn = IFN_BSWAP;
   13570              :                 name = "__builtin_bswapg";
   13571              :                 break;
   13572           68 :               case RID_BUILTIN_BITREVERSEG:
   13573           68 :                 ifn = IFN_BITREVERSE;
   13574           68 :                 name = "__builtin_bitreverseg";
   13575           68 :                 break;
   13576          262 :               case RID_BUILTIN_CLMULG:
   13577          262 :                 ifn = IFN_CLMUL;
   13578          262 :                 name = "__builtin_clmulg";
   13579          262 :                 minarg = 2;
   13580          262 :                 maxarg = 3;
   13581          262 :                 break;
   13582          537 :               case RID_BUILTIN_BITCOMPRESSG:
   13583          537 :                 ifn = IFN_BITCOMPRESS;
   13584          537 :                 name = "__builtin_bitcompressg";
   13585          537 :                 minarg = 2;
   13586          537 :                 maxarg = 2;
   13587          537 :                 break;
   13588          555 :               case RID_BUILTIN_BITEXPANDG:
   13589          555 :                 ifn = IFN_BITEXPAND;
   13590          555 :                 name = "__builtin_bitexpandg";
   13591          555 :                 minarg = 2;
   13592          555 :                 maxarg = 2;
   13593          555 :                 break;
   13594            0 :               default:
   13595            0 :                 gcc_unreachable ();
   13596              :               }
   13597              : 
   13598         1471 :             c_parser_consume_token (parser);
   13599         1471 :             if (!c_parser_get_builtin_args (parser, name, &cexpr_list, false,
   13600              :                                             &close_paren_loc))
   13601              :               {
   13602            0 :                 expr.set_error ();
   13603            0 :                 break;
   13604              :               }
   13605              : 
   13606         1471 :             const unsigned nargs = vec_safe_length (cexpr_list);
   13607         1471 :             if (nargs < minarg || nargs > maxarg)
   13608              :               {
   13609           17 :                 error_at (loc, "wrong number of arguments to %qs", name);
   13610           17 :                 expr.set_error ();
   13611           17 :                 break;
   13612              :               }
   13613              : 
   13614         1454 :             c_expr_t *arg_p = &(*cexpr_list)[0];
   13615         1454 :             *arg_p = convert_lvalue_to_rvalue (loc, *arg_p, true, true);
   13616         1454 :             tree arg = arg_p->value;
   13617         1454 :             if (error_operand_p (arg))
   13618              :               {
   13619            2 :                 expr.set_error ();
   13620            2 :                 break;
   13621              :               }
   13622         1452 :             tree type = TYPE_MAIN_VARIANT (TREE_TYPE (arg));
   13623         1452 :             if (!INTEGRAL_TYPE_P (type))
   13624              :               {
   13625           20 :                 error_at (arg_p->get_location (),
   13626              :                           "%qs operand not an integral type", name);
   13627           20 :                 expr.set_error ();
   13628           20 :                 break;
   13629              :               }
   13630         1432 :             if (TREE_CODE (type) == ENUMERAL_TYPE)
   13631              :               {
   13632           25 :                 error_at (arg_p->get_location (),
   13633              :                           "argument %u in call to function "
   13634              :                           "%qs has enumerated type", 1, name);
   13635           25 :                 expr.set_error ();
   13636           25 :                 break;
   13637              :               }
   13638         1407 :             if (TREE_CODE (type) == BOOLEAN_TYPE)
   13639              :               {
   13640            6 :                 error_at (arg_p->get_location (),
   13641              :                           "argument %u in call to function "
   13642              :                           "%qs has boolean type", 1, name);
   13643            6 :                 expr.set_error ();
   13644            6 :                 break;
   13645              :               }
   13646         1401 :             if (!TYPE_UNSIGNED (type))
   13647              :               {
   13648           17 :                 error_at (arg_p->get_location (),
   13649              :                           "argument 1 in call to function "
   13650              :                           "%qs has signed type", name);
   13651           17 :                 expr.set_error ();
   13652           17 :                 break;
   13653              :               }
   13654         1384 :             if (ifn == IFN_BSWAP && (TYPE_PRECISION (type) % 8) != 0)
   13655              :               {
   13656            5 :                 error_at (arg_p->get_location (),
   13657              :                           "precision %d of argument 1 to function "
   13658              :                           "%qs is not a multiple of 8",
   13659            5 :                           TYPE_PRECISION (type), name);
   13660            5 :                 expr.set_error ();
   13661            5 :                 break;
   13662              :               }
   13663         1379 :             arg = c_fully_fold (arg, false, NULL);
   13664         1379 :             if (ifn != IFN_BSWAP && ifn != IFN_BITREVERSE)
   13665              :               {
   13666         1301 :                 arg_p = &(*cexpr_list)[1];
   13667         1301 :                 *arg_p = convert_lvalue_to_rvalue (loc, *arg_p, true, true);
   13668         1301 :                 tree arg2 = arg_p->value;
   13669         1301 :                 if (error_operand_p (arg2))
   13670              :                   {
   13671            0 :                     expr.set_error ();
   13672            0 :                     break;
   13673              :                   }
   13674         1301 :                 if (!comptypes_same_p (type,
   13675         1301 :                                        TYPE_MAIN_VARIANT (TREE_TYPE (arg2))))
   13676              :                   {
   13677           16 :                     error_at (loc, "arguments 1 and 2 to function %qs "
   13678              :                                    "have different types %qT and %qT",
   13679              :                               name, type,
   13680           16 :                               TYPE_MAIN_VARIANT (TREE_TYPE (arg2)));
   13681           16 :                     expr.set_error ();
   13682           16 :                     break;
   13683              :                   }
   13684         1285 :                 arg2 = c_fully_fold (arg2, false, NULL);
   13685         1285 :                 tree arg3 = NULL_TREE;
   13686         1285 :                 if (nargs == 3)
   13687              :                   {
   13688           85 :                     arg_p = &(*cexpr_list)[2];
   13689           85 :                     *arg_p = convert_lvalue_to_rvalue (loc, *arg_p,
   13690              :                                                        true, true);
   13691           85 :                     arg3 = arg_p->value;
   13692           85 :                     if (error_operand_p (arg3))
   13693              :                       {
   13694            0 :                         expr.set_error ();
   13695            0 :                         break;
   13696              :                       }
   13697           85 :                     if (!POINTER_TYPE_P (TREE_TYPE (arg3)))
   13698              :                       {
   13699            1 :                         error_at (arg_p->get_location (),
   13700              :                                   "argument 3 to function %qs does not have "
   13701              :                                   "pointer type", name);
   13702            1 :                         expr.set_error ();
   13703            1 :                         break;
   13704              :                       }
   13705           84 :                     tree htype = TREE_TYPE (TREE_TYPE (arg3));
   13706           84 :                     if (!comptypes_same_p (type, TYPE_MAIN_VARIANT (htype)))
   13707              :                       {
   13708            1 :                         error_at (loc, "arguments 1 and 3 to function %qs "
   13709              :                                        "have incompatible types %qT and %qT",
   13710            1 :                                   name, type, TREE_TYPE (arg3));
   13711            1 :                         expr.set_error ();
   13712            1 :                         break;
   13713              :                       }
   13714           83 :                     if (TYPE_READONLY (htype))
   13715              :                       {
   13716            1 :                         error_at (arg_p->get_location (),
   13717              :                                   "argument 3 to function %qs has pointer to "
   13718              :                                   "%qs type %qT",
   13719            1 :                                   name, "const", TREE_TYPE (arg3));
   13720            1 :                         expr.set_error ();
   13721            1 :                         break;
   13722              :                       }
   13723           82 :                     if (TYPE_ATOMIC (htype))
   13724              :                       {
   13725            1 :                         error_at (arg_p->get_location (),
   13726              :                                   "argument 3 to function %qs "
   13727              :                                   "has pointer to %qs type %qT",
   13728            1 :                                   name, "_Atomic", TREE_TYPE (arg3));
   13729            1 :                         expr.set_error ();
   13730            1 :                         break;
   13731              :                       }
   13732              :                   }
   13733         1281 :                 if (ifn == IFN_CLMUL)
   13734          231 :                   expr.value = fold_build_builtin_clmulg (loc, arg, arg2,
   13735              :                                                           arg3);
   13736              :                 else
   13737         1050 :                   expr.value
   13738         1050 :                     = fold_build_builtin_bitcompressg_bitexpandg (loc, ifn,
   13739              :                                                                   arg, arg2);
   13740              :               }
   13741              :             else
   13742           78 :               expr.value = fold_build_builtin_bswapg_bitreverseg (loc, ifn,
   13743              :                                                                   arg);
   13744         1359 :             set_c_expr_source_range (&expr, loc, close_paren_loc);
   13745         1359 :             break;
   13746              :           }
   13747            0 :         case RID_AT_SELECTOR:
   13748            0 :           {
   13749            0 :             gcc_assert (c_dialect_objc ());
   13750            0 :             c_parser_consume_token (parser);
   13751            0 :             matching_parens parens;
   13752            0 :             if (!parens.require_open (parser))
   13753              :               {
   13754            0 :                 expr.set_error ();
   13755            0 :                 break;
   13756              :               }
   13757            0 :             tree sel = c_parser_objc_selector_arg (parser);
   13758            0 :             location_t close_loc = c_parser_peek_token (parser)->location;
   13759            0 :             parens.skip_until_found_close (parser);
   13760            0 :             expr.value = objc_build_selector_expr (loc, sel);
   13761            0 :             set_c_expr_source_range (&expr, loc, close_loc);
   13762              :           }
   13763            0 :           break;
   13764            0 :         case RID_AT_PROTOCOL:
   13765            0 :           {
   13766            0 :             gcc_assert (c_dialect_objc ());
   13767            0 :             c_parser_consume_token (parser);
   13768            0 :             matching_parens parens;
   13769            0 :             if (!parens.require_open (parser))
   13770              :               {
   13771            0 :                 expr.set_error ();
   13772            0 :                 break;
   13773              :               }
   13774            0 :             if (c_parser_next_token_is_not (parser, CPP_NAME))
   13775              :               {
   13776            0 :                 c_parser_error (parser, "expected identifier");
   13777            0 :                 c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   13778            0 :                 expr.set_error ();
   13779            0 :                 break;
   13780              :               }
   13781            0 :             tree id = c_parser_peek_token (parser)->value;
   13782            0 :             c_parser_consume_token (parser);
   13783            0 :             location_t close_loc = c_parser_peek_token (parser)->location;
   13784            0 :             parens.skip_until_found_close (parser);
   13785            0 :             expr.value = objc_build_protocol_expr (id);
   13786            0 :             set_c_expr_source_range (&expr, loc, close_loc);
   13787              :           }
   13788            0 :           break;
   13789            0 :         case RID_AT_ENCODE:
   13790            0 :           {
   13791              :             /* Extension to support C-structures in the archiver.  */
   13792            0 :             gcc_assert (c_dialect_objc ());
   13793            0 :             c_parser_consume_token (parser);
   13794            0 :             matching_parens parens;
   13795            0 :             if (!parens.require_open (parser))
   13796              :               {
   13797            0 :                 expr.set_error ();
   13798            0 :                 break;
   13799              :               }
   13800            0 :             t1 = c_parser_type_name (parser);
   13801            0 :             if (t1 == NULL)
   13802              :               {
   13803            0 :                 expr.set_error ();
   13804            0 :                 c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   13805            0 :                 break;
   13806              :               }
   13807            0 :             location_t close_loc = c_parser_peek_token (parser)->location;
   13808            0 :             parens.skip_until_found_close (parser);
   13809            0 :             tree type = groktypename (t1, NULL, NULL);
   13810            0 :             expr.value = objc_build_encode_expr (type);
   13811            0 :             set_c_expr_source_range (&expr, loc, close_loc);
   13812              :           }
   13813            0 :           break;
   13814         1427 :         case RID_GENERIC:
   13815         1427 :           expr = c_parser_generic_selection (parser);
   13816         1427 :           break;
   13817            3 :         case RID_OMP_ALL_MEMORY:
   13818            3 :           gcc_assert (flag_openmp);
   13819            3 :           c_parser_consume_token (parser);
   13820            3 :           error_at (loc, "%<omp_all_memory%> may only be used in OpenMP "
   13821              :                          "%<depend%> clause");
   13822            3 :           expr.set_error ();
   13823            3 :           break;
   13824              :         /* C23 'nullptr' literal.  */
   13825        11167 :         case RID_NULLPTR:
   13826        11167 :           c_parser_consume_token (parser);
   13827        11167 :           expr.value = nullptr_node;
   13828        11167 :           set_c_expr_source_range (&expr, tok_range);
   13829        11167 :           pedwarn_c11 (loc, OPT_Wpedantic,
   13830              :                        "ISO C does not support %qs before C23", "nullptr");
   13831        11167 :           break;
   13832         6809 :         case RID_TRUE:
   13833         6809 :           c_parser_consume_token (parser);
   13834         6809 :           expr.value = boolean_true_node;
   13835         6809 :           set_c_expr_source_range (&expr, tok_range);
   13836         6809 :           break;
   13837         6255 :         case RID_FALSE:
   13838         6255 :           c_parser_consume_token (parser);
   13839         6255 :           expr.value = boolean_false_node;
   13840         6255 :           set_c_expr_source_range (&expr, tok_range);
   13841         6255 :           break;
   13842           38 :         default:
   13843           38 :           c_parser_error (parser, "expected expression");
   13844           38 :           expr.set_error ();
   13845           38 :           break;
   13846              :         }
   13847              :       break;
   13848            2 :     case CPP_OPEN_SQUARE:
   13849            2 :       if (c_dialect_objc ())
   13850              :         {
   13851            0 :           tree receiver, args;
   13852            0 :           c_parser_consume_token (parser);
   13853            0 :           receiver = c_parser_objc_receiver (parser);
   13854            0 :           args = c_parser_objc_message_args (parser);
   13855            0 :           location_t close_loc = c_parser_peek_token (parser)->location;
   13856            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
   13857              :                                      "expected %<]%>");
   13858            0 :           expr.value = objc_build_message_expr (receiver, args);
   13859            0 :           set_c_expr_source_range (&expr, loc, close_loc);
   13860            0 :           break;
   13861              :         }
   13862              :       /* Else fall through to report error.  */
   13863              :       /* FALLTHRU */
   13864          793 :     default:
   13865          793 :       c_parser_error (parser, "expected expression");
   13866          793 :       expr.set_error ();
   13867          793 :       break;
   13868              :     }
   13869    244693465 :  out:
   13870    244693465 :   return c_parser_postfix_expression_after_primary
   13871    244693465 :     (parser, EXPR_LOC_OR_LOC (expr.value, loc), expr);
   13872              : }
   13873              : 
   13874              : /* Parse a postfix expression after a parenthesized type name: the
   13875              :    brace-enclosed initializer of a compound literal, possibly followed
   13876              :    by some postfix operators.  This is separate because it is not
   13877              :    possible to tell until after the type name whether a cast
   13878              :    expression has a cast or a compound literal, or whether the operand
   13879              :    of sizeof is a parenthesized type name or starts with a compound
   13880              :    literal.  TYPE_LOC is the location where TYPE_NAME starts--the
   13881              :    location of the first token after the parentheses around the type
   13882              :    name.  */
   13883              : 
   13884              : static struct c_expr
   13885       930295 : c_parser_postfix_expression_after_paren_type (c_parser *parser,
   13886              :                                               struct c_declspecs *scspecs,
   13887              :                                               struct c_type_name *type_name,
   13888              :                                               location_t type_loc)
   13889              : {
   13890       930295 :   tree type;
   13891       930295 :   struct c_expr init;
   13892       930295 :   bool non_const;
   13893       930295 :   struct c_expr expr;
   13894       930295 :   location_t start_loc;
   13895       930295 :   tree type_expr = NULL_TREE;
   13896       930295 :   bool type_expr_const = true;
   13897       930295 :   bool constexpr_p = scspecs ? scspecs->constexpr_p : false;
   13898       930295 :   unsigned int underspec_state = 0;
   13899       930295 :   check_compound_literal_type (type_loc, type_name);
   13900       930295 :   rich_location richloc (line_table, type_loc);
   13901       930295 :   start_loc = c_parser_peek_token (parser)->location;
   13902       930295 :   if (constexpr_p)
   13903              :     {
   13904          234 :       underspec_state = start_underspecified_init (start_loc, NULL_TREE);
   13905              :       /* A constexpr compound literal is subject to the constraints on
   13906              :          underspecified declarations, which may not declare tags or
   13907              :          members or structures or unions; it is undefined behavior to
   13908              :          declare the members of an enumeration.  Where the structure,
   13909              :          union or enumeration type is declared within the compound
   13910              :          literal initializer, this is diagnosed elsewhere as a result
   13911              :          of the above call to start_underspecified_init.  Diagnose
   13912              :          here the case of declaring such a type in the type specifiers
   13913              :          of the compound literal.  */
   13914          234 :       switch (type_name->specs->typespec_kind)
   13915              :         {
   13916            2 :         case ctsk_tagfirstref:
   13917            2 :         case ctsk_tagfirstref_attrs:
   13918            2 :           error_at (type_loc, "%qT declared in %<constexpr%> compound literal",
   13919              :                     type_name->specs->type);
   13920            2 :           break;
   13921              : 
   13922            4 :         case ctsk_tagdef:
   13923            4 :           error_at (type_loc, "%qT defined in %<constexpr%> compound literal",
   13924              :                     type_name->specs->type);
   13925            4 :           break;
   13926              : 
   13927              :         default:
   13928              :           break;
   13929              :         }
   13930              :     }
   13931      1860336 :   start_init (NULL_TREE, NULL,
   13932       930295 :               (global_bindings_p ()
   13933       930041 :                || (scspecs && scspecs->storage_class == csc_static)
   13934              :                || constexpr_p), constexpr_p, &richloc);
   13935       930295 :   type = groktypename (type_name, &type_expr, &type_expr_const);
   13936       930295 :   bool varsize_p = false;
   13937       930295 :   if (type != error_mark_node && C_TYPE_VARIABLE_SIZE (type))
   13938              :     {
   13939           16 :       pedwarn (type_loc, OPT_Wpedantic, "compound literal has variable size");
   13940           16 :       varsize_p = true;
   13941              :     }
   13942       930279 :   else if (TREE_CODE (type) == FUNCTION_TYPE)
   13943              :     {
   13944            3 :       error_at (type_loc, "compound literal has function type");
   13945            3 :       type = error_mark_node;
   13946              :     }
   13947       930295 :   if (constexpr_p && type != error_mark_node)
   13948              :     {
   13949          234 :       tree type_no_array = strip_array_types (type);
   13950              :       /* The type of a constexpr object must not be variably modified
   13951              :          (which applies to all compound literals), volatile, atomic or
   13952              :          restrict qualified or have a member with such a qualifier.
   13953              :          const qualification is implicitly added.  */
   13954          234 :       if (TYPE_QUALS (type_no_array)
   13955          234 :           .has (TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT | TYPE_QUAL_ATOMIC))
   13956            9 :         error_at (type_loc, "invalid qualifiers for %<constexpr%> object");
   13957          225 :       else if (RECORD_OR_UNION_TYPE_P (type_no_array)
   13958          225 :                && C_TYPE_FIELDS_NON_CONSTEXPR (type_no_array))
   13959            8 :         error_at (type_loc, "invalid qualifiers for field of "
   13960              :                   "%<constexpr%> object");
   13961          234 :       type = c_build_qualified_type (type,
   13962          234 :                                      (TYPE_QUALS (type_no_array)
   13963              :                                       | TYPE_QUAL_CONST));
   13964              :     }
   13965       930295 :   init = c_parser_braced_init (parser, type, false, NULL, varsize_p);
   13966       930295 :   if (constexpr_p)
   13967          234 :     finish_underspecified_init (NULL_TREE, underspec_state);
   13968       930295 :   finish_init ();
   13969       930295 :   maybe_warn_string_init (type_loc, type, init);
   13970              : 
   13971       930295 :   if (type != error_mark_node
   13972       930288 :       && !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (type))
   13973       930295 :       && current_function_decl)
   13974              :     {
   13975            0 :       error ("compound literal qualified by address-space qualifier");
   13976            0 :       type = error_mark_node;
   13977              :     }
   13978              : 
   13979      1860285 :   if (!pedwarn_c90 (start_loc, OPT_Wpedantic,
   13980       930295 :                     "ISO C90 forbids compound literals") && scspecs)
   13981          305 :     pedwarn_c11 (start_loc, OPT_Wpedantic,
   13982              :                  "ISO C forbids storage class specifiers in compound literals "
   13983              :                  "before C23");
   13984       930295 :   non_const = ((init.value && TREE_CODE (init.value) == CONSTRUCTOR)
   13985      1860127 :                ? CONSTRUCTOR_NON_CONST (init.value)
   13986          463 :                : init.original_code == C_MAYBE_CONST_EXPR);
   13987       930295 :   non_const |= !type_expr_const;
   13988       930295 :   unsigned int alignas_align = 0;
   13989       930295 :   if (type != error_mark_node
   13990       930288 :       && type_name->specs->align_log != -1)
   13991              :     {
   13992            4 :       alignas_align = 1U << type_name->specs->align_log;
   13993            4 :       if (alignas_align < min_align_of_type (type))
   13994              :         {
   13995            1 :           error_at (type_name->specs->locations[cdw_alignas],
   13996              :                     "%<_Alignas%> specifiers cannot reduce "
   13997              :                     "alignment of compound literal");
   13998            1 :           alignas_align = 0;
   13999              :         }
   14000              :     }
   14001       930295 :   expr.value = build_compound_literal (start_loc, type, init.value, non_const,
   14002              :                                        alignas_align, scspecs);
   14003       930295 :   set_c_expr_source_range (&expr, init.src_range);
   14004       930295 :   expr.m_decimal = 0;
   14005       930295 :   expr.original_code = ERROR_MARK;
   14006       930295 :   expr.original_type = NULL;
   14007       930295 :   if (type != error_mark_node
   14008       930288 :       && expr.value != error_mark_node
   14009       930216 :       && type_expr)
   14010              :     {
   14011           41 :       if (TREE_CODE (expr.value) == C_MAYBE_CONST_EXPR)
   14012              :         {
   14013           19 :           gcc_assert (C_MAYBE_CONST_EXPR_PRE (expr.value) == NULL_TREE);
   14014           19 :           C_MAYBE_CONST_EXPR_PRE (expr.value) = type_expr;
   14015              :         }
   14016              :       else
   14017              :         {
   14018           22 :           gcc_assert (!non_const);
   14019           22 :           expr.value = build2 (C_MAYBE_CONST_EXPR, type,
   14020              :                                type_expr, expr.value);
   14021              :         }
   14022              :     }
   14023       930295 :   return c_parser_postfix_expression_after_primary (parser, start_loc, expr);
   14024       930295 : }
   14025              : 
   14026              : /* Callback function for sizeof_pointer_memaccess_warning to compare
   14027              :    types.  */
   14028              : 
   14029              : static bool
   14030         3472 : sizeof_ptr_memacc_comptypes (tree type1, tree type2)
   14031              : {
   14032         3472 :   return comptypes (type1, type2) == 1;
   14033              : }
   14034              : 
   14035              : /* Warn for patterns where abs-like function appears to be used incorrectly,
   14036              :    gracefully ignore any non-abs-like function.  The warning location should
   14037              :    be LOC.  FNDECL is the declaration of called function, it must be a
   14038              :    BUILT_IN_NORMAL function.  ARG is the first and only argument of the
   14039              :    call.  */
   14040              : 
   14041              : static void
   14042        58224 : warn_for_abs (location_t loc, tree fndecl, tree arg)
   14043              : {
   14044              :   /* Avoid warning in unreachable subexpressions.  */
   14045        58224 :   if (c_inhibit_evaluation_warnings)
   14046              :     return;
   14047              : 
   14048        31886 :   tree atype = TREE_TYPE (arg);
   14049              : 
   14050              :   /* Casts from pointers (and thus arrays and fndecls) will generate
   14051              :      -Wint-conversion warnings.  Most other wrong types hopefully lead to type
   14052              :      mismatch errors.  TODO: Think about what to do with FIXED_POINT_TYPE_P
   14053              :      types and possibly other exotic types.  */
   14054        31886 :   if (!INTEGRAL_TYPE_P (atype)
   14055        31886 :       && !SCALAR_FLOAT_TYPE_P (atype)
   14056         5256 :       && TREE_CODE (atype) != COMPLEX_TYPE)
   14057              :     return;
   14058              : 
   14059        27108 :   enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
   14060              : 
   14061        27108 :   switch (fcode)
   14062              :     {
   14063           39 :     case BUILT_IN_ABS:
   14064           39 :     case BUILT_IN_LABS:
   14065           39 :     case BUILT_IN_LLABS:
   14066           39 :     case BUILT_IN_IMAXABS:
   14067           39 :       if (!INTEGRAL_TYPE_P (atype))
   14068              :         {
   14069            4 :           if (SCALAR_FLOAT_TYPE_P (atype))
   14070            3 :             warning_at (loc, OPT_Wabsolute_value,
   14071              :                         "using integer absolute value function %qD when "
   14072              :                         "argument is of floating-point type %qT",
   14073              :                         fndecl, atype);
   14074            1 :           else if (TREE_CODE (atype) == COMPLEX_TYPE)
   14075            1 :             warning_at (loc, OPT_Wabsolute_value,
   14076              :                         "using integer absolute value function %qD when "
   14077              :                         "argument is of complex type %qT", fndecl, atype);
   14078              :           else
   14079              :             gcc_unreachable ();
   14080              :           return;
   14081              :         }
   14082           35 :       if (TYPE_UNSIGNED (atype))
   14083            9 :         warning_at (loc, OPT_Wabsolute_value,
   14084              :                     "taking the absolute value of unsigned type %qT "
   14085              :                     "has no effect", atype);
   14086              :       break;
   14087              : 
   14088          572 :     CASE_FLT_FN (BUILT_IN_FABS):
   14089          572 :     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FABS):
   14090          572 :       if (!SCALAR_FLOAT_TYPE_P (atype)
   14091          572 :           || DECIMAL_FLOAT_MODE_P (TYPE_MODE (atype)))
   14092              :         {
   14093            4 :           if (INTEGRAL_TYPE_P (atype))
   14094            2 :             warning_at (loc, OPT_Wabsolute_value,
   14095              :                         "using floating-point absolute value function %qD "
   14096              :                         "when argument is of integer type %qT", fndecl, atype);
   14097            2 :           else if (DECIMAL_FLOAT_TYPE_P (atype))
   14098            1 :             warning_at (loc, OPT_Wabsolute_value,
   14099              :                         "using floating-point absolute value function %qD "
   14100              :                         "when argument is of decimal floating-point type %qT",
   14101              :                         fndecl, atype);
   14102            1 :           else if (TREE_CODE (atype) == COMPLEX_TYPE)
   14103            1 :             warning_at (loc, OPT_Wabsolute_value,
   14104              :                         "using floating-point absolute value function %qD when "
   14105              :                         "argument is of complex type %qT", fndecl, atype);
   14106              :           else
   14107            0 :             gcc_unreachable ();
   14108              :           return;
   14109              :         }
   14110              :       break;
   14111              : 
   14112            7 :     CASE_FLT_FN (BUILT_IN_CABS):
   14113            7 :       if (TREE_CODE (atype) != COMPLEX_TYPE)
   14114              :         {
   14115            4 :           if (INTEGRAL_TYPE_P (atype))
   14116            2 :             warning_at (loc, OPT_Wabsolute_value,
   14117              :                         "using complex absolute value function %qD when "
   14118              :                         "argument is of integer type %qT", fndecl, atype);
   14119            2 :           else if (SCALAR_FLOAT_TYPE_P (atype))
   14120            2 :             warning_at (loc, OPT_Wabsolute_value,
   14121              :                         "using complex absolute value function %qD when "
   14122              :                         "argument is of floating-point type %qT",
   14123              :                         fndecl, atype);
   14124              :           else
   14125              :             gcc_unreachable ();
   14126              : 
   14127              :           return;
   14128              :         }
   14129              :       break;
   14130              : 
   14131            6 :     case BUILT_IN_FABSD32:
   14132            6 :     case BUILT_IN_FABSD64:
   14133            6 :     case BUILT_IN_FABSD128:
   14134            6 :     case BUILT_IN_FABSD64X:
   14135            6 :       if (!DECIMAL_FLOAT_TYPE_P (atype))
   14136              :         {
   14137            4 :           if (INTEGRAL_TYPE_P (atype))
   14138            1 :             warning_at (loc, OPT_Wabsolute_value,
   14139              :                         "using decimal floating-point absolute value "
   14140              :                         "function %qD when argument is of integer type %qT",
   14141              :                         fndecl, atype);
   14142            3 :           else if (SCALAR_FLOAT_TYPE_P (atype))
   14143            2 :             warning_at (loc, OPT_Wabsolute_value,
   14144              :                         "using decimal floating-point absolute value "
   14145              :                         "function %qD when argument is of floating-point "
   14146              :                         "type %qT", fndecl, atype);
   14147            1 :           else if (TREE_CODE (atype) == COMPLEX_TYPE)
   14148            1 :             warning_at (loc, OPT_Wabsolute_value,
   14149              :                         "using decimal floating-point absolute value "
   14150              :                         "function %qD when argument is of complex type %qT",
   14151              :                         fndecl, atype);
   14152              :           else
   14153            0 :             gcc_unreachable ();
   14154              :           return;
   14155              :         }
   14156              :       break;
   14157              : 
   14158              :     default:
   14159              :       return;
   14160              :     }
   14161              : 
   14162          608 :   if (!TYPE_ARG_TYPES (TREE_TYPE (fndecl)))
   14163              :     return;
   14164              : 
   14165          607 :   tree ftype = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (fndecl)));
   14166          607 :   if (TREE_CODE (atype) == COMPLEX_TYPE)
   14167              :     {
   14168            3 :       gcc_assert (TREE_CODE (ftype) == COMPLEX_TYPE);
   14169            3 :       atype = TREE_TYPE (atype);
   14170            3 :       ftype = TREE_TYPE (ftype);
   14171              :     }
   14172              : 
   14173          607 :   if (TYPE_PRECISION (ftype) < TYPE_PRECISION (atype))
   14174            9 :     warning_at (loc, OPT_Wabsolute_value,
   14175              :                 "absolute value function %qD given an argument of type %qT "
   14176              :                 "but has parameter of type %qT which may cause truncation "
   14177              :                 "of value", fndecl, atype, ftype);
   14178              : }
   14179              : 
   14180              : 
   14181              : /* Parse a postfix expression after the initial primary or compound
   14182              :    literal; that is, parse a series of postfix operators.
   14183              : 
   14184              :    EXPR_LOC is the location of the primary expression.  */
   14185              : 
   14186              : static struct c_expr
   14187    245623810 : c_parser_postfix_expression_after_primary (c_parser *parser,
   14188              :                                            location_t expr_loc,
   14189              :                                            struct c_expr expr)
   14190              : {
   14191    245623810 :   struct c_expr orig_expr;
   14192    245623810 :   tree ident, idx, len;
   14193    245623810 :   location_t sizeof_arg_loc[6], comp_loc;
   14194    245623810 :   tree sizeof_arg[6];
   14195    245623810 :   unsigned int literal_zero_mask;
   14196    245623810 :   unsigned int i;
   14197    245623810 :   vec<tree, va_gc> *exprlist;
   14198    245623810 :   vec<tree, va_gc> *origtypes = NULL;
   14199    245623810 :   vec<location_t> arg_loc = vNULL;
   14200    304043799 :   location_t start;
   14201    304043799 :   location_t finish;
   14202              : 
   14203    304043799 :   while (true)
   14204              :     {
   14205    304043799 :       location_t op_loc = c_parser_peek_token (parser)->location;
   14206    304043799 :       switch (c_parser_peek_token (parser)->type)
   14207              :         {
   14208      3567253 :         case CPP_OPEN_SQUARE:
   14209              :           /* Array reference.  */
   14210      3567253 :           c_parser_consume_token (parser);
   14211      3567253 :           idx = len = NULL_TREE;
   14212      3567253 :           if (!c_omp_array_section_p
   14213      3568017 :               || c_parser_next_token_is_not (parser, CPP_COLON))
   14214      3567032 :             idx = c_parser_expression (parser).value;
   14215              : 
   14216      3567253 :           if (c_omp_array_section_p
   14217      3568017 :               && c_parser_next_token_is (parser, CPP_COLON))
   14218              :             {
   14219          609 :               c_parser_consume_token (parser);
   14220          609 :               if (c_parser_next_token_is_not (parser, CPP_CLOSE_SQUARE))
   14221          574 :                 len = c_parser_expression (parser).value;
   14222              : 
   14223          609 :               expr.value = build_omp_array_section (op_loc, expr.value, idx,
   14224              :                                                     len);
   14225              :             }
   14226              :           else
   14227      3566644 :             expr.value = build_array_ref (op_loc, expr.value, idx);
   14228              : 
   14229      3567253 :           c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE,
   14230              :                                      "expected %<]%>");
   14231              : 
   14232      3567253 :           start = expr.get_start ();
   14233      3567253 :           finish = parser->tokens_buf[0].location;
   14234      3567253 :           set_c_expr_source_range (&expr, start, finish);
   14235      3567253 :           expr.original_code = ERROR_MARK;
   14236      3567253 :           expr.original_type = NULL;
   14237      3567253 :           expr.m_decimal = 0;
   14238      3567253 :           break;
   14239     51855836 :         case CPP_OPEN_PAREN:
   14240              :           /* Function call.  */
   14241     51855836 :           {
   14242     51855836 :             matching_parens parens;
   14243     51855836 :             parens.consume_open (parser);
   14244    414846688 :             for (i = 0; i < 6; i++)
   14245              :               {
   14246    311135016 :                 sizeof_arg[i] = NULL_TREE;
   14247    311135016 :                 sizeof_arg_loc[i] = UNKNOWN_LOCATION;
   14248              :               }
   14249     51855836 :             literal_zero_mask = 0;
   14250     51855836 :             if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   14251              :               exprlist = NULL;
   14252     39491014 :             else if (TREE_CODE (expr.value) == FUNCTION_DECL
   14253     39423139 :                      && fndecl_built_in_p (expr.value, BUILT_IN_CLASSIFY_TYPE)
   14254     39492810 :                      && c_parser_next_tokens_start_typename (parser,
   14255              :                                                              cla_prefer_id))
   14256              :               {
   14257              :                 /* __builtin_classify_type (type)  */
   14258           29 :                 c_inhibit_evaluation_warnings++;
   14259           29 :                 in_alignof++;
   14260           29 :                 struct c_type_name *type = c_parser_type_name (parser);
   14261           29 :                 c_inhibit_evaluation_warnings--;
   14262           29 :                 in_alignof--;
   14263           29 :                 struct c_typespec ret;
   14264           29 :                 ret.expr = NULL_TREE;
   14265           29 :                 ret.spec = error_mark_node;
   14266           29 :                 ret.expr_const_operands = false;
   14267           29 :                 if (type != NULL)
   14268           29 :                   ret.spec = groktypename (type, &ret.expr,
   14269              :                                            &ret.expr_const_operands);
   14270           29 :                 parens.skip_until_found_close (parser);
   14271           29 :                 expr.value = build_int_cst (integer_type_node,
   14272           29 :                                             type_to_class (ret.spec));
   14273           29 :                 break;
   14274              :               }
   14275              :             else
   14276     39490985 :               exprlist = c_parser_expr_list (parser, true, false, &origtypes,
   14277              :                                              sizeof_arg_loc, sizeof_arg,
   14278              :                                              &arg_loc, &literal_zero_mask);
   14279     51855807 :             parens.skip_until_found_close (parser);
   14280              :           }
   14281     51855807 :           orig_expr = expr;
   14282     51855807 :           mark_exp_read (expr.value);
   14283     51855807 :           if (warn_sizeof_pointer_memaccess)
   14284      4685501 :             sizeof_pointer_memaccess_warning (sizeof_arg_loc,
   14285              :                                               expr.value, exprlist,
   14286              :                                               sizeof_arg,
   14287              :                                               sizeof_ptr_memacc_comptypes);
   14288     51855807 :           if (TREE_CODE (expr.value) == FUNCTION_DECL)
   14289              :             {
   14290     51778117 :               if (fndecl_built_in_p (expr.value, BUILT_IN_MEMSET)
   14291     51810298 :                   && vec_safe_length (exprlist) == 3)
   14292              :                 {
   14293        32181 :                   tree arg0 = (*exprlist)[0];
   14294        32181 :                   tree arg2 = (*exprlist)[2];
   14295        32181 :                   warn_for_memset (expr_loc, arg0, arg2, literal_zero_mask);
   14296              :                 }
   14297     51778117 :               if (warn_absolute_value
   14298      4399036 :                   && fndecl_built_in_p (expr.value, BUILT_IN_NORMAL)
   14299     51921930 :                   && vec_safe_length (exprlist) == 1)
   14300        58224 :                 warn_for_abs (expr_loc, expr.value, (*exprlist)[0]);
   14301     51778117 :               if (parser->omp_for_parse_state
   14302          178 :                   && parser->omp_for_parse_state->in_intervening_code
   14303     51778256 :                   && omp_runtime_api_call (expr.value))
   14304              :                 {
   14305            2 :                   error_at (expr_loc, "calls to the OpenMP runtime API are "
   14306              :                                       "not permitted in intervening code");
   14307            2 :                   parser->omp_for_parse_state->fail = true;
   14308              :                 }
   14309     51778117 :               if (warn_calloc_transposed_args)
   14310      4399011 :                 if (tree attr = lookup_attribute ("alloc_size",
   14311      4399011 :                                                   TYPE_ATTRIBUTES
   14312              :                                                     (TREE_TYPE (expr.value))))
   14313         1321 :                   if (TREE_VALUE (attr) && TREE_CHAIN (TREE_VALUE (attr)))
   14314          146 :                     warn_for_calloc (sizeof_arg_loc, expr.value, exprlist,
   14315              :                                      sizeof_arg, attr);
   14316              :             }
   14317              : 
   14318     51855807 :           start = expr.get_start ();
   14319     51855807 :           finish = parser->tokens_buf[0].get_finish ();
   14320     51855807 :           expr.value
   14321     51855807 :             = c_build_function_call_vec (expr_loc, arg_loc, expr.value,
   14322              :                                          exprlist, origtypes);
   14323     51855807 :           set_c_expr_source_range (&expr, start, finish);
   14324     51855807 :           expr.m_decimal = 0;
   14325              : 
   14326     51855807 :           expr.original_code = ERROR_MARK;
   14327     51855807 :           if (TREE_CODE (expr.value) == INTEGER_CST
   14328        12852 :               && TREE_CODE (orig_expr.value) == FUNCTION_DECL
   14329     51868659 :               && fndecl_built_in_p (orig_expr.value, BUILT_IN_CONSTANT_P))
   14330         1563 :             expr.original_code = C_MAYBE_CONST_EXPR;
   14331     51855807 :           expr.original_type = NULL;
   14332     51855807 :           if (exprlist)
   14333              :             {
   14334     39490985 :               release_tree_vector (exprlist);
   14335     39490985 :               release_tree_vector (origtypes);
   14336              :             }
   14337     51855807 :           arg_loc.release ();
   14338     51855807 :           break;
   14339      1773706 :         case CPP_DOT:
   14340              :           /* Structure element reference.  */
   14341      1773706 :           c_parser_consume_token (parser);
   14342      1773706 :           expr = default_function_array_conversion (expr_loc, expr);
   14343      1773706 :           if (c_parser_next_token_is (parser, CPP_NAME))
   14344              :             {
   14345      1773706 :               c_token *comp_tok = c_parser_peek_token (parser);
   14346      1773706 :               ident = comp_tok->value;
   14347      1773706 :               comp_loc = comp_tok->location;
   14348              :             }
   14349              :           else
   14350              :             {
   14351            0 :               c_parser_error (parser, "expected identifier");
   14352            0 :               expr.set_error ();
   14353            0 :               expr.original_code = ERROR_MARK;
   14354            0 :               expr.original_type = NULL;
   14355            0 :               return expr;
   14356              :             }
   14357      1773706 :           start = expr.get_start ();
   14358      1773706 :           finish = c_parser_peek_token (parser)->get_finish ();
   14359      1773706 :           c_parser_consume_token (parser);
   14360      1773706 :           expr.value = build_component_ref (op_loc, expr.value, ident,
   14361              :                                             comp_loc, UNKNOWN_LOCATION);
   14362      1773706 :           set_c_expr_source_range (&expr, start, finish);
   14363      1773706 :           expr.original_code = ERROR_MARK;
   14364      1773706 :           if (TREE_CODE (expr.value) != COMPONENT_REF)
   14365           32 :             expr.original_type = NULL;
   14366              :           else
   14367              :             {
   14368              :               /* Remember the original type of a bitfield.  */
   14369      1773674 :               tree field = TREE_OPERAND (expr.value, 1);
   14370      1773674 :               if (TREE_CODE (field) != FIELD_DECL)
   14371            0 :                 expr.original_type = NULL;
   14372              :               else
   14373      1773674 :                 expr.original_type = DECL_BIT_FIELD_TYPE (field);
   14374              :             }
   14375      1773706 :           expr.m_decimal = 0;
   14376      1773706 :           break;
   14377       511136 :         case CPP_DEREF:
   14378              :           /* Structure element reference.  */
   14379       511136 :           c_parser_consume_token (parser);
   14380       511136 :           expr = convert_lvalue_to_rvalue (expr_loc, expr, true, false);
   14381       511136 :           if (c_parser_next_token_is (parser, CPP_NAME))
   14382              :             {
   14383       511104 :               c_token *comp_tok = c_parser_peek_token (parser);
   14384       511104 :               ident = comp_tok->value;
   14385       511104 :               comp_loc = comp_tok->location;
   14386              :             }
   14387              :           else
   14388              :             {
   14389           32 :               c_parser_error (parser, "expected identifier");
   14390           32 :               expr.set_error ();
   14391           32 :               expr.original_code = ERROR_MARK;
   14392           32 :               expr.original_type = NULL;
   14393           32 :               return expr;
   14394              :             }
   14395       511104 :           start = expr.get_start ();
   14396       511104 :           finish = c_parser_peek_token (parser)->get_finish ();
   14397       511104 :           c_parser_consume_token (parser);
   14398       511104 :           expr.value = build_component_ref (op_loc,
   14399              :                                             build_indirect_ref (op_loc,
   14400              :                                                                 expr.value,
   14401              :                                                                 RO_ARROW),
   14402              :                                             ident, comp_loc,
   14403              :                                             expr.get_location ());
   14404       511104 :           set_c_expr_source_range (&expr, start, finish);
   14405       511104 :           expr.original_code = ERROR_MARK;
   14406       511104 :           if (TREE_CODE (expr.value) != COMPONENT_REF)
   14407          121 :             expr.original_type = NULL;
   14408              :           else
   14409              :             {
   14410              :               /* Remember the original type of a bitfield.  */
   14411       510983 :               tree field = TREE_OPERAND (expr.value, 1);
   14412       510983 :               if (TREE_CODE (field) != FIELD_DECL)
   14413            0 :                 expr.original_type = NULL;
   14414              :               else
   14415       510983 :                 expr.original_type = DECL_BIT_FIELD_TYPE (field);
   14416              :             }
   14417       511104 :           expr.m_decimal = 0;
   14418       511104 :           break;
   14419       693824 :         case CPP_PLUS_PLUS:
   14420              :           /* Postincrement.  */
   14421       693824 :           start = expr.get_start ();
   14422       693824 :           finish = c_parser_peek_token (parser)->get_finish ();
   14423       693824 :           c_parser_consume_token (parser);
   14424       693824 :           mark_exp_read_cond (expr.value);
   14425       693824 :           expr = default_function_array_conversion (expr_loc, expr);
   14426       693824 :           expr.value = build_unary_op (op_loc, POSTINCREMENT_EXPR,
   14427              :                                        expr.value, false);
   14428       693824 :           set_c_expr_source_range (&expr, start, finish);
   14429       693824 :           expr.original_code = ERROR_MARK;
   14430       693824 :           expr.original_type = NULL;
   14431       693824 :           break;
   14432        18266 :         case CPP_MINUS_MINUS:
   14433              :           /* Postdecrement.  */
   14434        18266 :           start = expr.get_start ();
   14435        18266 :           finish = c_parser_peek_token (parser)->get_finish ();
   14436        18266 :           c_parser_consume_token (parser);
   14437        18266 :           mark_exp_read_cond (expr.value);
   14438        18266 :           expr = default_function_array_conversion (expr_loc, expr);
   14439        18266 :           expr.value = build_unary_op (op_loc, POSTDECREMENT_EXPR,
   14440              :                                        expr.value, false);
   14441        18266 :           set_c_expr_source_range (&expr, start, finish);
   14442        18266 :           expr.original_code = ERROR_MARK;
   14443        18266 :           expr.original_type = NULL;
   14444        18266 :           break;
   14445    245623778 :         default:
   14446    245623778 :           return expr;
   14447              :         }
   14448              :     }
   14449              : }
   14450              : 
   14451              : /* Parse an expression (C90 6.3.17, C99 6.5.17, C11 6.5.17).
   14452              : 
   14453              :    expression:
   14454              :      assignment-expression
   14455              :      expression , assignment-expression
   14456              : */
   14457              : 
   14458              : static struct c_expr
   14459     57876355 : c_parser_expression (c_parser *parser)
   14460              : {
   14461     57876355 :   location_t tloc = c_parser_peek_token (parser)->location;
   14462     57876355 :   struct c_expr expr;
   14463     57876355 :   expr = c_parser_expr_no_commas (parser, NULL);
   14464     57876355 :   if (c_parser_next_token_is (parser, CPP_COMMA))
   14465        91936 :     expr = convert_lvalue_to_rvalue (tloc, expr, true, false);
   14466     57981549 :   while (c_parser_next_token_is (parser, CPP_COMMA))
   14467              :     {
   14468       105194 :       struct c_expr next;
   14469       105194 :       tree lhsval;
   14470       105194 :       location_t loc = c_parser_peek_token (parser)->location;
   14471       105194 :       location_t expr_loc;
   14472       105194 :       c_parser_consume_token (parser);
   14473       105194 :       expr_loc = c_parser_peek_token (parser)->location;
   14474       105194 :       lhsval = expr.value;
   14475       105194 :       while (TREE_CODE (lhsval) == COMPOUND_EXPR
   14476       119308 :              || TREE_CODE (lhsval) == NOP_EXPR)
   14477              :         {
   14478        14114 :           if (TREE_CODE (lhsval) == COMPOUND_EXPR)
   14479        14016 :             lhsval = TREE_OPERAND (lhsval, 1);
   14480              :           else
   14481           98 :             lhsval = TREE_OPERAND (lhsval, 0);
   14482              :         }
   14483       105194 :       if (DECL_P (lhsval) || handled_component_p (lhsval))
   14484           89 :         mark_exp_read (lhsval);
   14485       105194 :       if (c_parser_next_token_is (parser, CPP_EMBED))
   14486              :         {
   14487              :           /* Users aren't interested in millions of -Wunused-value
   14488              :              warnings when using #embed inside of a comma expression,
   14489              :              and one CPP_NUMBER plus CPP_COMMA before it and one
   14490              :              CPP_COMMA plus CPP_NUMBER after it is guaranteed by
   14491              :              the preprocessor.  Thus, parse the whole CPP_EMBED just
   14492              :              as a single INTEGER_CST, the last byte in it.  */
   14493            1 :           c_token *embed = c_parser_peek_token (parser);
   14494            1 :           tree val = embed->value;
   14495            1 :           unsigned last = RAW_DATA_LENGTH (val) - 1;
   14496            1 :           next.value = build_int_cst (TREE_TYPE (val),
   14497            1 :                                       RAW_DATA_UCHAR_ELT (val, last));
   14498            1 :           next.original_type = integer_type_node;
   14499            1 :           c_parser_consume_token (parser);
   14500              :         }
   14501              :       else
   14502              :         {
   14503       105193 :           next = c_parser_expr_no_commas (parser, NULL);
   14504       105193 :           next = convert_lvalue_to_rvalue (expr_loc, next, true, false);
   14505              :         }
   14506       105194 :       expr.value = build_compound_expr (loc, expr.value, next.value);
   14507       105194 :       expr.original_code = COMPOUND_EXPR;
   14508       105194 :       expr.original_type = next.original_type;
   14509       105194 :       expr.m_decimal = 0;
   14510              :     }
   14511     57876355 :   return expr;
   14512              : }
   14513              : 
   14514              : /* Parse an expression and convert functions or arrays to pointers and
   14515              :    lvalues to rvalues.  */
   14516              : 
   14517              : static struct c_expr
   14518     44003420 : c_parser_expression_conv (c_parser *parser)
   14519              : {
   14520     44003420 :   struct c_expr expr;
   14521     44003420 :   location_t loc = c_parser_peek_token (parser)->location;
   14522     44003420 :   expr = c_parser_expression (parser);
   14523     44003420 :   expr = convert_lvalue_to_rvalue (loc, expr, true, false);
   14524     44003420 :   return expr;
   14525              : }
   14526              : 
   14527              : /* Helper function of c_parser_expr_list.  Check if IDXth (0 based)
   14528              :    argument is a literal zero alone and if so, set it in literal_zero_mask.  */
   14529              : 
   14530              : static inline void
   14531    130614993 : c_parser_check_literal_zero (c_parser *parser, unsigned *literal_zero_mask,
   14532              :                              unsigned int idx)
   14533              : {
   14534    130614993 :   if (idx >= HOST_BITS_PER_INT)
   14535              :     return;
   14536              : 
   14537    130592310 :   c_token *tok = c_parser_peek_token (parser);
   14538    130592310 :   switch (tok->type)
   14539              :     {
   14540      7003057 :     case CPP_NUMBER:
   14541      7003057 :     case CPP_CHAR:
   14542      7003057 :     case CPP_WCHAR:
   14543      7003057 :     case CPP_CHAR16:
   14544      7003057 :     case CPP_CHAR32:
   14545      7003057 :     case CPP_UTF8CHAR:
   14546              :       /* If a parameter is literal zero alone, remember it
   14547              :          for -Wmemset-transposed-args warning.  */
   14548      7003057 :       if (integer_zerop (tok->value)
   14549      1278619 :           && !TREE_OVERFLOW (tok->value)
   14550      8281676 :           && (c_parser_peek_2nd_token (parser)->type == CPP_COMMA
   14551       885932 :               || c_parser_peek_2nd_token (parser)->type == CPP_CLOSE_PAREN))
   14552      1277708 :         *literal_zero_mask |= 1U << idx;
   14553              :     default:
   14554              :       break;
   14555              :     }
   14556              : }
   14557              : 
   14558              : /* Parse a non-empty list of expressions.  If CONVERT_P, convert
   14559              :    functions and arrays to pointers and lvalues to rvalues.  If
   14560              :    FOLD_P, fold the expressions.  If LOCATIONS is non-NULL, save the
   14561              :    locations of function arguments into this vector.
   14562              : 
   14563              :    nonempty-expr-list:
   14564              :      assignment-expression
   14565              :      nonempty-expr-list , assignment-expression
   14566              : */
   14567              : 
   14568              : static vec<tree, va_gc> *
   14569     44192441 : c_parser_expr_list (c_parser *parser, bool convert_p, bool fold_p,
   14570              :                     vec<tree, va_gc> **p_orig_types,
   14571              :                     location_t *sizeof_arg_loc, tree *sizeof_arg,
   14572              :                     vec<location_t> *locations,
   14573              :                     unsigned int *literal_zero_mask)
   14574              : {
   14575     44192441 :   vec<tree, va_gc> *ret;
   14576     44192441 :   vec<tree, va_gc> *orig_types;
   14577     44192441 :   struct c_expr expr;
   14578     44192441 :   unsigned int idx = 0;
   14579     44192441 :   bool save_c_omp_array_section_p = c_omp_array_section_p;
   14580     44192441 :   c_omp_array_section_p = false;
   14581              : 
   14582     44192441 :   ret = make_tree_vector ();
   14583     44192441 :   if (p_orig_types == NULL)
   14584              :     orig_types = NULL;
   14585              :   else
   14586     39490985 :     orig_types = make_tree_vector ();
   14587              : 
   14588     44192441 :   if (literal_zero_mask)
   14589     39490985 :     c_parser_check_literal_zero (parser, literal_zero_mask, 0);
   14590     44192441 :   expr = c_parser_expr_no_commas (parser, NULL);
   14591     44192441 :   if (convert_p)
   14592     39491456 :     expr = convert_lvalue_to_rvalue (expr.get_location (), expr, true, true);
   14593     44192441 :   if (fold_p)
   14594      4701456 :     expr.value = c_fully_fold (expr.value, false, NULL);
   14595     44192441 :   ret->quick_push (expr.value);
   14596     44192441 :   if (orig_types)
   14597     39490985 :     orig_types->quick_push (expr.original_type);
   14598     44192441 :   if (locations)
   14599     39490985 :     locations->safe_push (expr.get_location ());
   14600     44192441 :   if (sizeof_arg != NULL
   14601     39490985 :       && (expr.original_code == SIZEOF_EXPR
   14602     39490985 :           || expr.original_code == PAREN_SIZEOF_EXPR))
   14603              :     {
   14604         2369 :       sizeof_arg[0] = c_last_sizeof_arg;
   14605         2369 :       sizeof_arg_loc[0] = c_last_sizeof_loc;
   14606              :     }
   14607    136784960 :   while (c_parser_next_token_is (parser, CPP_COMMA))
   14608              :     {
   14609     92592519 :       c_parser_consume_token (parser);
   14610     92592519 :       if (c_parser_next_token_is (parser, CPP_EMBED))
   14611              :         {
   14612            3 :           c_token *embed = c_parser_peek_token (parser);
   14613            3 :           tree value = embed->value;
   14614            3 :           expr.original_code = INTEGER_CST;
   14615            3 :           expr.original_type = integer_type_node;
   14616            3 :           expr.value = NULL_TREE;
   14617            3 :           set_c_expr_source_range (&expr, embed->get_range ());
   14618            3 :           expr.m_decimal = 0;
   14619          381 :           for (unsigned int i = 0; i < (unsigned) RAW_DATA_LENGTH (value); i++)
   14620              :             {
   14621          378 :               if (literal_zero_mask
   14622          126 :                   && idx + 1 < HOST_BITS_PER_INT
   14623          409 :                   && RAW_DATA_POINTER (value)[i] == 0)
   14624            0 :                 *literal_zero_mask |= 1U << (idx + 1);
   14625          378 :               expr.value = build_int_cst (integer_type_node,
   14626          378 :                                           RAW_DATA_UCHAR_ELT (value, i));
   14627          378 :               vec_safe_push (ret, expr.value);
   14628          378 :               if (orig_types)
   14629          126 :                 vec_safe_push (orig_types, expr.original_type);
   14630          378 :               if (locations)
   14631          126 :                 locations->safe_push (expr.get_location ());
   14632          378 :               ++idx;
   14633              :             }
   14634            3 :           c_parser_consume_token (parser);
   14635            3 :           continue;
   14636            3 :         }
   14637     92592516 :       if (literal_zero_mask)
   14638     91124008 :         c_parser_check_literal_zero (parser, literal_zero_mask, idx + 1);
   14639     92592516 :       expr = c_parser_expr_no_commas (parser, NULL);
   14640     92592516 :       if (convert_p)
   14641     91124274 :         expr = convert_lvalue_to_rvalue (expr.get_location (), expr, true,
   14642              :                                          true);
   14643     92592516 :       if (fold_p)
   14644      1468508 :         expr.value = c_fully_fold (expr.value, false, NULL);
   14645     92592516 :       vec_safe_push (ret, expr.value);
   14646     92592516 :       if (orig_types)
   14647     91124008 :         vec_safe_push (orig_types, expr.original_type);
   14648     92592516 :       if (locations)
   14649     91124008 :         locations->safe_push (expr.get_location ());
   14650     92592516 :       if (++idx < 6
   14651     91026865 :           && sizeof_arg != NULL
   14652     92592516 :           && (expr.original_code == SIZEOF_EXPR
   14653     89558371 :               || expr.original_code == PAREN_SIZEOF_EXPR))
   14654              :         {
   14655        80375 :           sizeof_arg[idx] = c_last_sizeof_arg;
   14656        80375 :           sizeof_arg_loc[idx] = c_last_sizeof_loc;
   14657              :         }
   14658              :     }
   14659     44192441 :   if (orig_types)
   14660     39490985 :     *p_orig_types = orig_types;
   14661     44192441 :   c_omp_array_section_p = save_c_omp_array_section_p;
   14662     44192441 :   return ret;
   14663              : }
   14664              : 
   14665              : /* Parse Objective-C-specific constructs.  */
   14666              : 
   14667              : /* Parse an objc-class-definition.
   14668              : 
   14669              :    objc-class-definition:
   14670              :      @interface identifier objc-superclass[opt] objc-protocol-refs[opt]
   14671              :        objc-class-instance-variables[opt] objc-methodprotolist @end
   14672              :      @implementation identifier objc-superclass[opt]
   14673              :        objc-class-instance-variables[opt]
   14674              :      @interface identifier ( identifier ) objc-protocol-refs[opt]
   14675              :        objc-methodprotolist @end
   14676              :      @interface identifier ( ) objc-protocol-refs[opt]
   14677              :        objc-methodprotolist @end
   14678              :      @implementation identifier ( identifier )
   14679              : 
   14680              :    objc-superclass:
   14681              :      : identifier
   14682              : 
   14683              :    "@interface identifier (" must start "@interface identifier (
   14684              :    identifier ) ...": objc-methodprotolist in the first production may
   14685              :    not start with a parenthesized identifier as a declarator of a data
   14686              :    definition with no declaration specifiers if the objc-superclass,
   14687              :    objc-protocol-refs and objc-class-instance-variables are omitted.  */
   14688              : 
   14689              : static void
   14690            0 : c_parser_objc_class_definition (c_parser *parser, tree attributes)
   14691              : {
   14692            0 :   bool iface_p;
   14693            0 :   tree id1;
   14694            0 :   tree superclass;
   14695            0 :   if (c_parser_next_token_is_keyword (parser, RID_AT_INTERFACE))
   14696              :     iface_p = true;
   14697            0 :   else if (c_parser_next_token_is_keyword (parser, RID_AT_IMPLEMENTATION))
   14698              :     iface_p = false;
   14699              :   else
   14700            0 :     gcc_unreachable ();
   14701              : 
   14702            0 :   c_parser_consume_token (parser);
   14703            0 :   if (c_parser_next_token_is_not (parser, CPP_NAME))
   14704              :     {
   14705            0 :       c_parser_error (parser, "expected identifier");
   14706            0 :       return;
   14707              :     }
   14708            0 :   id1 = c_parser_peek_token (parser)->value;
   14709            0 :   location_t loc1 = c_parser_peek_token (parser)->location;
   14710            0 :   c_parser_consume_token (parser);
   14711            0 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   14712              :     {
   14713              :       /* We have a category or class extension.  */
   14714            0 :       tree id2;
   14715            0 :       tree proto = NULL_TREE;
   14716            0 :       matching_parens parens;
   14717            0 :       parens.consume_open (parser);
   14718            0 :       if (c_parser_next_token_is_not (parser, CPP_NAME))
   14719              :         {
   14720            0 :           if (iface_p && c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   14721              :             {
   14722              :               /* We have a class extension.  */
   14723              :               id2 = NULL_TREE;
   14724              :             }
   14725              :           else
   14726              :             {
   14727            0 :               c_parser_error (parser, "expected identifier or %<)%>");
   14728            0 :               c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   14729            0 :               return;
   14730              :             }
   14731              :         }
   14732              :       else
   14733              :         {
   14734            0 :           id2 = c_parser_peek_token (parser)->value;
   14735            0 :           c_parser_consume_token (parser);
   14736              :         }
   14737            0 :       parens.skip_until_found_close (parser);
   14738            0 :       if (!iface_p)
   14739              :         {
   14740            0 :           objc_start_category_implementation (id1, id2);
   14741            0 :           return;
   14742              :         }
   14743            0 :       if (c_parser_next_token_is (parser, CPP_LESS))
   14744            0 :         proto = c_parser_objc_protocol_refs (parser);
   14745            0 :       objc_start_category_interface (id1, id2, proto, attributes);
   14746            0 :       c_parser_objc_methodprotolist (parser);
   14747            0 :       c_parser_require_keyword (parser, RID_AT_END, "expected %<@end%>");
   14748            0 :       objc_finish_interface ();
   14749            0 :       return;
   14750              :     }
   14751            0 :   if (c_parser_next_token_is (parser, CPP_COLON))
   14752              :     {
   14753            0 :       c_parser_consume_token (parser);
   14754            0 :       if (c_parser_next_token_is_not (parser, CPP_NAME))
   14755              :         {
   14756            0 :           c_parser_error (parser, "expected identifier");
   14757            0 :           return;
   14758              :         }
   14759            0 :       superclass = c_parser_peek_token (parser)->value;
   14760            0 :       c_parser_consume_token (parser);
   14761              :     }
   14762              :   else
   14763              :     superclass = NULL_TREE;
   14764            0 :   if (iface_p)
   14765              :     {
   14766            0 :       tree proto = NULL_TREE;
   14767            0 :       if (c_parser_next_token_is (parser, CPP_LESS))
   14768            0 :         proto = c_parser_objc_protocol_refs (parser);
   14769            0 :       objc_start_class_interface (id1, loc1, superclass, proto, attributes);
   14770              :     }
   14771              :   else
   14772            0 :     objc_start_class_implementation (id1, superclass);
   14773            0 :   if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
   14774            0 :     c_parser_objc_class_instance_variables (parser);
   14775            0 :   if (iface_p)
   14776              :     {
   14777            0 :       objc_continue_interface ();
   14778            0 :       c_parser_objc_methodprotolist (parser);
   14779            0 :       c_parser_require_keyword (parser, RID_AT_END, "expected %<@end%>");
   14780            0 :       objc_finish_interface ();
   14781              :     }
   14782              :   else
   14783              :     {
   14784            0 :       objc_continue_implementation ();
   14785            0 :       return;
   14786              :     }
   14787              : }
   14788              : 
   14789              : /* Parse objc-class-instance-variables.
   14790              : 
   14791              :    objc-class-instance-variables:
   14792              :      { objc-instance-variable-decl-list[opt] }
   14793              : 
   14794              :    objc-instance-variable-decl-list:
   14795              :      objc-visibility-spec
   14796              :      objc-instance-variable-decl ;
   14797              :      ;
   14798              :      objc-instance-variable-decl-list objc-visibility-spec
   14799              :      objc-instance-variable-decl-list objc-instance-variable-decl ;
   14800              :      objc-instance-variable-decl-list ;
   14801              : 
   14802              :    objc-visibility-spec:
   14803              :      @private
   14804              :      @protected
   14805              :      @public
   14806              : 
   14807              :    objc-instance-variable-decl:
   14808              :      struct-declaration
   14809              : */
   14810              : 
   14811              : static void
   14812            0 : c_parser_objc_class_instance_variables (c_parser *parser)
   14813              : {
   14814            0 :   gcc_assert (c_parser_next_token_is (parser, CPP_OPEN_BRACE));
   14815            0 :   c_parser_consume_token (parser);
   14816            0 :   while (c_parser_next_token_is_not (parser, CPP_EOF))
   14817              :     {
   14818            0 :       tree decls;
   14819              :       /* Parse any stray semicolon.  */
   14820            0 :       if (c_parser_next_token_is (parser, CPP_SEMICOLON))
   14821              :         {
   14822            0 :           pedwarn (c_parser_peek_token (parser)->location, OPT_Wpedantic,
   14823              :                    "extra semicolon");
   14824            0 :           c_parser_consume_token (parser);
   14825            0 :           continue;
   14826              :         }
   14827              :       /* Stop if at the end of the instance variables.  */
   14828            0 :       if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
   14829              :         {
   14830            0 :           c_parser_consume_token (parser);
   14831            0 :           break;
   14832              :         }
   14833              :       /* Parse any objc-visibility-spec.  */
   14834            0 :       if (c_parser_next_token_is_keyword (parser, RID_AT_PRIVATE))
   14835              :         {
   14836            0 :           c_parser_consume_token (parser);
   14837            0 :           objc_set_visibility (OBJC_IVAR_VIS_PRIVATE);
   14838            0 :           continue;
   14839              :         }
   14840            0 :       else if (c_parser_next_token_is_keyword (parser, RID_AT_PROTECTED))
   14841              :         {
   14842            0 :           c_parser_consume_token (parser);
   14843            0 :           objc_set_visibility (OBJC_IVAR_VIS_PROTECTED);
   14844            0 :           continue;
   14845              :         }
   14846            0 :       else if (c_parser_next_token_is_keyword (parser, RID_AT_PUBLIC))
   14847              :         {
   14848            0 :           c_parser_consume_token (parser);
   14849            0 :           objc_set_visibility (OBJC_IVAR_VIS_PUBLIC);
   14850            0 :           continue;
   14851              :         }
   14852            0 :       else if (c_parser_next_token_is_keyword (parser, RID_AT_PACKAGE))
   14853              :         {
   14854            0 :           c_parser_consume_token (parser);
   14855            0 :           objc_set_visibility (OBJC_IVAR_VIS_PACKAGE);
   14856            0 :           continue;
   14857              :         }
   14858            0 :       else if (c_parser_next_token_is (parser, CPP_PRAGMA))
   14859              :         {
   14860            0 :           c_parser_pragma (parser, pragma_external, NULL, NULL_TREE);
   14861            0 :           continue;
   14862              :         }
   14863              : 
   14864              :       /* Parse some comma-separated declarations.  */
   14865            0 :       decls = c_parser_struct_declaration (parser, NULL);
   14866            0 :       if (decls == NULL)
   14867              :         {
   14868              :           /* There is a syntax error.  We want to skip the offending
   14869              :              tokens up to the next ';' (included) or '}'
   14870              :              (excluded).  */
   14871              : 
   14872              :           /* First, skip manually a ')' or ']'.  This is because they
   14873              :              reduce the nesting level, so c_parser_skip_until_found()
   14874              :              wouldn't be able to skip past them.  */
   14875            0 :           c_token *token = c_parser_peek_token (parser);
   14876            0 :           if (token->type == CPP_CLOSE_PAREN || token->type == CPP_CLOSE_SQUARE)
   14877            0 :             c_parser_consume_token (parser);
   14878              : 
   14879              :           /* Then, do the standard skipping.  */
   14880            0 :           c_parser_skip_until_found (parser, CPP_SEMICOLON, NULL);
   14881              : 
   14882              :           /* We hopefully recovered.  Start normal parsing again.  */
   14883            0 :           parser->error = false;
   14884            0 :           continue;
   14885            0 :         }
   14886              :       else
   14887              :         {
   14888              :           /* Comma-separated instance variables are chained together
   14889              :              in reverse order; add them one by one.  */
   14890            0 :           tree ivar = nreverse (decls);
   14891            0 :           for (; ivar; ivar = DECL_CHAIN (ivar))
   14892            0 :             objc_add_instance_variable (copy_node (ivar));
   14893              :         }
   14894            0 :       c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   14895              :     }
   14896            0 : }
   14897              : 
   14898              : /* Parse an objc-class-declaration.
   14899              : 
   14900              :    objc-class-declaration:
   14901              :      @class identifier-list ;
   14902              : */
   14903              : 
   14904              : static void
   14905            0 : c_parser_objc_class_declaration (c_parser *parser)
   14906              : {
   14907            0 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_CLASS));
   14908            0 :   c_parser_consume_token (parser);
   14909              :   /* Any identifiers, including those declared as type names, are OK
   14910              :      here.  */
   14911            0 :   while (true)
   14912              :     {
   14913            0 :       tree id;
   14914            0 :       if (c_parser_next_token_is_not (parser, CPP_NAME))
   14915              :         {
   14916            0 :           c_parser_error (parser, "expected identifier");
   14917            0 :           c_parser_skip_until_found (parser, CPP_SEMICOLON, NULL);
   14918            0 :           parser->error = false;
   14919            0 :           return;
   14920              :         }
   14921            0 :       id = c_parser_peek_token (parser)->value;
   14922            0 :       objc_declare_class (id);
   14923            0 :       c_parser_consume_token (parser);
   14924            0 :       if (c_parser_next_token_is (parser, CPP_COMMA))
   14925            0 :         c_parser_consume_token (parser);
   14926              :       else
   14927              :         break;
   14928            0 :     }
   14929            0 :   c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   14930              : }
   14931              : 
   14932              : /* Parse an objc-alias-declaration.
   14933              : 
   14934              :    objc-alias-declaration:
   14935              :      @compatibility_alias identifier identifier ;
   14936              : */
   14937              : 
   14938              : static void
   14939            0 : c_parser_objc_alias_declaration (c_parser *parser)
   14940              : {
   14941            0 :   tree id1, id2;
   14942            0 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_ALIAS));
   14943            0 :   c_parser_consume_token (parser);
   14944            0 :   if (c_parser_next_token_is_not (parser, CPP_NAME))
   14945              :     {
   14946            0 :       c_parser_error (parser, "expected identifier");
   14947            0 :       c_parser_skip_until_found (parser, CPP_SEMICOLON, NULL);
   14948            0 :       return;
   14949              :     }
   14950            0 :   id1 = c_parser_peek_token (parser)->value;
   14951            0 :   c_parser_consume_token (parser);
   14952            0 :   if (c_parser_next_token_is_not (parser, CPP_NAME))
   14953              :     {
   14954            0 :       c_parser_error (parser, "expected identifier");
   14955            0 :       c_parser_skip_until_found (parser, CPP_SEMICOLON, NULL);
   14956            0 :       return;
   14957              :     }
   14958            0 :   id2 = c_parser_peek_token (parser)->value;
   14959            0 :   c_parser_consume_token (parser);
   14960            0 :   c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   14961            0 :   objc_declare_alias (id1, id2);
   14962              : }
   14963              : 
   14964              : /* Parse an objc-protocol-definition.
   14965              : 
   14966              :    objc-protocol-definition:
   14967              :      @protocol identifier objc-protocol-refs[opt] objc-methodprotolist @end
   14968              :      @protocol identifier-list ;
   14969              : 
   14970              :    "@protocol identifier ;" should be resolved as "@protocol
   14971              :    identifier-list ;": objc-methodprotolist may not start with a
   14972              :    semicolon in the first alternative if objc-protocol-refs are
   14973              :    omitted.  */
   14974              : 
   14975              : static void
   14976            0 : c_parser_objc_protocol_definition (c_parser *parser, tree attributes)
   14977              : {
   14978            0 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_PROTOCOL));
   14979              : 
   14980            0 :   c_parser_consume_token (parser);
   14981            0 :   if (c_parser_next_token_is_not (parser, CPP_NAME))
   14982              :     {
   14983            0 :       c_parser_error (parser, "expected identifier");
   14984            0 :       return;
   14985              :     }
   14986            0 :   if (c_parser_peek_2nd_token (parser)->type == CPP_COMMA
   14987            0 :       || c_parser_peek_2nd_token (parser)->type == CPP_SEMICOLON)
   14988              :     {
   14989              :       /* Any identifiers, including those declared as type names, are
   14990              :          OK here.  */
   14991            0 :       while (true)
   14992              :         {
   14993            0 :           tree id;
   14994            0 :           if (c_parser_next_token_is_not (parser, CPP_NAME))
   14995              :             {
   14996            0 :               c_parser_error (parser, "expected identifier");
   14997            0 :               break;
   14998              :             }
   14999            0 :           id = c_parser_peek_token (parser)->value;
   15000            0 :           objc_declare_protocol (id, attributes);
   15001            0 :           c_parser_consume_token (parser);
   15002            0 :           if (c_parser_next_token_is (parser, CPP_COMMA))
   15003            0 :             c_parser_consume_token (parser);
   15004              :           else
   15005              :             break;
   15006            0 :         }
   15007            0 :       c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   15008              :     }
   15009              :   else
   15010              :     {
   15011            0 :       tree id = c_parser_peek_token (parser)->value;
   15012            0 :       tree proto = NULL_TREE;
   15013            0 :       c_parser_consume_token (parser);
   15014            0 :       if (c_parser_next_token_is (parser, CPP_LESS))
   15015            0 :         proto = c_parser_objc_protocol_refs (parser);
   15016            0 :       parser->objc_pq_context = true;
   15017            0 :       objc_start_protocol (id, proto, attributes);
   15018            0 :       c_parser_objc_methodprotolist (parser);
   15019            0 :       c_parser_require_keyword (parser, RID_AT_END, "expected %<@end%>");
   15020            0 :       parser->objc_pq_context = false;
   15021            0 :       objc_finish_interface ();
   15022              :     }
   15023              : }
   15024              : 
   15025              : /* Parse an objc-method-type.
   15026              : 
   15027              :    objc-method-type:
   15028              :      +
   15029              :      -
   15030              : 
   15031              :    Return true if it is a class method (+) and false if it is
   15032              :    an instance method (-).
   15033              : */
   15034              : static inline bool
   15035            0 : c_parser_objc_method_type (c_parser *parser)
   15036              : {
   15037            0 :   switch (c_parser_peek_token (parser)->type)
   15038              :     {
   15039            0 :     case CPP_PLUS:
   15040            0 :       c_parser_consume_token (parser);
   15041            0 :       return true;
   15042            0 :     case CPP_MINUS:
   15043            0 :       c_parser_consume_token (parser);
   15044            0 :       return false;
   15045            0 :     default:
   15046            0 :       gcc_unreachable ();
   15047              :     }
   15048              : }
   15049              : 
   15050              : /* Parse an objc-method-definition.
   15051              : 
   15052              :    objc-method-definition:
   15053              :      objc-method-type objc-method-decl ;[opt] compound-statement
   15054              : */
   15055              : 
   15056              : static void
   15057            0 : c_parser_objc_method_definition (c_parser *parser)
   15058              : {
   15059            0 :   bool is_class_method = c_parser_objc_method_type (parser);
   15060            0 :   tree decl, attributes = NULL_TREE, expr = NULL_TREE;
   15061            0 :   parser->objc_pq_context = true;
   15062            0 :   decl = c_parser_objc_method_decl (parser, is_class_method, &attributes,
   15063              :                                     &expr);
   15064            0 :   if (decl == error_mark_node)
   15065            0 :     return;  /* Bail here. */
   15066              : 
   15067            0 :   if (c_parser_next_token_is (parser, CPP_SEMICOLON))
   15068              :     {
   15069            0 :       c_parser_consume_token (parser);
   15070            0 :       pedwarn (c_parser_peek_token (parser)->location, OPT_Wpedantic,
   15071              :                "extra semicolon in method definition specified");
   15072              :     }
   15073              : 
   15074            0 :   if (!c_parser_next_token_is (parser, CPP_OPEN_BRACE))
   15075              :     {
   15076            0 :       c_parser_error (parser, "expected %<{%>");
   15077            0 :       return;
   15078              :     }
   15079              : 
   15080            0 :   parser->objc_pq_context = false;
   15081            0 :   if (objc_start_method_definition (is_class_method, decl, attributes, expr))
   15082              :     {
   15083            0 :       add_stmt (c_parser_compound_statement (parser));
   15084            0 :       objc_finish_method_definition (current_function_decl);
   15085              :     }
   15086              :   else
   15087              :     {
   15088              :       /* This code is executed when we find a method definition
   15089              :          outside of an @implementation context (or invalid for other
   15090              :          reasons).  Parse the method (to keep going) but do not emit
   15091              :          any code.
   15092              :       */
   15093            0 :       c_parser_compound_statement (parser);
   15094              :     }
   15095              : }
   15096              : 
   15097              : /* Parse an objc-methodprotolist.
   15098              : 
   15099              :    objc-methodprotolist:
   15100              :      empty
   15101              :      objc-methodprotolist objc-methodproto
   15102              :      objc-methodprotolist declaration
   15103              :      objc-methodprotolist ;
   15104              :      @optional
   15105              :      @required
   15106              : 
   15107              :    The declaration is a data definition, which may be missing
   15108              :    declaration specifiers under the same rules and diagnostics as
   15109              :    other data definitions outside functions, and the stray semicolon
   15110              :    is diagnosed the same way as a stray semicolon outside a
   15111              :    function.  */
   15112              : 
   15113              : static void
   15114            0 : c_parser_objc_methodprotolist (c_parser *parser)
   15115              : {
   15116            0 :   while (true)
   15117              :     {
   15118              :       /* The list is terminated by @end.  */
   15119            0 :       switch (c_parser_peek_token (parser)->type)
   15120              :         {
   15121            0 :         case CPP_SEMICOLON:
   15122            0 :           pedwarn (c_parser_peek_token (parser)->location, OPT_Wpedantic,
   15123              :                    "ISO C does not allow extra %<;%> outside of a function");
   15124            0 :           c_parser_consume_token (parser);
   15125            0 :           break;
   15126            0 :         case CPP_PLUS:
   15127            0 :         case CPP_MINUS:
   15128            0 :           c_parser_objc_methodproto (parser);
   15129            0 :           break;
   15130            0 :         case CPP_PRAGMA:
   15131            0 :           c_parser_pragma (parser, pragma_external, NULL, NULL_TREE);
   15132            0 :           break;
   15133              :         case CPP_EOF:
   15134              :           return;
   15135            0 :         default:
   15136            0 :           if (c_parser_next_token_is_keyword (parser, RID_AT_END))
   15137              :             return;
   15138            0 :           else if (c_parser_next_token_is_keyword (parser, RID_AT_PROPERTY))
   15139            0 :             c_parser_objc_at_property_declaration (parser);
   15140            0 :           else if (c_parser_next_token_is_keyword (parser, RID_AT_OPTIONAL))
   15141              :             {
   15142            0 :               objc_set_method_opt (true);
   15143            0 :               c_parser_consume_token (parser);
   15144              :             }
   15145            0 :           else if (c_parser_next_token_is_keyword (parser, RID_AT_REQUIRED))
   15146              :             {
   15147            0 :               objc_set_method_opt (false);
   15148            0 :               c_parser_consume_token (parser);
   15149              :             }
   15150              :           else
   15151            0 :             c_parser_declaration_or_fndef (parser, false, false, true,
   15152              :                                            false, true, false);
   15153              :           break;
   15154              :         }
   15155              :     }
   15156              : }
   15157              : 
   15158              : /* Parse an objc-methodproto.
   15159              : 
   15160              :    objc-methodproto:
   15161              :      objc-method-type objc-method-decl ;
   15162              : */
   15163              : 
   15164              : static void
   15165            0 : c_parser_objc_methodproto (c_parser *parser)
   15166              : {
   15167            0 :   bool is_class_method = c_parser_objc_method_type (parser);
   15168            0 :   tree decl, attributes = NULL_TREE;
   15169              : 
   15170              :   /* Remember protocol qualifiers in prototypes.  */
   15171            0 :   parser->objc_pq_context = true;
   15172            0 :   decl = c_parser_objc_method_decl (parser, is_class_method, &attributes,
   15173              :                                     NULL);
   15174              :   /* Forget protocol qualifiers now.  */
   15175            0 :   parser->objc_pq_context = false;
   15176              : 
   15177              :   /* Do not allow the presence of attributes to hide an erroneous
   15178              :      method implementation in the interface section.  */
   15179            0 :   if (!c_parser_next_token_is (parser, CPP_SEMICOLON))
   15180              :     {
   15181            0 :       c_parser_error (parser, "expected %<;%>");
   15182            0 :       return;
   15183              :     }
   15184              : 
   15185            0 :   if (decl != error_mark_node)
   15186            0 :     objc_add_method_declaration (is_class_method, decl, attributes);
   15187              : 
   15188            0 :   c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   15189              : }
   15190              : 
   15191              : /* If we are at a position that method attributes may be present, check that
   15192              :    there are not any parsed already (a syntax error) and then collect any
   15193              :    specified at the current location.  Finally, if new attributes were present,
   15194              :    check that the next token is legal ( ';' for decls and '{' for defs).  */
   15195              : 
   15196              : static bool
   15197            0 : c_parser_objc_maybe_method_attributes (c_parser* parser, tree* attributes)
   15198              : {
   15199            0 :   bool bad = false;
   15200            0 :   if (*attributes)
   15201              :     {
   15202            0 :       c_parser_error (parser,
   15203              :                     "method attributes must be specified at the end only");
   15204            0 :       *attributes = NULL_TREE;
   15205            0 :       bad = true;
   15206              :     }
   15207              : 
   15208            0 :   if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
   15209            0 :     *attributes = c_parser_gnu_attributes (parser);
   15210              : 
   15211              :   /* If there were no attributes here, just report any earlier error.  */
   15212            0 :   if (*attributes == NULL_TREE || bad)
   15213              :     return bad;
   15214              : 
   15215              :   /* If the attributes are followed by a ; or {, then just report any earlier
   15216              :      error.  */
   15217            0 :   if (c_parser_next_token_is (parser, CPP_SEMICOLON)
   15218            0 :       || c_parser_next_token_is (parser, CPP_OPEN_BRACE))
   15219              :     return bad;
   15220              : 
   15221              :   /* We've got attributes, but not at the end.  */
   15222            0 :   c_parser_error (parser,
   15223              :                   "expected %<;%> or %<{%> after method attribute definition");
   15224            0 :   return true;
   15225              : }
   15226              : 
   15227              : /* Parse an objc-method-decl.
   15228              : 
   15229              :    objc-method-decl:
   15230              :      ( objc-type-name ) objc-selector
   15231              :      objc-selector
   15232              :      ( objc-type-name ) objc-keyword-selector objc-optparmlist
   15233              :      objc-keyword-selector objc-optparmlist
   15234              :      gnu-attributes
   15235              : 
   15236              :    objc-keyword-selector:
   15237              :      objc-keyword-decl
   15238              :      objc-keyword-selector objc-keyword-decl
   15239              : 
   15240              :    objc-keyword-decl:
   15241              :      objc-selector : ( objc-type-name ) identifier
   15242              :      objc-selector : identifier
   15243              :      : ( objc-type-name ) identifier
   15244              :      : identifier
   15245              : 
   15246              :    objc-optparmlist:
   15247              :      objc-optparms objc-optellipsis
   15248              : 
   15249              :    objc-optparms:
   15250              :      empty
   15251              :      objc-opt-parms , parameter-declaration
   15252              : 
   15253              :    objc-optellipsis:
   15254              :      empty
   15255              :      , ...
   15256              : */
   15257              : 
   15258              : static tree
   15259            0 : c_parser_objc_method_decl (c_parser *parser, bool is_class_method,
   15260              :                            tree *attributes, tree *expr)
   15261              : {
   15262            0 :   tree type = NULL_TREE;
   15263            0 :   tree sel;
   15264            0 :   tree parms = NULL_TREE;
   15265            0 :   bool ellipsis = false;
   15266            0 :   bool attr_err = false;
   15267              : 
   15268            0 :   *attributes = NULL_TREE;
   15269            0 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   15270              :     {
   15271            0 :       matching_parens parens;
   15272            0 :       parens.consume_open (parser);
   15273            0 :       type = c_parser_objc_type_name (parser);
   15274            0 :       parens.skip_until_found_close (parser);
   15275              :     }
   15276            0 :   sel = c_parser_objc_selector (parser);
   15277              :   /* If there is no selector, or a colon follows, we have an
   15278              :      objc-keyword-selector.  If there is a selector, and a colon does
   15279              :      not follow, that selector ends the objc-method-decl.  */
   15280            0 :   if (!sel || c_parser_next_token_is (parser, CPP_COLON))
   15281              :     {
   15282              :       tree tsel = sel;
   15283              :       tree list = NULL_TREE;
   15284            0 :       while (true)
   15285              :         {
   15286            0 :           tree atype = NULL_TREE, id, keyworddecl;
   15287            0 :           tree param_attr = NULL_TREE;
   15288            0 :           if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   15289              :             break;
   15290            0 :           if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   15291              :             {
   15292            0 :               c_parser_consume_token (parser);
   15293            0 :               atype = c_parser_objc_type_name (parser);
   15294            0 :               c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   15295              :                                          "expected %<)%>");
   15296              :             }
   15297              :           /* New ObjC allows attributes on method parameters.  */
   15298            0 :           if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
   15299            0 :             param_attr = c_parser_gnu_attributes (parser);
   15300            0 :           if (c_parser_next_token_is_not (parser, CPP_NAME))
   15301              :             {
   15302            0 :               c_parser_error (parser, "expected identifier");
   15303            0 :               return error_mark_node;
   15304              :             }
   15305            0 :           id = c_parser_peek_token (parser)->value;
   15306            0 :           c_parser_consume_token (parser);
   15307            0 :           keyworddecl = objc_build_keyword_decl (tsel, atype, id, param_attr);
   15308            0 :           list = chainon (list, keyworddecl);
   15309            0 :           tsel = c_parser_objc_selector (parser);
   15310            0 :           if (!tsel && c_parser_next_token_is_not (parser, CPP_COLON))
   15311              :             break;
   15312              :         }
   15313              : 
   15314            0 :       attr_err |= c_parser_objc_maybe_method_attributes (parser, attributes) ;
   15315              : 
   15316              :       /* Parse the optional parameter list.  Optional Objective-C
   15317              :          method parameters follow the C syntax, and may include '...'
   15318              :          to denote a variable number of arguments.  */
   15319            0 :       parms = make_node (TREE_LIST);
   15320            0 :       while (c_parser_next_token_is (parser, CPP_COMMA))
   15321              :         {
   15322            0 :           struct c_parm *parm;
   15323            0 :           c_parser_consume_token (parser);
   15324            0 :           if (c_parser_next_token_is (parser, CPP_ELLIPSIS))
   15325              :             {
   15326            0 :               ellipsis = true;
   15327            0 :               c_parser_consume_token (parser);
   15328            0 :               attr_err |= c_parser_objc_maybe_method_attributes
   15329            0 :                                                 (parser, attributes) ;
   15330            0 :               break;
   15331              :             }
   15332            0 :           parm = c_parser_parameter_declaration (parser, NULL_TREE, false);
   15333            0 :           if (parm == NULL)
   15334              :             break;
   15335            0 :           parms = chainon (parms,
   15336              :                            build_tree_list (NULL_TREE, grokparm (parm, expr)));
   15337              :         }
   15338              :       sel = list;
   15339              :     }
   15340              :   else
   15341            0 :     attr_err |= c_parser_objc_maybe_method_attributes (parser, attributes) ;
   15342              : 
   15343            0 :   if (sel == NULL)
   15344              :     {
   15345            0 :       c_parser_error (parser, "objective-c method declaration is expected");
   15346            0 :       return error_mark_node;
   15347              :     }
   15348              : 
   15349            0 :   if (attr_err)
   15350            0 :     return error_mark_node;
   15351              : 
   15352            0 :   return objc_build_method_signature (is_class_method, type, sel, parms, ellipsis);
   15353              : }
   15354              : 
   15355              : /* Parse an objc-type-name.
   15356              : 
   15357              :    objc-type-name:
   15358              :      objc-type-qualifiers[opt] type-name
   15359              :      objc-type-qualifiers[opt]
   15360              : 
   15361              :    objc-type-qualifiers:
   15362              :      objc-type-qualifier
   15363              :      objc-type-qualifiers objc-type-qualifier
   15364              : 
   15365              :    objc-type-qualifier: one of
   15366              :      in out inout bycopy byref oneway
   15367              : */
   15368              : 
   15369              : static tree
   15370            0 : c_parser_objc_type_name (c_parser *parser)
   15371              : {
   15372            0 :   tree quals = NULL_TREE;
   15373            0 :   struct c_type_name *type_name = NULL;
   15374            0 :   tree type = NULL_TREE;
   15375            0 :   while (true)
   15376              :     {
   15377            0 :       c_token *token = c_parser_peek_token (parser);
   15378            0 :       if (token->type == CPP_KEYWORD
   15379            0 :           && (token->keyword == RID_IN
   15380              :               || token->keyword == RID_OUT
   15381              :               || token->keyword == RID_INOUT
   15382              :               || token->keyword == RID_BYCOPY
   15383              :               || token->keyword == RID_BYREF
   15384            0 :               || token->keyword == RID_ONEWAY))
   15385              :         {
   15386            0 :           quals = chainon (build_tree_list (NULL_TREE, token->value), quals);
   15387            0 :           c_parser_consume_token (parser);
   15388              :         }
   15389              :       else
   15390              :         break;
   15391            0 :     }
   15392            0 :   if (c_parser_next_tokens_start_typename (parser, cla_prefer_type))
   15393            0 :     type_name = c_parser_type_name (parser);
   15394            0 :   if (type_name)
   15395            0 :     type = groktypename (type_name, NULL, NULL);
   15396              : 
   15397              :   /* If the type is unknown, and error has already been produced and
   15398              :      we need to recover from the error.  In that case, use NULL_TREE
   15399              :      for the type, as if no type had been specified; this will use the
   15400              :      default type ('id') which is good for error recovery.  */
   15401            0 :   if (type == error_mark_node)
   15402            0 :     type = NULL_TREE;
   15403              : 
   15404            0 :   return build_tree_list (quals, type);
   15405              : }
   15406              : 
   15407              : /* Parse objc-protocol-refs.
   15408              : 
   15409              :    objc-protocol-refs:
   15410              :      < identifier-list >
   15411              : */
   15412              : 
   15413              : static tree
   15414            0 : c_parser_objc_protocol_refs (c_parser *parser)
   15415              : {
   15416            0 :   tree list = NULL_TREE;
   15417            0 :   gcc_assert (c_parser_next_token_is (parser, CPP_LESS));
   15418            0 :   c_parser_consume_token (parser);
   15419              :   /* Any identifiers, including those declared as type names, are OK
   15420              :      here.  */
   15421            0 :   while (true)
   15422              :     {
   15423            0 :       tree id;
   15424            0 :       if (c_parser_next_token_is_not (parser, CPP_NAME))
   15425              :         {
   15426            0 :           c_parser_error (parser, "expected identifier");
   15427            0 :           break;
   15428              :         }
   15429            0 :       id = c_parser_peek_token (parser)->value;
   15430            0 :       list = chainon (list, build_tree_list (NULL_TREE, id));
   15431            0 :       c_parser_consume_token (parser);
   15432            0 :       if (c_parser_next_token_is (parser, CPP_COMMA))
   15433            0 :         c_parser_consume_token (parser);
   15434              :       else
   15435              :         break;
   15436            0 :     }
   15437            0 :   c_parser_require (parser, CPP_GREATER, "expected %<>%>");
   15438            0 :   return list;
   15439              : }
   15440              : 
   15441              : /* Parse an objc-try-catch-finally-statement.
   15442              : 
   15443              :    objc-try-catch-finally-statement:
   15444              :      @try compound-statement objc-catch-list[opt]
   15445              :      @try compound-statement objc-catch-list[opt] @finally compound-statement
   15446              : 
   15447              :    objc-catch-list:
   15448              :      @catch ( objc-catch-parameter-declaration ) compound-statement
   15449              :      objc-catch-list @catch ( objc-catch-parameter-declaration ) compound-statement
   15450              : 
   15451              :    objc-catch-parameter-declaration:
   15452              :      parameter-declaration
   15453              :      '...'
   15454              : 
   15455              :    where '...' is to be interpreted literally, that is, it means CPP_ELLIPSIS.
   15456              : 
   15457              :    PS: This function is identical to cp_parser_objc_try_catch_finally_statement
   15458              :    for C++.  Keep them in sync.  */
   15459              : 
   15460              : static void
   15461            0 : c_parser_objc_try_catch_finally_statement (c_parser *parser)
   15462              : {
   15463            0 :   location_t location;
   15464            0 :   tree stmt;
   15465              : 
   15466            0 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_TRY));
   15467            0 :   c_parser_consume_token (parser);
   15468            0 :   location = c_parser_peek_token (parser)->location;
   15469            0 :   objc_maybe_warn_exceptions (location);
   15470            0 :   stmt = c_parser_compound_statement (parser);
   15471            0 :   objc_begin_try_stmt (location, stmt);
   15472              : 
   15473            0 :   while (c_parser_next_token_is_keyword (parser, RID_AT_CATCH))
   15474              :     {
   15475            0 :       struct c_parm *parm;
   15476            0 :       tree parameter_declaration = error_mark_node;
   15477            0 :       bool seen_open_paren = false;
   15478              : 
   15479            0 :       c_parser_consume_token (parser);
   15480            0 :       matching_parens parens;
   15481            0 :       if (!parens.require_open (parser))
   15482            0 :         seen_open_paren = true;
   15483            0 :       if (c_parser_next_token_is (parser, CPP_ELLIPSIS))
   15484              :         {
   15485              :           /* We have "@catch (...)" (where the '...' are literally
   15486              :              what is in the code).  Skip the '...'.
   15487              :              parameter_declaration is set to NULL_TREE, and
   15488              :              objc_being_catch_clauses() knows that that means
   15489              :              '...'.  */
   15490            0 :           c_parser_consume_token (parser);
   15491            0 :           parameter_declaration = NULL_TREE;
   15492              :         }
   15493              :       else
   15494              :         {
   15495              :           /* We have "@catch (NSException *exception)" or something
   15496              :              like that.  Parse the parameter declaration.  */
   15497            0 :           parm = c_parser_parameter_declaration (parser, NULL_TREE, false);
   15498            0 :           if (parm == NULL)
   15499            0 :             parameter_declaration = error_mark_node;
   15500              :           else
   15501            0 :             parameter_declaration = grokparm (parm, NULL);
   15502              :         }
   15503            0 :       if (seen_open_paren)
   15504            0 :         parens.require_close (parser);
   15505              :       else
   15506              :         {
   15507              :           /* If there was no open parenthesis, we are recovering from
   15508              :              an error, and we are trying to figure out what mistake
   15509              :              the user has made.  */
   15510              : 
   15511              :           /* If there is an immediate closing parenthesis, the user
   15512              :              probably forgot the opening one (ie, they typed "@catch
   15513              :              NSException *e)".  Parse the closing parenthesis and keep
   15514              :              going.  */
   15515            0 :           if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   15516            0 :             c_parser_consume_token (parser);
   15517              : 
   15518              :           /* If these is no immediate closing parenthesis, the user
   15519              :              probably doesn't know that parenthesis are required at
   15520              :              all (ie, they typed "@catch NSException *e").  So, just
   15521              :              forget about the closing parenthesis and keep going.  */
   15522              :         }
   15523            0 :       objc_begin_catch_clause (parameter_declaration);
   15524            0 :       if (c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
   15525            0 :         c_parser_compound_statement_nostart (parser);
   15526            0 :       objc_finish_catch_clause ();
   15527              :     }
   15528            0 :   if (c_parser_next_token_is_keyword (parser, RID_AT_FINALLY))
   15529              :     {
   15530            0 :       c_parser_consume_token (parser);
   15531            0 :       location = c_parser_peek_token (parser)->location;
   15532            0 :       stmt = c_parser_compound_statement (parser);
   15533            0 :       objc_build_finally_clause (location, stmt);
   15534              :     }
   15535            0 :   objc_finish_try_stmt ();
   15536            0 : }
   15537              : 
   15538              : /* Parse an objc-synchronized-statement.
   15539              : 
   15540              :    objc-synchronized-statement:
   15541              :      @synchronized ( expression ) compound-statement
   15542              : */
   15543              : 
   15544              : static void
   15545            0 : c_parser_objc_synchronized_statement (c_parser *parser)
   15546              : {
   15547            0 :   location_t loc;
   15548            0 :   tree expr, stmt;
   15549            0 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_SYNCHRONIZED));
   15550            0 :   c_parser_consume_token (parser);
   15551            0 :   loc = c_parser_peek_token (parser)->location;
   15552            0 :   objc_maybe_warn_exceptions (loc);
   15553            0 :   matching_parens parens;
   15554            0 :   if (parens.require_open (parser))
   15555              :     {
   15556            0 :       struct c_expr ce = c_parser_expression (parser);
   15557            0 :       ce = convert_lvalue_to_rvalue (loc, ce, false, false);
   15558            0 :       expr = ce.value;
   15559            0 :       expr = c_fully_fold (expr, false, NULL);
   15560            0 :       parens.skip_until_found_close (parser);
   15561              :     }
   15562              :   else
   15563            0 :     expr = error_mark_node;
   15564            0 :   stmt = c_parser_compound_statement (parser);
   15565            0 :   objc_build_synchronized (loc, expr, stmt);
   15566            0 : }
   15567              : 
   15568              : /* Parse an objc-selector; return NULL_TREE without an error if the
   15569              :    next token is not an objc-selector.
   15570              : 
   15571              :    objc-selector:
   15572              :      identifier
   15573              :      one of
   15574              :        enum struct union if else while do for switch case default
   15575              :        break continue return goto asm sizeof typeof typeof_unqual __alignof
   15576              :        unsigned long const short volatile signed restrict _Complex
   15577              :        in out inout bycopy byref oneway int char float double void _Bool
   15578              :        _Atomic
   15579              : 
   15580              :    ??? Why this selection of keywords but not, for example, storage
   15581              :    class specifiers?  */
   15582              : 
   15583              : static tree
   15584            0 : c_parser_objc_selector (c_parser *parser)
   15585              : {
   15586            0 :   c_token *token = c_parser_peek_token (parser);
   15587            0 :   tree value = token->value;
   15588            0 :   if (token->type == CPP_NAME)
   15589              :     {
   15590            0 :       c_parser_consume_token (parser);
   15591            0 :       return value;
   15592              :     }
   15593            0 :   if (token->type != CPP_KEYWORD)
   15594              :     return NULL_TREE;
   15595            0 :   switch (token->keyword)
   15596              :     {
   15597            0 :     case RID_ENUM:
   15598            0 :     case RID_STRUCT:
   15599            0 :     case RID_UNION:
   15600            0 :     case RID_IF:
   15601            0 :     case RID_ELSE:
   15602            0 :     case RID_WHILE:
   15603            0 :     case RID_DO:
   15604            0 :     case RID_FOR:
   15605            0 :     case RID_SWITCH:
   15606            0 :     case RID_CASE:
   15607            0 :     case RID_DEFAULT:
   15608            0 :     case RID_BREAK:
   15609            0 :     case RID_CONTINUE:
   15610            0 :     case RID_RETURN:
   15611            0 :     case RID_GOTO:
   15612            0 :     case RID_ASM:
   15613            0 :     case RID_SIZEOF:
   15614            0 :     case RID_TYPEOF:
   15615            0 :     case RID_TYPEOF_UNQUAL:
   15616            0 :     case RID_ALIGNOF:
   15617            0 :     case RID_UNSIGNED:
   15618            0 :     case RID_LONG:
   15619            0 :     case RID_CONST:
   15620            0 :     case RID_SHORT:
   15621            0 :     case RID_VOLATILE:
   15622            0 :     case RID_SIGNED:
   15623            0 :     case RID_RESTRICT:
   15624            0 :     case RID_COMPLEX:
   15625            0 :     case RID_IN:
   15626            0 :     case RID_OUT:
   15627            0 :     case RID_INOUT:
   15628            0 :     case RID_BYCOPY:
   15629            0 :     case RID_BYREF:
   15630            0 :     case RID_ONEWAY:
   15631            0 :     case RID_INT:
   15632            0 :     case RID_CHAR:
   15633            0 :     case RID_FLOAT:
   15634            0 :     case RID_DOUBLE:
   15635            0 :     CASE_RID_FLOATN_NX:
   15636            0 :     case RID_VOID:
   15637            0 :     case RID_BOOL:
   15638            0 :     case RID_ATOMIC:
   15639            0 :     case RID_AUTO_TYPE:
   15640            0 :     case RID_INT_N_0:
   15641            0 :     case RID_INT_N_1:
   15642            0 :     case RID_INT_N_2:
   15643            0 :     case RID_INT_N_3:
   15644            0 :       c_parser_consume_token (parser);
   15645            0 :       return value;
   15646              :     default:
   15647              :       return NULL_TREE;
   15648              :     }
   15649              : }
   15650              : 
   15651              : /* Parse an objc-selector-arg.
   15652              : 
   15653              :    objc-selector-arg:
   15654              :      objc-selector
   15655              :      objc-keywordname-list
   15656              : 
   15657              :    objc-keywordname-list:
   15658              :      objc-keywordname
   15659              :      objc-keywordname-list objc-keywordname
   15660              : 
   15661              :    objc-keywordname:
   15662              :      objc-selector :
   15663              :      :
   15664              : */
   15665              : 
   15666              : static tree
   15667            0 : c_parser_objc_selector_arg (c_parser *parser)
   15668              : {
   15669            0 :   tree sel = c_parser_objc_selector (parser);
   15670            0 :   tree list = NULL_TREE;
   15671            0 :   if (sel
   15672            0 :       && c_parser_next_token_is_not (parser, CPP_COLON)
   15673            0 :       && c_parser_next_token_is_not (parser, CPP_SCOPE))
   15674              :     return sel;
   15675            0 :   while (true)
   15676              :     {
   15677            0 :       if (c_parser_next_token_is (parser, CPP_SCOPE))
   15678              :         {
   15679            0 :           c_parser_consume_token (parser);
   15680            0 :           list = chainon (list, build_tree_list (sel, NULL_TREE));
   15681            0 :           list = chainon (list, build_tree_list (NULL_TREE, NULL_TREE));
   15682              :         }
   15683              :       else
   15684              :         {
   15685            0 :           if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   15686              :             return list;
   15687            0 :           list = chainon (list, build_tree_list (sel, NULL_TREE));
   15688              :         }
   15689            0 :       sel = c_parser_objc_selector (parser);
   15690            0 :       if (!sel
   15691            0 :           && c_parser_next_token_is_not (parser, CPP_COLON)
   15692            0 :           && c_parser_next_token_is_not (parser, CPP_SCOPE))
   15693              :         break;
   15694              :     }
   15695              :   return list;
   15696              : }
   15697              : 
   15698              : /* Parse an objc-receiver.
   15699              : 
   15700              :    objc-receiver:
   15701              :      expression
   15702              :      class-name
   15703              :      type-name
   15704              : */
   15705              : 
   15706              : static tree
   15707            0 : c_parser_objc_receiver (c_parser *parser)
   15708              : {
   15709            0 :   location_t loc = c_parser_peek_token (parser)->location;
   15710              : 
   15711            0 :   if (c_parser_peek_token (parser)->type == CPP_NAME
   15712            0 :       && (c_parser_peek_token (parser)->id_kind == C_ID_TYPENAME
   15713            0 :           || c_parser_peek_token (parser)->id_kind == C_ID_CLASSNAME))
   15714              :     {
   15715            0 :       tree id = c_parser_peek_token (parser)->value;
   15716            0 :       c_parser_consume_token (parser);
   15717            0 :       return objc_get_class_reference (id);
   15718              :     }
   15719            0 :   struct c_expr ce = c_parser_expression (parser);
   15720            0 :   ce = convert_lvalue_to_rvalue (loc, ce, false, false);
   15721            0 :   return c_fully_fold (ce.value, false, NULL);
   15722              : }
   15723              : 
   15724              : /* Parse objc-message-args.
   15725              : 
   15726              :    objc-message-args:
   15727              :      objc-selector
   15728              :      objc-keywordarg-list
   15729              : 
   15730              :    objc-keywordarg-list:
   15731              :      objc-keywordarg
   15732              :      objc-keywordarg-list objc-keywordarg
   15733              : 
   15734              :    objc-keywordarg:
   15735              :      objc-selector : objc-keywordexpr
   15736              :      : objc-keywordexpr
   15737              : */
   15738              : 
   15739              : static tree
   15740            0 : c_parser_objc_message_args (c_parser *parser)
   15741              : {
   15742            0 :   tree sel = c_parser_objc_selector (parser);
   15743            0 :   tree list = NULL_TREE;
   15744            0 :   if (sel && c_parser_next_token_is_not (parser, CPP_COLON))
   15745              :     return sel;
   15746            0 :   while (true)
   15747              :     {
   15748            0 :       tree keywordexpr;
   15749            0 :       if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   15750            0 :         return error_mark_node;
   15751            0 :       keywordexpr = c_parser_objc_keywordexpr (parser);
   15752            0 :       list = chainon (list, build_tree_list (sel, keywordexpr));
   15753            0 :       sel = c_parser_objc_selector (parser);
   15754            0 :       if (!sel && c_parser_next_token_is_not (parser, CPP_COLON))
   15755              :         break;
   15756              :     }
   15757              :   return list;
   15758              : }
   15759              : 
   15760              : /* Parse an objc-keywordexpr.
   15761              : 
   15762              :    objc-keywordexpr:
   15763              :      nonempty-expr-list
   15764              : */
   15765              : 
   15766              : static tree
   15767            0 : c_parser_objc_keywordexpr (c_parser *parser)
   15768              : {
   15769            0 :   tree ret;
   15770            0 :   vec<tree, va_gc> *expr_list = c_parser_expr_list (parser, true, true,
   15771              :                                                 NULL, NULL, NULL, NULL);
   15772            0 :   if (vec_safe_length (expr_list) == 1)
   15773              :     {
   15774              :       /* Just return the expression, remove a level of
   15775              :          indirection.  */
   15776            0 :       ret = (*expr_list)[0];
   15777              :     }
   15778              :   else
   15779              :     {
   15780              :       /* We have a comma expression, we will collapse later.  */
   15781            0 :       ret = build_tree_list_vec (expr_list);
   15782              :     }
   15783            0 :   release_tree_vector (expr_list);
   15784            0 :   return ret;
   15785              : }
   15786              : 
   15787              : /* A check, needed in several places, that ObjC interface, implementation or
   15788              :    method definitions are not prefixed by incorrect items.  */
   15789              : static bool
   15790            0 : c_parser_objc_diagnose_bad_element_prefix (c_parser *parser,
   15791              :                                            struct c_declspecs *specs)
   15792              : {
   15793            0 :   if (!specs->declspecs_seen_p || specs->non_sc_seen_p
   15794            0 :       || specs->typespec_kind != ctsk_none)
   15795              :     {
   15796            0 :       c_parser_error (parser,
   15797              :                       "no type or storage class may be specified here,");
   15798            0 :       c_parser_skip_to_end_of_block_or_statement (parser);
   15799            0 :       return true;
   15800              :     }
   15801              :   return false;
   15802              : }
   15803              : 
   15804              : /* Parse an Objective-C @property declaration.  The syntax is:
   15805              : 
   15806              :    objc-property-declaration:
   15807              :      '@property' objc-property-attributes[opt] struct-declaration ;
   15808              : 
   15809              :    objc-property-attributes:
   15810              :     '(' objc-property-attribute-list ')'
   15811              : 
   15812              :    objc-property-attribute-list:
   15813              :      objc-property-attribute
   15814              :      objc-property-attribute-list, objc-property-attribute
   15815              : 
   15816              :    objc-property-attribute
   15817              :      'getter' = identifier
   15818              :      'setter' = identifier
   15819              :      'readonly'
   15820              :      'readwrite'
   15821              :      'assign'
   15822              :      'retain'
   15823              :      'copy'
   15824              :      'nonatomic'
   15825              : 
   15826              :   For example:
   15827              :     @property NSString *name;
   15828              :     @property (readonly) id object;
   15829              :     @property (retain, nonatomic, getter=getTheName) id name;
   15830              :     @property int a, b, c;
   15831              : 
   15832              :   PS: This function is identical to cp_parser_objc_at_propery_declaration
   15833              :   for C++.  Keep them in sync.  */
   15834              : static void
   15835            0 : c_parser_objc_at_property_declaration (c_parser *parser)
   15836              : {
   15837            0 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_PROPERTY));
   15838            0 :   location_t loc = c_parser_peek_token (parser)->location;
   15839            0 :   c_parser_consume_token (parser);  /* Eat '@property'.  */
   15840              : 
   15841              :   /* Parse the optional attribute list.
   15842              : 
   15843              :      A list of parsed, but not verified, attributes.  */
   15844            0 :   vec<property_attribute_info *> prop_attr_list = vNULL;
   15845              : 
   15846            0 :   bool syntax_error = false;
   15847            0 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   15848              :     {
   15849            0 :       matching_parens parens;
   15850              : 
   15851            0 :       location_t attr_start = c_parser_peek_token (parser)->location;
   15852              :       /* Eat the '(' */
   15853            0 :       parens.consume_open (parser);
   15854              : 
   15855              :       /* Property attribute keywords are valid now.  */
   15856            0 :       parser->objc_property_attr_context = true;
   15857              : 
   15858              :       /* Allow @property (), with a warning.  */
   15859            0 :       location_t attr_end = c_parser_peek_token (parser)->location;
   15860              : 
   15861            0 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   15862              :         {
   15863            0 :           location_t attr_comb = make_location (attr_end, attr_start, attr_end);
   15864            0 :           warning_at (attr_comb, OPT_Wattributes,
   15865              :                       "empty property attribute list");
   15866              :         }
   15867              :       else
   15868            0 :         while (true)
   15869              :           {
   15870            0 :             c_token *token = c_parser_peek_token (parser);
   15871            0 :             attr_start = token->location;
   15872            0 :             attr_end = get_finish (token->location);
   15873            0 :             location_t attr_comb = make_location (attr_start, attr_start,
   15874              :                                                   attr_end);
   15875              : 
   15876            0 :             if (token->type == CPP_CLOSE_PAREN || token->type == CPP_COMMA)
   15877              :               {
   15878            0 :                 warning_at (attr_comb, OPT_Wattributes,
   15879              :                             "missing property attribute");
   15880            0 :                 if (token->type == CPP_CLOSE_PAREN)
   15881              :                   break;
   15882            0 :                 c_parser_consume_token (parser);
   15883            0 :                 continue;
   15884              :               }
   15885              : 
   15886            0 :             tree attr_name = NULL_TREE;
   15887            0 :             enum rid keyword = RID_MAX; /* Not a valid property attribute.  */
   15888            0 :             bool add_at = false;
   15889            0 :             if (token->type == CPP_KEYWORD)
   15890              :               {
   15891            0 :                 keyword = token->keyword;
   15892            0 :                 if (OBJC_IS_AT_KEYWORD (keyword))
   15893              :                   {
   15894              :                     /* For '@' keywords the token value has the keyword,
   15895              :                        prepend the '@' for diagnostics.  */
   15896            0 :                     attr_name = token->value;
   15897            0 :                     add_at = true;
   15898              :                   }
   15899              :                 else
   15900            0 :                   attr_name = ridpointers[(int)keyword];
   15901              :               }
   15902            0 :             else if (token->type == CPP_NAME)
   15903            0 :               attr_name = token->value;
   15904            0 :             c_parser_consume_token (parser);
   15905              : 
   15906            0 :             enum objc_property_attribute_kind prop_kind
   15907            0 :               = objc_prop_attr_kind_for_rid (keyword);
   15908            0 :             property_attribute_info *prop
   15909            0 :               = new property_attribute_info (attr_name, attr_comb, prop_kind);
   15910            0 :             prop_attr_list.safe_push (prop);
   15911              : 
   15912            0 :             tree meth_name;
   15913            0 :             switch (prop->prop_kind)
   15914              :               {
   15915              :               default: break;
   15916            0 :               case OBJC_PROPERTY_ATTR_UNKNOWN:
   15917            0 :                 if (attr_name)
   15918            0 :                   error_at (attr_comb, "unknown property attribute %<%s%s%>",
   15919            0 :                             add_at ? "@" : "", IDENTIFIER_POINTER (attr_name));
   15920              :                 else
   15921            0 :                   error_at (attr_comb, "unknown property attribute");
   15922            0 :                 prop->parse_error = syntax_error = true;
   15923            0 :                 break;
   15924              : 
   15925            0 :               case OBJC_PROPERTY_ATTR_GETTER:
   15926            0 :               case OBJC_PROPERTY_ATTR_SETTER:
   15927            0 :                 if (c_parser_next_token_is_not (parser, CPP_EQ))
   15928              :                   {
   15929            0 :                     attr_comb = make_location (attr_end, attr_start, attr_end);
   15930            0 :                     error_at (attr_comb, "expected %<=%> after Objective-C %qE",
   15931              :                               attr_name);
   15932            0 :                     prop->parse_error = syntax_error = true;
   15933            0 :                     break;
   15934              :                   }
   15935            0 :                 token = c_parser_peek_token (parser);
   15936            0 :                 attr_end = token->location;
   15937            0 :                 c_parser_consume_token (parser); /* eat the = */
   15938            0 :                 if (c_parser_next_token_is_not (parser, CPP_NAME))
   15939              :                   {
   15940            0 :                     attr_comb = make_location (attr_end, attr_start, attr_end);
   15941            0 :                     error_at (attr_comb, "expected %qE selector name",
   15942              :                               attr_name);
   15943            0 :                     prop->parse_error = syntax_error = true;
   15944            0 :                     break;
   15945              :                   }
   15946              :                 /* Get the end of the method name, and consume the name.  */
   15947            0 :                 token = c_parser_peek_token (parser);
   15948            0 :                 attr_end = get_finish (token->location);
   15949            0 :                 meth_name = token->value;
   15950            0 :                 c_parser_consume_token (parser);
   15951            0 :                 if (prop->prop_kind == OBJC_PROPERTY_ATTR_SETTER)
   15952              :                   {
   15953            0 :                     if (c_parser_next_token_is_not (parser, CPP_COLON))
   15954              :                       {
   15955            0 :                         attr_comb = make_location (attr_end, attr_start,
   15956              :                                                    attr_end);
   15957            0 :                         error_at (attr_comb, "setter method names must"
   15958              :                                   " terminate with %<:%>");
   15959            0 :                         prop->parse_error = syntax_error = true;
   15960              :                       }
   15961              :                     else
   15962              :                       {
   15963            0 :                         attr_end = get_finish (c_parser_peek_token
   15964            0 :                                                (parser)->location);
   15965            0 :                         c_parser_consume_token (parser);
   15966              :                       }
   15967            0 :                     attr_comb = make_location (attr_start, attr_start,
   15968              :                                                attr_end);
   15969              :                   }
   15970              :                 else
   15971            0 :                   attr_comb = make_location (attr_start, attr_start,
   15972              :                                                attr_end);
   15973            0 :                 prop->ident = meth_name;
   15974              :                 /* Updated location including all that was successfully
   15975              :                    parsed.  */
   15976            0 :                 prop->prop_loc = attr_comb;
   15977            0 :                 break;
   15978              :             }
   15979              : 
   15980              :           /* If we see a comma here, then keep going - even if we already
   15981              :              saw a syntax error.  For simple mistakes e.g. (assign, getter=x)
   15982              :              this makes a more useful output and avoid spurious warnings about
   15983              :              missing attributes that are, in fact, specified after the one with
   15984              :              the syntax error.  */
   15985            0 :           if (c_parser_next_token_is (parser, CPP_COMMA))
   15986            0 :             c_parser_consume_token (parser);
   15987              :           else
   15988              :             break;
   15989              :         }
   15990            0 :       parser->objc_property_attr_context = false;
   15991              : 
   15992            0 :       if (syntax_error && c_parser_next_token_is_not (parser, CPP_CLOSE_PAREN))
   15993              :         /* We don't really want to chew the whole of the file looking for a
   15994              :            matching closing parenthesis, so we will try to read the decl and
   15995              :            let the error handling for that close out the statement.  */
   15996              :         ;
   15997              :       else
   15998            0 :         syntax_error = false, parens.skip_until_found_close (parser);
   15999              :     }
   16000              : 
   16001              :   /* 'properties' is the list of properties that we read.  Usually a
   16002              :      single one, but maybe more (eg, in "@property int a, b, c;" there
   16003              :      are three).  */
   16004            0 :   tree properties = c_parser_struct_declaration (parser, NULL);
   16005              : 
   16006            0 :   if (properties == error_mark_node)
   16007            0 :     c_parser_skip_until_found (parser, CPP_SEMICOLON, NULL);
   16008              :   else
   16009              :     {
   16010            0 :       if (properties == NULL_TREE)
   16011            0 :         c_parser_error (parser, "expected identifier");
   16012              :       else
   16013              :         {
   16014              :           /* Comma-separated properties are chained together in reverse order;
   16015              :              add them one by one.  */
   16016            0 :           properties = nreverse (properties);
   16017            0 :           for (; properties; properties = TREE_CHAIN (properties))
   16018            0 :             objc_add_property_declaration (loc, copy_node (properties),
   16019              :                                             prop_attr_list);
   16020              :         }
   16021            0 :       c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   16022              :     }
   16023              : 
   16024            0 :   while (!prop_attr_list.is_empty())
   16025            0 :     delete prop_attr_list.pop ();
   16026            0 :   prop_attr_list.release ();
   16027            0 :   parser->error = false;
   16028            0 : }
   16029              : 
   16030              : /* Parse an Objective-C @synthesize declaration.  The syntax is:
   16031              : 
   16032              :    objc-synthesize-declaration:
   16033              :      @synthesize objc-synthesize-identifier-list ;
   16034              : 
   16035              :    objc-synthesize-identifier-list:
   16036              :      objc-synthesize-identifier
   16037              :      objc-synthesize-identifier-list, objc-synthesize-identifier
   16038              : 
   16039              :    objc-synthesize-identifier
   16040              :      identifier
   16041              :      identifier = identifier
   16042              : 
   16043              :   For example:
   16044              :     @synthesize MyProperty;
   16045              :     @synthesize OneProperty, AnotherProperty=MyIvar, YetAnotherProperty;
   16046              : 
   16047              :   PS: This function is identical to cp_parser_objc_at_synthesize_declaration
   16048              :   for C++.  Keep them in sync.
   16049              : */
   16050              : static void
   16051            0 : c_parser_objc_at_synthesize_declaration (c_parser *parser)
   16052              : {
   16053            0 :   tree list = NULL_TREE;
   16054            0 :   location_t loc;
   16055            0 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_SYNTHESIZE));
   16056            0 :   loc = c_parser_peek_token (parser)->location;
   16057              : 
   16058            0 :   c_parser_consume_token (parser);
   16059            0 :   while (true)
   16060              :     {
   16061            0 :       tree property, ivar;
   16062            0 :       if (c_parser_next_token_is_not (parser, CPP_NAME))
   16063              :         {
   16064            0 :           c_parser_error (parser, "expected identifier");
   16065            0 :           c_parser_skip_until_found (parser, CPP_SEMICOLON, NULL);
   16066              :           /* Once we find the semicolon, we can resume normal parsing.
   16067              :              We have to reset parser->error manually because
   16068              :              c_parser_skip_until_found() won't reset it for us if the
   16069              :              next token is precisely a semicolon.  */
   16070            0 :           parser->error = false;
   16071            0 :           return;
   16072              :         }
   16073            0 :       property = c_parser_peek_token (parser)->value;
   16074            0 :       c_parser_consume_token (parser);
   16075            0 :       if (c_parser_next_token_is (parser, CPP_EQ))
   16076              :         {
   16077            0 :           c_parser_consume_token (parser);
   16078            0 :           if (c_parser_next_token_is_not (parser, CPP_NAME))
   16079              :             {
   16080            0 :               c_parser_error (parser, "expected identifier");
   16081            0 :               c_parser_skip_until_found (parser, CPP_SEMICOLON, NULL);
   16082            0 :               parser->error = false;
   16083            0 :               return;
   16084              :             }
   16085            0 :           ivar = c_parser_peek_token (parser)->value;
   16086            0 :           c_parser_consume_token (parser);
   16087              :         }
   16088              :       else
   16089              :         ivar = NULL_TREE;
   16090            0 :       list = chainon (list, build_tree_list (ivar, property));
   16091            0 :       if (c_parser_next_token_is (parser, CPP_COMMA))
   16092            0 :         c_parser_consume_token (parser);
   16093              :       else
   16094              :         break;
   16095            0 :     }
   16096            0 :   c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   16097            0 :   objc_add_synthesize_declaration (loc, list);
   16098              : }
   16099              : 
   16100              : /* Parse an Objective-C @dynamic declaration.  The syntax is:
   16101              : 
   16102              :    objc-dynamic-declaration:
   16103              :      @dynamic identifier-list ;
   16104              : 
   16105              :    For example:
   16106              :      @dynamic MyProperty;
   16107              :      @dynamic MyProperty, AnotherProperty;
   16108              : 
   16109              :   PS: This function is identical to cp_parser_objc_at_dynamic_declaration
   16110              :   for C++.  Keep them in sync.
   16111              : */
   16112              : static void
   16113            0 : c_parser_objc_at_dynamic_declaration (c_parser *parser)
   16114              : {
   16115            0 :   tree list = NULL_TREE;
   16116            0 :   location_t loc;
   16117            0 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_DYNAMIC));
   16118            0 :   loc = c_parser_peek_token (parser)->location;
   16119              : 
   16120            0 :   c_parser_consume_token (parser);
   16121            0 :   while (true)
   16122              :     {
   16123            0 :       tree property;
   16124            0 :       if (c_parser_next_token_is_not (parser, CPP_NAME))
   16125              :         {
   16126            0 :           c_parser_error (parser, "expected identifier");
   16127            0 :           c_parser_skip_until_found (parser, CPP_SEMICOLON, NULL);
   16128            0 :           parser->error = false;
   16129            0 :           return;
   16130              :         }
   16131            0 :       property = c_parser_peek_token (parser)->value;
   16132            0 :       list = chainon (list, build_tree_list (NULL_TREE, property));
   16133            0 :       c_parser_consume_token (parser);
   16134            0 :       if (c_parser_next_token_is (parser, CPP_COMMA))
   16135            0 :         c_parser_consume_token (parser);
   16136              :       else
   16137              :         break;
   16138            0 :     }
   16139            0 :   c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   16140            0 :   objc_add_dynamic_declaration (loc, list);
   16141              : }
   16142              : 
   16143              : 
   16144              : /* Parse a pragma GCC ivdep.  */
   16145              : 
   16146              : static bool
   16147          128 : c_parse_pragma_ivdep (c_parser *parser)
   16148              : {
   16149            0 :   c_parser_consume_pragma (parser);
   16150            0 :   c_parser_skip_to_pragma_eol (parser);
   16151          128 :   return true;
   16152              : }
   16153              : 
   16154              : /* Parse a pragma GCC novector.  */
   16155              : 
   16156              : static bool
   16157         3056 : c_parse_pragma_novector (c_parser *parser)
   16158              : {
   16159            0 :   c_parser_consume_pragma (parser);
   16160            0 :   c_parser_skip_to_pragma_eol (parser);
   16161         3056 :   return true;
   16162              : }
   16163              : 
   16164              : /* Parse a pragma GCC unroll.  */
   16165              : 
   16166              : static unsigned short
   16167          298 : c_parser_pragma_unroll (c_parser *parser)
   16168              : {
   16169          298 :   unsigned short unroll;
   16170          298 :   c_parser_consume_pragma (parser);
   16171          298 :   location_t location = c_parser_peek_token (parser)->location;
   16172          298 :   tree expr = c_parser_expr_no_commas (parser, NULL).value;
   16173          298 :   mark_exp_read (expr);
   16174          298 :   expr = c_fully_fold (expr, false, NULL);
   16175          298 :   HOST_WIDE_INT lunroll = 0;
   16176          596 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (expr))
   16177          297 :       || TREE_CODE (expr) != INTEGER_CST
   16178          296 :       || (lunroll = tree_to_shwi (expr)) < 0
   16179          593 :       || lunroll >= USHRT_MAX)
   16180              :     {
   16181            4 :       error_at (location, "%<#pragma GCC unroll%> requires an"
   16182              :                 " assignment-expression that evaluates to a non-negative"
   16183              :                 " integral constant less than %u", USHRT_MAX);
   16184            4 :       unroll = 0;
   16185              :     }
   16186              :   else
   16187              :     {
   16188          294 :       unroll = (unsigned short)lunroll;
   16189          294 :       if (unroll == 0)
   16190              :         unroll = 1;
   16191              :     }
   16192              : 
   16193          298 :   c_parser_skip_to_pragma_eol (parser);
   16194          298 :   return unroll;
   16195              : }
   16196              : 
   16197              : /* Handle pragmas.  Some OpenMP pragmas are associated with, and therefore
   16198              :    should be considered, statements.  ALLOW_STMT is true if we're within
   16199              :    the context of a function and such pragmas are to be allowed.  Returns
   16200              :    true if we actually parsed such a pragma.  BEFORE_LABELS is last statement
   16201              :    before possible labels, see get_before_labels description for details.  */
   16202              : 
   16203              : static bool
   16204      1981521 : c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p,
   16205              :                  tree before_labels)
   16206              : {
   16207      1981521 :   unsigned int id;
   16208      1981521 :   const char *construct = NULL;
   16209              : 
   16210      1981521 :   input_location = c_parser_peek_token (parser)->location;
   16211      1981521 :   id = c_parser_peek_token (parser)->pragma_kind;
   16212      1981521 :   gcc_assert (id != PRAGMA_NONE);
   16213      1981521 :   if (parser->omp_for_parse_state
   16214           16 :       && parser->omp_for_parse_state->in_intervening_code
   16215           13 :       && id >= PRAGMA_OMP__START_ && id <= PRAGMA_OMP__LAST_
   16216              :       /* Allow a safe subset of non-executable directives. See classification in
   16217              :          array c_omp_directives.  */
   16218            7 :       && id != PRAGMA_OMP_METADIRECTIVE && id != PRAGMA_OMP_NOTHING
   16219            5 :       && id != PRAGMA_OMP_ASSUME && id != PRAGMA_OMP_ERROR)
   16220              :     {
   16221            2 :       error_at (
   16222              :         input_location,
   16223              :         "intervening code must not contain executable OpenMP directives");
   16224            2 :       parser->omp_for_parse_state->fail = true;
   16225            2 :       c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
   16226            2 :       return false;
   16227              :     }
   16228              : 
   16229      1981519 :   switch (id)
   16230              :     {
   16231          144 :     case PRAGMA_OACC_DECLARE:
   16232          144 :       c_parser_oacc_declare (parser);
   16233          144 :       return false;
   16234              : 
   16235          136 :     case PRAGMA_OACC_ENTER_DATA:
   16236          136 :       if (context != pragma_compound)
   16237              :         {
   16238              :           construct = "acc enter data";
   16239           62 :         in_compound:
   16240           62 :           if (context == pragma_stmt)
   16241              :             {
   16242           59 :               error_at (c_parser_peek_token (parser)->location,
   16243              :                         "%<#pragma %s%> may only be used in compound "
   16244              :                         "statements", construct);
   16245           59 :               c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
   16246           59 :               return true;
   16247              :             }
   16248            3 :           goto bad_stmt;
   16249              :         }
   16250          133 :       c_parser_oacc_enter_exit_data (parser, true);
   16251          133 :       return false;
   16252              : 
   16253          131 :     case PRAGMA_OACC_EXIT_DATA:
   16254          131 :       if (context != pragma_compound)
   16255              :         {
   16256            3 :           construct = "acc exit data";
   16257            3 :           goto in_compound;
   16258              :         }
   16259          128 :       c_parser_oacc_enter_exit_data (parser, false);
   16260          128 :       return false;
   16261              : 
   16262          350 :     case PRAGMA_OACC_ROUTINE:
   16263          350 :       if (context != pragma_external)
   16264              :         {
   16265            5 :           error_at (c_parser_peek_token (parser)->location,
   16266              :                     "%<#pragma acc routine%> must be at file scope");
   16267            5 :           c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
   16268            5 :           return false;
   16269              :         }
   16270          345 :       c_parser_oacc_routine (parser, context);
   16271          345 :       return false;
   16272              : 
   16273          100 :     case PRAGMA_OACC_UPDATE:
   16274          100 :       if (context != pragma_compound)
   16275              :         {
   16276            8 :           construct = "acc update";
   16277            8 :           goto in_compound;
   16278              :         }
   16279           92 :       c_parser_oacc_update (parser);
   16280           92 :       return false;
   16281              : 
   16282          373 :     case PRAGMA_OMP_BARRIER:
   16283          373 :       if (context != pragma_compound)
   16284              :         {
   16285           11 :           construct = "omp barrier";
   16286           11 :           goto in_compound;
   16287              :         }
   16288          362 :       c_parser_omp_barrier (parser);
   16289          362 :       return false;
   16290              : 
   16291           76 :     case PRAGMA_OMP_DEPOBJ:
   16292           76 :       if (context != pragma_compound)
   16293              :         {
   16294            1 :           construct = "omp depobj";
   16295            1 :           goto in_compound;
   16296              :         }
   16297           75 :       c_parser_omp_depobj (parser);
   16298           75 :       return false;
   16299              : 
   16300           68 :     case PRAGMA_OMP_FLUSH:
   16301           68 :       if (context != pragma_compound)
   16302              :         {
   16303            9 :           construct = "omp flush";
   16304            9 :           goto in_compound;
   16305              :         }
   16306           59 :       c_parser_omp_flush (parser);
   16307           59 :       return false;
   16308              : 
   16309          183 :     case PRAGMA_OMP_INTEROP:
   16310          183 :       if (context != pragma_compound)
   16311              :         {
   16312            0 :           construct = "omp interop";
   16313            0 :           goto in_compound;
   16314              :         }
   16315          183 :       c_parser_omp_interop (parser);
   16316          183 :       return false;
   16317              : 
   16318          103 :     case PRAGMA_OMP_TASKWAIT:
   16319          103 :       if (context != pragma_compound)
   16320              :         {
   16321            8 :           construct = "omp taskwait";
   16322            8 :           goto in_compound;
   16323              :         }
   16324           95 :       c_parser_omp_taskwait (parser);
   16325           95 :       return false;
   16326              : 
   16327           14 :     case PRAGMA_OMP_TASKYIELD:
   16328           14 :       if (context != pragma_compound)
   16329              :         {
   16330            8 :           construct = "omp taskyield";
   16331            8 :           goto in_compound;
   16332              :         }
   16333            6 :       c_parser_omp_taskyield (parser);
   16334            6 :       return false;
   16335              : 
   16336          229 :     case PRAGMA_OMP_CANCEL:
   16337          229 :       if (context != pragma_compound)
   16338              :         {
   16339            8 :           construct = "omp cancel";
   16340            8 :           goto in_compound;
   16341              :         }
   16342          221 :       c_parser_omp_cancel (parser);
   16343          221 :       return false;
   16344              : 
   16345          179 :     case PRAGMA_OMP_CANCELLATION_POINT:
   16346          179 :       return c_parser_omp_cancellation_point (parser, context);
   16347              : 
   16348            9 :     case PRAGMA_OMP_GROUPPRIVATE:
   16349            9 :       c_parser_omp_groupprivate (parser);
   16350            9 :       return false;
   16351              : 
   16352           79 :     case PRAGMA_OMP_THREADPRIVATE:
   16353           79 :       c_parser_omp_threadprivate (parser);
   16354           79 :       return false;
   16355              : 
   16356         8376 :     case PRAGMA_OMP_TARGET:
   16357         8376 :       return c_parser_omp_target (parser, context, if_p);
   16358              : 
   16359          141 :     case PRAGMA_OMP_BEGIN:
   16360          141 :       c_parser_omp_begin (parser);
   16361          141 :       return false;
   16362              : 
   16363          235 :     case PRAGMA_OMP_END:
   16364          235 :       c_parser_omp_end (parser);
   16365          235 :       return false;
   16366              : 
   16367           22 :     case PRAGMA_OMP_SCAN:
   16368           22 :       error_at (c_parser_peek_token (parser)->location,
   16369              :                 "%<#pragma omp scan%> may only be used in "
   16370              :                 "a loop construct with %<inscan%> %<reduction%> clause");
   16371           22 :       c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
   16372           22 :       return false;
   16373              : 
   16374            5 :     case PRAGMA_OMP_SECTION:
   16375            5 :       error_at (c_parser_peek_token (parser)->location,
   16376              :                 "%<#pragma omp section%> may only be used in "
   16377              :                 "%<#pragma omp sections%> construct");
   16378            5 :       c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
   16379            5 :       return false;
   16380              : 
   16381         1359 :     case PRAGMA_OMP_DECLARE:
   16382         1359 :       return c_parser_omp_declare (parser, context);
   16383              : 
   16384           72 :     case PRAGMA_OMP_REQUIRES:
   16385           72 :       if (context != pragma_external)
   16386              :         {
   16387            8 :           error_at (c_parser_peek_token (parser)->location,
   16388              :                     "%<#pragma %s%> may only be used at file scope",
   16389              :                     "omp requires");
   16390            8 :           c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
   16391            8 :           return false;
   16392              :         }
   16393           64 :       c_parser_omp_requires (parser);
   16394           64 :       return false;
   16395              : 
   16396          118 :     case PRAGMA_OMP_ALLOCATE:
   16397          118 :       c_parser_omp_allocate (parser);
   16398          118 :       return false;
   16399              : 
   16400           39 :     case PRAGMA_OMP_ASSUMES:
   16401           39 :       if (context != pragma_external)
   16402              :         {
   16403            1 :           error_at (c_parser_peek_token (parser)->location,
   16404              :                     "%<#pragma %s%> may only be used at file scope",
   16405              :                     "omp assumes");
   16406            1 :           c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
   16407            1 :           return false;
   16408              :         }
   16409           38 :       c_parser_omp_assumes (parser);
   16410           38 :       return false;
   16411              : 
   16412           79 :     case PRAGMA_OMP_NOTHING:
   16413           79 :       c_parser_omp_nothing (parser);
   16414           79 :       return false;
   16415              : 
   16416          110 :     case PRAGMA_OMP_METADIRECTIVE:
   16417          110 :       c_parser_omp_metadirective (parser, if_p);
   16418          110 :       return true;
   16419              : 
   16420          126 :     case PRAGMA_OMP_ERROR:
   16421          126 :       return c_parser_omp_error (parser, context);
   16422              : 
   16423          545 :     case PRAGMA_OMP_ORDERED:
   16424          545 :       return c_parser_omp_ordered (parser, context, if_p);
   16425              : 
   16426         3465 :     case PRAGMA_NOVECTOR:
   16427         3465 :     case PRAGMA_UNROLL:
   16428         3465 :     case PRAGMA_IVDEP:
   16429         3465 :       {
   16430         3465 :         bool novector = false;
   16431         3465 :         unsigned short unroll = 0;
   16432         3465 :         bool ivdep = false;
   16433              : 
   16434         3465 :         switch (id)
   16435              :           {
   16436         3052 :           case PRAGMA_NOVECTOR:
   16437         3052 :             novector = c_parse_pragma_novector (parser);
   16438         3052 :             break;
   16439          288 :           case PRAGMA_UNROLL:
   16440          288 :             unroll = c_parser_pragma_unroll (parser);
   16441          288 :             break;
   16442          125 :           case PRAGMA_IVDEP:
   16443          125 :             ivdep = c_parse_pragma_ivdep (parser);
   16444          125 :             break;
   16445              :           default:
   16446              :             gcc_unreachable ();
   16447              :           }
   16448              : 
   16449         3465 :         c_token *tok = c_parser_peek_token (parser);
   16450         3465 :         bool has_more = tok->type == CPP_PRAGMA;
   16451         3482 :         while (has_more)
   16452              :           {
   16453           17 :             switch (tok->pragma_kind)
   16454              :               {
   16455            3 :               case PRAGMA_IVDEP:
   16456            3 :                 ivdep = c_parse_pragma_ivdep (parser);
   16457            3 :                 break;
   16458           10 :               case PRAGMA_UNROLL:
   16459           10 :                 unroll = c_parser_pragma_unroll (parser);
   16460           10 :                 break;
   16461            4 :               case PRAGMA_NOVECTOR:
   16462            4 :                 novector = c_parse_pragma_novector (parser);
   16463            4 :                 break;
   16464              :               default:
   16465              :                 has_more = false;
   16466              :                 break;
   16467              :               }
   16468           17 :             tok = c_parser_peek_token (parser);
   16469           28 :             has_more = has_more && tok->type == CPP_PRAGMA;
   16470              :           }
   16471         3465 :         if (!c_parser_next_token_is_keyword (parser, RID_FOR)
   16472           74 :             && !c_parser_next_token_is_keyword (parser, RID_WHILE)
   16473         3524 :             && !c_parser_next_token_is_keyword (parser, RID_DO))
   16474              :           {
   16475            0 :             c_parser_error (parser, "for, while or do statement expected");
   16476            0 :             return false;
   16477              :           }
   16478         3465 :         if (c_parser_next_token_is_keyword (parser, RID_FOR))
   16479         3391 :           c_parser_for_statement (parser, ivdep, unroll, novector, if_p,
   16480              :                                   before_labels);
   16481           74 :         else if (c_parser_next_token_is_keyword (parser, RID_WHILE))
   16482           15 :           c_parser_while_statement (parser, ivdep, unroll, novector, if_p,
   16483              :                                     before_labels);
   16484              :         else
   16485           59 :           c_parser_do_statement (parser, ivdep, unroll, novector,
   16486              :                                  before_labels);
   16487              :       }
   16488              :       return true;
   16489              : 
   16490            1 :     case PRAGMA_GCC_PCH_PREPROCESS:
   16491            1 :       c_parser_error (parser, "%<#pragma GCC pch_preprocess%> must be first");
   16492            1 :       c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
   16493            1 :       return false;
   16494              : 
   16495           89 :     case PRAGMA_OACC_WAIT:
   16496           89 :       if (context != pragma_compound)
   16497              :         {
   16498            3 :           construct = "acc wait";
   16499            3 :           goto in_compound;
   16500              :         }
   16501              :         /* FALL THROUGH.  */
   16502              : 
   16503      1964649 :     default:
   16504      1964649 :       if (id < PRAGMA_FIRST_EXTERNAL)
   16505              :         {
   16506        17654 :           if (context != pragma_stmt && context != pragma_compound)
   16507              :             {
   16508            2 :             bad_stmt:
   16509            5 :               c_parser_error (parser, "expected declaration specifiers");
   16510            5 :               c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
   16511            5 :               return false;
   16512              :             }
   16513        17652 :           c_parser_omp_construct (parser, if_p);
   16514        17652 :           return true;
   16515              :         }
   16516      1946995 :       break;
   16517              :     }
   16518              : 
   16519      1946995 :   c_parser_consume_pragma (parser);
   16520      1946995 :   c_invoke_pragma_handler (id);
   16521              : 
   16522              :   /* Skip to EOL, but suppress any error message.  Those will have been
   16523              :      generated by the handler routine through calling error, as opposed
   16524              :      to calling c_parser_error.  */
   16525      1946995 :   parser->error = true;
   16526      1946995 :   c_parser_skip_to_pragma_eol (parser);
   16527              : 
   16528      1946995 :   return false;
   16529              : }
   16530              : 
   16531              : /* The interface the pragma parsers have to the lexer.  */
   16532              : 
   16533              : enum cpp_ttype
   16534      3684034 : pragma_lex (tree *value, location_t *loc)
   16535              : {
   16536      3684034 :   c_token *tok = c_parser_peek_token (the_parser);
   16537      3684034 :   enum cpp_ttype ret = tok->type;
   16538              : 
   16539      3684034 :   *value = tok->value;
   16540      3684034 :   if (loc)
   16541      1538881 :     *loc = tok->location;
   16542              : 
   16543      3684034 :   if (ret == CPP_PRAGMA_EOL || ret == CPP_EOF)
   16544              :     ret = CPP_EOF;
   16545      2078444 :   else if (ret == CPP_STRING)
   16546       652299 :     *value = c_parser_string_literal (the_parser, false, false).value;
   16547              :   else
   16548              :     {
   16549      1426145 :       if (ret == CPP_KEYWORD)
   16550          366 :         ret = CPP_NAME;
   16551      1426145 :       c_parser_consume_token (the_parser);
   16552              :     }
   16553              : 
   16554      3684034 :   return ret;
   16555              : }
   16556              : 
   16557              : void
   16558        11056 : pragma_lex_discard_to_eol ()
   16559              : {
   16560        11056 :   cpp_ttype type;
   16561        11056 :   do
   16562              :     {
   16563        11056 :       type = c_parser_peek_token (the_parser)->type;
   16564        11056 :       gcc_assert (type != CPP_EOF);
   16565        11056 :       c_parser_consume_token (the_parser);
   16566        11056 :     } while (type != CPP_PRAGMA_EOL);
   16567        11056 : }
   16568              : 
   16569              : static void
   16570           12 : c_parser_pragma_pch_preprocess (c_parser *parser)
   16571              : {
   16572           12 :   tree name = NULL;
   16573              : 
   16574           12 :   parser->lex_joined_string = true;
   16575           12 :   c_parser_consume_pragma (parser);
   16576           12 :   if (c_parser_next_token_is (parser, CPP_STRING))
   16577              :     {
   16578           12 :       name = c_parser_peek_token (parser)->value;
   16579           12 :       c_parser_consume_token (parser);
   16580              :     }
   16581              :   else
   16582            0 :     c_parser_error (parser, "expected string literal");
   16583           12 :   c_parser_skip_to_pragma_eol (parser);
   16584           12 :   parser->lex_joined_string = false;
   16585              : 
   16586           12 :   if (name)
   16587           12 :     c_common_pch_pragma (parse_in, TREE_STRING_POINTER (name));
   16588           12 : }
   16589              : 
   16590              : /* OpenACC and OpenMP parsing routines.  */
   16591              : 
   16592              : /* Returns name of the next clause.
   16593              :    If the clause is not recognized PRAGMA_OMP_CLAUSE_NONE is returned and
   16594              :    the token is not consumed.  Otherwise appropriate pragma_omp_clause is
   16595              :    returned and the token is consumed.  */
   16596              : 
   16597              : static pragma_omp_clause
   16598        36077 : c_parser_omp_clause_name (c_parser *parser)
   16599              : {
   16600        36077 :   pragma_omp_clause result = PRAGMA_OMP_CLAUSE_NONE;
   16601              : 
   16602        36077 :   if (c_parser_next_token_is_keyword (parser, RID_AUTO))
   16603              :     result = PRAGMA_OACC_CLAUSE_AUTO;
   16604        35952 :   else if (c_parser_next_token_is_keyword (parser, RID_IF))
   16605              :     result = PRAGMA_OMP_CLAUSE_IF;
   16606        35059 :   else if (c_parser_next_token_is_keyword (parser, RID_DEFAULT))
   16607              :     result = PRAGMA_OMP_CLAUSE_DEFAULT;
   16608        34330 :   else if (c_parser_next_token_is_keyword (parser, RID_FOR))
   16609              :     result = PRAGMA_OMP_CLAUSE_FOR;
   16610        34246 :   else if (c_parser_next_token_is (parser, CPP_NAME))
   16611              :     {
   16612        34160 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   16613              : 
   16614        34160 :       switch (p[0])
   16615              :         {
   16616         1134 :         case 'a':
   16617         1134 :           if (!strcmp ("affinity", p))
   16618              :             result = PRAGMA_OMP_CLAUSE_AFFINITY;
   16619          983 :           else if (!strcmp ("aligned", p))
   16620              :             result = PRAGMA_OMP_CLAUSE_ALIGNED;
   16621          755 :           else if (!strcmp ("allocate", p))
   16622              :             result = PRAGMA_OMP_CLAUSE_ALLOCATE;
   16623          270 :           else if (!strcmp ("async", p))
   16624              :             result = PRAGMA_OACC_CLAUSE_ASYNC;
   16625           30 :           else if (!strcmp ("attach", p))
   16626        36077 :             result = PRAGMA_OACC_CLAUSE_ATTACH;
   16627              :           break;
   16628          124 :         case 'b':
   16629          124 :           if (!strcmp ("bind", p))
   16630        36077 :             result = PRAGMA_OMP_CLAUSE_BIND;
   16631              :           break;
   16632         5041 :         case 'c':
   16633         5041 :           if (!strcmp ("collapse", p))
   16634              :             result = PRAGMA_OMP_CLAUSE_COLLAPSE;
   16635         1642 :           else if (!strcmp ("copy", p))
   16636              :             result = PRAGMA_OACC_CLAUSE_COPY;
   16637          858 :           else if (!strcmp ("copyin", p))
   16638              :             result = PRAGMA_OMP_CLAUSE_COPYIN;
   16639          422 :           else if (!strcmp ("copyout", p))
   16640              :             result = PRAGMA_OACC_CLAUSE_COPYOUT;
   16641           99 :           else if (!strcmp ("copyprivate", p))
   16642              :             result = PRAGMA_OMP_CLAUSE_COPYPRIVATE;
   16643           75 :           else if (!strcmp ("create", p))
   16644        36077 :             result = PRAGMA_OACC_CLAUSE_CREATE;
   16645              :           break;
   16646         3572 :         case 'd':
   16647         3572 :           if (!strcmp ("defaultmap", p))
   16648              :             result = PRAGMA_OMP_CLAUSE_DEFAULTMAP;
   16649         3331 :           else if (!strcmp ("delete", p))
   16650              :             result = PRAGMA_OACC_CLAUSE_DELETE;
   16651         3263 :           else if (!strcmp ("depend", p))
   16652              :             result = PRAGMA_OMP_CLAUSE_DEPEND;
   16653         2406 :           else if (!strcmp ("destroy", p))
   16654              :             result = PRAGMA_OMP_CLAUSE_DESTROY;
   16655         2365 :           else if (!strcmp ("detach", p))
   16656              :             result = PRAGMA_OACC_CLAUSE_DETACH;
   16657         2311 :           else if (!strcmp ("device", p))
   16658              :             result = PRAGMA_OMP_CLAUSE_DEVICE;
   16659         1887 :           else if (!strcmp ("deviceptr", p))
   16660              :             result = PRAGMA_OACC_CLAUSE_DEVICEPTR;
   16661         1830 :           else if (!strcmp ("device_resident", p))
   16662              :             result = PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT;
   16663         1814 :           else if (!strcmp ("device_type", p))
   16664              :             result = PRAGMA_OMP_CLAUSE_DEVICE_TYPE;
   16665         1761 :           else if (!strcmp ("dist_schedule", p))
   16666              :             result = PRAGMA_OMP_CLAUSE_DIST_SCHEDULE;
   16667          167 :           else if (!strcmp ("doacross", p))
   16668              :             result = PRAGMA_OMP_CLAUSE_DOACROSS;
   16669           22 :           else if (!strcmp ("dyn_groupprivate", p))
   16670        36077 :             result = PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE;
   16671              :           break;
   16672           63 :         case 'e':
   16673           63 :           if (!strcmp ("enter", p))
   16674        36077 :             result = PRAGMA_OMP_CLAUSE_ENTER;
   16675              :           break;
   16676         3657 :         case 'f':
   16677         3657 :           if (!strcmp ("filter", p))
   16678              :             result = PRAGMA_OMP_CLAUSE_FILTER;
   16679         3594 :           else if (!strcmp ("final", p))
   16680              :             result = PRAGMA_OMP_CLAUSE_FINAL;
   16681         3495 :           else if (!strcmp ("finalize", p))
   16682              :             result = PRAGMA_OACC_CLAUSE_FINALIZE;
   16683         3483 :           else if (!strcmp ("firstprivate", p))
   16684              :             result = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE;
   16685         2607 :           else if (!strcmp ("from", p))
   16686              :             result = PRAGMA_OMP_CLAUSE_FROM;
   16687           73 :           else if (!strcmp ("full", p))
   16688        36077 :             result = PRAGMA_OMP_CLAUSE_FULL;
   16689              :           break;
   16690          651 :         case 'g':
   16691          651 :           if (!strcmp ("gang", p))
   16692              :             result = PRAGMA_OACC_CLAUSE_GANG;
   16693           62 :           else if (!strcmp ("grainsize", p))
   16694        36077 :             result = PRAGMA_OMP_CLAUSE_GRAINSIZE;
   16695              :           break;
   16696          158 :         case 'h':
   16697          158 :           if (!strcmp ("has_device_addr", p))
   16698              :             result = PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR;
   16699           70 :           else if (!strcmp ("hint", p))
   16700              :             result = PRAGMA_OMP_CLAUSE_HINT;
   16701           41 :           else if (!strcmp ("host", p))
   16702        36077 :             result = PRAGMA_OACC_CLAUSE_HOST;
   16703              :           break;
   16704          819 :         case 'i':
   16705          819 :           if (!strcmp ("if_present", p))
   16706              :             result = PRAGMA_OACC_CLAUSE_IF_PRESENT;
   16707          800 :           else if (!strcmp ("in_reduction", p))
   16708              :             result = PRAGMA_OMP_CLAUSE_IN_REDUCTION;
   16709          478 :           else if (!strcmp ("inbranch", p))
   16710              :             result = PRAGMA_OMP_CLAUSE_INBRANCH;
   16711          396 :           else if (!strcmp ("independent", p))
   16712              :             result = PRAGMA_OACC_CLAUSE_INDEPENDENT;
   16713          351 :           else if (!strcmp ("indirect", p))
   16714              :             result = PRAGMA_OMP_CLAUSE_INDIRECT;
   16715          325 :           else if (!strcmp ("init", p))
   16716              :             result = PRAGMA_OMP_CLAUSE_INIT;
   16717          158 :           else if (!strcmp ("is_device_ptr", p))
   16718              :             result = PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR;
   16719           43 :           else if (!strcmp ("interop", p))
   16720        36077 :             result = PRAGMA_OMP_CLAUSE_INTEROP;
   16721              :           break;
   16722         1308 :         case 'l':
   16723         1308 :           if (!strcmp ("lastprivate", p))
   16724              :             result = PRAGMA_OMP_CLAUSE_LASTPRIVATE;
   16725          540 :           else if (!strcmp ("linear", p))
   16726              :             result = PRAGMA_OMP_CLAUSE_LINEAR;
   16727           59 :           else if (!strcmp ("link", p))
   16728              :             result = PRAGMA_OMP_CLAUSE_LINK;
   16729           12 :           else if (!strcmp ("local", p))
   16730        36077 :             result = PRAGMA_OMP_CLAUSE_LOCAL;
   16731              :           break;
   16732         2399 :         case 'm':
   16733         2399 :           if (!strcmp ("map", p))
   16734              :             result = PRAGMA_OMP_CLAUSE_MAP;
   16735           79 :           else if (!strcmp ("mergeable", p))
   16736        36077 :             result = PRAGMA_OMP_CLAUSE_MERGEABLE;
   16737              :           break;
   16738         1989 :         case 'n':
   16739         1989 :           if (!strcmp ("no_create", p))
   16740              :             result = PRAGMA_OACC_CLAUSE_NO_CREATE;
   16741         1979 :           else if (!strcmp ("nocontext", p))
   16742              :             result = PRAGMA_OMP_CLAUSE_NOCONTEXT;
   16743         1956 :           else if (!strcmp ("nogroup", p))
   16744              :             result = PRAGMA_OMP_CLAUSE_NOGROUP;
   16745         1938 :           else if (!strcmp ("nohost", p))
   16746              :             result = PRAGMA_OACC_CLAUSE_NOHOST;
   16747         1913 :           else if (!strcmp ("nontemporal", p))
   16748              :             result = PRAGMA_OMP_CLAUSE_NONTEMPORAL;
   16749         1792 :           else if (!strcmp ("notinbranch", p))
   16750              :             result = PRAGMA_OMP_CLAUSE_NOTINBRANCH;
   16751         1651 :           else if (!strcmp ("novariants", p))
   16752              :             result = PRAGMA_OMP_CLAUSE_NOVARIANTS;
   16753         1627 :           else if (!strcmp ("nowait", p))
   16754              :             result = PRAGMA_OMP_CLAUSE_NOWAIT;
   16755         1232 :           else if (!strcmp ("num_gangs", p))
   16756              :             result = PRAGMA_OACC_CLAUSE_NUM_GANGS;
   16757          930 :           else if (!strcmp ("num_tasks", p))
   16758              :             result = PRAGMA_OMP_CLAUSE_NUM_TASKS;
   16759          880 :           else if (!strcmp ("num_teams", p))
   16760              :             result = PRAGMA_OMP_CLAUSE_NUM_TEAMS;
   16761          674 :           else if (!strcmp ("num_threads", p))
   16762              :             result = PRAGMA_OMP_CLAUSE_NUM_THREADS;
   16763          207 :           else if (!strcmp ("num_workers", p))
   16764        36077 :             result = PRAGMA_OACC_CLAUSE_NUM_WORKERS;
   16765              :           break;
   16766          692 :         case 'o':
   16767          692 :           if (!strcmp ("ordered", p))
   16768              :             result = PRAGMA_OMP_CLAUSE_ORDERED;
   16769          382 :           else if (!strcmp ("order", p))
   16770        36077 :             result = PRAGMA_OMP_CLAUSE_ORDER;
   16771              :           break;
   16772         1676 :         case 'p':
   16773         1676 :           if (!strcmp ("parallel", p))
   16774              :             result = PRAGMA_OMP_CLAUSE_PARALLEL;
   16775         1561 :           else if (!strcmp ("partial", p))
   16776              :             result = PRAGMA_OMP_CLAUSE_PARTIAL;
   16777         1331 :           else if (!strcmp ("present", p))
   16778              :             result = PRAGMA_OACC_CLAUSE_PRESENT;
   16779              :           /* As of OpenACC 2.5, these are now aliases of the non-present_or
   16780              :              clauses.  */
   16781         1203 :           else if (!strcmp ("present_or_copy", p)
   16782         1190 :                    || !strcmp ("pcopy", p))
   16783              :             result = PRAGMA_OACC_CLAUSE_COPY;
   16784         1181 :           else if (!strcmp ("present_or_copyin", p)
   16785         1165 :                    || !strcmp ("pcopyin", p))
   16786              :             result = PRAGMA_OACC_CLAUSE_COPYIN;
   16787         1156 :           else if (!strcmp ("present_or_copyout", p)
   16788         1103 :                    || !strcmp ("pcopyout", p))
   16789              :             result = PRAGMA_OACC_CLAUSE_COPYOUT;
   16790         1089 :           else if (!strcmp ("present_or_create", p)
   16791         1075 :                    || !strcmp ("pcreate", p))
   16792              :             result = PRAGMA_OACC_CLAUSE_CREATE;
   16793         1070 :           else if (!strcmp ("priority", p))
   16794              :             result = PRAGMA_OMP_CLAUSE_PRIORITY;
   16795          972 :           else if (!strcmp ("private", p))
   16796              :             result = PRAGMA_OMP_CLAUSE_PRIVATE;
   16797          205 :           else if (!strcmp ("proc_bind", p))
   16798        36077 :             result = PRAGMA_OMP_CLAUSE_PROC_BIND;
   16799              :           break;
   16800         2819 :         case 'r':
   16801         2819 :           if (!strcmp ("reduction", p))
   16802        36077 :             result = PRAGMA_OMP_CLAUSE_REDUCTION;
   16803              :           break;
   16804         5295 :         case 's':
   16805         5295 :           if (!strcmp ("safelen", p))
   16806              :             result = PRAGMA_OMP_CLAUSE_SAFELEN;
   16807         5028 :           else if (!strcmp ("schedule", p))
   16808              :             result = PRAGMA_OMP_CLAUSE_SCHEDULE;
   16809         1541 :           else if (!strcmp ("sections", p))
   16810              :             result = PRAGMA_OMP_CLAUSE_SECTIONS;
   16811         1463 :           else if (!strcmp ("self", p))
   16812              :             result = PRAGMA_OACC_CLAUSE_SELF;
   16813         1397 :           else if (!strcmp ("seq", p))
   16814              :             result = PRAGMA_OACC_CLAUSE_SEQ;
   16815         1136 :           else if (!strcmp ("shared", p))
   16816              :             result = PRAGMA_OMP_CLAUSE_SHARED;
   16817          425 :           else if (!strcmp ("simd", p))
   16818              :             result = PRAGMA_OMP_CLAUSE_SIMD;
   16819          368 :           else if (!strcmp ("simdlen", p))
   16820        36077 :             result = PRAGMA_OMP_CLAUSE_SIMDLEN;
   16821              :           break;
   16822         1093 :         case 't':
   16823         1093 :           if (!strcmp ("task_reduction", p))
   16824              :             result = PRAGMA_OMP_CLAUSE_TASK_REDUCTION;
   16825         1007 :           else if (!strcmp ("taskgroup", p))
   16826              :             result = PRAGMA_OMP_CLAUSE_TASKGROUP;
   16827          897 :           else if (!strcmp ("thread_limit", p))
   16828              :             result = PRAGMA_OMP_CLAUSE_THREAD_LIMIT;
   16829          742 :           else if (!strcmp ("threads", p))
   16830              :             result = PRAGMA_OMP_CLAUSE_THREADS;
   16831          696 :           else if (!strcmp ("tile", p))
   16832              :             result = PRAGMA_OACC_CLAUSE_TILE;
   16833          573 :           else if (!strcmp ("to", p))
   16834        36077 :             result = PRAGMA_OMP_CLAUSE_TO;
   16835              :           break;
   16836          378 :         case 'u':
   16837          378 :           if (!strcmp ("uniform", p))
   16838              :             result = PRAGMA_OMP_CLAUSE_UNIFORM;
   16839          261 :           else if (!strcmp ("untied", p))
   16840              :             result = PRAGMA_OMP_CLAUSE_UNTIED;
   16841          164 :           else if (!strcmp ("use", p))
   16842              :             result = PRAGMA_OMP_CLAUSE_USE;
   16843          121 :           else if (!strcmp ("use_device", p))
   16844              :             result = PRAGMA_OACC_CLAUSE_USE_DEVICE;
   16845          100 :           else if (!strcmp ("use_device_addr", p))
   16846              :             result = PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR;
   16847           65 :           else if (!strcmp ("use_device_ptr", p))
   16848              :             result = PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR;
   16849           55 :           else if (!strcmp ("uses_allocators", p))
   16850        36077 :             result = PRAGMA_OMP_CLAUSE_USES_ALLOCATORS;
   16851              :           break;
   16852          741 :         case 'v':
   16853          741 :           if (!strcmp ("vector", p))
   16854              :             result = PRAGMA_OACC_CLAUSE_VECTOR;
   16855          223 :           else if (!strcmp ("vector_length", p))
   16856        36077 :             result = PRAGMA_OACC_CLAUSE_VECTOR_LENGTH;
   16857              :           break;
   16858          550 :         case 'w':
   16859          550 :           if (!strcmp ("wait", p))
   16860              :             result = PRAGMA_OACC_CLAUSE_WAIT;
   16861          453 :           else if (!strcmp ("worker", p))
   16862        36077 :             result = PRAGMA_OACC_CLAUSE_WORKER;
   16863              :           break;
   16864              :         }
   16865              :     }
   16866              : 
   16867        36077 :   if (result != PRAGMA_OMP_CLAUSE_NONE)
   16868        35961 :     c_parser_consume_token (parser);
   16869              : 
   16870        36077 :   return result;
   16871              : }
   16872              : 
   16873              : /* Validate that a clause of the given type does not already exist.  */
   16874              : 
   16875              : static void
   16876        18679 : check_no_duplicate_clause (tree clauses, enum omp_clause_code code,
   16877              :                            const char *name)
   16878              : {
   16879        18679 :   if (tree c = omp_find_clause (clauses, code))
   16880          348 :     error_at (OMP_CLAUSE_LOCATION (c), "too many %qs clauses", name);
   16881        18679 : }
   16882              : 
   16883              : /* OpenACC 2.0
   16884              :    Parse wait clause or wait directive parameters.  */
   16885              : 
   16886              : static tree
   16887          131 : c_parser_oacc_wait_list (c_parser *parser, location_t clause_loc, tree list)
   16888              : {
   16889          131 :   vec<tree, va_gc> *args;
   16890          131 :   tree t, args_tree;
   16891              : 
   16892          131 :   matching_parens parens;
   16893          131 :   if (!parens.require_open (parser))
   16894              :     return list;
   16895              : 
   16896          131 :   args = c_parser_expr_list (parser, false, true, NULL, NULL, NULL, NULL);
   16897          131 :   args_tree = build_tree_list_vec (args);
   16898              : 
   16899          436 :   for (t = args_tree; t; t = TREE_CHAIN (t))
   16900              :     {
   16901          174 :       tree targ = TREE_VALUE (t);
   16902              : 
   16903          174 :       if (targ != error_mark_node)
   16904              :         {
   16905          160 :           if (!INTEGRAL_TYPE_P (TREE_TYPE (targ)))
   16906              :             {
   16907            6 :               c_parser_error (parser, "expression must be integral");
   16908            6 :               targ = error_mark_node;
   16909              :             }
   16910              :           else
   16911              :             {
   16912          154 :               tree c = build_omp_clause (clause_loc, OMP_CLAUSE_WAIT);
   16913              : 
   16914          154 :               OMP_CLAUSE_DECL (c) = targ;
   16915          154 :               OMP_CLAUSE_CHAIN (c) = list;
   16916          154 :               list = c;
   16917              :             }
   16918              :         }
   16919              :     }
   16920              : 
   16921          131 :   release_tree_vector (args);
   16922          131 :   parens.require_close (parser);
   16923          131 :   return list;
   16924              : }
   16925              : 
   16926              : /* OpenACC 2.0, OpenMP 2.5:
   16927              :    variable-list:
   16928              :      identifier
   16929              :      variable-list , identifier
   16930              : 
   16931              :    If KIND is nonzero, create the appropriate node and install the
   16932              :    decl in OMP_CLAUSE_DECL and add the node to the head of the list.
   16933              :    If KIND is nonzero, CLAUSE_LOC is the location of the clause.
   16934              : 
   16935              :    If KIND is zero (= OMP_CLAUSE_ERROR), create a TREE_LIST with the decl
   16936              :    in TREE_PURPOSE and the location in TREE_VALUE (accessible using
   16937              :    EXPR_LOCATION); return the list created.
   16938              : 
   16939              :    The optional ALLOW_DEREF argument is true if list items can use the deref
   16940              :    (->) operator.  */
   16941              : 
   16942              : struct omp_dim
   16943              : {
   16944              :   tree low_bound, length;
   16945              :   location_t loc;
   16946              :   bool no_colon;
   16947         3361 :   omp_dim (tree lb, tree len, location_t lo, bool nc)
   16948         3361 :   : low_bound (lb), length (len), loc (lo), no_colon (nc) {}
   16949              : };
   16950              : 
   16951              : static tree
   16952        17488 : c_parser_omp_variable_list (c_parser *parser,
   16953              :                             location_t clause_loc,
   16954              :                             enum omp_clause_code kind, tree list,
   16955              :                             bool map_lvalue = false)
   16956              : {
   16957        17488 :   auto_vec<omp_dim> dims;
   16958        17488 :   bool array_section_p;
   16959        17488 :   auto_vec<c_token> tokens;
   16960        17488 :   unsigned int tokens_avail = 0;
   16961        17488 :   c_token *saved_tokens = NULL;
   16962              : 
   16963        21576 :   while (1)
   16964              :     {
   16965        21576 :       tree t = NULL_TREE;
   16966        21576 :       location_t tloc = c_parser_peek_token (parser)->location;
   16967              : 
   16968        21576 :       if (kind == OMP_CLAUSE_DEPEND || kind == OMP_CLAUSE_AFFINITY)
   16969              :         {
   16970          893 :           if (c_parser_next_token_is_not (parser, CPP_NAME)
   16971          893 :               || c_parser_peek_token (parser)->id_kind != C_ID_ID)
   16972              :             {
   16973           29 :               struct c_expr expr;
   16974           29 :               if (kind == OMP_CLAUSE_DEPEND
   16975           27 :                   && c_parser_next_token_is_keyword (parser,
   16976              :                                                      RID_OMP_ALL_MEMORY)
   16977           45 :                   && (c_parser_peek_2nd_token (parser)->type == CPP_COMMA
   16978           13 :                       || (c_parser_peek_2nd_token (parser)->type
   16979              :                           == CPP_CLOSE_PAREN)))
   16980              :                 {
   16981           15 :                   expr.value = ridpointers[RID_OMP_ALL_MEMORY];
   16982           15 :                   c_parser_consume_token (parser);
   16983              :                 }
   16984              :               else
   16985           14 :                 expr = c_parser_expr_no_commas (parser, NULL);
   16986           29 :               if (expr.value != error_mark_node)
   16987              :                 {
   16988           27 :                   tree u = build_omp_clause (clause_loc, kind);
   16989           27 :                   OMP_CLAUSE_DECL (u) = expr.value;
   16990           27 :                   OMP_CLAUSE_CHAIN (u) = list;
   16991           27 :                   list = u;
   16992              :                 }
   16993              : 
   16994           29 :               if (c_parser_next_token_is_not (parser, CPP_COMMA))
   16995              :                 break;
   16996              : 
   16997            4 :               c_parser_consume_token (parser);
   16998            4 :               continue;
   16999            4 :             }
   17000              : 
   17001          864 :           tokens.truncate (0);
   17002          864 :           unsigned int nesting_depth = 0;
   17003        11312 :           while (1)
   17004              :             {
   17005         6088 :               c_token *token = c_parser_peek_token (parser);
   17006         6088 :               switch (token->type)
   17007              :                 {
   17008              :                 case CPP_EOF:
   17009              :                 case CPP_PRAGMA_EOL:
   17010              :                   break;
   17011          938 :                 case CPP_OPEN_BRACE:
   17012          938 :                 case CPP_OPEN_PAREN:
   17013          938 :                 case CPP_OPEN_SQUARE:
   17014          938 :                   ++nesting_depth;
   17015          938 :                   goto add;
   17016         1736 :                 case CPP_CLOSE_BRACE:
   17017         1736 :                 case CPP_CLOSE_PAREN:
   17018         1736 :                 case CPP_CLOSE_SQUARE:
   17019         1736 :                   if (nesting_depth-- == 0)
   17020              :                     break;
   17021          938 :                   goto add;
   17022          138 :                 case CPP_COMMA:
   17023          138 :                   if (nesting_depth == 0)
   17024              :                     break;
   17025           72 :                   goto add;
   17026         5224 :                 default:
   17027         5224 :                 add:
   17028         5224 :                   tokens.safe_push (*token);
   17029         5224 :                   c_parser_consume_token (parser);
   17030         5224 :                   continue;
   17031              :                 }
   17032          864 :               break;
   17033         5224 :             }
   17034              : 
   17035              :           /* Make sure nothing tries to read past the end of the tokens.  */
   17036          864 :           c_token eof_token;
   17037          864 :           memset (&eof_token, 0, sizeof (eof_token));
   17038          864 :           eof_token.type = CPP_EOF;
   17039          864 :           tokens.safe_push (eof_token);
   17040          864 :           tokens.safe_push (eof_token);
   17041              : 
   17042          864 :           saved_tokens = parser->tokens;
   17043          864 :           tokens_avail = parser->tokens_avail;
   17044          864 :           parser->tokens = tokens.address ();
   17045         1728 :           parser->tokens_avail = tokens.length ();
   17046              :         }
   17047        20683 :       else if (map_lvalue
   17048         2841 :                && (kind == OMP_CLAUSE_MAP
   17049              :                    || kind == OMP_CLAUSE_TO
   17050         2841 :                    || kind == OMP_CLAUSE_FROM))
   17051              :         {
   17052         2841 :           location_t loc = c_parser_peek_token (parser)->location;
   17053         2841 :           bool save_c_omp_array_section_p = c_omp_array_section_p;
   17054         2841 :           c_omp_array_section_p = true;
   17055         2841 :           c_expr expr = c_parser_expr_no_commas (parser, NULL);
   17056         2841 :           if (expr.value != error_mark_node)
   17057         2827 :             mark_exp_read (expr.value);
   17058         2841 :           c_omp_array_section_p = save_c_omp_array_section_p;
   17059         2841 :           tree decl = expr.value;
   17060              : 
   17061              :          /* This code rewrites a parsed expression containing various tree
   17062              :             codes used to represent array accesses into a more uniform nest of
   17063              :             OMP_ARRAY_SECTION nodes before it is processed by
   17064              :             c-typeck.cc:handle_omp_array_sections_1.  It might be more
   17065              :             efficient to move this logic to that function instead, analysing
   17066              :             the parsed expression directly rather than this preprocessed
   17067              :             form.  (See also equivalent code in cp/parser.cc,
   17068              :             cp/semantics.cc).  */
   17069         2841 :           dims.truncate (0);
   17070         2841 :           if (TREE_CODE (decl) == OMP_ARRAY_SECTION)
   17071              :             {
   17072         1130 :               while (TREE_CODE (decl) == OMP_ARRAY_SECTION)
   17073              :                 {
   17074          595 :                   tree low_bound = TREE_OPERAND (decl, 1);
   17075          595 :                   tree length = TREE_OPERAND (decl, 2);
   17076          595 :                   dims.safe_push (omp_dim (low_bound, length, loc, false));
   17077          595 :                   decl = TREE_OPERAND (decl, 0);
   17078              :                 }
   17079              : 
   17080          568 :               while (TREE_CODE (decl) == ARRAY_REF
   17081              :                      || TREE_CODE (decl) == INDIRECT_REF
   17082          568 :                      || TREE_CODE (decl) == COMPOUND_EXPR)
   17083              :                 {
   17084           33 :                   if (TREE_CODE (decl) == COMPOUND_EXPR)
   17085              :                     {
   17086            2 :                       decl = TREE_OPERAND (decl, 1);
   17087            2 :                       STRIP_NOPS (decl);
   17088              :                     }
   17089           31 :                   else if (TREE_CODE (decl) == INDIRECT_REF)
   17090              :                     {
   17091           46 :                       dims.safe_push (omp_dim (integer_zero_node,
   17092           23 :                                                integer_one_node, loc, true));
   17093           23 :                       decl = TREE_OPERAND (decl, 0);
   17094              :                     }
   17095              :                   else  /* ARRAY_REF. */
   17096              :                     {
   17097            8 :                       tree index = TREE_OPERAND (decl, 1);
   17098           16 :                       dims.safe_push (omp_dim (index, integer_one_node, loc,
   17099            8 :                                                true));
   17100            8 :                       decl = TREE_OPERAND (decl, 0);
   17101              :                     }
   17102              :                 }
   17103              : 
   17104         1696 :               for (int i = dims.length () - 1; i >= 0; i--)
   17105          626 :                 decl = build_omp_array_section (loc,  decl, dims[i].low_bound,
   17106          626 :                                                 dims[i].length);
   17107              :             }
   17108         2306 :           else if (TREE_CODE (decl) == INDIRECT_REF)
   17109              :             {
   17110              :               /* Turn indirection of a pointer "*foo" into "foo[0:1]".  */
   17111           55 :               decl = TREE_OPERAND (decl, 0);
   17112           55 :               STRIP_NOPS (decl);
   17113              : 
   17114           55 :               decl = build_omp_array_section (loc, decl, integer_zero_node,
   17115              :                                               integer_one_node);
   17116              :             }
   17117         2251 :           else if (TREE_CODE (decl) == ARRAY_REF)
   17118              :             {
   17119           13 :               tree idx = TREE_OPERAND (decl, 1);
   17120              : 
   17121           13 :               decl = TREE_OPERAND (decl, 0);
   17122           13 :               STRIP_NOPS (decl);
   17123              : 
   17124           13 :               decl = build_omp_array_section (loc, decl, idx, integer_one_node);
   17125              :             }
   17126         2238 :           else if (TREE_CODE (decl) == NON_LVALUE_EXPR
   17127         2238 :                    || CONVERT_EXPR_P (decl))
   17128            0 :             decl = TREE_OPERAND (decl, 0);
   17129              : 
   17130         2841 :           tree u = build_omp_clause (loc, kind);
   17131         2841 :           OMP_CLAUSE_DECL (u) = decl;
   17132         2841 :           OMP_CLAUSE_CHAIN (u) = list;
   17133         2841 :           list = u;
   17134              : 
   17135         2841 :           goto next_item;
   17136              :         }
   17137              : 
   17138        18706 :       if (c_parser_next_token_is (parser, CPP_NAME)
   17139        18706 :           && c_parser_peek_token (parser)->id_kind == C_ID_ID)
   17140              :         {
   17141        18668 :           t = lookup_name (c_parser_peek_token (parser)->value);
   17142              : 
   17143        18668 :           if (t == NULL_TREE)
   17144              :             {
   17145           14 :               undeclared_variable (c_parser_peek_token (parser)->location,
   17146           14 :               c_parser_peek_token (parser)->value);
   17147           14 :               t = error_mark_node;
   17148              :             }
   17149              : 
   17150        18668 :           c_parser_consume_token (parser);
   17151              :         }
   17152           38 :       else if (c_parser_next_token_is (parser, CPP_KEYWORD)
   17153           38 :                && (c_parser_peek_token (parser)->keyword == RID_FUNCTION_NAME
   17154           15 :                    || (c_parser_peek_token (parser)->keyword
   17155              :                        == RID_PRETTY_FUNCTION_NAME)
   17156            9 :                    || (c_parser_peek_token (parser)->keyword
   17157              :                        == RID_C99_FUNCTION_NAME)))
   17158           20 :         t = c_parser_predefined_identifier (parser).value;
   17159              :       else
   17160              :         {
   17161           18 :           c_parser_error (parser, "expected identifier");
   17162           18 :           break;
   17163              :         }
   17164              : 
   17165        18688 :       if (t == error_mark_node)
   17166              :         ;
   17167        18670 :       else if (kind != 0)  /* kind != OMP_CLAUSE_ERROR */
   17168              :         {
   17169        18437 :           switch (kind)
   17170              :             {
   17171          139 :             case OMP_CLAUSE__CACHE_:
   17172              :               /* The OpenACC cache directive explicitly only allows "array
   17173              :                  elements or subarrays".  */
   17174          139 :               if (c_parser_peek_token (parser)->type != CPP_OPEN_SQUARE)
   17175              :                 {
   17176            3 :                   c_parser_error (parser, "expected %<[%>");
   17177            3 :                   t = error_mark_node;
   17178            3 :                   break;
   17179              :                 }
   17180              :               /* FALLTHROUGH  */
   17181              :             case OMP_CLAUSE_MAP:
   17182              :             case OMP_CLAUSE_FROM:
   17183              :             case OMP_CLAUSE_TO:
   17184         6350 :             start_component_ref:
   17185         6678 :               while (c_parser_next_token_is (parser, CPP_DOT)
   17186        13137 :                      || c_parser_next_token_is (parser, CPP_DEREF))
   17187              :                 {
   17188          328 :                   location_t op_loc = c_parser_peek_token (parser)->location;
   17189          328 :                   location_t arrow_loc = UNKNOWN_LOCATION;
   17190          328 :                   if (c_parser_next_token_is (parser, CPP_DEREF))
   17191              :                     {
   17192          109 :                       c_expr t_expr;
   17193          109 :                       t_expr.value = t;
   17194          109 :                       t_expr.original_code = ERROR_MARK;
   17195          109 :                       t_expr.original_type = NULL;
   17196          109 :                       set_c_expr_source_range (&t_expr, op_loc, op_loc);
   17197          109 :                       t_expr.m_decimal = 0;
   17198          109 :                       t_expr = convert_lvalue_to_rvalue (op_loc, t_expr,
   17199              :                                                          true, false);
   17200          109 :                       t = build_indirect_ref (op_loc, t_expr.value, RO_ARROW);
   17201          109 :                       arrow_loc = t_expr.get_location ();
   17202              :                     }
   17203          328 :                   c_parser_consume_token (parser);
   17204          328 :                   if (!c_parser_next_token_is (parser, CPP_NAME))
   17205              :                     {
   17206            0 :                       c_parser_error (parser, "expected identifier");
   17207            0 :                       t = error_mark_node;
   17208            0 :                       break;
   17209              :                     }
   17210              : 
   17211          328 :                   c_token *comp_tok = c_parser_peek_token (parser);
   17212          328 :                   tree ident = comp_tok->value;
   17213          328 :                   location_t comp_loc = comp_tok->location;
   17214          328 :                   c_parser_consume_token (parser);
   17215          328 :                   t = build_component_ref (op_loc, t, ident, comp_loc,
   17216              :                                            arrow_loc);
   17217              :                 }
   17218              :               /* FALLTHROUGH  */
   17219        11144 :             case OMP_CLAUSE_AFFINITY:
   17220        11144 :             case OMP_CLAUSE_DEPEND:
   17221        11144 :             case OMP_CLAUSE_REDUCTION:
   17222        11144 :             case OMP_CLAUSE_IN_REDUCTION:
   17223        11144 :             case OMP_CLAUSE_TASK_REDUCTION:
   17224        11144 :             case OMP_CLAUSE_HAS_DEVICE_ADDR:
   17225        11144 :               array_section_p = false;
   17226        11144 :               dims.truncate (0);
   17227        25023 :               while (c_parser_next_token_is (parser, CPP_OPEN_SQUARE))
   17228              :                 {
   17229         2735 :                   location_t loc = UNKNOWN_LOCATION;
   17230         2735 :                   tree low_bound = NULL_TREE, length = NULL_TREE;
   17231         2735 :                   bool no_colon = false;
   17232              : 
   17233         2735 :                   c_parser_consume_token (parser);
   17234         2735 :                   if (!c_parser_next_token_is (parser, CPP_COLON))
   17235              :                     {
   17236         2310 :                       location_t expr_loc
   17237         2310 :                         = c_parser_peek_token (parser)->location;
   17238         2310 :                       c_expr expr = c_parser_expression (parser);
   17239         2310 :                       expr = convert_lvalue_to_rvalue (expr_loc, expr,
   17240              :                                                        false, true);
   17241         2310 :                       low_bound = expr.value;
   17242         2310 :                       loc = expr_loc;
   17243              :                     }
   17244         2735 :                   if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE))
   17245              :                     {
   17246          435 :                       length = integer_one_node;
   17247          435 :                       no_colon = true;
   17248              :                     }
   17249              :                   else
   17250              :                     {
   17251              :                       /* Look for `:'.  */
   17252         2300 :                       if (!c_parser_require (parser, CPP_COLON,
   17253              :                                              "expected %<:%>"))
   17254              :                         {
   17255            0 :                           t = error_mark_node;
   17256            0 :                           break;
   17257              :                         }
   17258         2300 :                       array_section_p = true;
   17259         2300 :                       if (!c_parser_next_token_is (parser, CPP_CLOSE_SQUARE))
   17260              :                         {
   17261         2111 :                           location_t expr_loc
   17262         2111 :                             = c_parser_peek_token (parser)->location;
   17263         2111 :                           c_expr expr = c_parser_expression (parser);
   17264         2111 :                           expr = convert_lvalue_to_rvalue (expr_loc, expr,
   17265              :                                                            false, true);
   17266         2111 :                           length = expr.value;
   17267              :                         }
   17268              :                     }
   17269              :                   /* Look for the closing `]'.  */
   17270         2735 :                   if (!c_parser_require (parser, CPP_CLOSE_SQUARE,
   17271              :                                          "expected %<]%>"))
   17272              :                     {
   17273            0 :                       t = error_mark_node;
   17274            0 :                       break;
   17275              :                     }
   17276              : 
   17277         2735 :                   dims.safe_push (omp_dim (low_bound, length, loc, no_colon));
   17278              :                 }
   17279              : 
   17280        11144 :               if (t != error_mark_node)
   17281              :                 {
   17282        11144 :                   if ((kind == OMP_CLAUSE_MAP
   17283        11144 :                        || kind == OMP_CLAUSE_FROM
   17284         5757 :                        || kind == OMP_CLAUSE_TO)
   17285         6214 :                       && !array_section_p
   17286        16101 :                       && (c_parser_next_token_is (parser, CPP_DOT)
   17287         4953 :                           || c_parser_next_token_is (parser, CPP_DEREF)))
   17288              :                     {
   17289            8 :                       for (unsigned i = 0; i < dims.length (); i++)
   17290              :                         {
   17291            4 :                           gcc_assert (dims[i].length == integer_one_node);
   17292            4 :                           t = build_array_ref (dims[i].loc,
   17293            4 :                                                t, dims[i].low_bound);
   17294              :                         }
   17295            4 :                       goto start_component_ref;
   17296              :                     }
   17297              :                   else
   17298        13871 :                     for (unsigned i = 0; i < dims.length (); i++)
   17299         5462 :                       t = build_omp_array_section (clause_loc, t,
   17300         2731 :                                                    dims[i].low_bound,
   17301         2731 :                                                    dims[i].length);
   17302              :                 }
   17303              : 
   17304        11140 :               if ((kind == OMP_CLAUSE_DEPEND || kind == OMP_CLAUSE_AFFINITY)
   17305          860 :                   && t != error_mark_node
   17306          860 :                   && parser->tokens_avail != 2)
   17307              :                 {
   17308           44 :                   if (array_section_p)
   17309              :                     {
   17310           12 :                       error_at (c_parser_peek_token (parser)->location,
   17311              :                                 "expected %<)%> or %<,%>");
   17312           12 :                       t = error_mark_node;
   17313              :                     }
   17314              :                   else
   17315              :                     {
   17316           32 :                       parser->tokens = tokens.address ();
   17317           32 :                       parser->tokens_avail = tokens.length ();
   17318              : 
   17319           32 :                       t = c_parser_expr_no_commas (parser, NULL).value;
   17320           32 :                       if (t != error_mark_node && parser->tokens_avail != 2)
   17321              :                         {
   17322            0 :                           error_at (c_parser_peek_token (parser)->location,
   17323              :                                     "expected %<)%> or %<,%>");
   17324            0 :                           t = error_mark_node;
   17325              :                         }
   17326              :                     }
   17327              :                 }
   17328              :               break;
   17329              :             default:
   17330              :               break;
   17331              :             }
   17332              : 
   17333        18437 :           if (t != error_mark_node)
   17334              :             {
   17335        18422 :               tree u = build_omp_clause (clause_loc, kind);
   17336        18422 :               OMP_CLAUSE_DECL (u) = t;
   17337        18422 :               OMP_CLAUSE_CHAIN (u) = list;
   17338        18422 :               list = u;
   17339              :             }
   17340              :         }
   17341              :       else  /* kind == OMP_CLAUSE_ERROR */
   17342          233 :         list = tree_cons (t, build_empty_stmt (tloc), list);
   17343              : 
   17344        18688 :       if (kind == OMP_CLAUSE_DEPEND || kind == OMP_CLAUSE_AFFINITY)
   17345              :         {
   17346          864 :           parser->tokens = saved_tokens;
   17347          864 :           parser->tokens_avail = tokens_avail;
   17348              :         }
   17349              : 
   17350        17824 :     next_item:
   17351        21529 :       if (c_parser_next_token_is_not (parser, CPP_COMMA))
   17352              :         break;
   17353              : 
   17354         4084 :       c_parser_consume_token (parser);
   17355              :     }
   17356              : 
   17357        17488 :   return list;
   17358        17488 : }
   17359              : 
   17360              : /* Similarly, but expect leading and trailing parenthesis.  This is a very
   17361              :    common case for OpenACC and OpenMP clauses.  The optional ALLOW_DEREF
   17362              :    argument is true if list items can use the deref (->) operator.  */
   17363              : 
   17364              : static tree
   17365         3752 : c_parser_omp_var_list_parens (c_parser *parser, enum omp_clause_code kind,
   17366              :                               tree list, bool map_lvalue = false)
   17367              : {
   17368              :   /* The clauses location.  */
   17369         3752 :   location_t loc = c_parser_peek_token (parser)->location;
   17370              : 
   17371         3752 :   if (parser->in_omp_decl_attribute)
   17372              :     {
   17373           42 :       if (kind)
   17374              :         {
   17375           22 :           tree u = build_omp_clause (loc, kind);
   17376           22 :           OMP_CLAUSE_DECL (u) = parser->in_omp_decl_attribute;
   17377           22 :           OMP_CLAUSE_CHAIN (u) = list;
   17378           22 :           return u;
   17379              :         }
   17380              :       else
   17381           20 :         return tree_cons (parser->in_omp_decl_attribute, NULL_TREE, list);
   17382              :     }
   17383              : 
   17384         3710 :   matching_parens parens;
   17385         3710 :   if (parens.require_open (parser))
   17386              :     {
   17387         3706 :       list = c_parser_omp_variable_list (parser, loc, kind, list, map_lvalue);
   17388         3706 :       parens.skip_until_found_close (parser);
   17389              :     }
   17390              :   return list;
   17391              : }
   17392              : 
   17393              : /* OpenACC 2.0:
   17394              :    copy ( variable-list )
   17395              :    copyin ( variable-list )
   17396              :    copyout ( variable-list )
   17397              :    create ( variable-list )
   17398              :    delete ( variable-list )
   17399              :    present ( variable-list )
   17400              : 
   17401              :    OpenACC 2.6:
   17402              :    no_create ( variable-list )
   17403              :    attach ( variable-list )
   17404              :    detach ( variable-list )
   17405              : 
   17406              :    OpenACC 2.7:
   17407              :    copyin (readonly : variable-list )
   17408              :  */
   17409              : 
   17410              : static tree
   17411         2026 : c_parser_oacc_data_clause (c_parser *parser, pragma_omp_clause c_kind,
   17412              :                            tree list)
   17413              : {
   17414         2026 :   enum gomp_map_kind kind;
   17415         2026 :   switch (c_kind)
   17416              :     {
   17417              :     case PRAGMA_OACC_CLAUSE_ATTACH:
   17418              :       kind = GOMP_MAP_ATTACH;
   17419              :       break;
   17420          806 :     case PRAGMA_OACC_CLAUSE_COPY:
   17421          806 :       kind = GOMP_MAP_TOFROM;
   17422          806 :       break;
   17423          359 :     case PRAGMA_OACC_CLAUSE_COPYIN:
   17424          359 :       kind = GOMP_MAP_TO;
   17425          359 :       break;
   17426          390 :     case PRAGMA_OACC_CLAUSE_COPYOUT:
   17427          390 :       kind = GOMP_MAP_FROM;
   17428          390 :       break;
   17429           94 :     case PRAGMA_OACC_CLAUSE_CREATE:
   17430           94 :       kind = GOMP_MAP_ALLOC;
   17431           94 :       break;
   17432           68 :     case PRAGMA_OACC_CLAUSE_DELETE:
   17433           68 :       kind = GOMP_MAP_RELEASE;
   17434           68 :       break;
   17435           20 :     case PRAGMA_OACC_CLAUSE_DETACH:
   17436           20 :       kind = GOMP_MAP_DETACH;
   17437           20 :       break;
   17438           36 :     case PRAGMA_OACC_CLAUSE_DEVICE:
   17439           36 :       kind = GOMP_MAP_FORCE_TO;
   17440           36 :       break;
   17441           16 :     case PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT:
   17442           16 :       kind = GOMP_MAP_DEVICE_RESIDENT;
   17443           16 :       break;
   17444           13 :     case PRAGMA_OACC_CLAUSE_LINK:
   17445           13 :       kind = GOMP_MAP_LINK;
   17446           13 :       break;
   17447           10 :     case PRAGMA_OACC_CLAUSE_NO_CREATE:
   17448           10 :       kind = GOMP_MAP_IF_PRESENT;
   17449           10 :       break;
   17450          128 :     case PRAGMA_OACC_CLAUSE_PRESENT:
   17451          128 :       kind = GOMP_MAP_FORCE_PRESENT;
   17452          128 :       break;
   17453           59 :     case PRAGMA_OACC_CLAUSE_SELF:
   17454              :       /* "The 'host' clause is a synonym for the 'self' clause."  */
   17455           59 :     case PRAGMA_OACC_CLAUSE_HOST:
   17456           59 :       kind = GOMP_MAP_FORCE_FROM;
   17457           59 :       break;
   17458            0 :     default:
   17459            0 :       gcc_unreachable ();
   17460              :     }
   17461              : 
   17462         2026 :   tree nl = list;
   17463         2026 :   bool readonly = false;
   17464         2026 :   location_t open_loc = c_parser_peek_token (parser)->location;
   17465         2026 :   matching_parens parens;
   17466         2026 :   if (parens.require_open (parser))
   17467              :     {
   17468              :       /* Turn on readonly modifier parsing for copyin clause.  */
   17469         2026 :       if (c_kind == PRAGMA_OACC_CLAUSE_COPYIN)
   17470              :         {
   17471          359 :           c_token *token = c_parser_peek_token (parser);
   17472          359 :           if (token->type == CPP_NAME
   17473          359 :               && !strcmp (IDENTIFIER_POINTER (token->value), "readonly")
   17474          366 :               && c_parser_peek_2nd_token (parser)->type == CPP_COLON)
   17475              :             {
   17476            7 :               c_parser_consume_token (parser);
   17477            7 :               c_parser_consume_token (parser);
   17478            7 :               readonly = true;
   17479              :             }
   17480              :         }
   17481         2026 :       nl = c_parser_omp_variable_list (parser, open_loc, OMP_CLAUSE_MAP, list,
   17482              :                                        false);
   17483         2026 :       parens.skip_until_found_close (parser);
   17484              :     }
   17485              : 
   17486         4671 :   for (tree c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   17487              :     {
   17488         2645 :       OMP_CLAUSE_SET_MAP_KIND (c, kind);
   17489         2645 :       if (readonly)
   17490           13 :         OMP_CLAUSE_MAP_READONLY (c) = 1;
   17491              :     }
   17492              : 
   17493         2026 :   return nl;
   17494              : }
   17495              : 
   17496              : /* OpenACC 2.0:
   17497              :    deviceptr ( variable-list ) */
   17498              : 
   17499              : static tree
   17500           57 : c_parser_oacc_data_clause_deviceptr (c_parser *parser, tree list)
   17501              : {
   17502           57 :   tree vars, t;
   17503              : 
   17504              :   /* Can't use OMP_CLAUSE_MAP here (that is, can't use the generic
   17505              :      c_parser_oacc_data_clause), as for PRAGMA_OACC_CLAUSE_DEVICEPTR,
   17506              :      variable-list must only allow for pointer variables.  */
   17507           57 :   vars = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ERROR, NULL);
   17508          175 :   for (t = vars; t && t; t = TREE_CHAIN (t))
   17509              :     {
   17510           61 :       tree v = TREE_PURPOSE (t);
   17511           61 :       location_t loc = EXPR_LOCATION (TREE_VALUE (t));
   17512              : 
   17513           61 :       if (!VAR_P (v) && TREE_CODE (v) != PARM_DECL)
   17514            3 :         error_at (loc, "%qD is not a variable", v);
   17515           58 :       else if (TREE_TYPE (v) == error_mark_node)
   17516              :         ;
   17517           57 :       else if (!POINTER_TYPE_P (TREE_TYPE (v)))
   17518            7 :         error_at (loc, "%qD is not a pointer variable", v);
   17519              : 
   17520           61 :       tree u = build_omp_clause (loc, OMP_CLAUSE_MAP);
   17521           61 :       OMP_CLAUSE_SET_MAP_KIND (u, GOMP_MAP_FORCE_DEVICEPTR);
   17522           61 :       OMP_CLAUSE_DECL (u) = v;
   17523           61 :       OMP_CLAUSE_CHAIN (u) = list;
   17524           61 :       list = u;
   17525              :     }
   17526              : 
   17527           57 :   return list;
   17528              : }
   17529              : 
   17530              : /* OpenACC 2.0, OpenMP 3.0:
   17531              :    collapse ( constant-expression ) */
   17532              : 
   17533              : static tree
   17534         3399 : c_parser_omp_clause_collapse (c_parser *parser, tree list)
   17535              : {
   17536         3399 :   tree c, num = error_mark_node;
   17537         3399 :   HOST_WIDE_INT n;
   17538         3399 :   location_t loc;
   17539              : 
   17540         3399 :   check_no_duplicate_clause (list, OMP_CLAUSE_COLLAPSE, "collapse");
   17541         3399 :   check_no_duplicate_clause (list, OMP_CLAUSE_TILE, "tile");
   17542              : 
   17543         3399 :   loc = c_parser_peek_token (parser)->location;
   17544         3399 :   matching_parens parens;
   17545         3399 :   if (parens.require_open (parser))
   17546              :     {
   17547         3399 :       num = c_parser_expr_no_commas (parser, NULL).value;
   17548         3399 :       parens.skip_until_found_close (parser);
   17549              :     }
   17550         3399 :   if (num == error_mark_node)
   17551              :     return list;
   17552         3399 :   mark_exp_read (num);
   17553         3399 :   num = c_fully_fold (num, false, NULL);
   17554         6798 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (num))
   17555         3399 :       || !tree_fits_shwi_p (num)
   17556         3399 :       || (n = tree_to_shwi (num)) <= 0
   17557         6798 :       || (int) n != n)
   17558              :     {
   17559            0 :       error_at (loc,
   17560              :                 "collapse argument needs positive constant integer expression");
   17561            0 :       return list;
   17562              :     }
   17563         3399 :   c = build_omp_clause (loc, OMP_CLAUSE_COLLAPSE);
   17564         3399 :   OMP_CLAUSE_COLLAPSE_EXPR (c) = num;
   17565         3399 :   OMP_CLAUSE_CHAIN (c) = list;
   17566         3399 :   return c;
   17567              : }
   17568              : 
   17569              : /* OpenMP 2.5:
   17570              :    copyin ( variable-list ) */
   17571              : 
   17572              : static tree
   17573          102 : c_parser_omp_clause_copyin (c_parser *parser, tree list)
   17574              : {
   17575          102 :   return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_COPYIN, list);
   17576              : }
   17577              : 
   17578              : /* OpenMP 2.5:
   17579              :    copyprivate ( variable-list ) */
   17580              : 
   17581              : static tree
   17582           24 : c_parser_omp_clause_copyprivate (c_parser *parser, tree list)
   17583              : {
   17584           24 :   return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_COPYPRIVATE, list);
   17585              : }
   17586              : 
   17587              : /* OpenMP 2.5:
   17588              :    default ( none | shared )
   17589              : 
   17590              :    OpenMP 5.1:
   17591              :    default ( private | firstprivate )
   17592              : 
   17593              :    OpenACC:
   17594              :    default ( none | present ) */
   17595              : 
   17596              : static tree
   17597          729 : c_parser_omp_clause_default (c_parser *parser, tree list, bool is_oacc)
   17598              : {
   17599          729 :   enum omp_clause_default_kind kind = OMP_CLAUSE_DEFAULT_UNSPECIFIED;
   17600          729 :   location_t loc = c_parser_peek_token (parser)->location;
   17601          729 :   tree c;
   17602              : 
   17603          729 :   matching_parens parens;
   17604          729 :   if (!parens.require_open (parser))
   17605              :     return list;
   17606          726 :   if (c_parser_next_token_is (parser, CPP_NAME))
   17607              :     {
   17608          714 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   17609              : 
   17610          714 :       switch (p[0])
   17611              :         {
   17612          391 :         case 'n':
   17613          391 :           if (strcmp ("none", p) != 0)
   17614            0 :             goto invalid_kind;
   17615              :           kind = OMP_CLAUSE_DEFAULT_NONE;
   17616              :           break;
   17617              : 
   17618           23 :         case 'p':
   17619           23 :           if (is_oacc)
   17620              :             {
   17621           18 :               if (strcmp ("present", p) != 0)
   17622            3 :                 goto invalid_kind;
   17623              :               kind = OMP_CLAUSE_DEFAULT_PRESENT;
   17624              :             }
   17625              :           else
   17626              :             {
   17627            5 :               if (strcmp ("private", p) != 0)
   17628            0 :                 goto invalid_kind;
   17629              :               kind = OMP_CLAUSE_DEFAULT_PRIVATE;
   17630              :             }
   17631              :           break;
   17632              : 
   17633            9 :         case 'f':
   17634            9 :           if (strcmp ("firstprivate", p) != 0 || is_oacc)
   17635            0 :             goto invalid_kind;
   17636              :           kind = OMP_CLAUSE_DEFAULT_FIRSTPRIVATE;
   17637              :           break;
   17638              : 
   17639          287 :         case 's':
   17640          287 :           if (strcmp ("shared", p) != 0 || is_oacc)
   17641            0 :             goto invalid_kind;
   17642              :           kind = OMP_CLAUSE_DEFAULT_SHARED;
   17643              :           break;
   17644              : 
   17645            4 :         default:
   17646            4 :           goto invalid_kind;
   17647              :         }
   17648              : 
   17649          701 :       c_parser_consume_token (parser);
   17650              :     }
   17651              :   else
   17652              :     {
   17653           25 :     invalid_kind:
   17654           25 :       if (is_oacc)
   17655           21 :         c_parser_error (parser, "expected %<none%> or %<present%>");
   17656              :       else
   17657            4 :         c_parser_error (parser, "expected %<none%>, %<shared%>, "
   17658              :                                 "%<private%> or %<firstprivate%>");
   17659              :     }
   17660          726 :   parens.skip_until_found_close (parser);
   17661              : 
   17662          726 :   if (kind == OMP_CLAUSE_DEFAULT_UNSPECIFIED)
   17663              :     return list;
   17664              : 
   17665          701 :   check_no_duplicate_clause (list, OMP_CLAUSE_DEFAULT, "default");
   17666          701 :   c = build_omp_clause (loc, OMP_CLAUSE_DEFAULT);
   17667          701 :   OMP_CLAUSE_CHAIN (c) = list;
   17668          701 :   OMP_CLAUSE_DEFAULT_KIND (c) = kind;
   17669              : 
   17670          701 :   return c;
   17671              : }
   17672              : 
   17673              : /* OpenMP 2.5:
   17674              :    firstprivate ( variable-list ) */
   17675              : 
   17676              : static tree
   17677          875 : c_parser_omp_clause_firstprivate (c_parser *parser, tree list)
   17678              : {
   17679          762 :   return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_FIRSTPRIVATE, list);
   17680              : }
   17681              : 
   17682              : /* OpenMP 3.1:
   17683              :    final ( expression ) */
   17684              : 
   17685              : static tree
   17686           99 : c_parser_omp_clause_final (c_parser *parser, tree list)
   17687              : {
   17688           99 :   location_t loc = c_parser_peek_token (parser)->location;
   17689           99 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   17690              :     {
   17691           99 :       matching_parens parens;
   17692           99 :       tree t, c;
   17693           99 :       if (!parens.require_open (parser))
   17694            0 :         t = error_mark_node;
   17695              :       else
   17696              :         {
   17697           99 :           location_t eloc = c_parser_peek_token (parser)->location;
   17698           99 :           c_expr expr = c_parser_expr_no_commas (parser, NULL);
   17699           99 :           t = convert_lvalue_to_rvalue (eloc, expr, true, true).value;
   17700           99 :           t = c_objc_common_truthvalue_conversion (eloc, t);
   17701           99 :           t = c_fully_fold (t, false, NULL);
   17702           99 :           parens.skip_until_found_close (parser);
   17703              :         }
   17704              : 
   17705           99 :       check_no_duplicate_clause (list, OMP_CLAUSE_FINAL, "final");
   17706              : 
   17707           99 :       c = build_omp_clause (loc, OMP_CLAUSE_FINAL);
   17708           99 :       OMP_CLAUSE_FINAL_EXPR (c) = t;
   17709           99 :       OMP_CLAUSE_CHAIN (c) = list;
   17710           99 :       list = c;
   17711              :     }
   17712              :   else
   17713            0 :     c_parser_error (parser, "expected %<(%>");
   17714              : 
   17715           99 :   return list;
   17716              : }
   17717              : 
   17718              : /* OpenMP 5.1:
   17719              :    indirect [( expression )]
   17720              : */
   17721              : 
   17722              : static tree
   17723           26 : c_parser_omp_clause_indirect (c_parser *parser, tree list)
   17724              : {
   17725           26 :   location_t location = c_parser_peek_token (parser)->location;
   17726           26 :   tree t;
   17727              : 
   17728           26 :   if (c_parser_peek_token (parser)->type == CPP_OPEN_PAREN)
   17729              :     {
   17730           17 :       matching_parens parens;
   17731           17 :       if (!parens.require_open (parser))
   17732            1 :         return list;
   17733              : 
   17734           17 :       location_t loc = c_parser_peek_token (parser)->location;
   17735           17 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   17736           17 :       expr = convert_lvalue_to_rvalue (loc, expr, true, true);
   17737           17 :       t = c_objc_common_truthvalue_conversion (loc, expr.value);
   17738           17 :       t = c_fully_fold (t, false, NULL);
   17739           34 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
   17740           34 :           || TREE_CODE (t) != INTEGER_CST)
   17741              :         {
   17742            1 :           c_parser_error (parser, "expected constant logical expression");
   17743            1 :           return list;
   17744              :         }
   17745           16 :       parens.skip_until_found_close (parser);
   17746              :     }
   17747              :   else
   17748            9 :     t = integer_one_node;
   17749              : 
   17750           25 :   check_no_duplicate_clause (list, OMP_CLAUSE_INDIRECT, "indirect");
   17751              : 
   17752           25 :   tree c = build_omp_clause (location, OMP_CLAUSE_INDIRECT);
   17753           25 :   OMP_CLAUSE_INDIRECT_EXPR (c) = t;
   17754           25 :   OMP_CLAUSE_CHAIN (c) = list;
   17755              : 
   17756           25 :   return c;
   17757              : }
   17758              : 
   17759              : /* OpenACC, OpenMP 2.5:
   17760              :    if ( expression )
   17761              : 
   17762              :    OpenMP 4.5:
   17763              :    if ( directive-name-modifier : expression )
   17764              : 
   17765              :    directive-name-modifier:
   17766              :      parallel | task | taskloop | target data | target | target update
   17767              :      | target enter data | target exit data
   17768              : 
   17769              :    OpenMP 5.0:
   17770              :    directive-name-modifier:
   17771              :      ... | simd | cancel  */
   17772              : 
   17773              : static tree
   17774          893 : c_parser_omp_clause_if (c_parser *parser, tree list, bool is_omp)
   17775              : {
   17776          893 :   location_t location = c_parser_peek_token (parser)->location;
   17777          893 :   enum tree_code if_modifier = ERROR_MARK;
   17778              : 
   17779          893 :   matching_parens parens;
   17780          893 :   if (!parens.require_open (parser))
   17781              :     return list;
   17782              : 
   17783         1681 :   if (is_omp && c_parser_next_token_is (parser, CPP_NAME))
   17784              :     {
   17785          641 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   17786          641 :       int n = 2;
   17787          641 :       if (strcmp (p, "cancel") == 0)
   17788              :         if_modifier = VOID_CST;
   17789          626 :       else if (strcmp (p, "parallel") == 0)
   17790              :         if_modifier = OMP_PARALLEL;
   17791          487 :       else if (strcmp (p, "simd") == 0)
   17792              :         if_modifier = OMP_SIMD;
   17793          381 :       else if (strcmp (p, "task") == 0)
   17794              :         if_modifier = OMP_TASK;
   17795          370 :       else if (strcmp (p, "taskloop") == 0)
   17796              :         if_modifier = OMP_TASKLOOP;
   17797          319 :       else if (strcmp (p, "target") == 0)
   17798              :         {
   17799          102 :           if_modifier = OMP_TARGET;
   17800          102 :           if (c_parser_peek_2nd_token (parser)->type == CPP_NAME)
   17801              :             {
   17802           37 :               p = IDENTIFIER_POINTER (c_parser_peek_2nd_token (parser)->value);
   17803           37 :               if (strcmp ("data", p) == 0)
   17804              :                 if_modifier = OMP_TARGET_DATA;
   17805           29 :               else if (strcmp ("update", p) == 0)
   17806              :                 if_modifier = OMP_TARGET_UPDATE;
   17807           18 :               else if (strcmp ("enter", p) == 0)
   17808              :                 if_modifier = OMP_TARGET_ENTER_DATA;
   17809           10 :               else if (strcmp ("exit", p) == 0)
   17810              :                 if_modifier = OMP_TARGET_EXIT_DATA;
   17811            0 :               if (if_modifier != OMP_TARGET)
   17812              :                 {
   17813           37 :                   n = 3;
   17814           37 :                   c_parser_consume_token (parser);
   17815              :                 }
   17816              :               else
   17817              :                 {
   17818            0 :                   location_t loc = c_parser_peek_2nd_token (parser)->location;
   17819            0 :                   error_at (loc, "expected %<data%>, %<update%>, %<enter%> "
   17820              :                                  "or %<exit%>");
   17821            0 :                   if_modifier = ERROR_MARK;
   17822              :                 }
   17823            0 :               if (if_modifier == OMP_TARGET_ENTER_DATA
   17824           37 :                   || if_modifier == OMP_TARGET_EXIT_DATA)
   17825              :                 {
   17826           18 :                   if (c_parser_peek_2nd_token (parser)->type == CPP_NAME)
   17827              :                     {
   17828           18 :                       p = IDENTIFIER_POINTER
   17829              :                                 (c_parser_peek_2nd_token (parser)->value);
   17830           18 :                       if (strcmp ("data", p) == 0)
   17831              :                         n = 4;
   17832              :                     }
   17833            0 :                   if (n == 4)
   17834           18 :                     c_parser_consume_token (parser);
   17835              :                   else
   17836              :                     {
   17837            0 :                       location_t loc
   17838            0 :                         = c_parser_peek_2nd_token (parser)->location;
   17839            0 :                       error_at (loc, "expected %<data%>");
   17840            0 :                       if_modifier = ERROR_MARK;
   17841              :                     }
   17842              :                 }
   17843              :             }
   17844              :         }
   17845           37 :       if (if_modifier != ERROR_MARK)
   17846              :         {
   17847          424 :           if (c_parser_peek_2nd_token (parser)->type == CPP_COLON)
   17848              :             {
   17849          423 :               c_parser_consume_token (parser);
   17850          423 :               c_parser_consume_token (parser);
   17851              :             }
   17852              :           else
   17853              :             {
   17854            1 :               if (n > 2)
   17855              :                 {
   17856            0 :                   location_t loc = c_parser_peek_2nd_token (parser)->location;
   17857            0 :                   error_at (loc, "expected %<:%>");
   17858              :                 }
   17859              :               if_modifier = ERROR_MARK;
   17860              :             }
   17861              :         }
   17862              :     }
   17863              : 
   17864          893 :   location_t loc = c_parser_peek_token (parser)->location;
   17865          893 :   c_expr expr = c_parser_expr_no_commas (parser, NULL);
   17866          893 :   expr = convert_lvalue_to_rvalue (loc, expr, true, true);
   17867          893 :   tree t = c_objc_common_truthvalue_conversion (loc, expr.value), c;
   17868          893 :   t = c_fully_fold (t, false, NULL);
   17869          893 :   parens.skip_until_found_close (parser);
   17870              : 
   17871         4900 :   for (c = list; c ; c = OMP_CLAUSE_CHAIN (c))
   17872         3154 :     if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IF)
   17873              :       {
   17874          174 :         if (if_modifier != ERROR_MARK
   17875          174 :             && OMP_CLAUSE_IF_MODIFIER (c) == if_modifier)
   17876              :           {
   17877            9 :             const char *p = NULL;
   17878            9 :             switch (if_modifier)
   17879              :               {
   17880              :               case VOID_CST: p = "cancel"; break;
   17881            1 :               case OMP_PARALLEL: p = "parallel"; break;
   17882            0 :               case OMP_SIMD: p = "simd"; break;
   17883            1 :               case OMP_TASK: p = "task"; break;
   17884            1 :               case OMP_TASKLOOP: p = "taskloop"; break;
   17885            1 :               case OMP_TARGET_DATA: p = "target data"; break;
   17886            1 :               case OMP_TARGET: p = "target"; break;
   17887            1 :               case OMP_TARGET_UPDATE: p = "target update"; break;
   17888            1 :               case OMP_TARGET_ENTER_DATA: p = "target enter data"; break;
   17889            1 :               case OMP_TARGET_EXIT_DATA: p = "target exit data"; break;
   17890              :               default: gcc_unreachable ();
   17891              :               }
   17892            9 :             error_at (location, "too many %<if%> clauses with %qs modifier",
   17893              :                       p);
   17894            9 :             return list;
   17895              :           }
   17896          165 :         else if (OMP_CLAUSE_IF_MODIFIER (c) == if_modifier)
   17897              :           {
   17898           13 :             if (!is_omp)
   17899            1 :               error_at (location, "too many %<if%> clauses");
   17900              :             else
   17901           12 :               error_at (location, "too many %<if%> clauses without modifier");
   17902              :             return list;
   17903              :           }
   17904          152 :         else if (if_modifier == ERROR_MARK
   17905          152 :                  || OMP_CLAUSE_IF_MODIFIER (c) == ERROR_MARK)
   17906              :           {
   17907           18 :             error_at (location, "if any %<if%> clause has modifier, then all "
   17908              :                                 "%<if%> clauses have to use modifier");
   17909           18 :             return list;
   17910              :           }
   17911              :       }
   17912              : 
   17913          853 :   c = build_omp_clause (location, OMP_CLAUSE_IF);
   17914          853 :   OMP_CLAUSE_IF_MODIFIER (c) = if_modifier;
   17915          853 :   OMP_CLAUSE_IF_EXPR (c) = t;
   17916          853 :   OMP_CLAUSE_CHAIN (c) = list;
   17917          853 :   return c;
   17918              : }
   17919              : 
   17920              : /* OpenMP 2.5:
   17921              :    lastprivate ( variable-list )
   17922              : 
   17923              :    OpenMP 5.0:
   17924              :    lastprivate ( [ lastprivate-modifier : ] variable-list ) */
   17925              : 
   17926              : static tree
   17927          768 : c_parser_omp_clause_lastprivate (c_parser *parser, tree list)
   17928              : {
   17929              :   /* The clauses location.  */
   17930          768 :   location_t loc = c_parser_peek_token (parser)->location;
   17931              : 
   17932          768 :   if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
   17933              :     {
   17934          768 :       bool conditional = false;
   17935          768 :       if (c_parser_next_token_is (parser, CPP_NAME)
   17936          768 :           && c_parser_peek_2nd_token (parser)->type == CPP_COLON)
   17937              :         {
   17938          111 :           const char *p
   17939          111 :             = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   17940          111 :           if (strcmp (p, "conditional") == 0)
   17941              :             {
   17942          111 :               conditional = true;
   17943          111 :               c_parser_consume_token (parser);
   17944          111 :               c_parser_consume_token (parser);
   17945              :             }
   17946              :         }
   17947          768 :       tree nlist = c_parser_omp_variable_list (parser, loc,
   17948              :                                                OMP_CLAUSE_LASTPRIVATE, list);
   17949          768 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
   17950          768 :       if (conditional)
   17951          254 :         for (tree c = nlist; c != list; c = OMP_CLAUSE_CHAIN (c))
   17952          143 :           OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c) = 1;
   17953              :       return nlist;
   17954              :     }
   17955              :   return list;
   17956              : }
   17957              : 
   17958              : /* OpenMP 3.1:
   17959              :    mergeable */
   17960              : 
   17961              : static tree
   17962           79 : c_parser_omp_clause_mergeable (c_parser *parser ATTRIBUTE_UNUSED, tree list)
   17963              : {
   17964           79 :   tree c;
   17965              : 
   17966              :   /* FIXME: Should we allow duplicates?  */
   17967           79 :   check_no_duplicate_clause (list, OMP_CLAUSE_MERGEABLE, "mergeable");
   17968              : 
   17969           79 :   c = build_omp_clause (c_parser_peek_token (parser)->location,
   17970              :                         OMP_CLAUSE_MERGEABLE);
   17971           79 :   OMP_CLAUSE_CHAIN (c) = list;
   17972              : 
   17973           79 :   return c;
   17974              : }
   17975              : 
   17976              : /* OpenMP 2.5:
   17977              :    nowait */
   17978              : 
   17979              : static tree
   17980          395 : c_parser_omp_clause_nowait (c_parser *parser ATTRIBUTE_UNUSED, tree list)
   17981              : {
   17982          395 :   tree c;
   17983          395 :   location_t loc = c_parser_peek_token (parser)->location;
   17984              : 
   17985          395 :   check_no_duplicate_clause (list, OMP_CLAUSE_NOWAIT, "nowait");
   17986              : 
   17987          395 :   c = build_omp_clause (loc, OMP_CLAUSE_NOWAIT);
   17988          395 :   OMP_CLAUSE_CHAIN (c) = list;
   17989          395 :   return c;
   17990              : }
   17991              : 
   17992              : /* OpenMP 2.5:
   17993              :    num_threads ( expression ) */
   17994              : 
   17995              : static tree
   17996          467 : c_parser_omp_clause_num_threads (c_parser *parser, tree list)
   17997              : {
   17998          467 :   location_t num_threads_loc = c_parser_peek_token (parser)->location;
   17999          467 :   matching_parens parens;
   18000          467 :   if (parens.require_open (parser))
   18001              :     {
   18002          467 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   18003          467 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   18004          467 :       expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   18005          467 :       tree c, t = expr.value;
   18006          467 :       t = c_fully_fold (t, false, NULL);
   18007              : 
   18008          467 :       parens.skip_until_found_close (parser);
   18009              : 
   18010          467 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
   18011              :         {
   18012            0 :           c_parser_error (parser, "expected integer expression");
   18013            0 :           return list;
   18014              :         }
   18015              : 
   18016              :       /* Attempt to statically determine when the number isn't positive.  */
   18017          467 :       c = fold_build2_loc (expr_loc, LE_EXPR, boolean_type_node, t,
   18018          467 :                        build_int_cst (TREE_TYPE (t), 0));
   18019          467 :       protected_set_expr_location (c, expr_loc);
   18020          467 :       if (c == boolean_true_node)
   18021              :         {
   18022            1 :           warning_at (expr_loc, OPT_Wopenmp,
   18023              :                       "%<num_threads%> value must be positive");
   18024            1 :           t = integer_one_node;
   18025              :         }
   18026              : 
   18027          467 :       check_no_duplicate_clause (list, OMP_CLAUSE_NUM_THREADS, "num_threads");
   18028              : 
   18029          467 :       c = build_omp_clause (num_threads_loc, OMP_CLAUSE_NUM_THREADS);
   18030          467 :       OMP_CLAUSE_NUM_THREADS_EXPR (c) = t;
   18031          467 :       OMP_CLAUSE_CHAIN (c) = list;
   18032          467 :       list = c;
   18033              :     }
   18034              : 
   18035              :   return list;
   18036              : }
   18037              : 
   18038              : /* OpenMP 4.5:
   18039              :    num_tasks ( expression )
   18040              : 
   18041              :    OpenMP 5.1:
   18042              :    num_tasks ( strict : expression ) */
   18043              : 
   18044              : static tree
   18045           50 : c_parser_omp_clause_num_tasks (c_parser *parser, tree list)
   18046              : {
   18047           50 :   location_t num_tasks_loc = c_parser_peek_token (parser)->location;
   18048           50 :   matching_parens parens;
   18049           50 :   if (parens.require_open (parser))
   18050              :     {
   18051           50 :       bool strict = false;
   18052           50 :       if (c_parser_next_token_is (parser, CPP_NAME)
   18053           40 :           && c_parser_peek_2nd_token (parser)->type == CPP_COLON
   18054           51 :           && strcmp (IDENTIFIER_POINTER (c_parser_peek_token (parser)->value),
   18055              :                      "strict") == 0)
   18056              :         {
   18057            1 :           strict = true;
   18058            1 :           c_parser_consume_token (parser);
   18059            1 :           c_parser_consume_token (parser);
   18060              :         }
   18061              : 
   18062           50 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   18063           50 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   18064           50 :       expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   18065           50 :       tree c, t = expr.value;
   18066           50 :       t = c_fully_fold (t, false, NULL);
   18067              : 
   18068           50 :       parens.skip_until_found_close (parser);
   18069              : 
   18070           50 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
   18071              :         {
   18072            0 :           c_parser_error (parser, "expected integer expression");
   18073            0 :           return list;
   18074              :         }
   18075              : 
   18076              :       /* Attempt to statically determine when the number isn't positive.  */
   18077           50 :       c = fold_build2_loc (expr_loc, LE_EXPR, boolean_type_node, t,
   18078           50 :                            build_int_cst (TREE_TYPE (t), 0));
   18079           50 :       if (CAN_HAVE_LOCATION_P (c))
   18080           40 :         SET_EXPR_LOCATION (c, expr_loc);
   18081           50 :       if (c == boolean_true_node)
   18082              :         {
   18083            0 :           warning_at (expr_loc, OPT_Wopenmp,
   18084              :                       "%<num_tasks%> value must be positive");
   18085            0 :           t = integer_one_node;
   18086              :         }
   18087              : 
   18088           50 :       check_no_duplicate_clause (list, OMP_CLAUSE_NUM_TASKS, "num_tasks");
   18089              : 
   18090           50 :       c = build_omp_clause (num_tasks_loc, OMP_CLAUSE_NUM_TASKS);
   18091           50 :       OMP_CLAUSE_NUM_TASKS_EXPR (c) = t;
   18092           50 :       OMP_CLAUSE_NUM_TASKS_STRICT (c) = strict;
   18093           50 :       OMP_CLAUSE_CHAIN (c) = list;
   18094           50 :       list = c;
   18095              :     }
   18096              : 
   18097              :   return list;
   18098              : }
   18099              : 
   18100              : /* OpenMP 4.5:
   18101              :    grainsize ( expression )
   18102              : 
   18103              :    OpenMP 5.1:
   18104              :    grainsize ( strict : expression ) */
   18105              : 
   18106              : static tree
   18107           62 : c_parser_omp_clause_grainsize (c_parser *parser, tree list)
   18108              : {
   18109           62 :   location_t grainsize_loc = c_parser_peek_token (parser)->location;
   18110           62 :   matching_parens parens;
   18111           62 :   if (parens.require_open (parser))
   18112              :     {
   18113           62 :       bool strict = false;
   18114           62 :       if (c_parser_next_token_is (parser, CPP_NAME)
   18115           47 :           && c_parser_peek_2nd_token (parser)->type == CPP_COLON
   18116           63 :           && strcmp (IDENTIFIER_POINTER (c_parser_peek_token (parser)->value),
   18117              :                      "strict") == 0)
   18118              :         {
   18119            1 :           strict = true;
   18120            1 :           c_parser_consume_token (parser);
   18121            1 :           c_parser_consume_token (parser);
   18122              :         }
   18123              : 
   18124           62 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   18125           62 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   18126           62 :       expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   18127           62 :       tree c, t = expr.value;
   18128           62 :       t = c_fully_fold (t, false, NULL);
   18129              : 
   18130           62 :       parens.skip_until_found_close (parser);
   18131              : 
   18132           62 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
   18133              :         {
   18134            0 :           c_parser_error (parser, "expected integer expression");
   18135            0 :           return list;
   18136              :         }
   18137              : 
   18138              :       /* Attempt to statically determine when the number isn't positive.  */
   18139           62 :       c = fold_build2_loc (expr_loc, LE_EXPR, boolean_type_node, t,
   18140           62 :                            build_int_cst (TREE_TYPE (t), 0));
   18141           62 :       if (CAN_HAVE_LOCATION_P (c))
   18142           47 :         SET_EXPR_LOCATION (c, expr_loc);
   18143           62 :       if (c == boolean_true_node)
   18144              :         {
   18145            0 :           warning_at (expr_loc, OPT_Wopenmp,
   18146              :                       "%<grainsize%> value must be positive");
   18147            0 :           t = integer_one_node;
   18148              :         }
   18149              : 
   18150           62 :       check_no_duplicate_clause (list, OMP_CLAUSE_GRAINSIZE, "grainsize");
   18151              : 
   18152           62 :       c = build_omp_clause (grainsize_loc, OMP_CLAUSE_GRAINSIZE);
   18153           62 :       OMP_CLAUSE_GRAINSIZE_EXPR (c) = t;
   18154           62 :       OMP_CLAUSE_GRAINSIZE_STRICT (c) = strict;
   18155           62 :       OMP_CLAUSE_CHAIN (c) = list;
   18156           62 :       list = c;
   18157              :     }
   18158              : 
   18159              :   return list;
   18160              : }
   18161              : 
   18162              : /* OpenMP 4.5:
   18163              :    priority ( expression ) */
   18164              : 
   18165              : static tree
   18166           98 : c_parser_omp_clause_priority (c_parser *parser, tree list)
   18167              : {
   18168           98 :   location_t priority_loc = c_parser_peek_token (parser)->location;
   18169           98 :   matching_parens parens;
   18170           98 :   if (parens.require_open (parser))
   18171              :     {
   18172           98 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   18173           98 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   18174           98 :       expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   18175           98 :       tree c, t = expr.value;
   18176           98 :       t = c_fully_fold (t, false, NULL);
   18177              : 
   18178           98 :       parens.skip_until_found_close (parser);
   18179              : 
   18180           98 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
   18181              :         {
   18182            0 :           c_parser_error (parser, "expected integer expression");
   18183            0 :           return list;
   18184              :         }
   18185              : 
   18186              :       /* Attempt to statically determine when the number isn't
   18187              :          non-negative.  */
   18188           98 :       c = fold_build2_loc (expr_loc, LT_EXPR, boolean_type_node, t,
   18189           98 :                            build_int_cst (TREE_TYPE (t), 0));
   18190           98 :       if (CAN_HAVE_LOCATION_P (c))
   18191           87 :         SET_EXPR_LOCATION (c, expr_loc);
   18192           98 :       if (c == boolean_true_node)
   18193              :         {
   18194            0 :           warning_at (expr_loc, OPT_Wopenmp,
   18195              :                       "%<priority%> value must be non-negative");
   18196            0 :           t = integer_one_node;
   18197              :         }
   18198              : 
   18199           98 :       check_no_duplicate_clause (list, OMP_CLAUSE_PRIORITY, "priority");
   18200              : 
   18201           98 :       c = build_omp_clause (priority_loc, OMP_CLAUSE_PRIORITY);
   18202           98 :       OMP_CLAUSE_PRIORITY_EXPR (c) = t;
   18203           98 :       OMP_CLAUSE_CHAIN (c) = list;
   18204           98 :       list = c;
   18205              :     }
   18206              : 
   18207              :   return list;
   18208              : }
   18209              : 
   18210              : /* OpenMP 4.5:
   18211              :    hint ( expression ) */
   18212              : 
   18213              : static tree
   18214           58 : c_parser_omp_clause_hint (c_parser *parser, tree list)
   18215              : {
   18216           58 :   location_t hint_loc = c_parser_peek_token (parser)->location;
   18217           58 :   matching_parens parens;
   18218           58 :   if (parens.require_open (parser))
   18219              :     {
   18220           58 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   18221           58 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   18222           58 :       expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   18223           58 :       tree c, t = expr.value;
   18224           58 :       t = c_fully_fold (t, false, NULL);
   18225          116 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
   18226           57 :           || TREE_CODE (t) != INTEGER_CST
   18227          111 :           || tree_int_cst_sgn (t) == -1)
   18228              :         {
   18229            6 :           c_parser_error (parser, "expected constant integer expression "
   18230              :                                   "with valid sync-hint value");
   18231            6 :           return list;
   18232              :         }
   18233           52 :       parens.skip_until_found_close (parser);
   18234           52 :       check_no_duplicate_clause (list, OMP_CLAUSE_HINT, "hint");
   18235              : 
   18236           52 :       c = build_omp_clause (hint_loc, OMP_CLAUSE_HINT);
   18237           52 :       OMP_CLAUSE_HINT_EXPR (c) = t;
   18238           52 :       OMP_CLAUSE_CHAIN (c) = list;
   18239           52 :       list = c;
   18240              :     }
   18241              : 
   18242              :   return list;
   18243              : }
   18244              : 
   18245              : /* OpenMP 5.1:
   18246              :    filter ( integer-expression ) */
   18247              : 
   18248              : static tree
   18249           63 : c_parser_omp_clause_filter (c_parser *parser, tree list)
   18250              : {
   18251           63 :   location_t hint_loc = c_parser_peek_token (parser)->location;
   18252           63 :   matching_parens parens;
   18253           63 :   if (parens.require_open (parser))
   18254              :     {
   18255           63 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   18256           63 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   18257           63 :       expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   18258           63 :       tree c, t = expr.value;
   18259           63 :       t = c_fully_fold (t, false, NULL);
   18260           63 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
   18261              :         {
   18262            2 :           c_parser_error (parser, "expected integer expression");
   18263            2 :           return list;
   18264              :         }
   18265           61 :       parens.skip_until_found_close (parser);
   18266           61 :       check_no_duplicate_clause (list, OMP_CLAUSE_FILTER, "filter");
   18267              : 
   18268           61 :       c = build_omp_clause (hint_loc, OMP_CLAUSE_FILTER);
   18269           61 :       OMP_CLAUSE_FILTER_EXPR (c) = t;
   18270           61 :       OMP_CLAUSE_CHAIN (c) = list;
   18271           61 :       list = c;
   18272              :     }
   18273              : 
   18274              :   return list;
   18275              : }
   18276              : 
   18277              : /* OpenMP 4.5:
   18278              :    defaultmap ( tofrom : scalar )
   18279              : 
   18280              :    OpenMP 5.0:
   18281              :    defaultmap ( implicit-behavior [ : variable-category ] ) */
   18282              : 
   18283              : static tree
   18284          241 : c_parser_omp_clause_defaultmap (c_parser *parser, tree list)
   18285              : {
   18286          241 :   location_t loc = c_parser_peek_token (parser)->location;
   18287          241 :   tree c;
   18288          241 :   const char *p;
   18289          241 :   enum omp_clause_defaultmap_kind behavior = OMP_CLAUSE_DEFAULTMAP_DEFAULT;
   18290          241 :   enum omp_clause_defaultmap_kind category
   18291              :     = OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED;
   18292              : 
   18293          241 :   matching_parens parens;
   18294          241 :   if (!parens.require_open (parser))
   18295              :     return list;
   18296          241 :   if (c_parser_next_token_is_keyword (parser, RID_DEFAULT))
   18297              :     p = "default";
   18298          234 :   else if (!c_parser_next_token_is (parser, CPP_NAME))
   18299              :     {
   18300            2 :     invalid_behavior:
   18301            3 :       c_parser_error (parser, "expected %<alloc%>, %<to%>, %<from%>, "
   18302              :                               "%<tofrom%>, %<firstprivate%>, %<none%> "
   18303              :                               "or %<default%>");
   18304            3 :       goto out_err;
   18305              :     }
   18306              :   else
   18307          232 :     p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   18308              : 
   18309          239 :   switch (p[0])
   18310              :     {
   18311            7 :     case 'a':
   18312            7 :       if (strcmp ("alloc", p) == 0)
   18313              :         behavior = OMP_CLAUSE_DEFAULTMAP_ALLOC;
   18314              :       else
   18315            0 :         goto invalid_behavior;
   18316              :       break;
   18317              : 
   18318            7 :     case 'd':
   18319            7 :       if (strcmp ("default", p) == 0)
   18320              :         behavior = OMP_CLAUSE_DEFAULTMAP_DEFAULT;
   18321              :       else
   18322            0 :         goto invalid_behavior;
   18323              :       break;
   18324              : 
   18325           27 :     case 'f':
   18326           27 :       if (strcmp ("firstprivate", p) == 0)
   18327              :         behavior = OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE;
   18328            3 :       else if (strcmp ("from", p) == 0)
   18329              :         behavior = OMP_CLAUSE_DEFAULTMAP_FROM;
   18330              :       else
   18331            0 :         goto invalid_behavior;
   18332              :       break;
   18333              : 
   18334          104 :     case 'n':
   18335          104 :       if (strcmp ("none", p) == 0)
   18336              :         behavior = OMP_CLAUSE_DEFAULTMAP_NONE;
   18337              :       else
   18338            0 :         goto invalid_behavior;
   18339              :       break;
   18340              : 
   18341            4 :     case 'p':
   18342            4 :       if (strcmp ("present", p) == 0)
   18343              :         behavior = OMP_CLAUSE_DEFAULTMAP_PRESENT;
   18344              :       else
   18345            0 :         goto invalid_behavior;
   18346              :       break;
   18347              : 
   18348           89 :     case 't':
   18349           89 :       if (strcmp ("tofrom", p) == 0)
   18350              :         behavior = OMP_CLAUSE_DEFAULTMAP_TOFROM;
   18351            4 :       else if (strcmp ("to", p) == 0)
   18352              :         behavior = OMP_CLAUSE_DEFAULTMAP_TO;
   18353              :       else
   18354            0 :         goto invalid_behavior;
   18355              :       break;
   18356              : 
   18357            1 :     default:
   18358            1 :       goto invalid_behavior;
   18359              :     }
   18360          238 :   c_parser_consume_token (parser);
   18361              : 
   18362          238 :   if (!c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   18363              :     {
   18364          131 :       if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   18365            3 :         goto out_err;
   18366          128 :       if (!c_parser_next_token_is (parser, CPP_NAME))
   18367              :         {
   18368            1 :         invalid_category:
   18369            2 :           c_parser_error (parser, "expected %<scalar%>, %<aggregate%>, "
   18370              :                                   "%<pointer%> or %<all%>");
   18371            2 :           goto out_err;
   18372              :         }
   18373          127 :       p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   18374          127 :       switch (p[0])
   18375              :         {
   18376           22 :         case 'a':
   18377           22 :           if (strcmp ("aggregate", p) == 0)
   18378              :             category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE;
   18379            8 :           else if (strcmp ("all", p) == 0)
   18380              :             category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL;
   18381              :           else
   18382            0 :             goto invalid_category;
   18383              :           break;
   18384              : 
   18385           14 :         case 'p':
   18386           14 :           if (strcmp ("pointer", p) == 0)
   18387              :             category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER;
   18388              :           else
   18389            0 :             goto invalid_category;
   18390              :           break;
   18391              : 
   18392           90 :         case 's':
   18393           90 :           if (strcmp ("scalar", p) == 0)
   18394              :             category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR;
   18395              :           else
   18396            0 :             goto invalid_category;
   18397              :           break;
   18398              : 
   18399            1 :         default:
   18400            1 :           goto invalid_category;
   18401              :         }
   18402              : 
   18403          126 :       c_parser_consume_token (parser);
   18404              :     }
   18405          233 :   parens.skip_until_found_close (parser);
   18406              : 
   18407          971 :   for (c = list; c ; c = OMP_CLAUSE_CHAIN (c))
   18408          518 :     if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEFAULTMAP
   18409          518 :         && (category == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED
   18410              :             || category == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL
   18411           32 :             || OMP_CLAUSE_DEFAULTMAP_CATEGORY (c) == category
   18412           31 :             || (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
   18413              :                 == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)
   18414           29 :             || (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
   18415              :                 == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL)))
   18416              :       {
   18417           13 :         enum omp_clause_defaultmap_kind cat = category;
   18418           13 :         location_t loc = OMP_CLAUSE_LOCATION (c);
   18419           13 :         if (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED
   18420           13 :             || (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL
   18421            3 :                 && (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
   18422              :                     != OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)))
   18423            8 :           cat = OMP_CLAUSE_DEFAULTMAP_CATEGORY (c);
   18424           13 :         p = NULL;
   18425           13 :         switch (cat)
   18426              :           {
   18427              :           case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
   18428              :             p = NULL;
   18429              :             break;
   18430            3 :           case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL:
   18431            3 :             p = "all";
   18432            3 :             break;
   18433            2 :           case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
   18434            2 :             p = "aggregate";
   18435            2 :             break;
   18436            3 :           case OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER:
   18437            3 :             p = "pointer";
   18438            3 :             break;
   18439              :           case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
   18440              :             p = "scalar";
   18441              :             break;
   18442            0 :           default:
   18443            0 :             gcc_unreachable ();
   18444              :           }
   18445            8 :         if (p)
   18446           10 :           error_at (loc, "too many %<defaultmap%> clauses with %qs category",
   18447              :                     p);
   18448              :         else
   18449            3 :           error_at (loc, "too many %<defaultmap%> clauses with unspecified "
   18450              :                          "category");
   18451              :         break;
   18452              :       }
   18453              : 
   18454          233 :   c = build_omp_clause (loc, OMP_CLAUSE_DEFAULTMAP);
   18455          233 :   OMP_CLAUSE_DEFAULTMAP_SET_KIND (c, behavior, category);
   18456          233 :   OMP_CLAUSE_CHAIN (c) = list;
   18457          233 :   return c;
   18458              : 
   18459            8 :  out_err:
   18460            8 :   parens.skip_until_found_close (parser);
   18461            8 :   return list;
   18462              : }
   18463              : 
   18464              : /* OpenACC 2.0:
   18465              :    use_device ( variable-list )
   18466              : 
   18467              :    OpenMP 4.5:
   18468              :    use_device_ptr ( variable-list ) */
   18469              : 
   18470              : static tree
   18471           31 : c_parser_omp_clause_use_device_ptr (c_parser *parser, tree list)
   18472              : {
   18473           10 :   return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_USE_DEVICE_PTR,
   18474           10 :                                        list);
   18475              : }
   18476              : 
   18477              : /* OpenMP 5.0:
   18478              :    use_device_addr ( variable-list ) */
   18479              : 
   18480              : static tree
   18481           35 : c_parser_omp_clause_use_device_addr (c_parser *parser, tree list)
   18482              : {
   18483           35 :   return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_USE_DEVICE_ADDR,
   18484           35 :                                        list);
   18485              : }
   18486              : 
   18487              : /* OpenMP 5.1:
   18488              :    has_device_addr ( variable-list ) */
   18489              : 
   18490              : static tree
   18491           88 : c_parser_omp_clause_has_device_addr (c_parser *parser, tree list)
   18492              : {
   18493           88 :   return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_HAS_DEVICE_ADDR,
   18494           88 :                                        list);
   18495              : }
   18496              : 
   18497              : /* OpenMP 4.5:
   18498              :    is_device_ptr ( variable-list ) */
   18499              : 
   18500              : static tree
   18501          115 : c_parser_omp_clause_is_device_ptr (c_parser *parser, tree list)
   18502              : {
   18503          115 :   return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_IS_DEVICE_PTR, list);
   18504              : }
   18505              : 
   18506              : /* OpenACC:
   18507              :    num_gangs ( expression )
   18508              :    num_workers ( expression )
   18509              :    vector_length ( expression )  */
   18510              : 
   18511              : static tree
   18512          732 : c_parser_oacc_single_int_clause (c_parser *parser, omp_clause_code code,
   18513              :                                  tree list)
   18514              : {
   18515          732 :   location_t loc = c_parser_peek_token (parser)->location;
   18516              : 
   18517          732 :   matching_parens parens;
   18518          732 :   if (!parens.require_open (parser))
   18519              :     return list;
   18520              : 
   18521          726 :   location_t expr_loc = c_parser_peek_token (parser)->location;
   18522          726 :   c_expr expr = c_parser_expression (parser);
   18523          726 :   expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   18524          726 :   tree c, t = expr.value;
   18525          726 :   t = c_fully_fold (t, false, NULL);
   18526              : 
   18527          726 :   parens.skip_until_found_close (parser);
   18528              : 
   18529          726 :   if (t == error_mark_node)
   18530              :     return list;
   18531          702 :   else if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
   18532              :     {
   18533           16 :       error_at (expr_loc, "%qs expression must be integral",
   18534           16 :                 omp_clause_code_name[code]);
   18535           16 :       return list;
   18536              :     }
   18537              : 
   18538              :   /* Attempt to statically determine when the number isn't positive.  */
   18539          686 :   c = fold_build2_loc (expr_loc, LE_EXPR, boolean_type_node, t,
   18540          686 :                        build_int_cst (TREE_TYPE (t), 0));
   18541          686 :   protected_set_expr_location (c, expr_loc);
   18542          686 :   if (c == boolean_true_node)
   18543              :     {
   18544           36 :       warning_at (expr_loc, 0,
   18545              :                   "%qs value must be positive",
   18546           18 :                   omp_clause_code_name[code]);
   18547           18 :       t = integer_one_node;
   18548              :     }
   18549              : 
   18550          686 :   check_no_duplicate_clause (list, code, omp_clause_code_name[code]);
   18551              : 
   18552          686 :   c = build_omp_clause (loc, code);
   18553          686 :   OMP_CLAUSE_OPERAND (c, 0) = t;
   18554          686 :   OMP_CLAUSE_CHAIN (c) = list;
   18555          686 :   return c;
   18556              : }
   18557              : 
   18558              : /* OpenACC:
   18559              : 
   18560              :     gang [( gang-arg-list )]
   18561              :     worker [( [num:] int-expr )]
   18562              :     vector [( [length:] int-expr )]
   18563              : 
   18564              :   where gang-arg is one of:
   18565              : 
   18566              :     [num:] int-expr
   18567              :     static: size-expr
   18568              : 
   18569              :   and size-expr may be:
   18570              : 
   18571              :     *
   18572              :     int-expr
   18573              : */
   18574              : 
   18575              : static tree
   18576         1560 : c_parser_oacc_shape_clause (c_parser *parser, location_t loc,
   18577              :                             omp_clause_code kind,
   18578              :                             const char *str, tree list)
   18579              : {
   18580         1560 :   const char *id = "num";
   18581         1560 :   tree ops[2] = { NULL_TREE, NULL_TREE }, c;
   18582              : 
   18583         1560 :   if (kind == OMP_CLAUSE_VECTOR)
   18584          518 :     id = "length";
   18585              : 
   18586         1560 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   18587              :     {
   18588          246 :       c_parser_consume_token (parser);
   18589              : 
   18590          276 :       do
   18591              :         {
   18592          261 :           c_token *next = c_parser_peek_token (parser);
   18593          261 :           int idx = 0;
   18594              : 
   18595              :           /* Gang static argument.  */
   18596          261 :           if (kind == OMP_CLAUSE_GANG
   18597          403 :               && c_parser_next_token_is_keyword (parser, RID_STATIC))
   18598              :             {
   18599           70 :               c_parser_consume_token (parser);
   18600              : 
   18601           70 :               if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   18602           12 :                 goto cleanup_error;
   18603              : 
   18604           70 :               idx = 1;
   18605           70 :               if (ops[idx] != NULL_TREE)
   18606              :                 {
   18607            0 :                   c_parser_error (parser, "too many %<static%> arguments");
   18608            0 :                   goto cleanup_error;
   18609              :                 }
   18610              : 
   18611              :               /* Check for the '*' argument.  */
   18612           70 :               if (c_parser_next_token_is (parser, CPP_MULT)
   18613           70 :                   && (c_parser_peek_2nd_token (parser)->type == CPP_COMMA
   18614           30 :                       || c_parser_peek_2nd_token (parser)->type
   18615              :                          == CPP_CLOSE_PAREN))
   18616              :                 {
   18617           29 :                   c_parser_consume_token (parser);
   18618           29 :                   ops[idx] = integer_minus_one_node;
   18619              : 
   18620           29 :                   if (c_parser_next_token_is (parser, CPP_COMMA))
   18621              :                     {
   18622            1 :                       c_parser_consume_token (parser);
   18623            1 :                       continue;
   18624              :                     }
   18625              :                   else
   18626              :                     break;
   18627              :                 }
   18628              :             }
   18629              :           /* Worker num: argument and vector length: arguments.  */
   18630          191 :           else if (c_parser_next_token_is (parser, CPP_NAME)
   18631          149 :                    && strcmp (id, IDENTIFIER_POINTER (next->value)) == 0
   18632          324 :                    && c_parser_peek_2nd_token (parser)->type == CPP_COLON)
   18633              :             {
   18634          127 :               c_parser_consume_token (parser);  /* id  */
   18635          127 :               c_parser_consume_token (parser);  /* ':'  */
   18636              :             }
   18637              : 
   18638              :           /* Now collect the actual argument.  */
   18639          232 :           if (ops[idx] != NULL_TREE)
   18640              :             {
   18641            5 :               c_parser_error (parser, "unexpected argument");
   18642            5 :               goto cleanup_error;
   18643              :             }
   18644              : 
   18645          227 :           location_t expr_loc = c_parser_peek_token (parser)->location;
   18646          227 :           c_expr cexpr = c_parser_expr_no_commas (parser, NULL);
   18647          227 :           cexpr = convert_lvalue_to_rvalue (expr_loc, cexpr, false, true);
   18648          227 :           tree expr = cexpr.value;
   18649          227 :           if (expr == error_mark_node)
   18650            7 :             goto cleanup_error;
   18651              : 
   18652          220 :           expr = c_fully_fold (expr, false, NULL);
   18653              : 
   18654              :           /* Attempt to statically determine when the number isn't a
   18655              :              positive integer.  */
   18656              : 
   18657          220 :           if (!INTEGRAL_TYPE_P (TREE_TYPE (expr)))
   18658              :             {
   18659           14 :               c_parser_error (parser, "expected integer expression");
   18660           14 :               return list;
   18661              :             }
   18662              : 
   18663          206 :           tree c = fold_build2_loc (expr_loc, LE_EXPR, boolean_type_node, expr,
   18664          206 :                                     build_int_cst (TREE_TYPE (expr), 0));
   18665          206 :           if (c == boolean_true_node)
   18666              :             {
   18667            1 :               warning_at (loc, 0,
   18668              :                           "%qs value must be positive", str);
   18669            1 :               expr = integer_one_node;
   18670              :             }
   18671              : 
   18672          206 :           ops[idx] = expr;
   18673              : 
   18674          220 :           if (kind == OMP_CLAUSE_GANG
   18675          305 :               && c_parser_next_token_is (parser, CPP_COMMA))
   18676              :             {
   18677           14 :               c_parser_consume_token (parser);
   18678           14 :               continue;
   18679              :             }
   18680              :           break;
   18681           15 :         }
   18682              :       while (1);
   18683              : 
   18684          220 :       if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
   18685            7 :         goto cleanup_error;
   18686              :     }
   18687              : 
   18688         1527 :   check_no_duplicate_clause (list, kind, str);
   18689              : 
   18690         1527 :   c = build_omp_clause (loc, kind);
   18691              : 
   18692         1527 :   if (ops[1])
   18693           67 :     OMP_CLAUSE_OPERAND (c, 1) = ops[1];
   18694              : 
   18695         1527 :   OMP_CLAUSE_OPERAND (c, 0) = ops[0];
   18696         1527 :   OMP_CLAUSE_CHAIN (c) = list;
   18697              : 
   18698         1527 :   return c;
   18699              : 
   18700           19 :  cleanup_error:
   18701           19 :   c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, 0);
   18702           19 :   return list;
   18703              : }
   18704              : 
   18705              : /* OpenACC 2.5:
   18706              :    auto
   18707              :    finalize
   18708              :    independent
   18709              :    nohost
   18710              :    seq */
   18711              : 
   18712              : static tree
   18713          487 : c_parser_oacc_simple_clause (location_t loc, enum omp_clause_code code,
   18714              :                              tree list)
   18715              : {
   18716          487 :   check_no_duplicate_clause (list, code, omp_clause_code_name[code]);
   18717              : 
   18718          487 :   tree c = build_omp_clause (loc, code);
   18719          487 :   OMP_CLAUSE_CHAIN (c) = list;
   18720              : 
   18721          487 :   return c;
   18722              : }
   18723              : 
   18724              : /* OpenACC:
   18725              :    async [( int-expr )] */
   18726              : 
   18727              : static tree
   18728          240 : c_parser_oacc_clause_async (c_parser *parser, tree list)
   18729              : {
   18730          240 :   tree c, t;
   18731          240 :   location_t loc = c_parser_peek_token (parser)->location;
   18732              : 
   18733          240 :   t = build_int_cst (integer_type_node, GOMP_ASYNC_NOVAL);
   18734              : 
   18735          240 :   if (c_parser_peek_token (parser)->type == CPP_OPEN_PAREN)
   18736              :     {
   18737          187 :       c_parser_consume_token (parser);
   18738              : 
   18739          187 :       t = c_parser_expr_no_commas (parser, NULL).value;
   18740          187 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
   18741            9 :         c_parser_error (parser, "expected integer expression");
   18742          178 :       else if (t == error_mark_node
   18743          178 :           || !c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
   18744              :         return list;
   18745              :     }
   18746              :   else
   18747           53 :     t = c_fully_fold (t, false, NULL);
   18748              : 
   18749          226 :   check_no_duplicate_clause (list, OMP_CLAUSE_ASYNC, "async");
   18750              : 
   18751          226 :   c = build_omp_clause (loc, OMP_CLAUSE_ASYNC);
   18752          226 :   OMP_CLAUSE_ASYNC_EXPR (c) = t;
   18753          226 :   OMP_CLAUSE_CHAIN (c) = list;
   18754          226 :   list = c;
   18755              : 
   18756          226 :   return list;
   18757              : }
   18758              : 
   18759              : /* OpenACC 2.0:
   18760              :    tile ( size-expr-list ) */
   18761              : 
   18762              : static tree
   18763          123 : c_parser_oacc_clause_tile (c_parser *parser, tree list)
   18764              : {
   18765          123 :   tree c, expr = error_mark_node;
   18766          123 :   location_t loc;
   18767          123 :   tree tile = NULL_TREE;
   18768              : 
   18769          123 :   check_no_duplicate_clause (list, OMP_CLAUSE_TILE, "tile");
   18770          123 :   check_no_duplicate_clause (list, OMP_CLAUSE_COLLAPSE, "collapse");
   18771              : 
   18772          123 :   loc = c_parser_peek_token (parser)->location;
   18773          123 :   if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
   18774              :     return list;
   18775              : 
   18776          163 :   do
   18777              :     {
   18778          163 :       if (tile && !c_parser_require (parser, CPP_COMMA, "expected %<,%>"))
   18779              :         return list;
   18780              : 
   18781          163 :       if (c_parser_next_token_is (parser, CPP_MULT)
   18782          163 :           && (c_parser_peek_2nd_token (parser)->type == CPP_COMMA
   18783           53 :               || c_parser_peek_2nd_token (parser)->type == CPP_CLOSE_PAREN))
   18784              :         {
   18785           60 :           c_parser_consume_token (parser);
   18786           60 :           expr = integer_zero_node;
   18787              :         }
   18788              :       else
   18789              :         {
   18790          103 :           location_t expr_loc = c_parser_peek_token (parser)->location;
   18791          103 :           c_expr cexpr = c_parser_expr_no_commas (parser, NULL);
   18792          103 :           cexpr = convert_lvalue_to_rvalue (expr_loc, cexpr, false, true);
   18793          103 :           expr = cexpr.value;
   18794              : 
   18795          103 :           if (expr == error_mark_node)
   18796              :             {
   18797            7 :               c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   18798              :                                          "expected %<)%>");
   18799            7 :               return list;
   18800              :             }
   18801              : 
   18802           96 :           expr = c_fully_fold (expr, false, NULL);
   18803              : 
   18804          192 :           if (!INTEGRAL_TYPE_P (TREE_TYPE (expr))
   18805           95 :               || !tree_fits_shwi_p (expr)
   18806          183 :               || tree_to_shwi (expr) <= 0)
   18807              :             {
   18808           16 :               error_at (expr_loc, "%<tile%> argument needs positive"
   18809              :                         " integral constant");
   18810           16 :               expr = integer_zero_node;
   18811              :             }
   18812              :         }
   18813              : 
   18814          156 :       tile = tree_cons (NULL_TREE, expr, tile);
   18815              :     }
   18816          156 :   while (c_parser_next_token_is_not (parser, CPP_CLOSE_PAREN));
   18817              : 
   18818              :   /* Consume the trailing ')'.  */
   18819          111 :   c_parser_consume_token (parser);
   18820              : 
   18821          111 :   c = build_omp_clause (loc, OMP_CLAUSE_TILE);
   18822          111 :   tile = nreverse (tile);
   18823          111 :   OMP_CLAUSE_TILE_LIST (c) = tile;
   18824          111 :   OMP_CLAUSE_CHAIN (c) = list;
   18825          111 :   return c;
   18826              : }
   18827              : 
   18828              : /* OpenACC:
   18829              :    wait [( int-expr-list )] */
   18830              : 
   18831              : static tree
   18832           97 : c_parser_oacc_clause_wait (c_parser *parser, tree list)
   18833              : {
   18834           97 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   18835              : 
   18836           97 :   if (c_parser_peek_token (parser)->type == CPP_OPEN_PAREN)
   18837           82 :     list = c_parser_oacc_wait_list (parser, clause_loc, list);
   18838              :   else
   18839              :     {
   18840           15 :       tree c = build_omp_clause (clause_loc, OMP_CLAUSE_WAIT);
   18841              : 
   18842           15 :       OMP_CLAUSE_DECL (c) = build_int_cst (integer_type_node, GOMP_ASYNC_NOVAL);
   18843           15 :       OMP_CLAUSE_CHAIN (c) = list;
   18844           15 :       list = c;
   18845              :     }
   18846              : 
   18847           97 :   return list;
   18848              : }
   18849              : 
   18850              : /* OpenACC 2.7:
   18851              :    self [( expression )] */
   18852              : 
   18853              : static tree
   18854           48 : c_parser_oacc_compute_clause_self (c_parser *parser, tree list)
   18855              : {
   18856           48 :   tree t;
   18857           48 :   location_t location = c_parser_peek_token (parser)->location;
   18858           48 :   if (c_parser_peek_token (parser)->type == CPP_OPEN_PAREN)
   18859              :     {
   18860           42 :       matching_parens parens;
   18861           42 :       parens.consume_open (parser);
   18862              : 
   18863           42 :       location_t loc = c_parser_peek_token (parser)->location;
   18864           42 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   18865           42 :       expr = convert_lvalue_to_rvalue (loc, expr, true, true);
   18866           42 :       t = c_objc_common_truthvalue_conversion (loc, expr.value);
   18867           42 :       t = c_fully_fold (t, false, NULL);
   18868           42 :       parens.skip_until_found_close (parser);
   18869              :     }
   18870              :   else
   18871            6 :     t = truthvalue_true_node;
   18872              : 
   18873           78 :   for (tree c = list; c; c = OMP_CLAUSE_CHAIN (c))
   18874           36 :     if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SELF)
   18875              :       {
   18876            6 :         error_at (location, "too many %<self%> clauses");
   18877            6 :         return list;
   18878              :       }
   18879              : 
   18880           42 :   tree c = build_omp_clause (location, OMP_CLAUSE_SELF);
   18881           42 :   OMP_CLAUSE_SELF_EXPR (c) = t;
   18882           42 :   OMP_CLAUSE_CHAIN (c) = list;
   18883           42 :   return c;
   18884              : }
   18885              : 
   18886              : /* OpenMP 5.0:
   18887              :    order ( concurrent )
   18888              : 
   18889              :    OpenMP 5.1:
   18890              :    order ( order-modifier : concurrent )
   18891              : 
   18892              :    order-modifier:
   18893              :      reproducible
   18894              :      unconstrained  */
   18895              : 
   18896              : static tree
   18897          376 : c_parser_omp_clause_order (c_parser *parser, tree list)
   18898              : {
   18899          376 :   location_t loc = c_parser_peek_token (parser)->location;
   18900          376 :   tree c;
   18901          376 :   const char *p;
   18902          376 :   bool unconstrained = false;
   18903          376 :   bool reproducible = false;
   18904              : 
   18905          376 :   matching_parens parens;
   18906          376 :   if (!parens.require_open (parser))
   18907              :     return list;
   18908          374 :   if (c_parser_next_token_is (parser, CPP_NAME)
   18909          374 :       && c_parser_peek_2nd_token (parser)->type == CPP_COLON)
   18910              :     {
   18911          107 :       p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   18912          107 :       if (strcmp (p, "unconstrained") == 0)
   18913              :         unconstrained = true;
   18914           56 :       else if (strcmp (p, "reproducible") == 0)
   18915              :         reproducible = true;
   18916              :       else
   18917              :         {
   18918            1 :           c_parser_error (parser, "expected %<reproducible%> or "
   18919              :                                   "%<unconstrained%>");
   18920            1 :           goto out_err;
   18921              :         }
   18922          106 :       c_parser_consume_token (parser);
   18923          106 :       c_parser_consume_token (parser);
   18924              :     }
   18925          373 :   if (!c_parser_next_token_is (parser, CPP_NAME))
   18926              :     {
   18927            0 :       c_parser_error (parser, "expected %<concurrent%>");
   18928            0 :       goto out_err;
   18929              :     }
   18930          373 :   p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   18931          373 :   if (strcmp (p, "concurrent") != 0)
   18932              :     {
   18933            1 :       c_parser_error (parser, "expected %<concurrent%>");
   18934            1 :       goto out_err;
   18935              :     }
   18936          372 :   c_parser_consume_token (parser);
   18937          372 :   parens.skip_until_found_close (parser);
   18938          372 :   check_no_duplicate_clause (list, OMP_CLAUSE_ORDER, "order");
   18939          372 :   c = build_omp_clause (loc, OMP_CLAUSE_ORDER);
   18940          372 :   OMP_CLAUSE_ORDER_UNCONSTRAINED (c) = unconstrained;
   18941          372 :   OMP_CLAUSE_ORDER_REPRODUCIBLE (c) = reproducible;
   18942          372 :   OMP_CLAUSE_CHAIN (c) = list;
   18943          372 :   return c;
   18944              : 
   18945            2 :  out_err:
   18946            2 :   parens.skip_until_found_close (parser);
   18947            2 :   return list;
   18948              : }
   18949              : 
   18950              : 
   18951              : /* OpenMP 5.0:
   18952              :    bind ( teams | parallel | thread ) */
   18953              : 
   18954              : static tree
   18955          122 : c_parser_omp_clause_bind (c_parser *parser, tree list)
   18956              : {
   18957          122 :   location_t loc = c_parser_peek_token (parser)->location;
   18958          122 :   tree c;
   18959          122 :   const char *p;
   18960          122 :   enum omp_clause_bind_kind kind = OMP_CLAUSE_BIND_THREAD;
   18961              : 
   18962          122 :   matching_parens parens;
   18963          122 :   if (!parens.require_open (parser))
   18964              :     return list;
   18965          120 :   if (!c_parser_next_token_is (parser, CPP_NAME))
   18966              :     {
   18967            3 :      invalid:
   18968            4 :       c_parser_error (parser,
   18969              :                       "expected %<teams%>, %<parallel%> or %<thread%>");
   18970            4 :       parens.skip_until_found_close (parser);
   18971            4 :       return list;
   18972              :     }
   18973          117 :   p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   18974          117 :   if (strcmp (p, "teams") == 0)
   18975              :     kind = OMP_CLAUSE_BIND_TEAMS;
   18976           78 :   else if (strcmp (p, "parallel") == 0)
   18977              :     kind = OMP_CLAUSE_BIND_PARALLEL;
   18978           41 :   else if (strcmp (p, "thread") != 0)
   18979            1 :     goto invalid;
   18980          116 :   c_parser_consume_token (parser);
   18981          116 :   parens.skip_until_found_close (parser);
   18982              :   /* check_no_duplicate_clause (list, OMP_CLAUSE_BIND, "bind"); */
   18983          116 :   c = build_omp_clause (loc, OMP_CLAUSE_BIND);
   18984          116 :   OMP_CLAUSE_BIND_KIND (c) = kind;
   18985          116 :   OMP_CLAUSE_CHAIN (c) = list;
   18986          116 :   return c;
   18987              : }
   18988              : 
   18989              : 
   18990              : /* OpenMP 2.5:
   18991              :    ordered
   18992              : 
   18993              :    OpenMP 4.5:
   18994              :    ordered ( constant-expression ) */
   18995              : 
   18996              : static tree
   18997          310 : c_parser_omp_clause_ordered (c_parser *parser, tree list)
   18998              : {
   18999          310 :   check_no_duplicate_clause (list, OMP_CLAUSE_ORDERED, "ordered");
   19000              : 
   19001          310 :   tree c, num = NULL_TREE;
   19002          310 :   HOST_WIDE_INT n;
   19003          310 :   location_t loc = c_parser_peek_token (parser)->location;
   19004          310 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   19005              :     {
   19006          169 :       matching_parens parens;
   19007          169 :       parens.consume_open (parser);
   19008          169 :       num = c_parser_expr_no_commas (parser, NULL).value;
   19009          169 :       parens.skip_until_found_close (parser);
   19010              :     }
   19011          310 :   if (num == error_mark_node)
   19012              :     return list;
   19013          310 :   if (num)
   19014              :     {
   19015          169 :       mark_exp_read (num);
   19016          169 :       num = c_fully_fold (num, false, NULL);
   19017          338 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (num))
   19018          169 :           || !tree_fits_shwi_p (num)
   19019          169 :           || (n = tree_to_shwi (num)) <= 0
   19020          338 :           || (int) n != n)
   19021              :         {
   19022            0 :           error_at (loc, "ordered argument needs positive "
   19023              :                          "constant integer expression");
   19024            0 :           return list;
   19025              :         }
   19026              :     }
   19027          310 :   c = build_omp_clause (loc, OMP_CLAUSE_ORDERED);
   19028          310 :   OMP_CLAUSE_ORDERED_EXPR (c) = num;
   19029          310 :   OMP_CLAUSE_CHAIN (c) = list;
   19030          310 :   return c;
   19031              : }
   19032              : 
   19033              : /* OpenMP 2.5:
   19034              :    private ( variable-list ) */
   19035              : 
   19036              : static tree
   19037          767 : c_parser_omp_clause_private (c_parser *parser, tree list)
   19038              : {
   19039          701 :   return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_PRIVATE, list);
   19040              : }
   19041              : 
   19042              : /* OpenMP 2.5:
   19043              :    reduction ( reduction-operator : variable-list )
   19044              : 
   19045              :    reduction-operator:
   19046              :      One of: + * - & ^ | && ||
   19047              : 
   19048              :    OpenMP 3.1:
   19049              : 
   19050              :    reduction-operator:
   19051              :      One of: + * - & ^ | && || max min
   19052              : 
   19053              :    OpenMP 4.0:
   19054              : 
   19055              :    reduction-operator:
   19056              :      One of: + * - & ^ | && ||
   19057              :      identifier
   19058              : 
   19059              :    OpenMP 5.0:
   19060              :    reduction ( reduction-modifier, reduction-operator : variable-list )
   19061              :    in_reduction ( reduction-operator : variable-list )
   19062              :    task_reduction ( reduction-operator : variable-list )  */
   19063              : 
   19064              : static tree
   19065         3227 : c_parser_omp_clause_reduction (c_parser *parser, enum omp_clause_code kind,
   19066              :                                bool is_omp, tree list)
   19067              : {
   19068         3227 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   19069         3227 :   matching_parens parens;
   19070         3227 :   if (parens.require_open (parser))
   19071              :     {
   19072         3227 :       bool task = false;
   19073         3227 :       bool inscan = false;
   19074         3227 :       enum tree_code code = ERROR_MARK;
   19075         3227 :       tree reduc_id = NULL_TREE;
   19076              : 
   19077         3227 :       if (kind == OMP_CLAUSE_REDUCTION && is_omp)
   19078              :         {
   19079         1914 :           if (c_parser_next_token_is_keyword (parser, RID_DEFAULT)
   19080         1914 :               && c_parser_peek_2nd_token (parser)->type == CPP_COMMA)
   19081              :             {
   19082           87 :               c_parser_consume_token (parser);
   19083           87 :               c_parser_consume_token (parser);
   19084              :             }
   19085         1827 :           else if (c_parser_next_token_is (parser, CPP_NAME)
   19086         1827 :                    && c_parser_peek_2nd_token (parser)->type == CPP_COMMA)
   19087              :             {
   19088          472 :               const char *p
   19089          472 :                 = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   19090          472 :               if (strcmp (p, "task") == 0)
   19091              :                 task = true;
   19092          289 :               else if (strcmp (p, "inscan") == 0)
   19093              :                 inscan = true;
   19094              :               if (task || inscan)
   19095              :                 {
   19096          472 :                   c_parser_consume_token (parser);
   19097          472 :                   c_parser_consume_token (parser);
   19098              :                 }
   19099              :             }
   19100              :         }
   19101              : 
   19102         3227 :       switch (c_parser_peek_token (parser)->type)
   19103              :         {
   19104              :         case CPP_PLUS:
   19105              :           code = PLUS_EXPR;
   19106              :           break;
   19107          265 :         case CPP_MULT:
   19108          265 :           code = MULT_EXPR;
   19109          265 :           break;
   19110          167 :         case CPP_MINUS:
   19111          167 :           if (is_omp)
   19112              :             {
   19113           14 :               location_t loc = c_parser_peek_token (parser)->location;
   19114           14 :               gcc_rich_location richloc (loc);
   19115           14 :               richloc.add_fixit_replace ("+");
   19116           14 :               warning_at (&richloc, OPT_Wdeprecated_openmp,
   19117              :                           "%<-%> operator for reductions deprecated in "
   19118              :                           "OpenMP 5.2");
   19119           14 :             }
   19120              :           code = MINUS_EXPR;
   19121              :           break;
   19122           33 :         case CPP_AND:
   19123           33 :           code = BIT_AND_EXPR;
   19124           33 :           break;
   19125           20 :         case CPP_XOR:
   19126           20 :           code = BIT_XOR_EXPR;
   19127           20 :           break;
   19128           88 :         case CPP_OR:
   19129           88 :           code = BIT_IOR_EXPR;
   19130           88 :           break;
   19131           77 :         case CPP_AND_AND:
   19132           77 :           code = TRUTH_ANDIF_EXPR;
   19133           77 :           break;
   19134           88 :         case CPP_OR_OR:
   19135           88 :           code = TRUTH_ORIF_EXPR;
   19136           88 :           break;
   19137          277 :         case CPP_NAME:
   19138          277 :           {
   19139          277 :             const char *p
   19140          277 :               = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   19141          277 :             if (strcmp (p, "min") == 0)
   19142              :               {
   19143              :                 code = MIN_EXPR;
   19144              :                 break;
   19145              :               }
   19146          227 :             if (strcmp (p, "max") == 0)
   19147              :               {
   19148              :                 code = MAX_EXPR;
   19149              :                 break;
   19150              :               }
   19151          132 :             reduc_id = c_parser_peek_token (parser)->value;
   19152          132 :             break;
   19153              :           }
   19154            0 :         default:
   19155            0 :           c_parser_error (parser,
   19156              :                           "expected %<+%>, %<*%>, %<-%>, %<&%>, "
   19157              :                           "%<^%>, %<|%>, %<&&%>, %<||%> or identifier");
   19158            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, 0);
   19159            0 :           return list;
   19160              :         }
   19161         3227 :       c_parser_consume_token (parser);
   19162         3227 :       reduc_id = c_omp_reduction_id (code, reduc_id);
   19163         3227 :       if (c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   19164              :         {
   19165         3227 :           tree nl, c;
   19166              : 
   19167         3227 :           nl = c_parser_omp_variable_list (parser, clause_loc, kind, list);
   19168        10299 :           for (c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   19169              :             {
   19170         3845 :               tree d = OMP_CLAUSE_DECL (c), type;
   19171         3845 :               if (TREE_CODE (d) != OMP_ARRAY_SECTION)
   19172         3324 :                 type = TREE_TYPE (d);
   19173              :               else
   19174              :                 {
   19175              :                   int cnt = 0;
   19176              :                   tree t;
   19177          638 :                   for (t = d;
   19178         1159 :                       TREE_CODE (t) == OMP_ARRAY_SECTION;
   19179          638 :                       t = TREE_OPERAND (t, 0))
   19180          638 :                     cnt++;
   19181          521 :                   type = TREE_TYPE (t);
   19182         1157 :                   while (cnt > 0)
   19183              :                     {
   19184          638 :                       if (TREE_CODE (type) != POINTER_TYPE
   19185          401 :                           && TREE_CODE (type) != ARRAY_TYPE)
   19186              :                         break;
   19187          636 :                       type = TREE_TYPE (type);
   19188          636 :                       cnt--;
   19189              :                     }
   19190              :                 }
   19191         3938 :               while (TREE_CODE (type) == ARRAY_TYPE)
   19192           93 :                 type = TREE_TYPE (type);
   19193         3845 :               OMP_CLAUSE_REDUCTION_CODE (c) = code;
   19194         3845 :               if (task)
   19195          215 :                 OMP_CLAUSE_REDUCTION_TASK (c) = 1;
   19196         3630 :               else if (inscan)
   19197          404 :                 OMP_CLAUSE_REDUCTION_INSCAN (c) = 1;
   19198         3845 :               if (code == ERROR_MARK
   19199          226 :                   || !(INTEGRAL_TYPE_P (type)
   19200         3703 :                        || SCALAR_FLOAT_TYPE_P (type)
   19201              :                        || TREE_CODE (type) == COMPLEX_TYPE))
   19202          278 :                 OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)
   19203          556 :                   = c_omp_reduction_lookup (reduc_id,
   19204          278 :                                             TYPE_MAIN_VARIANT (type));
   19205              :             }
   19206              : 
   19207              :           list = nl;
   19208              :         }
   19209         3227 :       parens.skip_until_found_close (parser);
   19210              :     }
   19211              :   return list;
   19212              : }
   19213              : 
   19214              : /* OpenMP 2.5:
   19215              :    schedule ( schedule-kind )
   19216              :    schedule ( schedule-kind , expression )
   19217              : 
   19218              :    schedule-kind:
   19219              :      static | dynamic | guided | runtime | auto
   19220              : 
   19221              :    OpenMP 4.5:
   19222              :    schedule ( schedule-modifier : schedule-kind )
   19223              :    schedule ( schedule-modifier [ , schedule-modifier ] : schedule-kind , expression )
   19224              : 
   19225              :    schedule-modifier:
   19226              :      simd
   19227              :      monotonic
   19228              :      nonmonotonic  */
   19229              : 
   19230              : static tree
   19231         3487 : c_parser_omp_clause_schedule (c_parser *parser, tree list)
   19232              : {
   19233         3487 :   tree c, t;
   19234         3487 :   location_t loc = c_parser_peek_token (parser)->location;
   19235         3487 :   int modifiers = 0, nmodifiers = 0;
   19236              : 
   19237         3487 :   matching_parens parens;
   19238         3487 :   if (!parens.require_open (parser))
   19239              :     return list;
   19240              : 
   19241         3485 :   c = build_omp_clause (loc, OMP_CLAUSE_SCHEDULE);
   19242              : 
   19243         3485 :   location_t comma = UNKNOWN_LOCATION;
   19244         6984 :   while (c_parser_next_token_is (parser, CPP_NAME))
   19245              :     {
   19246         1782 :       tree kind = c_parser_peek_token (parser)->value;
   19247         1782 :       const char *p = IDENTIFIER_POINTER (kind);
   19248         1782 :       if (strcmp ("simd", p) == 0)
   19249           31 :         OMP_CLAUSE_SCHEDULE_SIMD (c) = 1;
   19250         1751 :       else if (strcmp ("monotonic", p) == 0)
   19251           74 :         modifiers |= OMP_CLAUSE_SCHEDULE_MONOTONIC;
   19252         1677 :       else if (strcmp ("nonmonotonic", p) == 0)
   19253           84 :         modifiers |= OMP_CLAUSE_SCHEDULE_NONMONOTONIC;
   19254              :       else
   19255              :         break;
   19256          189 :       comma = UNKNOWN_LOCATION;
   19257          189 :       c_parser_consume_token (parser);
   19258          189 :       if (nmodifiers++ == 0
   19259          367 :           && c_parser_next_token_is (parser, CPP_COMMA))
   19260              :         {
   19261           14 :           comma = c_parser_peek_token (parser)->location;
   19262           14 :           c_parser_consume_token (parser);
   19263              :         }
   19264              :       else
   19265              :         {
   19266          175 :           c_parser_require (parser, CPP_COLON, "expected %<:%>");
   19267          175 :           break;
   19268              :         }
   19269              :     }
   19270         3485 :   if (comma != UNKNOWN_LOCATION)
   19271            3 :     error_at (comma, "expected %<:%>");
   19272              : 
   19273         3485 :   if ((modifiers & (OMP_CLAUSE_SCHEDULE_MONOTONIC
   19274              :                     | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
   19275              :       == (OMP_CLAUSE_SCHEDULE_MONOTONIC
   19276              :           | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
   19277              :     {
   19278            2 :       error_at (loc, "both %<monotonic%> and %<nonmonotonic%> modifiers "
   19279              :                      "specified");
   19280            2 :       modifiers = 0;
   19281              :     }
   19282              : 
   19283         3485 :   if (c_parser_next_token_is (parser, CPP_NAME))
   19284              :     {
   19285         1710 :       tree kind = c_parser_peek_token (parser)->value;
   19286         1710 :       const char *p = IDENTIFIER_POINTER (kind);
   19287              : 
   19288         1710 :       switch (p[0])
   19289              :         {
   19290          170 :         case 'd':
   19291          170 :           if (strcmp ("dynamic", p) != 0)
   19292            0 :             goto invalid_kind;
   19293          170 :           OMP_CLAUSE_SCHEDULE_KIND (c) = OMP_CLAUSE_SCHEDULE_DYNAMIC;
   19294          170 :           break;
   19295              : 
   19296          762 :         case 'g':
   19297          762 :           if (strcmp ("guided", p) != 0)
   19298            0 :             goto invalid_kind;
   19299          762 :           OMP_CLAUSE_SCHEDULE_KIND (c) = OMP_CLAUSE_SCHEDULE_GUIDED;
   19300          762 :           break;
   19301              : 
   19302          777 :         case 'r':
   19303          777 :           if (strcmp ("runtime", p) != 0)
   19304            0 :             goto invalid_kind;
   19305          777 :           OMP_CLAUSE_SCHEDULE_KIND (c) = OMP_CLAUSE_SCHEDULE_RUNTIME;
   19306          777 :           break;
   19307              : 
   19308            1 :         default:
   19309            1 :           goto invalid_kind;
   19310              :         }
   19311              :     }
   19312         1775 :   else if (c_parser_next_token_is_keyword (parser, RID_STATIC))
   19313         1094 :     OMP_CLAUSE_SCHEDULE_KIND (c) = OMP_CLAUSE_SCHEDULE_STATIC;
   19314          681 :   else if (c_parser_next_token_is_keyword (parser, RID_AUTO))
   19315          680 :     OMP_CLAUSE_SCHEDULE_KIND (c) = OMP_CLAUSE_SCHEDULE_AUTO;
   19316              :   else
   19317            1 :     goto invalid_kind;
   19318              : 
   19319         3483 :   c_parser_consume_token (parser);
   19320         3483 :   if (c_parser_next_token_is (parser, CPP_COMMA))
   19321              :     {
   19322         1810 :       location_t here;
   19323         1810 :       c_parser_consume_token (parser);
   19324              : 
   19325         1810 :       here = c_parser_peek_token (parser)->location;
   19326         1810 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   19327         1810 :       expr = convert_lvalue_to_rvalue (here, expr, false, true);
   19328         1810 :       t = expr.value;
   19329         1810 :       t = c_fully_fold (t, false, NULL);
   19330              : 
   19331         1810 :       if (OMP_CLAUSE_SCHEDULE_KIND (c) == OMP_CLAUSE_SCHEDULE_RUNTIME)
   19332            1 :         error_at (here, "schedule %<runtime%> does not take "
   19333              :                   "a %<chunk_size%> parameter");
   19334         1809 :       else if (OMP_CLAUSE_SCHEDULE_KIND (c) == OMP_CLAUSE_SCHEDULE_AUTO)
   19335            0 :         error_at (here,
   19336              :                   "schedule %<auto%> does not take "
   19337              :                   "a %<chunk_size%> parameter");
   19338         1809 :       else if (TREE_CODE (TREE_TYPE (t)) == INTEGER_TYPE
   19339         1809 :                || TREE_CODE (TREE_TYPE (t)) == BITINT_TYPE)
   19340              :         {
   19341              :           /* Attempt to statically determine when the number isn't
   19342              :              positive.  */
   19343         1808 :           tree s = fold_build2_loc (loc, LE_EXPR, boolean_type_node, t,
   19344         1808 :                                     build_int_cst (TREE_TYPE (t), 0));
   19345         1808 :           protected_set_expr_location (s, loc);
   19346         1808 :           if (s == boolean_true_node)
   19347              :             {
   19348            2 :               warning_at (loc, OPT_Wopenmp,
   19349              :                           "chunk size value must be positive");
   19350            2 :               t = integer_one_node;
   19351              :             }
   19352         1808 :           OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = t;
   19353              :         }
   19354              :       else
   19355            1 :         c_parser_error (parser, "expected integer expression");
   19356              : 
   19357         1810 :       parens.skip_until_found_close (parser);
   19358              :     }
   19359              :   else
   19360         1673 :     c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   19361              :                                "expected %<,%> or %<)%>");
   19362              : 
   19363         6966 :   OMP_CLAUSE_SCHEDULE_KIND (c)
   19364         6966 :     = (enum omp_clause_schedule_kind)
   19365         3483 :       (OMP_CLAUSE_SCHEDULE_KIND (c) | modifiers);
   19366              : 
   19367         3483 :   check_no_duplicate_clause (list, OMP_CLAUSE_SCHEDULE, "schedule");
   19368         3483 :   OMP_CLAUSE_CHAIN (c) = list;
   19369         3483 :   return c;
   19370              : 
   19371            2 :  invalid_kind:
   19372            2 :   c_parser_error (parser, "invalid schedule kind");
   19373            2 :   c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, 0);
   19374            2 :   return list;
   19375              : }
   19376              : 
   19377              : /* OpenMP 2.5:
   19378              :    shared ( variable-list ) */
   19379              : 
   19380              : static tree
   19381          711 : c_parser_omp_clause_shared (c_parser *parser, tree list)
   19382              : {
   19383          711 :   return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_SHARED, list);
   19384              : }
   19385              : 
   19386              : /* OpenMP 3.0:
   19387              :    untied */
   19388              : 
   19389              : static tree
   19390           97 : c_parser_omp_clause_untied (c_parser *parser ATTRIBUTE_UNUSED, tree list)
   19391              : {
   19392           97 :   tree c;
   19393              : 
   19394              :   /* FIXME: Should we allow duplicates?  */
   19395           97 :   check_no_duplicate_clause (list, OMP_CLAUSE_UNTIED, "untied");
   19396              : 
   19397           97 :   c = build_omp_clause (c_parser_peek_token (parser)->location,
   19398              :                         OMP_CLAUSE_UNTIED);
   19399           97 :   OMP_CLAUSE_CHAIN (c) = list;
   19400              : 
   19401           97 :   return c;
   19402              : }
   19403              : 
   19404              : /* OpenMP 4.0:
   19405              :    inbranch
   19406              :    notinbranch */
   19407              : 
   19408              : static tree
   19409          223 : c_parser_omp_clause_branch (c_parser *parser ATTRIBUTE_UNUSED,
   19410              :                             enum omp_clause_code code, tree list)
   19411              : {
   19412          223 :   check_no_duplicate_clause (list, code, omp_clause_code_name[code]);
   19413              : 
   19414          223 :   tree c = build_omp_clause (c_parser_peek_token (parser)->location, code);
   19415          223 :   OMP_CLAUSE_CHAIN (c) = list;
   19416              : 
   19417          223 :   return c;
   19418              : }
   19419              : 
   19420              : /* OpenMP 4.0:
   19421              :    parallel
   19422              :    for
   19423              :    sections
   19424              :    taskgroup */
   19425              : 
   19426              : static tree
   19427          387 : c_parser_omp_clause_cancelkind (c_parser *parser ATTRIBUTE_UNUSED,
   19428              :                                 enum omp_clause_code code, tree list)
   19429              : {
   19430          387 :   tree c = build_omp_clause (c_parser_peek_token (parser)->location, code);
   19431          387 :   OMP_CLAUSE_CHAIN (c) = list;
   19432              : 
   19433          387 :   return c;
   19434              : }
   19435              : 
   19436              : /* OpenMP 4.5:
   19437              :    nogroup */
   19438              : 
   19439              : static tree
   19440           18 : c_parser_omp_clause_nogroup (c_parser *parser ATTRIBUTE_UNUSED, tree list)
   19441              : {
   19442           18 :   check_no_duplicate_clause (list, OMP_CLAUSE_NOGROUP, "nogroup");
   19443           18 :   tree c = build_omp_clause (c_parser_peek_token (parser)->location,
   19444              :                              OMP_CLAUSE_NOGROUP);
   19445           18 :   OMP_CLAUSE_CHAIN (c) = list;
   19446           18 :   return c;
   19447              : }
   19448              : 
   19449              : /* OpenMP 4.5:
   19450              :    simd
   19451              :    threads */
   19452              : 
   19453              : static tree
   19454          103 : c_parser_omp_clause_orderedkind (c_parser *parser ATTRIBUTE_UNUSED,
   19455              :                                  enum omp_clause_code code, tree list)
   19456              : {
   19457          103 :   check_no_duplicate_clause (list, code, omp_clause_code_name[code]);
   19458          103 :   tree c = build_omp_clause (c_parser_peek_token (parser)->location, code);
   19459          103 :   OMP_CLAUSE_CHAIN (c) = list;
   19460          103 :   return c;
   19461              : }
   19462              : 
   19463              : /* OpenMP 4.0:
   19464              :    num_teams ( expression )
   19465              : 
   19466              :    OpenMP 5.1:
   19467              :    num_teams ( expression : expression ) */
   19468              : 
   19469              : static tree
   19470          206 : c_parser_omp_clause_num_teams (c_parser *parser, tree list)
   19471              : {
   19472          206 :   location_t num_teams_loc = c_parser_peek_token (parser)->location;
   19473          206 :   matching_parens parens;
   19474          206 :   if (parens.require_open (parser))
   19475              :     {
   19476          206 :       location_t upper_loc = c_parser_peek_token (parser)->location;
   19477          206 :       location_t lower_loc = UNKNOWN_LOCATION;
   19478          206 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   19479          206 :       expr = convert_lvalue_to_rvalue (upper_loc, expr, false, true);
   19480          206 :       tree c, upper = expr.value, lower = NULL_TREE;
   19481          206 :       upper = c_fully_fold (upper, false, NULL);
   19482              : 
   19483          206 :       if (c_parser_next_token_is (parser, CPP_COLON))
   19484              :         {
   19485           51 :           c_parser_consume_token (parser);
   19486           51 :           lower_loc = upper_loc;
   19487           51 :           lower = upper;
   19488           51 :           upper_loc = c_parser_peek_token (parser)->location;
   19489           51 :           expr = c_parser_expr_no_commas (parser, NULL);
   19490           51 :           expr = convert_lvalue_to_rvalue (upper_loc, expr, false, true);
   19491           51 :           upper = expr.value;
   19492           51 :           upper = c_fully_fold (upper, false, NULL);
   19493              :         }
   19494              : 
   19495          206 :       parens.skip_until_found_close (parser);
   19496              : 
   19497          412 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (upper))
   19498          412 :           || (lower && !INTEGRAL_TYPE_P (TREE_TYPE (lower))))
   19499              :         {
   19500            0 :           c_parser_error (parser, "expected integer expression");
   19501            0 :           return list;
   19502              :         }
   19503              : 
   19504              :       /* Attempt to statically determine when the number isn't positive.  */
   19505          206 :       c = fold_build2_loc (upper_loc, LE_EXPR, boolean_type_node, upper,
   19506          206 :                            build_int_cst (TREE_TYPE (upper), 0));
   19507          206 :       protected_set_expr_location (c, upper_loc);
   19508          206 :       if (c == boolean_true_node)
   19509              :         {
   19510            4 :           warning_at (upper_loc, OPT_Wopenmp,
   19511              :                       "%<num_teams%> value must be positive");
   19512            4 :           upper = integer_one_node;
   19513              :         }
   19514          206 :       if (lower)
   19515              :         {
   19516           51 :           c = fold_build2_loc (lower_loc, LE_EXPR, boolean_type_node, lower,
   19517           51 :                                build_int_cst (TREE_TYPE (lower), 0));
   19518           51 :           protected_set_expr_location (c, lower_loc);
   19519           51 :           if (c == boolean_true_node)
   19520              :             {
   19521            2 :               warning_at (lower_loc, OPT_Wopenmp,
   19522              :                           "%<num_teams%> value must be positive");
   19523            2 :               lower = NULL_TREE;
   19524              :             }
   19525           49 :           else if (TREE_CODE (lower) == INTEGER_CST
   19526            7 :                    && TREE_CODE (upper) == INTEGER_CST
   19527           54 :                    && tree_int_cst_lt (upper, lower))
   19528              :             {
   19529            2 :               warning_at (lower_loc, OPT_Wopenmp,
   19530              :                           "%<num_teams%> lower bound %qE bigger than upper "
   19531              :                           "bound %qE", lower, upper);
   19532            2 :               lower = NULL_TREE;
   19533              :             }
   19534              :         }
   19535              : 
   19536          206 :       check_no_duplicate_clause (list, OMP_CLAUSE_NUM_TEAMS, "num_teams");
   19537              : 
   19538          206 :       c = build_omp_clause (num_teams_loc, OMP_CLAUSE_NUM_TEAMS);
   19539          206 :       OMP_CLAUSE_NUM_TEAMS_UPPER_EXPR (c) = upper;
   19540          206 :       OMP_CLAUSE_NUM_TEAMS_LOWER_EXPR (c) = lower;
   19541          206 :       OMP_CLAUSE_CHAIN (c) = list;
   19542          206 :       list = c;
   19543              :     }
   19544              : 
   19545              :   return list;
   19546              : }
   19547              : 
   19548              : /* OpenMP 4.0:
   19549              :    thread_limit ( expression ) */
   19550              : 
   19551              : static tree
   19552          155 : c_parser_omp_clause_thread_limit (c_parser *parser, tree list)
   19553              : {
   19554          155 :   location_t num_thread_limit_loc = c_parser_peek_token (parser)->location;
   19555          155 :   matching_parens parens;
   19556          155 :   if (parens.require_open (parser))
   19557              :     {
   19558          155 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   19559          155 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   19560          155 :       expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   19561          155 :       tree c, t = expr.value;
   19562          155 :       t = c_fully_fold (t, false, NULL);
   19563              : 
   19564          155 :       parens.skip_until_found_close (parser);
   19565              : 
   19566          155 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
   19567              :         {
   19568            0 :           c_parser_error (parser, "expected integer expression");
   19569            0 :           return list;
   19570              :         }
   19571              : 
   19572              :       /* Attempt to statically determine when the number isn't positive.  */
   19573          155 :       c = fold_build2_loc (expr_loc, LE_EXPR, boolean_type_node, t,
   19574          155 :                            build_int_cst (TREE_TYPE (t), 0));
   19575          155 :       protected_set_expr_location (c, expr_loc);
   19576          155 :       if (c == boolean_true_node)
   19577              :         {
   19578            0 :           warning_at (expr_loc, OPT_Wopenmp,
   19579              :                       "%<thread_limit%> value must be positive");
   19580            0 :           t = integer_one_node;
   19581              :         }
   19582              : 
   19583          155 :       check_no_duplicate_clause (list, OMP_CLAUSE_THREAD_LIMIT,
   19584              :                                  "thread_limit");
   19585              : 
   19586          155 :       c = build_omp_clause (num_thread_limit_loc, OMP_CLAUSE_THREAD_LIMIT);
   19587          155 :       OMP_CLAUSE_THREAD_LIMIT_EXPR (c) = t;
   19588          155 :       OMP_CLAUSE_CHAIN (c) = list;
   19589          155 :       list = c;
   19590              :     }
   19591              : 
   19592              :   return list;
   19593              : }
   19594              : 
   19595              : /* OpenMP 4.0:
   19596              :    aligned ( variable-list )
   19597              :    aligned ( variable-list : constant-expression ) */
   19598              : 
   19599              : static tree
   19600          228 : c_parser_omp_clause_aligned (c_parser *parser, tree list)
   19601              : {
   19602          228 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   19603          228 :   tree nl, c;
   19604              : 
   19605          228 :   matching_parens parens;
   19606          228 :   if (!parens.require_open (parser))
   19607              :     return list;
   19608              : 
   19609          228 :   nl = c_parser_omp_variable_list (parser, clause_loc,
   19610              :                                    OMP_CLAUSE_ALIGNED, list);
   19611              : 
   19612          228 :   if (c_parser_next_token_is (parser, CPP_COLON))
   19613              :     {
   19614          212 :       c_parser_consume_token (parser);
   19615          212 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   19616          212 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   19617          212 :       expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   19618          212 :       tree alignment = expr.value;
   19619          212 :       alignment = c_fully_fold (alignment, false, NULL);
   19620          212 :       if (TREE_CODE (alignment) != INTEGER_CST
   19621          210 :           || !INTEGRAL_TYPE_P (TREE_TYPE (alignment))
   19622          422 :           || tree_int_cst_sgn (alignment) != 1)
   19623              :         {
   19624            4 :           error_at (clause_loc, "%<aligned%> clause alignment expression must "
   19625              :                                 "be positive constant integer expression");
   19626            4 :           alignment = NULL_TREE;
   19627              :         }
   19628              : 
   19629          444 :       for (c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   19630          232 :         OMP_CLAUSE_ALIGNED_ALIGNMENT (c) = alignment;
   19631              :     }
   19632              : 
   19633          228 :   parens.skip_until_found_close (parser);
   19634          228 :   return nl;
   19635              : }
   19636              : 
   19637              : /* OpenMP 5.0:
   19638              :    allocate ( variable-list )
   19639              :    allocate ( expression : variable-list )
   19640              : 
   19641              :    OpenMP 5.1:
   19642              :    allocate ( allocator-modifier : variable-list )
   19643              :    allocate ( allocator-modifier , allocator-modifier : variable-list )
   19644              : 
   19645              :    allocator-modifier:
   19646              :    allocator ( expression )
   19647              :    align ( expression )  */
   19648              : 
   19649              : static tree
   19650          485 : c_parser_omp_clause_allocate (c_parser *parser, tree list)
   19651              : {
   19652          485 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   19653          485 :   tree nl, c;
   19654          485 :   tree allocator = NULL_TREE;
   19655          485 :   tree align = NULL_TREE;
   19656              : 
   19657          485 :   matching_parens parens;
   19658          485 :   if (!parens.require_open (parser))
   19659              :     return list;
   19660              : 
   19661          485 :   if ((c_parser_next_token_is_not (parser, CPP_NAME)
   19662            5 :        && c_parser_next_token_is_not (parser, CPP_KEYWORD))
   19663          485 :       || (c_parser_peek_2nd_token (parser)->type != CPP_COMMA
   19664          466 :           && c_parser_peek_2nd_token (parser)->type != CPP_CLOSE_PAREN))
   19665              :     {
   19666          220 :       bool has_modifiers = false;
   19667          220 :       tree orig_type = NULL_TREE;
   19668          220 :       if (c_parser_next_token_is (parser, CPP_NAME)
   19669          220 :           && c_parser_peek_2nd_token (parser)->type == CPP_OPEN_PAREN)
   19670              :         {
   19671           76 :           unsigned int n = 3;
   19672           76 :           const char *p
   19673           76 :             = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   19674           29 :           if ((strcmp (p, "allocator") == 0 || strcmp (p, "align") == 0)
   19675           74 :               && c_parser_check_balanced_raw_token_sequence (parser, &n)
   19676          150 :               && (c_parser_peek_nth_token_raw (parser, n)->type
   19677              :                   == CPP_CLOSE_PAREN))
   19678              :             {
   19679           74 :               if (c_parser_peek_nth_token_raw (parser, n + 1)->type
   19680              :                   == CPP_COLON)
   19681              :                 has_modifiers = true;
   19682           39 :               else if (c_parser_peek_nth_token_raw (parser, n + 1)->type
   19683              :                        == CPP_COMMA
   19684           39 :                        && (c_parser_peek_nth_token_raw (parser, n + 2)->type
   19685              :                            == CPP_NAME)
   19686           78 :                        && (c_parser_peek_nth_token_raw (parser, n + 3)->type
   19687              :                            == CPP_OPEN_PAREN))
   19688              :                 {
   19689           39 :                   c_token *tok = c_parser_peek_nth_token_raw (parser, n + 2);
   19690           39 :                   const char *q = IDENTIFIER_POINTER (tok->value);
   19691           39 :                   n += 4;
   19692           39 :                   if ((strcmp (q, "allocator") == 0
   19693           26 :                        || strcmp (q, "align") == 0)
   19694           39 :                       && c_parser_check_balanced_raw_token_sequence (parser,
   19695              :                                                                      &n)
   19696           39 :                       && (c_parser_peek_nth_token_raw (parser, n)->type
   19697              :                           == CPP_CLOSE_PAREN)
   19698           78 :                       && (c_parser_peek_nth_token_raw (parser, n + 1)->type
   19699              :                           == CPP_COLON))
   19700              :                     has_modifiers = true;
   19701              :                 }
   19702              :             }
   19703              :           if (has_modifiers)
   19704              :             {
   19705           74 :               c_parser_consume_token (parser);
   19706           74 :               matching_parens parens2;
   19707           74 :               parens2.require_open (parser);
   19708           74 :               location_t expr_loc = c_parser_peek_token (parser)->location;
   19709           74 :               c_expr expr = c_parser_expr_no_commas (parser, NULL);
   19710           74 :               expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   19711           74 :               if (expr.value == error_mark_node)
   19712              :                 ;
   19713           73 :               else if (strcmp (p, "allocator") == 0)
   19714              :                 {
   19715           46 :                   allocator = expr.value;
   19716           46 :                   allocator = c_fully_fold (allocator, false, NULL);
   19717            3 :                   orig_type = expr.original_type
   19718           46 :                               ? expr.original_type : TREE_TYPE (allocator);
   19719           46 :                   orig_type = TYPE_MAIN_VARIANT (orig_type);
   19720              :                 }
   19721              :               else
   19722              :                 {
   19723           27 :                   align = expr.value;
   19724           27 :                   align = c_fully_fold (align, false, NULL);
   19725              :                 }
   19726           74 :               parens2.skip_until_found_close (parser);
   19727           74 :               if (c_parser_next_token_is (parser, CPP_COMMA))
   19728              :                 {
   19729           39 :                   c_parser_consume_token (parser);
   19730           39 :                   c_token *tok = c_parser_peek_token (parser);
   19731           39 :                   const char *q = "";
   19732           39 :                   if (c_parser_next_token_is (parser, CPP_NAME))
   19733           39 :                     q = IDENTIFIER_POINTER (tok->value);
   19734           39 :                   if (strcmp (q, "allocator") != 0 && strcmp (q, "align") != 0)
   19735              :                     {
   19736            0 :                       c_parser_error (parser, "expected %<allocator%> or "
   19737              :                                               "%<align%>");
   19738            0 :                       parens.skip_until_found_close (parser);
   19739            2 :                       return list;
   19740              :                     }
   19741           39 :                   else if (strcmp (p, q) == 0)
   19742              :                     {
   19743            2 :                       error_at (tok->location, "duplicate %qs modifier", p);
   19744            2 :                       parens.skip_until_found_close (parser);
   19745            2 :                       return list;
   19746              :                     }
   19747           37 :                   c_parser_consume_token (parser);
   19748           37 :                   if (!parens2.require_open (parser))
   19749              :                     {
   19750            0 :                       parens.skip_until_found_close (parser);
   19751            0 :                       return list;
   19752              :                     }
   19753           37 :                   expr_loc = c_parser_peek_token (parser)->location;
   19754           37 :                   expr = c_parser_expr_no_commas (parser, NULL);
   19755           37 :                   expr = convert_lvalue_to_rvalue (expr_loc, expr, false,
   19756              :                                                    true);
   19757           37 :                   if (strcmp (q, "allocator") == 0)
   19758              :                     {
   19759           12 :                       allocator = expr.value;
   19760           12 :                       allocator = c_fully_fold (allocator, false, NULL);
   19761            2 :                       orig_type = expr.original_type
   19762           12 :                                   ? expr.original_type : TREE_TYPE (allocator);
   19763           12 :                       orig_type = TYPE_MAIN_VARIANT (orig_type);
   19764              :                     }
   19765              :                   else
   19766              :                     {
   19767           25 :                       align = expr.value;
   19768           25 :                       align = c_fully_fold (align, false, NULL);
   19769              :                     }
   19770           37 :                   parens2.skip_until_found_close (parser);
   19771              :                 }
   19772              :             }
   19773              :         }
   19774           74 :       if (!has_modifiers)
   19775              :         {
   19776          146 :           location_t expr_loc = c_parser_peek_token (parser)->location;
   19777          146 :           c_expr expr = c_parser_expr_no_commas (parser, NULL);
   19778          146 :           expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   19779          146 :           if (expr.value != error_mark_node)
   19780              :             {
   19781          145 :               allocator = expr.value;
   19782          145 :               allocator = c_fully_fold (allocator, false, NULL);
   19783            7 :               orig_type = expr.original_type
   19784          145 :                           ? expr.original_type : TREE_TYPE (allocator);
   19785          145 :               orig_type = TYPE_MAIN_VARIANT (orig_type);
   19786              :             }
   19787              :         }
   19788          218 :       if (allocator
   19789          218 :           && (!INTEGRAL_TYPE_P (TREE_TYPE (allocator))
   19790          200 :               || TREE_CODE (orig_type) != ENUMERAL_TYPE
   19791          396 :               || (TYPE_NAME (orig_type)
   19792          198 :                   != get_identifier ("omp_allocator_handle_t"))))
   19793              :         {
   19794            8 :           error_at (clause_loc, "%<allocate%> clause allocator expression "
   19795              :                                 "has type %qT rather than "
   19796              :                                 "%<omp_allocator_handle_t%>",
   19797            4 :                                 TREE_TYPE (allocator));
   19798            4 :           allocator = NULL_TREE;
   19799              :         }
   19800          218 :       if (align
   19801          218 :           && (!INTEGRAL_TYPE_P (TREE_TYPE (align))
   19802           50 :               || !tree_fits_uhwi_p (align)
   19803           49 :               || !integer_pow2p (align)))
   19804              :         {
   19805            4 :           error_at (clause_loc, "%<allocate%> clause %<align%> modifier "
   19806              :                                 "argument needs to be positive constant "
   19807              :                                 "power of two integer expression");
   19808            4 :           align = NULL_TREE;
   19809              :         }
   19810          218 :       if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   19811              :         {
   19812            0 :           parens.skip_until_found_close (parser);
   19813            0 :           return list;
   19814              :         }
   19815              :     }
   19816              : 
   19817          483 :   nl = c_parser_omp_variable_list (parser, clause_loc,
   19818              :                                    OMP_CLAUSE_ALLOCATE, list);
   19819              : 
   19820          483 :   if (allocator || align)
   19821          508 :     for (c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   19822              :       {
   19823          300 :         OMP_CLAUSE_ALLOCATE_ALLOCATOR (c) = allocator;
   19824          300 :         OMP_CLAUSE_ALLOCATE_ALIGN (c) = align;
   19825              :       }
   19826              : 
   19827          483 :   parens.skip_until_found_close (parser);
   19828          483 :   return nl;
   19829              : }
   19830              : 
   19831              : /* OpenMP 5.0:
   19832              :    uses_allocators ( allocator-list )
   19833              : 
   19834              :    allocator-list:
   19835              :    allocator
   19836              :    allocator , allocator-list
   19837              :    allocator ( traits-array )
   19838              :    allocator ( traits-array ) , allocator-list
   19839              : 
   19840              :    Deprecated in 5.2, removed in 6.0: 'allocator(trait-array)' syntax.
   19841              : 
   19842              :    OpenMP 5.2:
   19843              : 
   19844              :    uses_allocators ( modifier : allocator-list )
   19845              :    uses_allocators ( modifier , modifier : allocator-list )
   19846              : 
   19847              :    OpenMP 6.0:
   19848              :    uses_allocators ( [modifier-list :] allocator-list [; ...] )
   19849              : 
   19850              :    modifier:
   19851              :    traits ( traits-array )
   19852              :    memspace ( mem-space-handle )  */
   19853              : 
   19854              : static tree
   19855           55 : c_parser_omp_clause_uses_allocators (c_parser *parser, tree list)
   19856              : {
   19857           55 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   19858           55 :   tree nl = list;
   19859           55 :   matching_parens parens;
   19860           55 :   if (!parens.require_open (parser))
   19861              :     return list;
   19862              : 
   19863           55 : parse_next:
   19864              : 
   19865           59 :   bool has_modifiers = false;
   19866           59 :   bool seen_allocators = false;
   19867           59 :   tree memspace_expr = NULL_TREE;
   19868           59 :   tree traits_var = NULL_TREE;
   19869              : 
   19870           59 :   if (c_parser_next_token_is (parser, CPP_NAME)
   19871           59 :       && c_parser_peek_2nd_token (parser)->type == CPP_OPEN_PAREN)
   19872              :     {
   19873           38 :       unsigned int n = 3;
   19874           38 :       const char *p
   19875           38 :         = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   19876           25 :       if ((strcmp (p, "traits") == 0 || strcmp (p, "memspace") == 0)
   19877           26 :           && c_parser_check_balanced_raw_token_sequence (parser, &n)
   19878           64 :           && (c_parser_peek_nth_token_raw (parser, n)->type
   19879              :               == CPP_CLOSE_PAREN))
   19880              :         {
   19881           26 :           if (c_parser_peek_nth_token_raw (parser, n + 1)->type
   19882              :               == CPP_COLON)
   19883              :             has_modifiers = true;
   19884            9 :           else if (c_parser_peek_nth_token_raw (parser, n + 1)->type
   19885              :                    == CPP_COMMA
   19886            8 :                    && (c_parser_peek_nth_token_raw (parser, n + 2)->type
   19887              :                        == CPP_NAME)
   19888           17 :                    && (c_parser_peek_nth_token_raw (parser, n + 3)->type
   19889              :                        == CPP_OPEN_PAREN))
   19890              :             {
   19891            7 :               c_token *tok = c_parser_peek_nth_token_raw (parser, n + 2);
   19892            7 :               const char *q = IDENTIFIER_POINTER (tok->value);
   19893            7 :               n += 4;
   19894            7 :               if ((strcmp (q, "traits") == 0
   19895            3 :                    || strcmp (q, "memspace") == 0)
   19896            7 :                   && c_parser_check_balanced_raw_token_sequence (parser, &n)
   19897           14 :                   && (c_parser_peek_nth_token_raw (parser, n)->type
   19898              :                       == CPP_CLOSE_PAREN))
   19899              :                 {
   19900            7 :                   if (c_parser_peek_nth_token_raw (parser, n + 1)->type
   19901              :                       == CPP_COLON)
   19902            6 :                     has_modifiers = true;
   19903            7 :                   if ((c_parser_peek_nth_token_raw (parser, n + 1)->type
   19904              :                        == CPP_COMMA)
   19905            7 :                       && (c_parser_peek_nth_token_raw (parser, n + 2)->type
   19906              :                           == CPP_NAME))
   19907              :                     {
   19908            1 :                       c_token *tok
   19909            1 :                         = c_parser_peek_nth_token_raw (parser, n + 2);
   19910            1 :                       const char *m = IDENTIFIER_POINTER (tok->value);
   19911            1 :                       if (strcmp (p, m) == 0 || strcmp (q, m) == 0)
   19912              :                         {
   19913            1 :                           error_at (tok->location, "duplicate %qs modifier", m);
   19914            1 :                           goto end;
   19915              :                         }
   19916              :                     }
   19917              :                 }
   19918              :             }
   19919              :         }
   19920            6 :       if (has_modifiers)
   19921              :         {
   19922           23 :           c_parser_consume_token (parser);
   19923           23 :           matching_parens parens2;
   19924           23 :           parens2.require_open (parser);
   19925           23 :           c_expr expr = c_parser_expr_no_commas (parser, NULL);
   19926           23 :           if (expr.value == error_mark_node)
   19927              :             ;
   19928           20 :           else if (strcmp (p, "traits") == 0)
   19929              :             {
   19930           11 :               traits_var = expr.value;
   19931           11 :               traits_var = c_fully_fold (traits_var, false, NULL);
   19932           11 :               mark_exp_read (traits_var);
   19933              :             }
   19934              :           else
   19935              :             {
   19936            9 :               memspace_expr = expr.value;
   19937            9 :               memspace_expr = c_fully_fold (memspace_expr, false, NULL);
   19938              :             }
   19939           23 :           parens2.skip_until_found_close (parser);
   19940           23 :           if (c_parser_next_token_is (parser, CPP_COMMA))
   19941              :             {
   19942            6 :               c_parser_consume_token (parser);
   19943            6 :               c_token *tok = c_parser_peek_token (parser);
   19944            6 :               const char *q = "";
   19945            6 :               if (c_parser_next_token_is (parser, CPP_NAME))
   19946            6 :                 q = IDENTIFIER_POINTER (tok->value);
   19947            6 :               if (strcmp (q, "traits") != 0 && strcmp (q, "memspace") != 0)
   19948              :                 {
   19949            0 :                   c_parser_error (parser, "expected %<traits%> or "
   19950              :                                   "%<memspace%>");
   19951            0 :                   parens.skip_until_found_close (parser);
   19952            0 :                   return list;
   19953              :                 }
   19954            6 :               else if (strcmp (p, q) == 0)
   19955              :                 {
   19956            0 :                   error_at (tok->location, "duplicate %qs modifier", p);
   19957            0 :                   parens.skip_until_found_close (parser);
   19958            0 :                   return list;
   19959              :                 }
   19960            6 :               c_parser_consume_token (parser);
   19961            6 :               if (!parens2.require_open (parser))
   19962              :                 {
   19963            0 :                   parens.skip_until_found_close (parser);
   19964            0 :                   return list;
   19965              :                 }
   19966            6 :               expr = c_parser_expr_no_commas (parser, NULL);
   19967            6 :               if (strcmp (q, "traits") == 0)
   19968              :                 {
   19969            3 :                   traits_var = expr.value;
   19970            3 :                   traits_var = c_fully_fold (traits_var, false, NULL);
   19971            3 :                   mark_exp_read (traits_var);
   19972              :                 }
   19973              :               else
   19974              :                 {
   19975            3 :                   memspace_expr = expr.value;
   19976            3 :                   memspace_expr = c_fully_fold (memspace_expr, false, NULL);
   19977              :                 }
   19978            6 :               parens2.skip_until_found_close (parser);
   19979              :             }
   19980           23 :           if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   19981            0 :             goto end;
   19982              :         }
   19983              :     }
   19984              : 
   19985           69 :   while (c_parser_next_token_is (parser, CPP_NAME))
   19986              :     {
   19987           69 :       location_t alloc_loc = c_parser_peek_token (parser)->location;
   19988           69 :       c_token *tok = c_parser_peek_token (parser);
   19989           69 :       const char *tok_s = IDENTIFIER_POINTER (tok->value);
   19990           69 :       tree t = lookup_name (tok->value);
   19991           69 :       if (t == NULL_TREE)
   19992              :         {
   19993            4 :           undeclared_variable (tok->location, tok->value);
   19994            4 :           t = error_mark_node;
   19995              :         }
   19996           69 :       c_parser_consume_token (parser);
   19997              : 
   19998              :       /* Legacy traits syntax.  */
   19999           69 :       tree legacy_traits = NULL_TREE;
   20000           69 :       if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
   20001           19 :           && c_parser_peek_2nd_token (parser)->type == CPP_NAME
   20002           88 :           && c_parser_peek_nth_token_raw (parser, 3)->type == CPP_CLOSE_PAREN)
   20003              :         {
   20004           19 :           matching_parens parens2;
   20005           19 :           parens2.require_open (parser);
   20006           19 :           const char *tok_a
   20007           19 :             = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   20008           19 :           c_expr expr = c_parser_expr_no_commas (parser, NULL);
   20009           19 :           location_t close_loc = c_parser_peek_token (parser)->location;
   20010           19 :           parens2.skip_until_found_close (parser);
   20011              : 
   20012           19 :           if (has_modifiers)
   20013              :             {
   20014            2 :               error_at (make_location (alloc_loc, alloc_loc, close_loc),
   20015              :                         "legacy %<%s(%s)%> traits syntax not allowed in "
   20016              :                         "%<uses_allocators%> clause when using modifiers",
   20017              :                         tok_s, tok_a);
   20018            3 :               goto end;
   20019              :             }
   20020           17 :           legacy_traits = c_fully_fold (expr.value, false, NULL);
   20021           17 :           if (legacy_traits == error_mark_node)
   20022            1 :             goto end;
   20023           16 :           mark_exp_read (legacy_traits);
   20024              : 
   20025           16 :           gcc_rich_location richloc (make_location (alloc_loc, alloc_loc, close_loc));
   20026           16 :           if (nl == list)
   20027              :             {
   20028              :               /* Fixit only works well if it is the only first item.  */
   20029           13 :               richloc.add_fixit_replace (alloc_loc, "traits");
   20030           13 :               richloc.add_fixit_insert_after (close_loc, ": ");
   20031           13 :               richloc.add_fixit_insert_after (close_loc, tok_s);
   20032              :             }
   20033           16 :           warning_at (&richloc, OPT_Wdeprecated_openmp,
   20034              :                       "the specification of arguments to %<uses_allocators%> "
   20035              :                       "where each item is of the form %<allocator(traits)%> is "
   20036              :                       "deprecated since OpenMP 5.2");
   20037           16 :         }
   20038              : 
   20039           66 :       if (seen_allocators && has_modifiers)
   20040              :         {
   20041            2 :           error_at (c_parser_peek_token (parser)->location,
   20042              :                     "%<uses_allocators%> clause only accepts a single "
   20043              :                     "allocator when using modifiers");
   20044            2 :           goto end;
   20045              :         }
   20046           64 :       seen_allocators = true;
   20047              : 
   20048           64 :       tree c = build_omp_clause (clause_loc,
   20049              :                                  OMP_CLAUSE_USES_ALLOCATORS);
   20050           64 :       OMP_CLAUSE_USES_ALLOCATORS_ALLOCATOR (c) = t;
   20051           64 :       OMP_CLAUSE_USES_ALLOCATORS_MEMSPACE (c) = memspace_expr;
   20052           64 :       OMP_CLAUSE_USES_ALLOCATORS_TRAITS (c) = (legacy_traits
   20053           64 :                                                ? legacy_traits : traits_var);
   20054           64 :       OMP_CLAUSE_CHAIN (c) = nl;
   20055           64 :       nl = c;
   20056              : 
   20057           64 :       if (c_parser_next_token_is (parser, CPP_COMMA))
   20058           11 :         c_parser_consume_token (parser);
   20059              :       else
   20060              :         break;
   20061              :     }
   20062              : 
   20063           53 :   if (c_parser_next_token_is (parser, CPP_SEMICOLON))
   20064              :     {
   20065            4 :       c_parser_consume_token (parser);
   20066            4 :       goto parse_next;
   20067              :     }
   20068              : 
   20069           49 :  end:
   20070           55 :   parens.skip_until_found_close (parser);
   20071           55 :   return nl;
   20072              : }
   20073              : 
   20074              : /* OpenMP 4.0:
   20075              :    linear ( variable-list )
   20076              :    linear ( variable-list : expression )
   20077              : 
   20078              :    OpenMP 4.5:
   20079              :    linear ( modifier ( variable-list ) )
   20080              :    linear ( modifier ( variable-list ) : expression )
   20081              : 
   20082              :    modifier:
   20083              :      val
   20084              : 
   20085              :    OpenMP 5.2:
   20086              :    linear ( variable-list : modifiers-list )
   20087              : 
   20088              :    modifiers:
   20089              :      val
   20090              :      step ( expression )  */
   20091              : 
   20092              : static tree
   20093          481 : c_parser_omp_clause_linear (c_parser *parser, tree list)
   20094              : {
   20095          481 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   20096          481 :   location_t rm1_loc = UNKNOWN_LOCATION, rm2_loc = UNKNOWN_LOCATION;
   20097          481 :   location_t after_colon_loc = UNKNOWN_LOCATION;
   20098          481 :   tree nl, c, step;
   20099          481 :   enum omp_clause_linear_kind kind = OMP_CLAUSE_LINEAR_DEFAULT;
   20100          481 :   bool old_linear_modifier = false;
   20101              : 
   20102          481 :   matching_parens parens;
   20103          481 :   if (!parens.require_open (parser))
   20104              :     return list;
   20105              : 
   20106          481 :   if (c_parser_next_token_is (parser, CPP_NAME))
   20107              :     {
   20108          481 :       c_token *tok = c_parser_peek_token (parser);
   20109          481 :       const char *p = IDENTIFIER_POINTER (tok->value);
   20110          481 :       if (strcmp ("val", p) == 0)
   20111           12 :         kind = OMP_CLAUSE_LINEAR_VAL;
   20112          481 :       if (c_parser_peek_2nd_token (parser)->type != CPP_OPEN_PAREN)
   20113              :         kind = OMP_CLAUSE_LINEAR_DEFAULT;
   20114           12 :       if (kind != OMP_CLAUSE_LINEAR_DEFAULT)
   20115              :         {
   20116           12 :           old_linear_modifier = true;
   20117           12 :           rm1_loc = make_location (tok->location, tok->location,
   20118           12 :                                    c_parser_peek_2nd_token (parser)->location);
   20119           12 :           c_parser_consume_token (parser);
   20120           12 :           c_parser_consume_token (parser);
   20121              :         }
   20122              :     }
   20123              : 
   20124          481 :   nl = c_parser_omp_variable_list (parser, clause_loc,
   20125              :                                    OMP_CLAUSE_LINEAR, list);
   20126              : 
   20127          481 :   if (kind != OMP_CLAUSE_LINEAR_DEFAULT)
   20128              :     {
   20129           12 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   20130           12 :         rm2_loc = c_parser_peek_token (parser)->location;
   20131           12 :       parens.skip_until_found_close (parser);
   20132              :     }
   20133              : 
   20134          481 :   if (c_parser_next_token_is (parser, CPP_COLON))
   20135              :     {
   20136          354 :       c_parser_consume_token (parser);
   20137          354 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   20138          354 :       after_colon_loc = expr_loc;
   20139          354 :       bool has_modifiers = false;
   20140          354 :       if (kind == OMP_CLAUSE_LINEAR_DEFAULT
   20141          697 :           && c_parser_next_token_is (parser, CPP_NAME))
   20142              :         {
   20143           74 :           c_token *tok = c_parser_peek_token (parser);
   20144           74 :           const char *p = IDENTIFIER_POINTER (tok->value);
   20145           74 :           unsigned int pos = 0;
   20146           74 :           if (strcmp ("val", p) == 0)
   20147            9 :             pos = 2;
   20148           65 :           else if (strcmp ("step", p) == 0
   20149           65 :                    && c_parser_peek_2nd_token (parser)->type == CPP_OPEN_PAREN)
   20150              :             {
   20151           13 :               pos = 3;
   20152           13 :               if (c_parser_check_balanced_raw_token_sequence (parser, &pos)
   20153           13 :                   && (c_parser_peek_nth_token_raw (parser, pos)->type
   20154              :                       == CPP_CLOSE_PAREN))
   20155           13 :                 ++pos;
   20156              :               else
   20157            0 :                 pos = 0;
   20158              :             }
   20159           74 :           if (pos)
   20160              :             {
   20161           22 :               tok = c_parser_peek_nth_token_raw (parser, pos);
   20162           22 :               if (tok->type == CPP_COMMA || tok->type == CPP_CLOSE_PAREN)
   20163           19 :                 has_modifiers = true;
   20164              :             }
   20165              :         }
   20166           74 :       if (has_modifiers)
   20167              :         {
   20168              :           step = NULL_TREE;
   20169           29 :           while (c_parser_next_token_is (parser, CPP_NAME))
   20170              :             {
   20171           29 :               c_token *tok = c_parser_peek_token (parser);
   20172           29 :               const char *p = IDENTIFIER_POINTER (tok->value);
   20173           29 :               if (strcmp ("val", p) == 0)
   20174              :                 {
   20175           11 :                   if (kind != OMP_CLAUSE_LINEAR_DEFAULT)
   20176              :                     error_at (tok->location, "multiple linear modifiers");
   20177           11 :                   kind = OMP_CLAUSE_LINEAR_DEFAULT;
   20178           11 :                   c_parser_consume_token (parser);
   20179              :                 }
   20180           18 :               else if (strcmp ("step", p) == 0)
   20181              :                 {
   20182           18 :                   c_parser_consume_token (parser);
   20183           18 :                   matching_parens parens2;
   20184           18 :                   if (parens2.require_open (parser))
   20185              :                     {
   20186           18 :                       if (step)
   20187            0 :                         error_at (tok->location,
   20188              :                                   "multiple %<step%> modifiers");
   20189           18 :                       expr_loc = c_parser_peek_token (parser)->location;
   20190           18 :                       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   20191           18 :                       expr = convert_lvalue_to_rvalue (expr_loc, expr, false,
   20192              :                                                        true);
   20193           18 :                       step = c_fully_fold (expr.value, false, NULL);
   20194           18 :                       if (!INTEGRAL_TYPE_P (TREE_TYPE (step)))
   20195              :                         {
   20196            0 :                           error_at (clause_loc, "%<linear%> clause step "
   20197              :                                                 "expression must be integral");
   20198            0 :                           step = integer_one_node;
   20199              :                         }
   20200           18 :                       parens2.skip_until_found_close (parser);
   20201              :                     }
   20202              :                   else
   20203              :                     break;
   20204              :                 }
   20205              :               else
   20206              :                 break;
   20207           29 :               if (c_parser_next_token_is (parser, CPP_COMMA))
   20208              :                 {
   20209           10 :                   c_parser_consume_token (parser);
   20210           10 :                   continue;
   20211              :                 }
   20212              :               break;
   20213              :             }
   20214           19 :           if (!step)
   20215            1 :             step = integer_one_node;
   20216              :         }
   20217              :       else
   20218              :         {
   20219          335 :           c_expr expr = c_parser_expr_no_commas (parser, NULL);
   20220          335 :           expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   20221          335 :           step = c_fully_fold (expr.value, false, NULL);
   20222          335 :           if (!INTEGRAL_TYPE_P (TREE_TYPE (step)))
   20223              :             {
   20224            2 :               error_at (clause_loc, "%<linear%> clause step expression must "
   20225              :                                     "be integral");
   20226            2 :               step = integer_one_node;
   20227              :             }
   20228              :         }
   20229              : 
   20230              :     }
   20231              :   else
   20232          127 :     step = integer_one_node;
   20233              : 
   20234          971 :   for (c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   20235              :     {
   20236          490 :       OMP_CLAUSE_LINEAR_STEP (c) = step;
   20237          490 :       OMP_CLAUSE_LINEAR_KIND (c) = kind;
   20238          490 :       OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (c) = old_linear_modifier;
   20239              :     }
   20240              : 
   20241          481 :   if (old_linear_modifier)
   20242              :     {
   20243           12 :       gcc_rich_location richloc (clause_loc);
   20244           12 :       if (rm2_loc != UNKNOWN_LOCATION)
   20245              :         {
   20246           12 :           richloc.add_fixit_remove (rm1_loc);
   20247           12 :           if (after_colon_loc != UNKNOWN_LOCATION)
   20248              :             {
   20249           11 :               richloc.add_fixit_remove (rm2_loc);
   20250           11 :               richloc.add_fixit_insert_before (after_colon_loc, "val, step (");
   20251           11 :               location_t close_loc = c_parser_peek_token (parser)->location;
   20252           11 :               richloc.add_fixit_insert_before (close_loc, ")");
   20253              :             }
   20254              :           else
   20255            1 :             richloc.add_fixit_replace (rm2_loc, " : val");
   20256              :         }
   20257           12 :       warning_at (&richloc, OPT_Wdeprecated_openmp,
   20258              :                   "specifying the list items as arguments to the "
   20259              :                   "modifiers is deprecated since OpenMP 5.2");
   20260           12 :     }
   20261              : 
   20262          481 :   parens.skip_until_found_close (parser);
   20263          481 :   return nl;
   20264              : }
   20265              : 
   20266              : /* OpenMP 5.0:
   20267              :    nontemporal ( variable-list ) */
   20268              : 
   20269              : static tree
   20270          121 : c_parser_omp_clause_nontemporal (c_parser *parser, tree list)
   20271              : {
   20272          121 :   return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_NONTEMPORAL, list);
   20273              : }
   20274              : 
   20275              : /* OpenMP 4.0:
   20276              :    safelen ( constant-expression ) */
   20277              : 
   20278              : static tree
   20279          267 : c_parser_omp_clause_safelen (c_parser *parser, tree list)
   20280              : {
   20281          267 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   20282          267 :   tree c, t;
   20283              : 
   20284          267 :   matching_parens parens;
   20285          267 :   if (!parens.require_open (parser))
   20286              :     return list;
   20287              : 
   20288          267 :   location_t expr_loc = c_parser_peek_token (parser)->location;
   20289          267 :   c_expr expr = c_parser_expr_no_commas (parser, NULL);
   20290          267 :   expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   20291          267 :   t = expr.value;
   20292          267 :   t = c_fully_fold (t, false, NULL);
   20293          267 :   if (TREE_CODE (t) != INTEGER_CST
   20294          265 :       || !INTEGRAL_TYPE_P (TREE_TYPE (t))
   20295          532 :       || tree_int_cst_sgn (t) != 1)
   20296              :     {
   20297            4 :       error_at (clause_loc, "%<safelen%> clause expression must "
   20298              :                             "be positive constant integer expression");
   20299            4 :       t = NULL_TREE;
   20300              :     }
   20301              : 
   20302          267 :   parens.skip_until_found_close (parser);
   20303          267 :   if (t == NULL_TREE || t == error_mark_node)
   20304              :     return list;
   20305              : 
   20306          263 :   check_no_duplicate_clause (list, OMP_CLAUSE_SAFELEN, "safelen");
   20307              : 
   20308          263 :   c = build_omp_clause (clause_loc, OMP_CLAUSE_SAFELEN);
   20309          263 :   OMP_CLAUSE_SAFELEN_EXPR (c) = t;
   20310          263 :   OMP_CLAUSE_CHAIN (c) = list;
   20311          263 :   return c;
   20312              : }
   20313              : 
   20314              : /* OpenMP 4.0:
   20315              :    simdlen ( constant-expression )
   20316              : 
   20317              :    OpenMP 6.1:
   20318              :    simdlen ([scaled(type[, constant-expression]):] constant-expression )  */
   20319              : 
   20320              : static tree
   20321          368 : c_parser_omp_clause_simdlen (c_parser *parser, tree list)
   20322              : {
   20323          368 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   20324          368 :   tree c, t = NULL_TREE, type = NULL_TREE, divisor = NULL_TREE;
   20325              : 
   20326          368 :   matching_parens parens;
   20327          368 :   if (!parens.require_open (parser))
   20328              :     return list;
   20329              : 
   20330          368 :   unsigned pos = 3;
   20331          368 :   if (c_parser_next_token_is (parser, CPP_NAME)
   20332           18 :       && c_parser_peek_2nd_token (parser)->type == CPP_OPEN_PAREN
   20333           17 :       && strcmp (IDENTIFIER_POINTER (c_parser_peek_token (parser)->value),
   20334              :                  "scaled") == 0
   20335           17 :       && c_parser_check_balanced_raw_token_sequence (parser, &pos)
   20336          385 :       && c_parser_peek_nth_token_raw (parser, ++pos)->type == CPP_COLON)
   20337              :     {
   20338           16 :       c_parser_consume_token (parser);
   20339           16 :       matching_parens parens2;
   20340           16 :       parens2.require_open (parser);
   20341              : 
   20342           16 :       location_t loc = c_parser_peek_token (parser)->location;
   20343           16 :       struct c_type_name *ctype = c_parser_type_name (parser);
   20344           16 :       if (ctype == NULL
   20345           15 :           || (type = groktypename (ctype, NULL, NULL)) == NULL
   20346           16 :           || (!INTEGRAL_TYPE_P (type)
   20347           15 :               && !SCALAR_FLOAT_TYPE_P (type)
   20348            2 :               && TREE_CODE (type) != COMPLEX_TYPE))
   20349              :         {
   20350            2 :           error_at (loc, "expected arithmetic type name as argument to the "
   20351              :                          "%<scaled%> modifier");
   20352            2 :           type = error_mark_node;
   20353              :         }
   20354           14 :       else if (c_parser_next_token_is (parser, CPP_COMMA))
   20355              :         {
   20356            9 :           c_parser_consume_token (parser);
   20357            9 :           loc = c_parser_peek_token (parser)->location;
   20358            9 :           c_expr expr = c_parser_expr_no_commas (parser, NULL);
   20359            9 :           expr = convert_lvalue_to_rvalue (loc, expr, false, true);
   20360            9 :           divisor = expr.value;
   20361            9 :           divisor = c_fully_fold (divisor, false, NULL);
   20362            9 :           if (TREE_CODE (divisor) != INTEGER_CST
   20363            8 :               || !INTEGRAL_TYPE_P (TREE_TYPE (divisor))
   20364           17 :               || tree_int_cst_sgn (divisor) != 1)
   20365              :             {
   20366            3 :               error_at (loc, "divisor expression of the %<scaled%> modifier "
   20367              :                              "must a be positive constant integer expression");
   20368            3 :               type = error_mark_node;
   20369              :             }
   20370              :         }
   20371           16 :       parens2.skip_until_found_close (parser);
   20372           16 :       c_parser_require (parser, CPP_COLON, "expected %<:%>");
   20373              :     }
   20374              : 
   20375          368 :   if (type != error_mark_node)
   20376              :     {
   20377          363 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   20378          363 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   20379          363 :       expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   20380          363 :       t = expr.value;
   20381          363 :       t = c_fully_fold (t, false, NULL);
   20382          363 :       if (TREE_CODE (t) != INTEGER_CST
   20383          360 :           || !INTEGRAL_TYPE_P (TREE_TYPE (t))
   20384          723 :           || tree_int_cst_sgn (t) != 1)
   20385              :         {
   20386            5 :           error_at (clause_loc, "%<simdlen%> clause expression must "
   20387              :                                 "be positive constant integer expression");
   20388            5 :           t = NULL_TREE;
   20389              :         }
   20390              :     }
   20391              : 
   20392          368 :   parens.skip_until_found_close (parser);
   20393          368 :   if (type == error_mark_node || t == NULL_TREE || t == error_mark_node)
   20394              :     return list;
   20395              : 
   20396          358 :   check_no_duplicate_clause (list, OMP_CLAUSE_SIMDLEN, "simdlen");
   20397              : 
   20398          358 :   c = build_omp_clause (clause_loc, OMP_CLAUSE_SIMDLEN);
   20399          358 :   OMP_CLAUSE_SIMDLEN_EXPR (c) = t;
   20400          358 :   OMP_CLAUSE_SIMDLEN_TYPE (c) = type;
   20401          358 :   OMP_CLAUSE_SIMDLEN_DIVISOR (c) = divisor;
   20402          358 :   OMP_CLAUSE_CHAIN (c) = list;
   20403          358 :   return c;
   20404              : }
   20405              : 
   20406              : /* OpenMP 4.5:
   20407              :    vec:
   20408              :      identifier [+/- integer]
   20409              :      vec , identifier [+/- integer]
   20410              : */
   20411              : 
   20412              : static tree
   20413          207 : c_parser_omp_clause_doacross_sink (c_parser *parser, location_t clause_loc,
   20414              :                                    tree list, bool depend_p)
   20415              : {
   20416          207 :   tree vec = NULL;
   20417          207 :   if (c_parser_next_token_is_not (parser, CPP_NAME)
   20418          207 :       || c_parser_peek_token (parser)->id_kind != C_ID_ID)
   20419              :     {
   20420            0 :       c_parser_error (parser, "expected identifier");
   20421            0 :       return list;
   20422              :     }
   20423              : 
   20424          207 :   if (!depend_p)
   20425              :     {
   20426           83 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   20427           83 :       if (strcmp (p, "omp_cur_iteration") == 0
   20428           36 :           && c_parser_peek_2nd_token (parser)->type == CPP_MINUS
   20429           34 :           && c_parser_peek_nth_token (parser, 3)->type == CPP_NUMBER
   20430          116 :           && c_parser_peek_nth_token (parser, 4)->type == CPP_CLOSE_PAREN)
   20431              :         {
   20432           33 :           tree val = c_parser_peek_nth_token (parser, 3)->value;
   20433           33 :           if (integer_onep (val))
   20434              :             {
   20435           33 :               c_parser_consume_token (parser);
   20436           33 :               c_parser_consume_token (parser);
   20437           33 :               c_parser_consume_token (parser);
   20438           33 :               tree u = build_omp_clause (clause_loc, OMP_CLAUSE_DOACROSS);
   20439           33 :               OMP_CLAUSE_DOACROSS_KIND (u) = OMP_CLAUSE_DOACROSS_SINK;
   20440           33 :               OMP_CLAUSE_CHAIN (u) = list;
   20441           33 :               return u;
   20442              :             }
   20443              :         }
   20444              :     }
   20445              : 
   20446              : 
   20447              : 
   20448         1152 :   while (c_parser_next_token_is (parser, CPP_NAME)
   20449         1152 :          && c_parser_peek_token (parser)->id_kind == C_ID_ID)
   20450              :     {
   20451         1152 :       tree t = lookup_name (c_parser_peek_token (parser)->value);
   20452         1152 :       tree addend = NULL;
   20453              : 
   20454         1152 :       if (t == NULL_TREE)
   20455              :         {
   20456            6 :           undeclared_variable (c_parser_peek_token (parser)->location,
   20457            6 :                                c_parser_peek_token (parser)->value);
   20458            6 :           t = error_mark_node;
   20459              :         }
   20460              : 
   20461         1152 :       c_parser_consume_token (parser);
   20462              : 
   20463         1152 :       bool neg = false;
   20464         1152 :       if (c_parser_next_token_is (parser, CPP_MINUS))
   20465              :         neg = true;
   20466          920 :       else if (!c_parser_next_token_is (parser, CPP_PLUS))
   20467              :         {
   20468          857 :           addend = integer_zero_node;
   20469          857 :           neg = false;
   20470          857 :           goto add_to_vector;
   20471              :         }
   20472          295 :       c_parser_consume_token (parser);
   20473              : 
   20474          295 :       if (c_parser_next_token_is_not (parser, CPP_NUMBER))
   20475              :         {
   20476            1 :           c_parser_error (parser, "expected integer");
   20477            1 :           return list;
   20478              :         }
   20479              : 
   20480          294 :       addend = c_parser_peek_token (parser)->value;
   20481          294 :       if (TREE_CODE (addend) != INTEGER_CST)
   20482              :         {
   20483            0 :           c_parser_error (parser, "expected integer");
   20484            0 :           return list;
   20485              :         }
   20486          294 :       c_parser_consume_token (parser);
   20487              : 
   20488         1151 :     add_to_vector:
   20489         1151 :       if (t != error_mark_node)
   20490              :         {
   20491         1146 :           vec = tree_cons (addend, t, vec);
   20492         1146 :           if (neg)
   20493          229 :             OMP_CLAUSE_DOACROSS_SINK_NEGATIVE (vec) = 1;
   20494              :         }
   20495              : 
   20496         1151 :       if (c_parser_next_token_is_not (parser, CPP_COMMA)
   20497          979 :           || c_parser_peek_2nd_token (parser)->type != CPP_NAME
   20498         2129 :           || c_parser_peek_2nd_token (parser)->id_kind != C_ID_ID)
   20499              :         break;
   20500              : 
   20501          978 :       c_parser_consume_token (parser);
   20502              :     }
   20503              : 
   20504          173 :   if (vec == NULL_TREE)
   20505              :     return list;
   20506              : 
   20507          169 :   tree u = build_omp_clause (clause_loc, OMP_CLAUSE_DOACROSS);
   20508          169 :   OMP_CLAUSE_DOACROSS_KIND (u) = OMP_CLAUSE_DOACROSS_SINK;
   20509          169 :   OMP_CLAUSE_DOACROSS_DEPEND (u) = depend_p;
   20510          169 :   OMP_CLAUSE_DECL (u) = nreverse (vec);
   20511          169 :   OMP_CLAUSE_CHAIN (u) = list;
   20512          169 :   return u;
   20513              : }
   20514              : 
   20515              : /* OpenMP 5.0:
   20516              :    iterators ( iterators-definition )
   20517              : 
   20518              :    iterators-definition:
   20519              :      iterator-specifier
   20520              :      iterator-specifier , iterators-definition
   20521              : 
   20522              :    iterator-specifier:
   20523              :      identifier = range-specification
   20524              :      iterator-type identifier = range-specification
   20525              : 
   20526              :    range-specification:
   20527              :      begin : end
   20528              :      begin : end : step  */
   20529              : 
   20530              : static tree
   20531          155 : c_parser_omp_iterators (c_parser *parser)
   20532              : {
   20533          155 :   tree ret = NULL_TREE, *last = &ret;
   20534          155 :   c_parser_consume_token (parser);
   20535              : 
   20536          155 :   push_scope ();
   20537              : 
   20538          155 :   matching_parens parens;
   20539          155 :   if (!parens.require_open (parser))
   20540            1 :     return error_mark_node;
   20541              : 
   20542          220 :   do
   20543              :     {
   20544          187 :       tree iter_type = NULL_TREE, type_expr = NULL_TREE;
   20545          187 :       if (c_parser_next_tokens_start_typename (parser, cla_prefer_id))
   20546              :         {
   20547           50 :           struct c_type_name *type = c_parser_type_name (parser);
   20548           50 :           if (type != NULL)
   20549           50 :             iter_type = groktypename (type, &type_expr, NULL);
   20550              :         }
   20551           50 :       if (iter_type == NULL_TREE)
   20552          137 :         iter_type = integer_type_node;
   20553              : 
   20554          187 :       location_t loc = c_parser_peek_token (parser)->location;
   20555          187 :       if (!c_parser_next_token_is (parser, CPP_NAME))
   20556              :         {
   20557            8 :           c_parser_error (parser, "expected identifier");
   20558            8 :           break;
   20559              :         }
   20560              : 
   20561          179 :       tree id = c_parser_peek_token (parser)->value;
   20562          179 :       c_parser_consume_token (parser);
   20563              : 
   20564          179 :       if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
   20565              :         break;
   20566              : 
   20567          177 :       location_t eloc = c_parser_peek_token (parser)->location;
   20568          177 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   20569          177 :       expr = convert_lvalue_to_rvalue (eloc, expr, true, false);
   20570          177 :       tree begin = expr.value;
   20571              : 
   20572          177 :       if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   20573              :         break;
   20574              : 
   20575          175 :       eloc = c_parser_peek_token (parser)->location;
   20576          175 :       expr = c_parser_expr_no_commas (parser, NULL);
   20577          175 :       expr = convert_lvalue_to_rvalue (eloc, expr, true, false);
   20578          175 :       tree end = expr.value;
   20579              : 
   20580          175 :       tree step = integer_one_node;
   20581          175 :       if (c_parser_next_token_is (parser, CPP_COLON))
   20582              :         {
   20583           59 :           c_parser_consume_token (parser);
   20584           59 :           eloc = c_parser_peek_token (parser)->location;
   20585           59 :           expr = c_parser_expr_no_commas (parser, NULL);
   20586           59 :           expr = convert_lvalue_to_rvalue (eloc, expr, true, false);
   20587           59 :           step = expr.value;
   20588              :         }
   20589              : 
   20590          175 :       tree iter_var = build_decl (loc, VAR_DECL, id, iter_type);
   20591          175 :       DECL_ARTIFICIAL (iter_var) = 1;
   20592          175 :       DECL_CONTEXT (iter_var) = current_function_decl;
   20593          175 :       pushdecl (iter_var);
   20594              : 
   20595          175 :       *last = make_omp_iterator ();
   20596          175 :       OMP_ITERATOR_VAR (*last) = iter_var;
   20597          175 :       OMP_ITERATOR_BEGIN (*last) = begin;
   20598          175 :       OMP_ITERATOR_END (*last) = end;
   20599          175 :       OMP_ITERATOR_STEP (*last) = step;
   20600          175 :       last = &TREE_CHAIN (*last);
   20601              : 
   20602          175 :       if (c_parser_next_token_is (parser, CPP_COMMA))
   20603              :         {
   20604           33 :           c_parser_consume_token (parser);
   20605           33 :           continue;
   20606              :         }
   20607              :       break;
   20608           33 :     }
   20609              :   while (1);
   20610              : 
   20611          154 :   parens.skip_until_found_close (parser);
   20612          154 :   return ret ? ret : error_mark_node;
   20613              : }
   20614              : 
   20615              : /* OpenMP 5.0:
   20616              :    affinity ( [aff-modifier :] variable-list )
   20617              :    aff-modifier:
   20618              :      iterator ( iterators-definition )  */
   20619              : 
   20620              : static tree
   20621          151 : c_parser_omp_clause_affinity (c_parser *parser, tree list)
   20622              : {
   20623          151 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   20624          151 :   tree nl, iterators = NULL_TREE;
   20625              : 
   20626          151 :   matching_parens parens;
   20627          151 :   if (!parens.require_open (parser))
   20628              :     return list;
   20629              : 
   20630          151 :   if (c_parser_next_token_is (parser, CPP_NAME))
   20631              :     {
   20632          149 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   20633          149 :       bool parse_iter = ((strcmp ("iterator", p) == 0)
   20634          149 :                          && (c_parser_peek_2nd_token (parser)->type
   20635           50 :                              == CPP_OPEN_PAREN));
   20636           50 :       if (parse_iter)
   20637              :         {
   20638           50 :           unsigned n = 3;
   20639           50 :           parse_iter = (c_parser_check_balanced_raw_token_sequence (parser, &n)
   20640           50 :                         && (c_parser_peek_nth_token_raw (parser, n)->type
   20641              :                             == CPP_CLOSE_PAREN)
   20642          100 :                         && (c_parser_peek_nth_token_raw (parser, n + 1)->type
   20643              :                             == CPP_COLON));
   20644              :         }
   20645            3 :       if (parse_iter)
   20646              :         {
   20647           47 :           iterators = c_parser_omp_iterators (parser);
   20648           47 :           if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   20649              :             {
   20650            0 :               if (iterators)
   20651            0 :                 pop_scope ();
   20652            0 :               parens.skip_until_found_close (parser);
   20653            0 :               return list;
   20654              :             }
   20655              :         }
   20656              :     }
   20657          151 :   nl = c_parser_omp_variable_list (parser, clause_loc, OMP_CLAUSE_AFFINITY,
   20658              :                                    list);
   20659          151 :   if (iterators)
   20660              :     {
   20661           47 :       tree block = pop_scope ();
   20662           47 :       if (iterators != error_mark_node)
   20663              :         {
   20664           43 :           OMP_ITERATOR_BLOCK (iterators) = block;
   20665           99 :           for (tree c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   20666          112 :             OMP_CLAUSE_DECL (c) = build_tree_list (iterators,
   20667           56 :                                                    OMP_CLAUSE_DECL (c));
   20668              :         }
   20669              :     }
   20670              : 
   20671          151 :   parens.skip_until_found_close (parser);
   20672          151 :   return nl;
   20673              : }
   20674              : 
   20675              : 
   20676              : /* OpenMP 4.0:
   20677              :    depend ( depend-kind: variable-list )
   20678              : 
   20679              :    depend-kind:
   20680              :      in | out | inout
   20681              : 
   20682              :    OpenMP 4.5:
   20683              :    depend ( source )
   20684              : 
   20685              :    depend ( sink  : vec )
   20686              : 
   20687              :    OpenMP 5.0:
   20688              :    depend ( depend-modifier , depend-kind: variable-list )
   20689              : 
   20690              :    depend-kind:
   20691              :      in | out | inout | mutexinoutset | depobj | inoutset
   20692              : 
   20693              :    depend-modifier:
   20694              :      iterator ( iterators-definition )  */
   20695              : 
   20696              : static tree
   20697          895 : c_parser_omp_clause_depend (c_parser *parser, tree list, location_t here)
   20698              : {
   20699          895 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   20700          895 :   enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_LAST;
   20701          895 :   enum omp_clause_doacross_kind dkind = OMP_CLAUSE_DOACROSS_LAST;
   20702          895 :   tree nl, c, iterators = NULL_TREE;
   20703              : 
   20704          895 :   matching_parens parens;
   20705          895 :   if (!parens.require_open (parser))
   20706              :     return list;
   20707              : 
   20708         1049 :   do
   20709              :     {
   20710          972 :       if (c_parser_next_token_is_not (parser, CPP_NAME))
   20711            0 :         goto invalid_kind;
   20712              : 
   20713          972 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   20714          972 :       if (strcmp ("iterator", p) == 0 && iterators == NULL_TREE)
   20715              :         {
   20716           77 :           iterators = c_parser_omp_iterators (parser);
   20717           77 :           c_parser_require (parser, CPP_COMMA, "expected %<,%>");
   20718           77 :           continue;
   20719              :         }
   20720          895 :       if (strcmp ("in", p) == 0)
   20721              :         kind = OMP_CLAUSE_DEPEND_IN;
   20722          644 :       else if (strcmp ("inout", p) == 0)
   20723              :         kind = OMP_CLAUSE_DEPEND_INOUT;
   20724          425 :       else if (strcmp ("inoutset", p) == 0)
   20725              :         kind = OMP_CLAUSE_DEPEND_INOUTSET;
   20726          410 :       else if (strcmp ("mutexinoutset", p) == 0)
   20727              :         kind = OMP_CLAUSE_DEPEND_MUTEXINOUTSET;
   20728          389 :       else if (strcmp ("out", p) == 0)
   20729              :         kind = OMP_CLAUSE_DEPEND_OUT;
   20730          244 :       else if (strcmp ("depobj", p) == 0)
   20731              :         kind = OMP_CLAUSE_DEPEND_DEPOBJ;
   20732          223 :       else if (strcmp ("sink", p) == 0)
   20733              :         {
   20734          124 :           gcc_rich_location richloc (clause_loc);
   20735          124 :           richloc.add_fixit_replace (here, "doacross");
   20736          124 :           warning_at (&richloc, OPT_Wdeprecated_openmp,
   20737              :                       "%<sink%> modifier with %<depend%> clause deprecated "
   20738              :                       "since OpenMP 5.2, use with %<doacross%>");
   20739          124 :           dkind = OMP_CLAUSE_DOACROSS_SINK;
   20740          124 :         }
   20741           99 :       else if (strcmp ("source", p) == 0)
   20742              :         {
   20743           97 :           gcc_rich_location richloc (clause_loc);
   20744           97 :           richloc.add_fixit_replace (here, "doacross");
   20745           97 :           warning_at (&richloc, OPT_Wdeprecated_openmp,
   20746              :                       "%<source%> modifier with %<depend%> clause deprecated "
   20747              :                       "since OpenMP 5.2, use with %<doacross%>");
   20748           97 :           dkind = OMP_CLAUSE_DOACROSS_SOURCE;
   20749           97 :         }
   20750              :       else
   20751            2 :         goto invalid_kind;
   20752          893 :       break;
   20753           77 :     }
   20754              :   while (1);
   20755              : 
   20756          893 :   c_parser_consume_token (parser);
   20757              : 
   20758          893 :   if (iterators
   20759          893 :       && (dkind == OMP_CLAUSE_DOACROSS_SOURCE
   20760          893 :           || dkind == OMP_CLAUSE_DOACROSS_SINK))
   20761              :     {
   20762            2 :       pop_scope ();
   20763            2 :       error_at (clause_loc, "%<iterator%> modifier incompatible with %qs",
   20764              :                 dkind == OMP_CLAUSE_DOACROSS_SOURCE ? "source" : "sink");
   20765            2 :       iterators = NULL_TREE;
   20766              :     }
   20767              : 
   20768          893 :   if (dkind == OMP_CLAUSE_DOACROSS_SOURCE)
   20769              :     {
   20770           97 :       c = build_omp_clause (clause_loc, OMP_CLAUSE_DOACROSS);
   20771           97 :       OMP_CLAUSE_DOACROSS_KIND (c) = dkind;
   20772           97 :       OMP_CLAUSE_DOACROSS_DEPEND (c) = 1;
   20773           97 :       OMP_CLAUSE_DECL (c) = NULL_TREE;
   20774           97 :       OMP_CLAUSE_CHAIN (c) = list;
   20775           97 :       parens.skip_until_found_close (parser);
   20776           97 :       return c;
   20777              :     }
   20778              : 
   20779          796 :   if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   20780            0 :     goto resync_fail;
   20781              : 
   20782          796 :   if (dkind == OMP_CLAUSE_DOACROSS_SINK)
   20783          124 :     nl = c_parser_omp_clause_doacross_sink (parser, clause_loc, list, true);
   20784              :   else
   20785              :     {
   20786          672 :       nl = c_parser_omp_variable_list (parser, clause_loc,
   20787              :                                        OMP_CLAUSE_DEPEND, list);
   20788              : 
   20789          672 :       if (iterators)
   20790              :         {
   20791           73 :           tree block = pop_scope ();
   20792           73 :           if (iterators == error_mark_node)
   20793              :             iterators = NULL_TREE;
   20794              :           else
   20795           68 :             OMP_ITERATOR_BLOCK (iterators) = block;
   20796              :         }
   20797              : 
   20798         1385 :       for (c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   20799              :         {
   20800          713 :           OMP_CLAUSE_DEPEND_KIND (c) = kind;
   20801          713 :           if (iterators)
   20802          150 :             OMP_CLAUSE_DECL (c)
   20803          150 :               = build_tree_list (iterators, OMP_CLAUSE_DECL (c));
   20804              :         }
   20805              :     }
   20806              : 
   20807          796 :   parens.skip_until_found_close (parser);
   20808          796 :   return nl;
   20809              : 
   20810            2 :  invalid_kind:
   20811            2 :   c_parser_error (parser, "invalid depend kind");
   20812            2 :  resync_fail:
   20813            2 :   parens.skip_until_found_close (parser);
   20814            2 :   if (iterators)
   20815            2 :     pop_scope ();
   20816              :   return list;
   20817              : }
   20818              : 
   20819              : /* OpenMP 5.2:
   20820              :    doacross ( source : )
   20821              :    doacross ( source : omp_cur_iteration )
   20822              : 
   20823              :    doacross ( sink : vec )
   20824              :    doacross ( sink : omp_cur_iteration - logical_iteration )  */
   20825              : 
   20826              : static tree
   20827          145 : c_parser_omp_clause_doacross (c_parser *parser, tree list)
   20828              : {
   20829          145 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   20830          145 :   enum omp_clause_doacross_kind kind = OMP_CLAUSE_DOACROSS_LAST;
   20831          145 :   tree nl;
   20832          145 :   const char *p;
   20833              : 
   20834          145 :   matching_parens parens;
   20835          145 :   if (!parens.require_open (parser))
   20836              :     return list;
   20837              : 
   20838          145 :   if (c_parser_next_token_is_not (parser, CPP_NAME))
   20839            0 :     goto invalid_kind;
   20840              : 
   20841          145 :   p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   20842          145 :   if (strcmp ("sink", p) == 0)
   20843              :     kind = OMP_CLAUSE_DOACROSS_SINK;
   20844           60 :   else if (strcmp ("source", p) == 0)
   20845              :     kind = OMP_CLAUSE_DOACROSS_SOURCE;
   20846              :   else
   20847            0 :     goto invalid_kind;
   20848              : 
   20849          145 :   c_parser_consume_token (parser);
   20850              : 
   20851          145 :   if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   20852            4 :     goto resync_fail;
   20853              : 
   20854          141 :   if (kind == OMP_CLAUSE_DOACROSS_SOURCE)
   20855              :     {
   20856           58 :       if (c_parser_next_token_is (parser, CPP_NAME)
   20857           58 :           && strcmp (IDENTIFIER_POINTER (c_parser_peek_token (parser)->value),
   20858              :                      "omp_cur_iteration") == 0)
   20859           28 :         c_parser_consume_token (parser);
   20860           58 :       nl = build_omp_clause (clause_loc, OMP_CLAUSE_DOACROSS);
   20861           58 :       OMP_CLAUSE_DOACROSS_KIND (nl) = OMP_CLAUSE_DOACROSS_SOURCE;
   20862           58 :       OMP_CLAUSE_DECL (nl) = NULL_TREE;
   20863           58 :       OMP_CLAUSE_CHAIN (nl) = list;
   20864              :     }
   20865              :   else
   20866           83 :     nl = c_parser_omp_clause_doacross_sink (parser, clause_loc, list, false);
   20867              : 
   20868          141 :   parens.skip_until_found_close (parser);
   20869          141 :   return nl;
   20870              : 
   20871            0 :  invalid_kind:
   20872            0 :   c_parser_error (parser, "invalid doacross kind");
   20873            4 :  resync_fail:
   20874            4 :   parens.skip_until_found_close (parser);
   20875            4 :   return list;
   20876              : }
   20877              : 
   20878              : /* OpenMP 6.1:
   20879              :    dyn_groupprivate ( [fallback-modifier : ] integer-expression )
   20880              : 
   20881              :    fallback-modifier
   20882              :       fallback( abort | default_mem | null )  */
   20883              : 
   20884              : static tree
   20885           21 : c_parser_omp_clause_dyn_groupprivate (c_parser *parser, tree list)
   20886              : {
   20887           21 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   20888           21 :   matching_parens parens;
   20889           21 :   if (!parens.require_open (parser))
   20890              :     return list;
   20891              : 
   20892           21 :   enum omp_clause_fallback_kind kind = OMP_CLAUSE_FALLBACK_UNSPECIFIED;
   20893              : 
   20894           21 :   unsigned n = 3;
   20895           21 :   if (c_parser_next_token_is (parser, CPP_NAME)
   20896           21 :       && (c_parser_peek_2nd_token (parser)->type == CPP_COLON
   20897            9 :           || (c_parser_peek_2nd_token (parser)->type == CPP_OPEN_PAREN
   20898            8 :               && c_parser_check_balanced_raw_token_sequence (parser, &n)
   20899            8 :               && (c_parser_peek_nth_token_raw (parser, n)->type
   20900              :                   == CPP_CLOSE_PAREN)
   20901            8 :               && (c_parser_peek_nth_token_raw (parser, n + 1)->type
   20902              :                   == CPP_COLON))))
   20903              :     {
   20904           10 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   20905           10 :       if (strcmp (p, "fallback") != 0)
   20906              :         {
   20907            3 :           c_parser_error (parser, "expected %<fallback%> modifier");
   20908            3 :           return list;
   20909              :         }
   20910            7 :       c_parser_consume_token (parser);
   20911            7 :       if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
   20912              :         return list;
   20913            6 :       p = "";
   20914            6 :       if (c_parser_next_token_is (parser, CPP_NAME))
   20915            5 :         p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   20916            6 :       if (strcmp (p, "abort") == 0)
   20917              :         kind = OMP_CLAUSE_FALLBACK_ABORT;
   20918            5 :       else if (strcmp (p, "default_mem") == 0)
   20919              :         kind = OMP_CLAUSE_FALLBACK_DEFAULT_MEM;
   20920            4 :       else if (strcmp (p, "null") == 0)
   20921              :         kind = OMP_CLAUSE_FALLBACK_NULL;
   20922              :       else
   20923              :         {
   20924            2 :           c_parser_error (parser, "expected %<abort%>, %<default_mem%>, or "
   20925              :                                   "%<null%> as fallback mode");
   20926            2 :           return list;
   20927              :         }
   20928            4 :       c_parser_consume_token (parser);
   20929            4 :       if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
   20930              :         return list;
   20931            3 :       if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   20932              :         return list;
   20933              :     }
   20934           14 :   location_t expr_loc = c_parser_peek_token (parser)->location;
   20935           14 :   c_expr expr = c_parser_expr_no_commas (parser, NULL);
   20936           14 :   expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   20937           14 :   tree size = c_fully_fold (expr.value, false, NULL);
   20938           14 :   parens.skip_until_found_close (parser);
   20939              : 
   20940           14 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (size)))
   20941              :     {
   20942            2 :       error_at (expr_loc, "expected integer expression");
   20943            2 :       return list;
   20944              :     }
   20945              : 
   20946              :   /* Attempt to statically determine when the number is negative.  */
   20947           12 :   tree c = fold_build2_loc (expr_loc, LT_EXPR, boolean_type_node, size,
   20948           12 :                             build_int_cst (TREE_TYPE (size), 0));
   20949           12 :   protected_set_expr_location (c, expr_loc);
   20950           12 :   if (c == boolean_true_node)
   20951              :     {
   20952            3 :       warning_at (expr_loc, OPT_Wopenmp,
   20953              :                   "%<dyn_groupprivate%> value must be non-negative");
   20954            3 :       size = integer_zero_node;
   20955              :     }
   20956           12 :   check_no_duplicate_clause (list, OMP_CLAUSE_DYN_GROUPPRIVATE,
   20957              :                              "dyn_groupprivate");
   20958              : 
   20959           12 :   c = build_omp_clause (clause_loc, OMP_CLAUSE_DYN_GROUPPRIVATE);
   20960           12 :   OMP_CLAUSE_DYN_GROUPPRIVATE_KIND (c) = kind;
   20961           12 :   OMP_CLAUSE_DYN_GROUPPRIVATE_EXPR (c) = size;
   20962           12 :   OMP_CLAUSE_CHAIN (c) = list;
   20963           12 :   list = c;
   20964              : 
   20965           12 :   return list;
   20966              : }
   20967              : 
   20968              : /* OpenMP 4.0:
   20969              :    map ( map-kind: variable-list )
   20970              :    map ( variable-list )
   20971              : 
   20972              :    map-kind:
   20973              :      alloc | to | from | tofrom
   20974              : 
   20975              :    OpenMP 4.5:
   20976              :    map-kind:
   20977              :      alloc | to | from | tofrom | release | delete
   20978              : 
   20979              :    map ( always [,] map-kind: variable-list )
   20980              : 
   20981              :    OpenMP 5.0:
   20982              :    map ( [map-type-modifier[,] ...] map-kind: variable-list )
   20983              : 
   20984              :    map-type-modifier:
   20985              :      always | close | present | iterator (iterators-definition)  */
   20986              : 
   20987              : static tree
   20988         2320 : c_parser_omp_clause_map (c_parser *parser, tree list, bool declare_mapper_p)
   20989              : {
   20990         2320 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   20991         2320 :   tree nl, c;
   20992         2320 :   enum gomp_map_kind kind = declare_mapper_p ? GOMP_MAP_UNSET : GOMP_MAP_TOFROM;
   20993              : 
   20994         2320 :   matching_parens parens;
   20995         2320 :   if (!parens.require_open (parser))
   20996              :     return list;
   20997              : 
   20998              :   int pos = 1;
   20999         2946 :   int map_kind_pos = 0;
   21000              :   int iterator_length = 0;
   21001         3572 :   for (;;)
   21002              :     {
   21003         2946 :       c_token *tok = c_parser_peek_nth_token_raw (parser, pos);
   21004         2946 :       if (tok->type != CPP_NAME)
   21005              :         break;
   21006              : 
   21007         2621 :       const char *p = IDENTIFIER_POINTER (tok->value);
   21008         2621 :       c_token *next_tok = c_parser_peek_nth_token_raw (parser, pos + 1);
   21009         2621 :       if (strcmp (p, "iterator") == 0 && next_tok->type == CPP_OPEN_PAREN)
   21010              :         {
   21011           18 :           unsigned n = pos + 2;
   21012           18 :           if (c_parser_check_balanced_raw_token_sequence (parser, &n)
   21013           18 :               && c_parser_peek_nth_token_raw (parser, n)->type
   21014              :                  == CPP_CLOSE_PAREN)
   21015              :             {
   21016           18 :               iterator_length = n - pos + 1;
   21017           18 :               pos = n;
   21018           18 :               next_tok = c_parser_peek_nth_token_raw (parser, pos + 1);
   21019              :             }
   21020              :         }
   21021              : 
   21022         2621 :       if (next_tok->type == CPP_COLON)
   21023              :         {
   21024              :           map_kind_pos = pos;
   21025              :           break;
   21026              :         }
   21027              : 
   21028          626 :       if (next_tok->type == CPP_COMMA)
   21029          235 :         pos++;
   21030          391 :       else if (c_parser_peek_nth_token_raw (parser, pos + 1)->type
   21031              :                == CPP_OPEN_PAREN)
   21032              :         {
   21033           14 :           unsigned int npos = pos + 2;
   21034           14 :           if (c_parser_check_balanced_raw_token_sequence (parser, &npos)
   21035           14 :               && (c_parser_peek_nth_token_raw (parser, npos)->type
   21036              :                   == CPP_CLOSE_PAREN)
   21037           28 :               && (c_parser_peek_nth_token_raw (parser, npos + 1)->type
   21038              :                   == CPP_COMMA))
   21039           13 :             pos = npos + 1;
   21040              :         }
   21041              : 
   21042          626 :       pos++;
   21043          626 :     }
   21044              : 
   21045         2320 :   int always_modifier = 0;
   21046         2320 :   int close_modifier = 0;
   21047         2320 :   int present_modifier = 0;
   21048         2320 :   int mapper_modifier = 0;
   21049         2320 :   int num_commas = 0;
   21050         2320 :   int num_identifiers = 0;
   21051         2320 :   tree mapper_name = NULL_TREE;
   21052         2320 :   tree iterators = NULL_TREE;
   21053         2781 :   for (int pos = 1; pos < map_kind_pos; ++pos)
   21054              :     {
   21055          479 :       c_token *tok = c_parser_peek_token (parser);
   21056              : 
   21057          479 :       if (tok->type == CPP_COMMA)
   21058              :         {
   21059          207 :           ++num_commas;
   21060          207 :           if (num_commas > num_identifiers)
   21061            0 :             c_parser_error (parser, "illegal comma");
   21062          207 :           c_parser_consume_token (parser);
   21063          207 :           continue;
   21064              :         }
   21065              : 
   21066          272 :       const char *p = IDENTIFIER_POINTER (tok->value);
   21067          272 :       if (strcmp ("always", p) == 0)
   21068              :         {
   21069          101 :           if (always_modifier)
   21070              :             {
   21071            4 :               c_parser_error (parser, "too many %<always%> modifiers");
   21072            4 :               parens.skip_until_found_close (parser);
   21073            4 :               return list;
   21074              :             }
   21075           97 :           always_modifier++;
   21076           97 :           c_parser_consume_token (parser);
   21077              :         }
   21078          171 :       else if (strcmp ("close", p) == 0)
   21079              :         {
   21080           67 :           if (close_modifier)
   21081              :             {
   21082            4 :               c_parser_error (parser, "too many %<close%> modifiers");
   21083            4 :               parens.skip_until_found_close (parser);
   21084            4 :               return list;
   21085              :             }
   21086           63 :           close_modifier++;
   21087           63 :           c_parser_consume_token (parser);
   21088              :         }
   21089          104 :       else if (strcmp ("iterator", p) == 0)
   21090              :         {
   21091           18 :           if (iterators)
   21092              :             {
   21093            1 :               c_parser_error (parser, "too many %<iterator%> modifiers");
   21094            1 :               parens.skip_until_found_close (parser);
   21095            1 :               return list;
   21096              :             }
   21097           17 :           iterators = c_parser_omp_iterators (parser);
   21098           17 :           pos += iterator_length - 1;
   21099              :         }
   21100           86 :       else if (strcmp ("mapper", p) == 0)
   21101              :         {
   21102           13 :           c_parser_consume_token (parser);
   21103              : 
   21104           13 :           matching_parens mparens;
   21105           13 :           if (mparens.require_open (parser))
   21106              :             {
   21107           13 :               if (mapper_modifier)
   21108              :                 {
   21109            0 :                   c_parser_error (parser, "too many %<mapper%> modifiers");
   21110              :                   /* Assume it's a well-formed mapper modifier, even if it
   21111              :                      seems to be in the wrong place.  */
   21112            0 :                   c_parser_consume_token (parser);
   21113            0 :                   mparens.require_close (parser);
   21114            0 :                   parens.skip_until_found_close (parser);
   21115            0 :                   return list;
   21116              :                 }
   21117              : 
   21118           13 :               tok = c_parser_peek_token (parser);
   21119              : 
   21120           13 :               switch (tok->type)
   21121              :                 {
   21122            6 :                 case CPP_NAME:
   21123            6 :                   {
   21124            6 :                     mapper_name = tok->value;
   21125            6 :                     c_parser_consume_token (parser);
   21126            6 :                     if (declare_mapper_p)
   21127              :                       {
   21128            1 :                         error_at (tok->location,
   21129              :                                   "in %<declare mapper%> directives, parameter "
   21130              :                                   "to %<mapper%> modifier must be %<default%>");
   21131              :                       }
   21132              :                   }
   21133              :                   break;
   21134              : 
   21135            7 :                 case CPP_KEYWORD:
   21136            7 :                   if (tok->keyword == RID_DEFAULT)
   21137              :                     {
   21138            7 :                       c_parser_consume_token (parser);
   21139            7 :                       break;
   21140              :                     }
   21141              :                   /* Fallthrough.  */
   21142              : 
   21143            0 :                 default:
   21144            0 :                   error_at (tok->location,
   21145              :                             "expected identifier or %<default%>");
   21146            0 :                   return list;
   21147              :                 }
   21148              : 
   21149           13 :               if (!mparens.require_close (parser))
   21150              :                 {
   21151            0 :                   parens.skip_until_found_close (parser);
   21152            0 :                   return list;
   21153              :                 }
   21154              : 
   21155           13 :               mapper_modifier++;
   21156           13 :               pos += 3;
   21157              :             }
   21158              :         }
   21159           73 :       else if (strcmp ("present", p) == 0)
   21160              :         {
   21161           68 :           if (present_modifier)
   21162              :             {
   21163            4 :               c_parser_error (parser, "too many %<present%> modifiers");
   21164            4 :               parens.skip_until_found_close (parser);
   21165            4 :               return list;
   21166              :             }
   21167           64 :           present_modifier++;
   21168           64 :           c_parser_consume_token (parser);
   21169              :         }
   21170              :       else
   21171              :         {
   21172            5 :           c_parser_error (parser, "%<map%> clause with map-type modifier other "
   21173              :                                   "than %<always%>, %<close%>, %<iterator%>, "
   21174              :                                   "%<mapper%> or %<present%>");
   21175            5 :           parens.skip_until_found_close (parser);
   21176            5 :           return list;
   21177              :         }
   21178          254 :       ++num_identifiers;
   21179          254 :       if (num_identifiers - 1 > num_commas)
   21180              :         {
   21181           30 :           gcc_rich_location richloc (clause_loc);
   21182           30 :           richloc.add_fixit_insert_before (tok->location, ",");
   21183           30 :           warning_at (&richloc, OPT_Wdeprecated_openmp,
   21184              :                       "%<map%> clause modifiers without comma separation is "
   21185              :                       "deprecated since OpenMP 5.2");
   21186           30 :         }
   21187              :       num_commas = num_identifiers - 1;
   21188              :     }
   21189              : 
   21190         2302 :   if (c_parser_next_token_is (parser, CPP_NAME)
   21191         2302 :       && c_parser_peek_2nd_token (parser)->type == CPP_COLON)
   21192              :     {
   21193         1977 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   21194         1977 :       int always_present_modifier = always_modifier && present_modifier;
   21195              : 
   21196         1977 :       if (strcmp ("alloc", p) == 0)
   21197          161 :         kind = present_modifier ? GOMP_MAP_PRESENT_ALLOC : GOMP_MAP_ALLOC;
   21198         1816 :       else if (strcmp ("to", p) == 0)
   21199         1062 :         kind = (always_present_modifier ? GOMP_MAP_ALWAYS_PRESENT_TO
   21200          547 :                 : present_modifier ? GOMP_MAP_PRESENT_TO
   21201          536 :                 : always_modifier ? GOMP_MAP_ALWAYS_TO
   21202              :                 : GOMP_MAP_TO);
   21203         1263 :       else if (strcmp ("from", p) == 0)
   21204         1219 :         kind = (always_present_modifier ? GOMP_MAP_ALWAYS_PRESENT_FROM
   21205          616 :                 : present_modifier ? GOMP_MAP_PRESENT_FROM
   21206          611 :                 : always_modifier ? GOMP_MAP_ALWAYS_FROM
   21207              :                 : GOMP_MAP_FROM);
   21208          641 :       else if (strcmp ("tofrom", p) == 0)
   21209         1116 :         kind = (always_present_modifier ? GOMP_MAP_ALWAYS_PRESENT_TOFROM
   21210          568 :                 : present_modifier ? GOMP_MAP_PRESENT_TOFROM
   21211          562 :                 : always_modifier ? GOMP_MAP_ALWAYS_TOFROM
   21212              :                 : GOMP_MAP_TOFROM);
   21213           67 :       else if (strcmp ("release", p) == 0)
   21214              :         kind = GOMP_MAP_RELEASE;
   21215           19 :       else if (strcmp ("delete", p) == 0)
   21216              :         kind = GOMP_MAP_DELETE;
   21217              :       else
   21218              :         {
   21219            0 :           c_parser_error (parser, "invalid map kind");
   21220            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   21221              :                                      "expected %<)%>");
   21222            0 :           return list;
   21223              :         }
   21224         1977 :       c_parser_consume_token (parser);
   21225         1977 :       c_parser_consume_token (parser);
   21226              :     }
   21227              : 
   21228         2302 :   nl = c_parser_omp_variable_list (parser, clause_loc, OMP_CLAUSE_MAP, list,
   21229              :                                    true);
   21230              : 
   21231         2302 :   tree last_new = NULL_TREE;
   21232              : 
   21233         2302 :   if (iterators)
   21234              :     {
   21235           16 :       tree block = pop_scope ();
   21236           16 :       if (iterators == error_mark_node)
   21237              :         iterators = NULL_TREE;
   21238              :       else
   21239           16 :         OMP_ITERATOR_BLOCK (iterators) = block;
   21240              :     }
   21241              : 
   21242         5143 :   for (c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   21243              :     {
   21244         2841 :       OMP_CLAUSE_SET_MAP_KIND (c, kind);
   21245         2841 :       OMP_CLAUSE_ITERATORS (c) = iterators;
   21246         2841 :       last_new = c;
   21247              :     }
   21248              : 
   21249         2302 :   if (mapper_name)
   21250              :     {
   21251            6 :       tree name = build_omp_clause (input_location, OMP_CLAUSE_MAP);
   21252            6 :       OMP_CLAUSE_SET_MAP_KIND (name, GOMP_MAP_PUSH_MAPPER_NAME);
   21253            6 :       OMP_CLAUSE_DECL (name) = mapper_name;
   21254            6 :       OMP_CLAUSE_CHAIN (name) = nl;
   21255            6 :       nl = name;
   21256              : 
   21257            6 :       gcc_assert (last_new);
   21258              : 
   21259            6 :       name = build_omp_clause (input_location, OMP_CLAUSE_MAP);
   21260            6 :       OMP_CLAUSE_SET_MAP_KIND (name, GOMP_MAP_POP_MAPPER_NAME);
   21261            6 :       OMP_CLAUSE_DECL (name) = null_pointer_node;
   21262            6 :       OMP_CLAUSE_CHAIN (name) = OMP_CLAUSE_CHAIN (last_new);
   21263            6 :       OMP_CLAUSE_CHAIN (last_new) = name;
   21264              :     }
   21265              : 
   21266         2302 :   parens.skip_until_found_close (parser);
   21267         2302 :   return nl;
   21268              : }
   21269              : 
   21270              : /* OpenMP 4.0:
   21271              :    device ( expression )
   21272              : 
   21273              :    OpenMP 5.0:
   21274              :    device ( [device-modifier :] integer-expression )
   21275              : 
   21276              :    device-modifier:
   21277              :      ancestor | device_num */
   21278              : 
   21279              : static tree
   21280          388 : c_parser_omp_clause_device (c_parser *parser, tree list)
   21281              : {
   21282          388 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   21283          388 :   location_t expr_loc;
   21284          388 :   c_expr expr;
   21285          388 :   tree c, t;
   21286          388 :   bool ancestor = false;
   21287              : 
   21288          388 :   matching_parens parens;
   21289          388 :   if (!parens.require_open (parser))
   21290              :     return list;
   21291              : 
   21292          388 :   if (c_parser_next_token_is (parser, CPP_NAME)
   21293          388 :       && c_parser_peek_2nd_token (parser)->type == CPP_COLON)
   21294              :     {
   21295           48 :       c_token *tok = c_parser_peek_token (parser);
   21296           48 :       const char *p = IDENTIFIER_POINTER (tok->value);
   21297           48 :       if (strcmp ("ancestor", p) == 0)
   21298              :         {
   21299              :           /* A requires directive with the reverse_offload clause must be
   21300              :           specified.  */
   21301           25 :           if ((omp_requires_mask & OMP_REQUIRES_REVERSE_OFFLOAD) == 0)
   21302              :             {
   21303            1 :               error_at (tok->location, "%<ancestor%> device modifier not "
   21304              :                                        "preceded by %<requires%> directive "
   21305              :                                        "with %<reverse_offload%> clause");
   21306            1 :               parens.skip_until_found_close (parser);
   21307            1 :               return list;
   21308              :             }
   21309              :           ancestor = true;
   21310              :         }
   21311           23 :       else if (strcmp ("device_num", p) == 0)
   21312              :         ;
   21313              :       else
   21314              :         {
   21315            1 :           error_at (tok->location, "expected %<ancestor%> or %<device_num%>");
   21316            1 :           parens.skip_until_found_close (parser);
   21317            1 :           return list;
   21318              :         }
   21319           46 :       c_parser_consume_token (parser);
   21320           46 :       c_parser_consume_token (parser);
   21321              :     }
   21322              : 
   21323          386 :   expr_loc = c_parser_peek_token (parser)->location;
   21324          386 :   expr = c_parser_expr_no_commas (parser, NULL);
   21325          386 :   expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   21326          386 :   t = expr.value;
   21327          386 :   t = c_fully_fold (t, false, NULL);
   21328              : 
   21329          386 :   parens.skip_until_found_close (parser);
   21330              : 
   21331          386 :   if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
   21332              :     {
   21333            2 :       c_parser_error (parser, "expected integer expression");
   21334            2 :       return list;
   21335              :     }
   21336          384 :   if (ancestor && TREE_CODE (t) == INTEGER_CST && !integer_onep (t))
   21337              :     {
   21338            1 :       error_at (expr_loc, "the %<device%> clause expression must evaluate to "
   21339              :                           "%<1%>");
   21340            1 :       return list;
   21341              :     }
   21342              : 
   21343          383 :   check_no_duplicate_clause (list, OMP_CLAUSE_DEVICE, "device");
   21344              : 
   21345          383 :   c = build_omp_clause (clause_loc, OMP_CLAUSE_DEVICE);
   21346              : 
   21347          383 :   OMP_CLAUSE_DEVICE_ID (c) = t;
   21348          383 :   OMP_CLAUSE_CHAIN (c) = list;
   21349          383 :   OMP_CLAUSE_DEVICE_ANCESTOR (c) = ancestor;
   21350              : 
   21351          383 :   list = c;
   21352          383 :   return list;
   21353              : }
   21354              : 
   21355              : /* OpenMP 4.0:
   21356              :    dist_schedule ( static )
   21357              :    dist_schedule ( static , expression ) */
   21358              : 
   21359              : static tree
   21360         1594 : c_parser_omp_clause_dist_schedule (c_parser *parser, tree list)
   21361              : {
   21362         1594 :   tree c, t = NULL_TREE;
   21363         1594 :   location_t loc = c_parser_peek_token (parser)->location;
   21364              : 
   21365         1594 :   matching_parens parens;
   21366         1594 :   if (!parens.require_open (parser))
   21367              :     return list;
   21368              : 
   21369         1594 :   if (!c_parser_next_token_is_keyword (parser, RID_STATIC))
   21370              :     {
   21371            0 :       c_parser_error (parser, "invalid dist_schedule kind");
   21372            0 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   21373              :                                  "expected %<)%>");
   21374            0 :       return list;
   21375              :     }
   21376              : 
   21377         1594 :   c_parser_consume_token (parser);
   21378         1594 :   if (c_parser_next_token_is (parser, CPP_COMMA))
   21379              :     {
   21380         1587 :       c_parser_consume_token (parser);
   21381              : 
   21382         1587 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   21383         1587 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   21384         1587 :       expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   21385         1587 :       t = expr.value;
   21386         1587 :       t = c_fully_fold (t, false, NULL);
   21387         1587 :       parens.skip_until_found_close (parser);
   21388              :     }
   21389              :   else
   21390            7 :     c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   21391              :                                "expected %<,%> or %<)%>");
   21392              : 
   21393              :   /* check_no_duplicate_clause (list, OMP_CLAUSE_DIST_SCHEDULE,
   21394              :                                 "dist_schedule"); */
   21395         1594 :   if (omp_find_clause (list, OMP_CLAUSE_DIST_SCHEDULE))
   21396            2 :     warning_at (loc, OPT_Wopenmp, "too many %qs clauses", "dist_schedule");
   21397         1594 :   if (t == error_mark_node)
   21398              :     return list;
   21399              : 
   21400         1594 :   c = build_omp_clause (loc, OMP_CLAUSE_DIST_SCHEDULE);
   21401         1594 :   OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (c) = t;
   21402         1594 :   OMP_CLAUSE_CHAIN (c) = list;
   21403         1594 :   return c;
   21404              : }
   21405              : 
   21406              : /* OpenMP 4.0:
   21407              :    proc_bind ( proc-bind-kind )
   21408              : 
   21409              :    proc-bind-kind:
   21410              :      primary | master | close | spread
   21411              :    where OpenMP 5.1 added 'primary' and deprecated the alias 'master'.  */
   21412              : 
   21413              : static tree
   21414          195 : c_parser_omp_clause_proc_bind (c_parser *parser, tree list)
   21415              : {
   21416          195 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   21417          195 :   enum omp_clause_proc_bind_kind kind;
   21418          195 :   tree c;
   21419              : 
   21420          195 :   matching_parens parens;
   21421          195 :   if (!parens.require_open (parser))
   21422              :     return list;
   21423              : 
   21424          195 :   if (c_parser_next_token_is (parser, CPP_NAME))
   21425              :     {
   21426          195 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   21427          195 :       if (strcmp ("primary", p) == 0)
   21428              :         kind = OMP_CLAUSE_PROC_BIND_PRIMARY;
   21429          194 :       else if (strcmp ("master", p) == 0)
   21430              :         {
   21431           17 :           gcc_rich_location richloc (clause_loc);
   21432           17 :           richloc.add_fixit_replace (c_parser_peek_token (parser)->location,
   21433              :                                      "primary");
   21434           17 :           warning_at (&richloc, OPT_Wdeprecated_openmp,
   21435              :                       "%<master%> affinity deprecated since OpenMP 5.1, "
   21436              :                       "use %<primary%>");
   21437           17 :           kind = OMP_CLAUSE_PROC_BIND_MASTER;
   21438           17 :         }
   21439          177 :       else if (strcmp ("close", p) == 0)
   21440              :         kind = OMP_CLAUSE_PROC_BIND_CLOSE;
   21441          165 :       else if (strcmp ("spread", p) == 0)
   21442              :         kind = OMP_CLAUSE_PROC_BIND_SPREAD;
   21443              :       else
   21444            0 :         goto invalid_kind;
   21445              :     }
   21446              :   else
   21447            0 :     goto invalid_kind;
   21448              : 
   21449          195 :   check_no_duplicate_clause (list, OMP_CLAUSE_PROC_BIND, "proc_bind");
   21450          195 :   c_parser_consume_token (parser);
   21451          195 :   parens.skip_until_found_close (parser);
   21452          195 :   c = build_omp_clause (clause_loc, OMP_CLAUSE_PROC_BIND);
   21453          195 :   OMP_CLAUSE_PROC_BIND_KIND (c) = kind;
   21454          195 :   OMP_CLAUSE_CHAIN (c) = list;
   21455          195 :   return c;
   21456              : 
   21457            0 :  invalid_kind:
   21458            0 :   c_parser_error (parser, "invalid proc_bind kind");
   21459            0 :   parens.skip_until_found_close (parser);
   21460            0 :   return list;
   21461              : }
   21462              : 
   21463              : /* OpenMP 5.0:
   21464              :    device_type ( host | nohost | any )  */
   21465              : 
   21466              : static tree
   21467           53 : c_parser_omp_clause_device_type (c_parser *parser, tree list)
   21468              : {
   21469           53 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   21470           53 :   enum omp_clause_device_type_kind kind;
   21471           53 :   tree c;
   21472              : 
   21473           53 :   matching_parens parens;
   21474           53 :   if (!parens.require_open (parser))
   21475              :     return list;
   21476              : 
   21477           53 :   if (c_parser_next_token_is (parser, CPP_NAME))
   21478              :     {
   21479           53 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   21480           53 :       if (strcmp ("host", p) == 0)
   21481              :         kind = OMP_CLAUSE_DEVICE_TYPE_HOST;
   21482           33 :       else if (strcmp ("nohost", p) == 0)
   21483              :         kind = OMP_CLAUSE_DEVICE_TYPE_NOHOST;
   21484           20 :       else if (strcmp ("any", p) == 0)
   21485              :         kind = OMP_CLAUSE_DEVICE_TYPE_ANY;
   21486              :       else
   21487            0 :         goto invalid_kind;
   21488              :     }
   21489              :   else
   21490            0 :     goto invalid_kind;
   21491              : 
   21492           53 :   check_no_duplicate_clause (list, OMP_CLAUSE_DEVICE_TYPE,
   21493              :                              "device_type");
   21494           53 :   c_parser_consume_token (parser);
   21495           53 :   parens.skip_until_found_close (parser);
   21496           53 :   c = build_omp_clause (clause_loc, OMP_CLAUSE_DEVICE_TYPE);
   21497           53 :   OMP_CLAUSE_DEVICE_TYPE_KIND (c) = kind;
   21498           53 :   OMP_CLAUSE_CHAIN (c) = list;
   21499           53 :   return c;
   21500              : 
   21501            0 :  invalid_kind:
   21502            0 :   c_parser_error (parser, "expected %<host%>, %<nohost%> or %<any%>");
   21503            0 :   parens.skip_until_found_close (parser);
   21504            0 :   return list;
   21505              : }
   21506              : 
   21507              : /* OpenMP 4.0:
   21508              :    from ( variable-list )
   21509              :    to ( variable-list )
   21510              : 
   21511              :    OpenMP 5.1:
   21512              :    from ( [motion-modifier[,] [motion-modifier[,]...]:] variable-list )
   21513              :    to ( [motion-modifier[,] [motion-modifier[,]...]:] variable-list )
   21514              : 
   21515              :    motion-modifier:
   21516              :      present | iterator (iterators-definition) | mapper (id)  */
   21517              : 
   21518              : static tree
   21519         3018 : c_parser_omp_clause_from_to (c_parser *parser, enum omp_clause_code kind,
   21520              :                              tree list)
   21521              : {
   21522         3018 :   location_t loc = c_parser_peek_token (parser)->location;
   21523         3018 :   matching_parens parens;
   21524         3018 :   if (!parens.require_open (parser))
   21525              :     return list;
   21526              : 
   21527         6537 :   int pos = 1, colon_pos = 0;
   21528              :   int iterator_length = 0;
   21529              : 
   21530         6537 :   while (c_parser_peek_nth_token_raw (parser, pos)->type == CPP_NAME)
   21531              :     {
   21532         3545 :       const char *identifier =
   21533         3545 :         IDENTIFIER_POINTER (c_parser_peek_nth_token_raw (parser, pos)->value);
   21534         3545 :       if (c_parser_peek_nth_token_raw (parser, pos + 1)->type
   21535              :           == CPP_OPEN_PAREN)
   21536              :         {
   21537           20 :           unsigned int npos = pos + 2;
   21538           20 :           if (c_parser_check_balanced_raw_token_sequence (parser, &npos)
   21539           20 :               && (c_parser_peek_nth_token_raw (parser, npos)->type
   21540              :                   == CPP_CLOSE_PAREN))
   21541              :             {
   21542           20 :               if (strcmp (identifier, "iterator") == 0)
   21543           15 :                 iterator_length = npos - pos + 1;
   21544           20 :               pos = npos;
   21545              :             }
   21546              :         }
   21547         3545 :       if (c_parser_peek_nth_token_raw (parser, pos + 1)->type == CPP_COMMA)
   21548          527 :         pos += 2;
   21549              :       else
   21550              :         pos++;
   21551         3545 :       if (c_parser_peek_nth_token_raw (parser, pos)->type == CPP_COLON)
   21552              :         {
   21553              :           colon_pos = pos;
   21554              :           break;
   21555              :         }
   21556              :     }
   21557              : 
   21558         3018 :   bool present = false, mapper_modifier = false;
   21559         3018 :   tree iterators = NULL_TREE;
   21560         3018 :   tree mapper_name = NULL_TREE;
   21561              : 
   21562         3052 :   for (int pos = 1; pos < colon_pos; ++pos)
   21563              :     {
   21564           36 :       c_token *token = c_parser_peek_token (parser);
   21565           36 :       if (token->type == CPP_COMMA)
   21566              :         {
   21567            5 :           c_parser_consume_token (parser);
   21568            5 :           continue;
   21569              :         }
   21570           31 :       const char *p = IDENTIFIER_POINTER (token->value);
   21571           31 :       if (strcmp ("present", p) == 0)
   21572              :         {
   21573           10 :           if (present)
   21574              :             {
   21575            0 :               c_parser_error (parser, "too many %<present%> modifiers");
   21576            0 :               parens.skip_until_found_close (parser);
   21577            0 :               return list;
   21578              :             }
   21579           10 :           present = true;
   21580           10 :           c_parser_consume_token (parser);
   21581              :         }
   21582           21 :       else if (strcmp ("iterator", p) == 0)
   21583              :         {
   21584           15 :           if (iterators)
   21585              :             {
   21586            1 :               c_parser_error (parser, "too many %<iterator%> modifiers");
   21587            1 :               parens.skip_until_found_close (parser);
   21588            1 :               return list;
   21589              :             }
   21590           14 :           iterators = c_parser_omp_iterators (parser);
   21591           14 :           pos += iterator_length - 1;
   21592              :         }
   21593            6 :       else if (strcmp ("mapper", p) == 0)
   21594              :         {
   21595            5 :           c_parser_consume_token (parser);
   21596              : 
   21597            5 :           matching_parens mparens;
   21598            5 :           if (mparens.require_open (parser))
   21599              :             {
   21600            5 :               if (mapper_modifier)
   21601              :                 {
   21602            0 :                   c_parser_error (parser, "too many %<mapper%> modifiers");
   21603              :                   /* Assume it's a well-formed mapper modifier, even if it
   21604              :                      seems to be in the wrong place.  */
   21605            0 :                   c_parser_consume_token (parser);
   21606            0 :                   mparens.require_close (parser);
   21607            0 :                   parens.skip_until_found_close (parser);
   21608            0 :                   return list;
   21609              :                 }
   21610              : 
   21611            5 :               token = c_parser_peek_token (parser);
   21612            5 :               switch (token->type)
   21613              :                 {
   21614            5 :                 case CPP_NAME:
   21615            5 :                   {
   21616            5 :                     mapper_name = token->value;
   21617            5 :                     c_parser_consume_token (parser);
   21618              :                   }
   21619            5 :                   break;
   21620            0 :                 case CPP_KEYWORD:
   21621            0 :                   if (token->keyword == RID_DEFAULT)
   21622              :                     {
   21623            0 :                       c_parser_consume_token (parser);
   21624            0 :                       break;
   21625              :                     }
   21626              :                   /* FALLTHROUGH  */
   21627            0 :                 default:
   21628            0 :                   error_at (token->location,
   21629              :                             "expected identifier or %<default%>");
   21630            0 :                   return list;
   21631              :                 }
   21632            5 :               if (!mparens.require_close (parser))
   21633              :                 {
   21634            0 :                   parens.skip_until_found_close (parser);
   21635            0 :                   return list;
   21636              :                 }
   21637            5 :               mapper_modifier = true;
   21638            5 :               pos += 3;
   21639              :             }
   21640              :         }
   21641              :       else
   21642              :         {
   21643            2 :           error_at (token->location,
   21644              :                     "%qs clause with modifier other than %<iterator%>, "
   21645              :                     "%<mapper%>, or %<present%>",
   21646              :                     kind == OMP_CLAUSE_TO ? "to" : "from");
   21647            1 :           parens.skip_until_found_close (parser);
   21648            1 :           return list;
   21649              :         }
   21650              :     }
   21651              : 
   21652         3016 :   if (colon_pos)
   21653           24 :     c_parser_require (parser, CPP_COLON, "expected %<:%>");
   21654              : 
   21655         3016 :   tree nl = c_parser_omp_variable_list (parser, loc, kind, list);
   21656         3016 :   parens.skip_until_found_close (parser);
   21657              : 
   21658         3016 :   if (present)
   21659           26 :     for (tree c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   21660           16 :       OMP_CLAUSE_MOTION_PRESENT (c) = 1;
   21661              : 
   21662         3016 :   if (iterators)
   21663              :     {
   21664           12 :       tree block = pop_scope ();
   21665           12 :       if (iterators == error_mark_node)
   21666              :         iterators = NULL_TREE;
   21667              :       else
   21668           12 :         OMP_ITERATOR_BLOCK (iterators) = block;
   21669              :     }
   21670              : 
   21671           12 :   if (iterators)
   21672           28 :     for (tree c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   21673           16 :       OMP_CLAUSE_ITERATORS (c) = iterators;
   21674              : 
   21675         3016 :   if (mapper_name)
   21676              :     {
   21677              :       tree last_new = NULL_TREE;
   21678           10 :       for (tree c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   21679            5 :         last_new = c;
   21680              : 
   21681            5 :       tree name = build_omp_clause (input_location, OMP_CLAUSE_MAP);
   21682            5 :       OMP_CLAUSE_SET_MAP_KIND (name, GOMP_MAP_PUSH_MAPPER_NAME);
   21683            5 :       OMP_CLAUSE_DECL (name) = mapper_name;
   21684            5 :       OMP_CLAUSE_CHAIN (name) = nl;
   21685            5 :       nl = name;
   21686              : 
   21687            5 :       gcc_assert (last_new);
   21688              : 
   21689            5 :       name = build_omp_clause (input_location, OMP_CLAUSE_MAP);
   21690            5 :       OMP_CLAUSE_SET_MAP_KIND (name, GOMP_MAP_POP_MAPPER_NAME);
   21691            5 :       OMP_CLAUSE_DECL (name) = null_pointer_node;
   21692            5 :       OMP_CLAUSE_CHAIN (name) = OMP_CLAUSE_CHAIN (last_new);
   21693            5 :       OMP_CLAUSE_CHAIN (last_new) = name;
   21694              :     }
   21695              : 
   21696              :   return nl;
   21697              : }
   21698              : 
   21699              : /* OpenMP 4.0:
   21700              :    uniform ( variable-list ) */
   21701              : 
   21702              : static tree
   21703          117 : c_parser_omp_clause_uniform (c_parser *parser, tree list)
   21704              : {
   21705              :   /* The clauses location.  */
   21706          117 :   location_t loc = c_parser_peek_token (parser)->location;
   21707              : 
   21708          117 :   matching_parens parens;
   21709          117 :   if (parens.require_open (parser))
   21710              :     {
   21711          117 :       list = c_parser_omp_variable_list (parser, loc, OMP_CLAUSE_UNIFORM,
   21712              :                                          list);
   21713          117 :       parens.skip_until_found_close (parser);
   21714              :     }
   21715          117 :   return list;
   21716              : }
   21717              : 
   21718              : /* OpenMP 5.1
   21719              :    full */
   21720              : 
   21721              : static tree
   21722           69 : c_parser_omp_clause_full (c_parser *parser, tree list)
   21723              : {
   21724           69 :   check_no_duplicate_clause (list, OMP_CLAUSE_FULL, "full");
   21725              : 
   21726           69 :   location_t loc = c_parser_peek_token (parser)->location;
   21727           69 :   tree c = build_omp_clause (loc, OMP_CLAUSE_FULL);
   21728           69 :   OMP_CLAUSE_CHAIN (c) = list;
   21729           69 :   return c;
   21730              : }
   21731              : 
   21732              : /* OpenMP 5.1
   21733              :    partial ( constant-expression ) */
   21734              : 
   21735              : static tree
   21736          230 : c_parser_omp_clause_partial (c_parser *parser, tree list)
   21737              : {
   21738          230 :   tree num = NULL_TREE;
   21739          230 :   location_t loc = c_parser_peek_token (parser)->location;
   21740              : 
   21741          230 :   check_no_duplicate_clause (list, OMP_CLAUSE_PARTIAL, "partial");
   21742              : 
   21743          230 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   21744              :     {
   21745          173 :       matching_parens parens;
   21746          173 :       parens.consume_open (parser);
   21747          173 :       num = c_parser_expr_no_commas (parser, NULL).value;
   21748          173 :       parens.skip_until_found_close (parser);
   21749              : 
   21750          173 :       if (num == error_mark_node)
   21751            7 :         return list;
   21752              : 
   21753          171 :       mark_exp_read (num);
   21754          171 :       num = c_fully_fold (num, false, NULL);
   21755          171 :       HOST_WIDE_INT n;
   21756          342 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (num))
   21757          170 :           || !tree_fits_shwi_p (num)
   21758          168 :           || (n = tree_to_shwi (num)) <= 0
   21759          337 :           || (int) n != n)
   21760              :         {
   21761            5 :           error_at (loc, "%<partial%> argument needs positive constant "
   21762              :                          "integer expression");
   21763            5 :           return list;
   21764              :         }
   21765              :     }
   21766              : 
   21767          223 :   tree c = build_omp_clause (loc, OMP_CLAUSE_PARTIAL);
   21768          223 :   OMP_CLAUSE_PARTIAL_EXPR (c) = num;
   21769          223 :   OMP_CLAUSE_CHAIN (c) = list;
   21770          223 :   return c;
   21771              : }
   21772              : 
   21773              : /* OpenMP 5.1
   21774              :    novariants ( scalar-expression ) */
   21775              : 
   21776              : static tree
   21777           24 : c_parser_omp_clause_novariants (c_parser *parser, tree list)
   21778              : {
   21779           24 :   matching_parens parens;
   21780           24 :   if (!parens.require_open (parser))
   21781              :     return list;
   21782              : 
   21783           24 :   location_t loc = c_parser_peek_token (parser)->location;
   21784           24 :   c_expr expr = c_parser_expr_no_commas (parser, NULL);
   21785           24 :   tree t = convert_lvalue_to_rvalue (loc, expr, true, true).value;
   21786           24 :   t = c_objc_common_truthvalue_conversion (loc, t);
   21787           24 :   t = c_fully_fold (t, false, NULL);
   21788           24 :   parens.skip_until_found_close (parser);
   21789              : 
   21790           24 :   check_no_duplicate_clause (list, OMP_CLAUSE_NOVARIANTS, "novariants");
   21791              : 
   21792           24 :   tree c = build_omp_clause (loc, OMP_CLAUSE_NOVARIANTS);
   21793           24 :   OMP_CLAUSE_NOVARIANTS_EXPR (c) = t;
   21794           24 :   OMP_CLAUSE_CHAIN (c) = list;
   21795           24 :   list = c;
   21796              : 
   21797           24 :   return list;
   21798              : }
   21799              : 
   21800              : /* OpenMP 5.1
   21801              :    nocontext ( scalar-expression ) */
   21802              : 
   21803              : static tree
   21804           23 : c_parser_omp_clause_nocontext (c_parser *parser, tree list)
   21805              : {
   21806           23 :   matching_parens parens;
   21807           23 :   if (!parens.require_open (parser))
   21808              :     return list;
   21809              : 
   21810           23 :   location_t loc = c_parser_peek_token (parser)->location;
   21811           23 :   c_expr expr = c_parser_expr_no_commas (parser, NULL);
   21812           23 :   tree t = convert_lvalue_to_rvalue (loc, expr, true, true).value;
   21813           23 :   t = c_objc_common_truthvalue_conversion (loc, t);
   21814           23 :   t = c_fully_fold (t, false, NULL);
   21815           23 :   parens.skip_until_found_close (parser);
   21816              : 
   21817           23 :   check_no_duplicate_clause (list, OMP_CLAUSE_NOCONTEXT, "nocontext");
   21818              : 
   21819           23 :   tree c = build_omp_clause (loc, OMP_CLAUSE_NOCONTEXT);
   21820           23 :   OMP_CLAUSE_NOCONTEXT_EXPR (c) = t;
   21821           23 :   OMP_CLAUSE_CHAIN (c) = list;
   21822           23 :   list = c;
   21823              : 
   21824           23 :   return list;
   21825              : }
   21826              : 
   21827              : /* OpenMP 5.0:
   21828              :    detach ( event-handle ) */
   21829              : 
   21830              : static tree
   21831           34 : c_parser_omp_clause_detach (c_parser *parser, tree list)
   21832              : {
   21833           34 :   matching_parens parens;
   21834           34 :   location_t clause_loc = c_parser_peek_token (parser)->location;
   21835              : 
   21836           34 :   if (!parens.require_open (parser))
   21837              :     return list;
   21838              : 
   21839           34 :   if (c_parser_next_token_is_not (parser, CPP_NAME)
   21840           34 :       || c_parser_peek_token (parser)->id_kind != C_ID_ID)
   21841              :     {
   21842            1 :       c_parser_error (parser, "expected identifier");
   21843            1 :       parens.skip_until_found_close (parser);
   21844            1 :       return list;
   21845              :     }
   21846              : 
   21847           33 :   tree t = lookup_name (c_parser_peek_token (parser)->value);
   21848           33 :   if (t == NULL_TREE)
   21849              :     {
   21850            0 :       undeclared_variable (c_parser_peek_token (parser)->location,
   21851            0 :                            c_parser_peek_token (parser)->value);
   21852            0 :       parens.skip_until_found_close (parser);
   21853            0 :       return list;
   21854              :     }
   21855           33 :   c_parser_consume_token (parser);
   21856              : 
   21857           33 :   tree type = TYPE_MAIN_VARIANT (TREE_TYPE (t));
   21858           33 :   if (!INTEGRAL_TYPE_P (type)
   21859              :       || TREE_CODE (type) != ENUMERAL_TYPE
   21860           33 :       || TYPE_NAME (type) != get_identifier ("omp_event_handle_t"))
   21861              :     {
   21862            1 :       error_at (clause_loc, "%<detach%> clause event handle "
   21863              :                             "has type %qT rather than "
   21864              :                             "%<omp_event_handle_t%>",
   21865              :                             type);
   21866            1 :       parens.skip_until_found_close (parser);
   21867            1 :       return list;
   21868              :     }
   21869              : 
   21870           32 :   tree u = build_omp_clause (clause_loc, OMP_CLAUSE_DETACH);
   21871           32 :   OMP_CLAUSE_DECL (u) = t;
   21872           32 :   OMP_CLAUSE_CHAIN (u) = list;
   21873           32 :   parens.skip_until_found_close (parser);
   21874           32 :   return u;
   21875              : }
   21876              : 
   21877              : /* OpenMP 5.0:
   21878              :    destroy ( variable-list ) */
   21879              : 
   21880              : static tree
   21881           41 : c_parser_omp_clause_destroy (c_parser *parser, tree list)
   21882              : {
   21883           41 :   tree nl = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_DESTROY, list);
   21884          127 :   for (tree c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   21885           45 :     TREE_ADDRESSABLE (OMP_CLAUSE_DECL (c)) = 1;
   21886           41 :   return nl;
   21887              : }
   21888              : 
   21889              : /* OpenMP 5.1:
   21890              :      prefer_type ( const-int-expr-or-string-literal-list )
   21891              : 
   21892              :    OpenMP 6.0:
   21893              :      prefer_type ( { preference-selector-list }, { ... } )
   21894              : 
   21895              :    with preference-selector being:
   21896              :      fr ( identifier-or-string-literal-list )
   21897              :      attr ( string-list )
   21898              : 
   21899              :    Data format:
   21900              :     For the foreign runtime identifiers, string values are converted to
   21901              :     their integer value; unknown string or integer values are set to
   21902              :     GOMP_INTEROP_IFR_KNOWN.
   21903              : 
   21904              :     Each item (a) GOMP_INTEROP_IFR_SEPARATOR
   21905              :               (b) for any 'fr', its integer value.
   21906              :                   Note: Spec only permits 1 'fr' entry (6.0; changed after TR13)
   21907              :               (c) GOMP_INTEROP_IFR_SEPARATOR
   21908              :               (d) list of \0-terminated non-empty strings for 'attr'
   21909              :               (e) '\0'
   21910              :     Tailing '\0'.  */
   21911              : 
   21912              : static tree
   21913          125 : c_parser_omp_modifier_prefer_type (c_parser *parser)
   21914              : {
   21915          125 :   if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
   21916            2 :     return error_mark_node;
   21917              : 
   21918          123 :   std::string str;
   21919              : 
   21920              :   /* Old Format: const-int-expr-or-string-literal-list */
   21921          123 :   if (!c_parser_next_token_is (parser, CPP_OPEN_BRACE))
   21922          240 :     while (true)
   21923              :       {
   21924          150 :         str += (char) GOMP_INTEROP_IFR_SEPARATOR;
   21925          150 :         if (c_parser_next_token_is (parser, CPP_STRING))
   21926              :           {
   21927          117 :             c_expr cval = c_parser_string_literal (parser, false, false);
   21928          117 :             if (cval.value == error_mark_node)
   21929            1 :               return error_mark_node;
   21930          117 :             if ((size_t) TREE_STRING_LENGTH (cval.value)
   21931          117 :                 != strlen (TREE_STRING_POINTER (cval.value)) + 1)
   21932              :               {
   21933            1 :                 error_at (cval.get_location (), "string literal must "
   21934              :                                                 "not contain %<\\0%>");
   21935            1 :                 parser->error = true;
   21936            1 :                 return error_mark_node;
   21937              :               }
   21938              : 
   21939          116 :             char c = omp_get_fr_id_from_name (TREE_STRING_POINTER (cval.value));
   21940          116 :             if (c == GOMP_INTEROP_IFR_UNKNOWN)
   21941            3 :               warning_at (cval.get_location (), OPT_Wopenmp,
   21942              :                           "unknown foreign runtime identifier %qs",
   21943            3 :                           TREE_STRING_POINTER (cval.value));
   21944          116 :             str += c;
   21945              :           }
   21946              :         else
   21947              :           {
   21948           33 :             c_expr cval = c_parser_expr_no_commas (parser, NULL);
   21949           33 :             tree value = c_fully_fold (cval.value, false, NULL);
   21950           64 :             if (INTEGRAL_TYPE_P (TREE_TYPE (value))
   21951           61 :                 && TREE_CODE (value) != INTEGER_CST)
   21952            3 :               value = convert_lvalue_to_rvalue (cval.get_start (), cval,
   21953              :                                                 false, true).value;
   21954           33 :             if (TREE_CODE (value) != INTEGER_CST
   21955           28 :                 || !tree_fits_shwi_p (value))
   21956              :               {
   21957            5 :                 c_parser_error (parser, "expected string literal or constant "
   21958              :                                         "integer expression");
   21959            5 :                 return error_mark_node;
   21960              :               }
   21961           28 :             HOST_WIDE_INT n = tree_to_shwi (value);
   21962           28 :             if (n < 1 || n > GOMP_INTEROP_IFR_LAST)
   21963              :               {
   21964            3 :                 warning_at (cval.get_location (), OPT_Wopenmp,
   21965              :                             "unknown foreign runtime identifier %qwd", n);
   21966            3 :                 n = GOMP_INTEROP_IFR_UNKNOWN;
   21967              :               }
   21968           28 :             str += (char) n;
   21969              :           }
   21970          144 :         str += (char) GOMP_INTEROP_IFR_SEPARATOR;
   21971          144 :         str += '\0';
   21972          144 :         if (c_parser_next_token_is (parser, CPP_COMMA))
   21973              :           {
   21974           90 :             c_parser_consume_token (parser);
   21975           90 :             continue;
   21976              :           }
   21977           54 :         if (!c_parser_require (parser, CPP_CLOSE_PAREN,
   21978              :                                "expected %<,%> or %<)%>"))
   21979            0 :           return error_mark_node;
   21980           54 :         str += '\0';
   21981           54 :         tree res = build_string (str.length (), str.data ());
   21982           54 :         TREE_TYPE (res) = build_array_type_nelts (unsigned_char_type_node,
   21983           54 :                                                   str.length ());
   21984           54 :         return res;
   21985           90 :       }
   21986              : 
   21987              :   /* New format. */
   21988           63 :   std::string str2;
   21989          128 :   while (true)
   21990              :     {
   21991          128 :       if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
   21992            1 :         return error_mark_node;
   21993          127 :       str += (char) GOMP_INTEROP_IFR_SEPARATOR;
   21994          127 :       str2.clear ();
   21995          127 :       bool has_fr = false;
   21996          205 :       while (true)
   21997              :         {
   21998          166 :           c_token *tok = c_parser_peek_token (parser);
   21999          166 :           if (tok->type != CPP_NAME
   22000          166 :               || (strcmp("fr", IDENTIFIER_POINTER (tok->value)) != 0
   22001           63 :                   && strcmp("attr", IDENTIFIER_POINTER (tok->value)) != 0))
   22002              :             {
   22003            0 :               c_parser_error (parser, "expected %<fr%> or %<attr%> preference "
   22004              :                                       "selector");
   22005            0 :               return error_mark_node;
   22006              :             }
   22007          166 :           c_parser_consume_token (parser);
   22008          166 :           bool is_fr = IDENTIFIER_POINTER (tok->value)[0] == 'f';
   22009          166 :           if (is_fr && has_fr)
   22010              :             {
   22011            1 :               c_parser_error (parser, "duplicated %<fr%> preference selector");
   22012            1 :               return error_mark_node;
   22013              :             }
   22014          165 :           if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
   22015            0 :             return error_mark_node;
   22016          175 :           while (true)
   22017              :             {
   22018          170 :               if (c_parser_next_token_is (parser, CPP_STRING))
   22019              :                 {
   22020          133 :                   c_expr cval = c_parser_string_literal (parser, false, false);
   22021          133 :                   tree value = cval.value;
   22022          133 :                   if (value == error_mark_node)
   22023            6 :                     return error_mark_node;
   22024          133 :                   if ((size_t) TREE_STRING_LENGTH (value)
   22025          133 :                       != strlen (TREE_STRING_POINTER (value)) + 1)
   22026              :                     {
   22027            2 :                       error_at (cval.get_location (), "string literal must "
   22028              :                                                       "not contain %<\\0%>");
   22029            2 :                       parser->error = true;
   22030            2 :                       return error_mark_node;
   22031              :                     }
   22032          131 :                   if (!is_fr)
   22033              :                     {
   22034           67 :                       if (!startswith (TREE_STRING_POINTER (value), "ompx_"))
   22035              :                         {
   22036            1 :                           error_at (cval.get_location (),
   22037              :                                     "%<attr%> string literal must start with "
   22038              :                                     "%<ompx_%>");
   22039            1 :                           parser->error = true;
   22040            1 :                           return error_mark_node;
   22041              :                         }
   22042           66 :                       if (strchr (TREE_STRING_POINTER (value), ','))
   22043              :                         {
   22044            2 :                           error_at (cval.get_location (),
   22045              :                                     "%<attr%> string literal must not contain "
   22046              :                                     "a comma");
   22047            2 :                           parser->error = true;
   22048            2 :                           return error_mark_node;
   22049              :                         }
   22050           64 :                       str2 += TREE_STRING_POINTER (value);
   22051           64 :                       str2 += '\0';
   22052              :                     }
   22053              :                   else
   22054              :                     {
   22055           64 :                       if (*TREE_STRING_POINTER (value) == '\0')
   22056              :                         {
   22057            1 :                           c_parser_error (parser, "non-empty string literal expected");
   22058            1 :                           return error_mark_node;
   22059              :                         }
   22060           63 :                       char c = omp_get_fr_id_from_name (TREE_STRING_POINTER (value));
   22061           63 :                       if (c == GOMP_INTEROP_IFR_UNKNOWN)
   22062            3 :                         warning_at (cval.get_location (), OPT_Wopenmp,
   22063              :                                     "unknown foreign runtime identifier %qs",
   22064            3 :                                     TREE_STRING_POINTER (value));
   22065           63 :                      str += c;
   22066           63 :                      has_fr = true;
   22067              :                     }
   22068              :                 }
   22069           37 :               else if (!is_fr)
   22070              :                 {
   22071            1 :                   c_parser_error (parser, "expected string literal");
   22072            1 :                   return error_mark_node;
   22073              :                 }
   22074              :               else
   22075              :                 {
   22076           36 :                   c_expr cval = c_parser_expr_no_commas (parser, NULL);
   22077           36 :                   tree value = c_fully_fold (cval.value, false, NULL);
   22078           70 :                   if (INTEGRAL_TYPE_P (TREE_TYPE (value))
   22079           68 :                       && TREE_CODE (value) != INTEGER_CST)
   22080            3 :                     value = convert_lvalue_to_rvalue (cval.get_start (), cval,
   22081              :                                                       false, true).value;
   22082              : 
   22083           36 :                   if (TREE_CODE (value) != INTEGER_CST
   22084           32 :                       || !tree_fits_shwi_p (value))
   22085              :                     {
   22086            4 :                       c_parser_error (parser, "expected string literal or "
   22087              :                                               "constant integer expression");
   22088            4 :                       return error_mark_node;
   22089              :                     }
   22090           32 :                   HOST_WIDE_INT n = tree_to_shwi (value);
   22091           32 :                   if (n < 1 || n > GOMP_INTEROP_IFR_LAST)
   22092              :                     {
   22093            0 :                       warning_at (cval.get_location (), OPT_Wopenmp,
   22094              :                                   "unknown foreign runtime identifier %qwd", n);
   22095            0 :                       n = GOMP_INTEROP_IFR_UNKNOWN;
   22096              :                     }
   22097           32 :                   str += (char) n;
   22098           32 :                   has_fr = true;
   22099              :                 }
   22100          164 :               if (!is_fr
   22101          223 :                   && c_parser_next_token_is (parser, CPP_COMMA))
   22102              :                 {
   22103            5 :                   c_parser_consume_token (parser);
   22104            5 :                   continue;
   22105              :                 }
   22106          213 :               if (!c_parser_require (parser, CPP_CLOSE_PAREN,
   22107              :                                      is_fr ? G_("expected %<)%>")
   22108              :                                            : G_("expected %<)%> or %<,%>")))
   22109            4 :                 return error_mark_node;
   22110          150 :               break;
   22111            5 :             }
   22112          150 :           if (c_parser_next_token_is (parser, CPP_COMMA))
   22113              :             {
   22114           39 :               c_parser_consume_token (parser);
   22115           39 :               continue;
   22116              :             }
   22117          111 :           if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
   22118              :             break;
   22119            2 :           c_parser_error (parser, "expected %<,%> or %<}%>");
   22120            2 :           return error_mark_node;
   22121           39 :         }
   22122          109 :       str += (char) GOMP_INTEROP_IFR_SEPARATOR;
   22123          109 :       str += str2;
   22124          109 :       str += '\0';
   22125          109 :       c_parser_consume_token (parser);
   22126          109 :       if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   22127              :         break;
   22128           66 :       if (!c_parser_require (parser, CPP_COMMA, "expected %<)%> or %<,%>"))
   22129            1 :         return error_mark_node;
   22130              :     }
   22131           43 :   c_parser_consume_token (parser);
   22132           43 :   str += '\0';
   22133           43 :   tree res = build_string (str.length (), str.data ());
   22134           43 :   TREE_TYPE (res) = build_array_type_nelts (unsigned_char_type_node,
   22135           43 :                                                   str.length ());
   22136           43 :   return res;
   22137          186 : }
   22138              : 
   22139              : /* OpenMP 5.1
   22140              :      modifiers of the 'init' clause, used by the 'init' and the
   22141              :      'append_args' clauses.
   22142              : 
   22143              :    Modifiers:
   22144              :      target
   22145              :      targetsync
   22146              :      prefer_type (preference-specification)
   22147              : 
   22148              :   Returns 'false' if an error has been issued.  */
   22149              : 
   22150              : static bool
   22151          234 : c_parser_omp_clause_init_modifiers (c_parser *parser, bool *target,
   22152              :                                     bool *targetsync, tree *prefer_type_tree)
   22153              : {
   22154          234 :   *target = false;
   22155          234 :   *targetsync = false;
   22156          234 :   *prefer_type_tree = NULL_TREE;
   22157              : 
   22158          540 :   do
   22159              :     {
   22160          387 :       c_token *tok = c_parser_peek_token (parser);
   22161          387 :       if (tok->type != CPP_NAME)
   22162            1 :         goto fail;
   22163          386 :       const char *p = IDENTIFIER_POINTER (tok->value);
   22164          386 :       if (strcmp ("targetsync", p) == 0)
   22165              :         {
   22166          105 :           if (*targetsync)
   22167            1 :             error_at (tok->location, "duplicate %<targetsync%> modifier");
   22168          105 :           *targetsync = true;
   22169          105 :           c_parser_consume_token (parser);
   22170              :         }
   22171          281 :       else if (strcmp ("target", p) == 0)
   22172              :         {
   22173          148 :           if (*target)
   22174            3 :             error_at (tok->location, "duplicate %<target%> modifier");
   22175          148 :           *target = true;
   22176          148 :           c_parser_consume_token (parser);
   22177              :         }
   22178          133 :       else if (strcmp ("prefer_type", p) == 0)
   22179              :         {
   22180          125 :           if (*prefer_type_tree != NULL_TREE)
   22181            1 :             error_at (tok->location, "duplicate %<prefer_type%> modifier");
   22182          125 :           c_parser_consume_token (parser);
   22183          125 :           *prefer_type_tree = c_parser_omp_modifier_prefer_type (parser);
   22184          125 :           if (*prefer_type_tree == error_mark_node)
   22185              :             return false;
   22186              :         }
   22187              :       else
   22188            8 :         goto fail;
   22189          350 :       tok = c_parser_peek_token (parser);
   22190          350 :       if (tok->type == CPP_COMMA)
   22191              :         {
   22192          153 :           c_parser_consume_token (parser);
   22193          153 :           continue;
   22194              :         }
   22195              :       /* Unknown token - either done or an error; handle it in the caller.  */
   22196              :       return true;
   22197          153 :     }
   22198              :   while (true);
   22199              : 
   22200            9 : fail:
   22201            9 :   c_parser_error (parser,
   22202              :                   "expected %<prefer_type%>, %<target%>, or %<targetsync%>");
   22203            9 :   return false;
   22204              : }
   22205              : 
   22206              : /* OpenMP 5.1:
   22207              :    init ( [init-modifier-list : ] variable-list )
   22208              : 
   22209              :    Modifiers:
   22210              :      target
   22211              :      targetsync
   22212              :      prefer_type (preference-specification) */
   22213              : 
   22214              : static tree
   22215          167 : c_parser_omp_clause_init (c_parser *parser, tree list)
   22216              : {
   22217          167 :   location_t loc = c_parser_peek_token (parser)->location;
   22218              : 
   22219          167 :   matching_parens parens;
   22220          167 :   if (!parens.require_open (parser))
   22221              :     return list;
   22222              : 
   22223          167 :   bool target = false;
   22224          167 :   bool targetsync = false;
   22225          167 :   tree prefer_type_tree = NULL_TREE;
   22226              : 
   22227          167 :   if (!c_parser_omp_clause_init_modifiers (parser, &target, &targetsync,
   22228              :                                            &prefer_type_tree)
   22229          167 :       || !c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   22230              :     {
   22231           39 :       if (prefer_type_tree != error_mark_node)
   22232           11 :         parens.skip_until_found_close (parser);
   22233              :       return list;
   22234              :     }
   22235              : 
   22236          128 :   if (!target && !targetsync)
   22237            2 :     error_at (loc,
   22238              :               "missing required %<target%> and/or %<targetsync%> modifier");
   22239              : 
   22240          128 :   tree nl = c_parser_omp_variable_list (parser, loc, OMP_CLAUSE_INIT, list,
   22241              :                                         false);
   22242          128 :   parens.skip_until_found_close (parser);
   22243              : 
   22244          408 :   for (tree c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   22245              :     {
   22246          152 :       TREE_ADDRESSABLE (OMP_CLAUSE_DECL (c)) = 1;
   22247          152 :       if (target)
   22248           90 :         OMP_CLAUSE_INIT_TARGET (c) = 1;
   22249          152 :       if (targetsync)
   22250           81 :         OMP_CLAUSE_INIT_TARGETSYNC (c) = 1;
   22251          152 :       if (prefer_type_tree)
   22252           73 :         OMP_CLAUSE_INIT_PREFER_TYPE (c) = prefer_type_tree;
   22253              :     }
   22254              :   return nl;
   22255              : }
   22256              : 
   22257              : /* OpenMP 5.0:
   22258              :    use ( variable-list ) */
   22259              : 
   22260              : static tree
   22261           43 : c_parser_omp_clause_use (c_parser *parser, tree list)
   22262              : {
   22263           43 :   return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_USE, list);
   22264              : }
   22265              : 
   22266              : /* OpenMP 6.0:
   22267              :    interop ( variable-list ) */
   22268              : 
   22269              : static tree
   22270           43 : c_parser_omp_clause_interop (c_parser *parser, tree list)
   22271              : {
   22272           43 :   check_no_duplicate_clause (list, OMP_CLAUSE_INTEROP, "interop");
   22273           43 :   tree nl = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_INTEROP, list);
   22274          145 :   for (tree c = nl; c != list; c = OMP_CLAUSE_CHAIN (c))
   22275              :     {
   22276           59 :       TREE_USED (OMP_CLAUSE_DECL (c)) = 1;
   22277           59 :       DECL_READ_P (OMP_CLAUSE_DECL (c)) = 1;
   22278              :     }
   22279           43 :   return nl;
   22280              : }
   22281              : 
   22282              : /* Parse all OpenACC clauses.  The set clauses allowed by the directive
   22283              :    is a bitmask in MASK.  Return the list of clauses found.  */
   22284              : 
   22285              : static tree
   22286         5352 : c_parser_oacc_all_clauses (c_parser *parser, omp_clause_mask mask,
   22287              :                            const char *where, bool finish_p = true,
   22288              :                            bool target_p = false)
   22289              : {
   22290         5352 :   tree clauses = NULL;
   22291         5352 :   bool first = true;
   22292              : 
   22293        12079 :   while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   22294              :     {
   22295         6773 :       location_t here;
   22296         6773 :       pragma_omp_clause c_kind;
   22297         6773 :       const char *c_name;
   22298         6773 :       tree prev = clauses;
   22299              : 
   22300         9391 :       if (!first && c_parser_next_token_is (parser, CPP_COMMA))
   22301           11 :         c_parser_consume_token (parser);
   22302              : 
   22303         6773 :       here = c_parser_peek_token (parser)->location;
   22304         6773 :       c_kind = c_parser_omp_clause_name (parser);
   22305              : 
   22306         6773 :       switch (c_kind)
   22307              :         {
   22308          240 :         case PRAGMA_OACC_CLAUSE_ASYNC:
   22309          240 :           clauses = c_parser_oacc_clause_async (parser, clauses);
   22310          240 :           c_name = "async";
   22311          240 :           break;
   22312          125 :         case PRAGMA_OACC_CLAUSE_AUTO:
   22313          125 :           clauses = c_parser_oacc_simple_clause (here, OMP_CLAUSE_AUTO,
   22314              :                                                  clauses);
   22315          125 :           c_name = "auto";
   22316          125 :           break;
   22317           27 :         case PRAGMA_OACC_CLAUSE_ATTACH:
   22318           27 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22319           27 :           c_name = "attach";
   22320           27 :           break;
   22321           59 :         case PRAGMA_OACC_CLAUSE_COLLAPSE:
   22322           59 :           clauses = c_parser_omp_clause_collapse (parser, clauses);
   22323           59 :           c_name = "collapse";
   22324           59 :           break;
   22325          806 :         case PRAGMA_OACC_CLAUSE_COPY:
   22326          806 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22327          806 :           c_name = "copy";
   22328          806 :           break;
   22329          359 :         case PRAGMA_OACC_CLAUSE_COPYIN:
   22330          359 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22331          359 :           c_name = "copyin";
   22332          359 :           break;
   22333          390 :         case PRAGMA_OACC_CLAUSE_COPYOUT:
   22334          390 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22335          390 :           c_name = "copyout";
   22336          390 :           break;
   22337           94 :         case PRAGMA_OACC_CLAUSE_CREATE:
   22338           94 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22339           94 :           c_name = "create";
   22340           94 :           break;
   22341           68 :         case PRAGMA_OACC_CLAUSE_DELETE:
   22342           68 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22343           68 :           c_name = "delete";
   22344           68 :           break;
   22345           88 :         case PRAGMA_OMP_CLAUSE_DEFAULT:
   22346           88 :           clauses = c_parser_omp_clause_default (parser, clauses, true);
   22347           88 :           c_name = "default";
   22348           88 :           break;
   22349           20 :         case PRAGMA_OACC_CLAUSE_DETACH:
   22350           20 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22351           20 :           c_name = "detach";
   22352           20 :           break;
   22353           36 :         case PRAGMA_OACC_CLAUSE_DEVICE:
   22354           36 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22355           36 :           c_name = "device";
   22356           36 :           break;
   22357           57 :         case PRAGMA_OACC_CLAUSE_DEVICEPTR:
   22358           57 :           clauses = c_parser_oacc_data_clause_deviceptr (parser, clauses);
   22359           57 :           c_name = "deviceptr";
   22360           57 :           break;
   22361           16 :         case PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT:
   22362           16 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22363           16 :           c_name = "device_resident";
   22364           16 :           break;
   22365           12 :         case PRAGMA_OACC_CLAUSE_FINALIZE:
   22366           12 :           clauses = c_parser_oacc_simple_clause (here, OMP_CLAUSE_FINALIZE,
   22367              :                                                  clauses);
   22368           12 :           c_name = "finalize";
   22369           12 :           break;
   22370          113 :         case PRAGMA_OACC_CLAUSE_FIRSTPRIVATE:
   22371          113 :           clauses = c_parser_omp_clause_firstprivate (parser, clauses);
   22372          113 :           c_name = "firstprivate";
   22373          113 :           break;
   22374          589 :         case PRAGMA_OACC_CLAUSE_GANG:
   22375          589 :           c_name = "gang";
   22376          589 :           clauses = c_parser_oacc_shape_clause (parser, here, OMP_CLAUSE_GANG,
   22377              :                                                 c_name, clauses);
   22378          589 :           break;
   22379           41 :         case PRAGMA_OACC_CLAUSE_HOST:
   22380           41 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22381           41 :           c_name = "host";
   22382           41 :           break;
   22383          105 :         case PRAGMA_OACC_CLAUSE_IF:
   22384          105 :           clauses = c_parser_omp_clause_if (parser, clauses, false);
   22385          105 :           c_name = "if";
   22386          105 :           break;
   22387           19 :         case PRAGMA_OACC_CLAUSE_IF_PRESENT:
   22388           19 :           clauses = c_parser_oacc_simple_clause (here, OMP_CLAUSE_IF_PRESENT,
   22389              :                                                  clauses);
   22390           19 :           c_name = "if_present";
   22391           19 :           break;
   22392           45 :         case PRAGMA_OACC_CLAUSE_INDEPENDENT:
   22393           45 :           clauses = c_parser_oacc_simple_clause (here, OMP_CLAUSE_INDEPENDENT,
   22394              :                                                  clauses);
   22395           45 :           c_name = "independent";
   22396           45 :           break;
   22397           13 :         case PRAGMA_OACC_CLAUSE_LINK:
   22398           13 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22399           13 :           c_name = "link";
   22400           13 :           break;
   22401           10 :         case PRAGMA_OACC_CLAUSE_NO_CREATE:
   22402           10 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22403           10 :           c_name = "no_create";
   22404           10 :           break;
   22405           25 :         case PRAGMA_OACC_CLAUSE_NOHOST:
   22406           25 :           clauses = c_parser_oacc_simple_clause (here, OMP_CLAUSE_NOHOST,
   22407              :                                                  clauses);
   22408           25 :           c_name = "nohost";
   22409           25 :           break;
   22410          302 :         case PRAGMA_OACC_CLAUSE_NUM_GANGS:
   22411          302 :           clauses = c_parser_oacc_single_int_clause (parser,
   22412              :                                                      OMP_CLAUSE_NUM_GANGS,
   22413              :                                                      clauses);
   22414          302 :           c_name = "num_gangs";
   22415          302 :           break;
   22416          207 :         case PRAGMA_OACC_CLAUSE_NUM_WORKERS:
   22417          207 :           clauses = c_parser_oacc_single_int_clause (parser,
   22418              :                                                      OMP_CLAUSE_NUM_WORKERS,
   22419              :                                                      clauses);
   22420          207 :           c_name = "num_workers";
   22421          207 :           break;
   22422          128 :         case PRAGMA_OACC_CLAUSE_PRESENT:
   22423          128 :           clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22424          128 :           c_name = "present";
   22425          128 :           break;
   22426           66 :         case PRAGMA_OACC_CLAUSE_PRIVATE:
   22427           66 :           clauses = c_parser_omp_clause_private (parser, clauses);
   22428           66 :           c_name = "private";
   22429           66 :           break;
   22430          905 :         case PRAGMA_OACC_CLAUSE_REDUCTION:
   22431          905 :           clauses
   22432          905 :             = c_parser_omp_clause_reduction (parser, OMP_CLAUSE_REDUCTION,
   22433              :                                              false, clauses);
   22434          905 :           c_name = "reduction";
   22435          905 :           break;
   22436           66 :         case PRAGMA_OACC_CLAUSE_SELF:
   22437           66 :           if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_HOST)) == 0)
   22438              :             /* OpenACC compute construct */
   22439           48 :             clauses = c_parser_oacc_compute_clause_self (parser, clauses);
   22440              :           else
   22441              :             /* OpenACC 'update' directive */
   22442           18 :             clauses = c_parser_oacc_data_clause (parser, c_kind, clauses);
   22443              :           c_name = "self";
   22444              :           break;
   22445          261 :         case PRAGMA_OACC_CLAUSE_SEQ:
   22446          261 :           clauses = c_parser_oacc_simple_clause (here, OMP_CLAUSE_SEQ,
   22447              :                                                  clauses);
   22448          261 :           c_name = "seq";
   22449          261 :           break;
   22450          123 :         case PRAGMA_OACC_CLAUSE_TILE:
   22451          123 :           clauses = c_parser_oacc_clause_tile (parser, clauses);
   22452          123 :           c_name = "tile";
   22453          123 :           break;
   22454           21 :         case PRAGMA_OACC_CLAUSE_USE_DEVICE:
   22455           21 :           clauses = c_parser_omp_clause_use_device_ptr (parser, clauses);
   22456           21 :           c_name = "use_device";
   22457           21 :           break;
   22458          518 :         case PRAGMA_OACC_CLAUSE_VECTOR:
   22459          518 :           c_name = "vector";
   22460          518 :           clauses = c_parser_oacc_shape_clause (parser, here, OMP_CLAUSE_VECTOR,
   22461              :                                                 c_name, clauses);
   22462          518 :           break;
   22463          223 :         case PRAGMA_OACC_CLAUSE_VECTOR_LENGTH:
   22464          223 :           clauses = c_parser_oacc_single_int_clause (parser,
   22465              :                                                      OMP_CLAUSE_VECTOR_LENGTH,
   22466              :                                                      clauses);
   22467          223 :           c_name = "vector_length";
   22468          223 :           break;
   22469           97 :         case PRAGMA_OACC_CLAUSE_WAIT:
   22470           97 :           clauses = c_parser_oacc_clause_wait (parser, clauses);
   22471           97 :           c_name = "wait";
   22472           97 :           break;
   22473          453 :         case PRAGMA_OACC_CLAUSE_WORKER:
   22474          453 :           c_name = "worker";
   22475          453 :           clauses = c_parser_oacc_shape_clause (parser, here, OMP_CLAUSE_WORKER,
   22476              :                                                 c_name, clauses);
   22477          453 :           break;
   22478           46 :         default:
   22479           46 :           c_parser_error (parser, "expected an OpenACC clause");
   22480           46 :           goto saw_error;
   22481              :         }
   22482              : 
   22483         6727 :       first = false;
   22484              : 
   22485         6727 :       if (((mask >> c_kind) & 1) == 0)
   22486              :         {
   22487              :           /* Remove the invalid clause(s) from the list to avoid
   22488              :              confusing the rest of the compiler.  */
   22489           18 :           clauses = prev;
   22490           18 :           error_at (here, "%qs is not valid for %qs", c_name, where);
   22491              :         }
   22492              :     }
   22493              : 
   22494         5306 :  saw_error:
   22495         5352 :   c_parser_skip_to_pragma_eol (parser);
   22496              : 
   22497         5352 :   if (finish_p)
   22498         7831 :     return c_finish_omp_clauses (clauses, target_p ? C_ORT_ACC_TARGET
   22499         4656 :                                                    : C_ORT_ACC);
   22500              : 
   22501              :   return clauses;
   22502              : }
   22503              : 
   22504              : /* Parse all OpenMP clauses.  The set clauses allowed by the directive
   22505              :    is a bitmask in MASK.  Return the list of clauses found.
   22506              :    FINISH_P set if c_finish_omp_clauses should be called.
   22507              :    NESTED non-zero if clauses should be terminated by closing paren instead
   22508              :    of end of pragma.  If it is 2, additionally commas are required in between
   22509              :    the clauses.  */
   22510              : 
   22511              : static tree
   22512        21368 : c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask,
   22513              :                           const char *where, bool finish_p = true,
   22514              :                           int nested = 0)
   22515              : {
   22516        21368 :   tree clauses = NULL;
   22517        21368 :   bool first = true;
   22518              : 
   22519        50512 :   while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   22520              :     {
   22521        29239 :       location_t here;
   22522        29239 :       pragma_omp_clause c_kind;
   22523        29239 :       const char *c_name;
   22524        29239 :       tree prev = clauses;
   22525              : 
   22526        29342 :       if (nested && c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   22527              :         break;
   22528              : 
   22529        29214 :       if (!first || nested != 2)
   22530              :         {
   22531        29188 :           if (c_parser_next_token_is (parser, CPP_COMMA))
   22532         2702 :             c_parser_consume_token (parser);
   22533        26486 :           else if (nested == 2)
   22534            3 :             error_at (c_parser_peek_token (parser)->location,
   22535              :                       "clauses in %<simd%> trait should be separated "
   22536              :                       "by %<,%>");
   22537              :         }
   22538              : 
   22539        29214 :       here = c_parser_peek_token (parser)->location;
   22540        29214 :       c_kind = c_parser_omp_clause_name (parser);
   22541              : 
   22542        29214 :       switch (c_kind)
   22543              :         {
   22544          122 :         case PRAGMA_OMP_CLAUSE_BIND:
   22545          122 :           clauses = c_parser_omp_clause_bind (parser, clauses);
   22546          122 :           c_name = "bind";
   22547          122 :           break;
   22548         3340 :         case PRAGMA_OMP_CLAUSE_COLLAPSE:
   22549         3340 :           clauses = c_parser_omp_clause_collapse (parser, clauses);
   22550         3340 :           c_name = "collapse";
   22551         3340 :           break;
   22552          102 :         case PRAGMA_OMP_CLAUSE_COPYIN:
   22553          102 :           clauses = c_parser_omp_clause_copyin (parser, clauses);
   22554          102 :           c_name = "copyin";
   22555          102 :           break;
   22556           24 :         case PRAGMA_OMP_CLAUSE_COPYPRIVATE:
   22557           24 :           clauses = c_parser_omp_clause_copyprivate (parser, clauses);
   22558           24 :           c_name = "copyprivate";
   22559           24 :           break;
   22560          641 :         case PRAGMA_OMP_CLAUSE_DEFAULT:
   22561          641 :           clauses = c_parser_omp_clause_default (parser, clauses, false);
   22562          641 :           c_name = "default";
   22563          641 :           break;
   22564           34 :         case PRAGMA_OMP_CLAUSE_DETACH:
   22565           34 :           clauses = c_parser_omp_clause_detach (parser, clauses);
   22566           34 :           c_name = "detach";
   22567           34 :           break;
   22568           63 :         case PRAGMA_OMP_CLAUSE_FILTER:
   22569           63 :           clauses = c_parser_omp_clause_filter (parser, clauses);
   22570           63 :           c_name = "filter";
   22571           63 :           break;
   22572          762 :         case PRAGMA_OMP_CLAUSE_FIRSTPRIVATE:
   22573          762 :           clauses = c_parser_omp_clause_firstprivate (parser, clauses);
   22574          762 :           c_name = "firstprivate";
   22575          762 :           break;
   22576           99 :         case PRAGMA_OMP_CLAUSE_FINAL:
   22577           99 :           clauses = c_parser_omp_clause_final (parser, clauses);
   22578           99 :           c_name = "final";
   22579           99 :           break;
   22580           62 :         case PRAGMA_OMP_CLAUSE_GRAINSIZE:
   22581           62 :           clauses = c_parser_omp_clause_grainsize (parser, clauses);
   22582           62 :           c_name = "grainsize";
   22583           62 :           break;
   22584           29 :         case PRAGMA_OMP_CLAUSE_HINT:
   22585           29 :           clauses = c_parser_omp_clause_hint (parser, clauses);
   22586           29 :           c_name = "hint";
   22587           29 :           break;
   22588          241 :         case PRAGMA_OMP_CLAUSE_DEFAULTMAP:
   22589          241 :           clauses = c_parser_omp_clause_defaultmap (parser, clauses);
   22590          241 :           c_name = "defaultmap";
   22591          241 :           break;
   22592          788 :         case PRAGMA_OMP_CLAUSE_IF:
   22593          788 :           clauses = c_parser_omp_clause_if (parser, clauses, true);
   22594          788 :           c_name = "if";
   22595          788 :           break;
   22596          322 :         case PRAGMA_OMP_CLAUSE_IN_REDUCTION:
   22597          322 :           clauses
   22598          322 :             = c_parser_omp_clause_reduction (parser, OMP_CLAUSE_IN_REDUCTION,
   22599              :                                              true, clauses);
   22600          322 :           c_name = "in_reduction";
   22601          322 :           break;
   22602           26 :         case PRAGMA_OMP_CLAUSE_INDIRECT:
   22603           26 :           clauses = c_parser_omp_clause_indirect (parser, clauses);
   22604           26 :           c_name = "indirect";
   22605           26 :           break;
   22606          768 :         case PRAGMA_OMP_CLAUSE_LASTPRIVATE:
   22607          768 :           clauses = c_parser_omp_clause_lastprivate (parser, clauses);
   22608          768 :           c_name = "lastprivate";
   22609          768 :           break;
   22610           79 :         case PRAGMA_OMP_CLAUSE_MERGEABLE:
   22611           79 :           clauses = c_parser_omp_clause_mergeable (parser, clauses);
   22612           79 :           c_name = "mergeable";
   22613           79 :           break;
   22614          395 :         case PRAGMA_OMP_CLAUSE_NOWAIT:
   22615          395 :           clauses = c_parser_omp_clause_nowait (parser, clauses);
   22616          395 :           c_name = "nowait";
   22617          395 :           break;
   22618           50 :         case PRAGMA_OMP_CLAUSE_NUM_TASKS:
   22619           50 :           clauses = c_parser_omp_clause_num_tasks (parser, clauses);
   22620           50 :           c_name = "num_tasks";
   22621           50 :           break;
   22622          467 :         case PRAGMA_OMP_CLAUSE_NUM_THREADS:
   22623          467 :           clauses = c_parser_omp_clause_num_threads (parser, clauses);
   22624          467 :           c_name = "num_threads";
   22625          467 :           break;
   22626          376 :         case PRAGMA_OMP_CLAUSE_ORDER:
   22627          376 :           clauses = c_parser_omp_clause_order (parser, clauses);
   22628          376 :           c_name = "order";
   22629          376 :           break;
   22630          310 :         case PRAGMA_OMP_CLAUSE_ORDERED:
   22631          310 :           clauses = c_parser_omp_clause_ordered (parser, clauses);
   22632          310 :           c_name = "ordered";
   22633          310 :           break;
   22634           98 :         case PRAGMA_OMP_CLAUSE_PRIORITY:
   22635           98 :           clauses = c_parser_omp_clause_priority (parser, clauses);
   22636           98 :           c_name = "priority";
   22637           98 :           break;
   22638          701 :         case PRAGMA_OMP_CLAUSE_PRIVATE:
   22639          701 :           clauses = c_parser_omp_clause_private (parser, clauses);
   22640          701 :           c_name = "private";
   22641          701 :           break;
   22642         1914 :         case PRAGMA_OMP_CLAUSE_REDUCTION:
   22643         1914 :           clauses
   22644         1914 :             = c_parser_omp_clause_reduction (parser, OMP_CLAUSE_REDUCTION,
   22645              :                                              true, clauses);
   22646         1914 :           c_name = "reduction";
   22647         1914 :           break;
   22648         3487 :         case PRAGMA_OMP_CLAUSE_SCHEDULE:
   22649         3487 :           clauses = c_parser_omp_clause_schedule (parser, clauses);
   22650         3487 :           c_name = "schedule";
   22651         3487 :           break;
   22652          711 :         case PRAGMA_OMP_CLAUSE_SHARED:
   22653          711 :           clauses = c_parser_omp_clause_shared (parser, clauses);
   22654          711 :           c_name = "shared";
   22655          711 :           break;
   22656           86 :         case PRAGMA_OMP_CLAUSE_TASK_REDUCTION:
   22657           86 :           clauses
   22658           86 :             = c_parser_omp_clause_reduction (parser, OMP_CLAUSE_TASK_REDUCTION,
   22659              :                                              true, clauses);
   22660           86 :           c_name = "task_reduction";
   22661           86 :           break;
   22662           97 :         case PRAGMA_OMP_CLAUSE_UNTIED:
   22663           97 :           clauses = c_parser_omp_clause_untied (parser, clauses);
   22664           97 :           c_name = "untied";
   22665           97 :           break;
   22666           82 :         case PRAGMA_OMP_CLAUSE_INBRANCH:
   22667           82 :           clauses = c_parser_omp_clause_branch (parser, OMP_CLAUSE_INBRANCH,
   22668              :                                                 clauses);
   22669           82 :           c_name = "inbranch";
   22670           82 :           break;
   22671          121 :         case PRAGMA_OMP_CLAUSE_NONTEMPORAL:
   22672          121 :           clauses = c_parser_omp_clause_nontemporal (parser, clauses);
   22673          121 :           c_name = "nontemporal";
   22674          121 :           break;
   22675          141 :         case PRAGMA_OMP_CLAUSE_NOTINBRANCH:
   22676          141 :           clauses = c_parser_omp_clause_branch (parser, OMP_CLAUSE_NOTINBRANCH,
   22677              :                                                 clauses);
   22678          141 :           c_name = "notinbranch";
   22679          141 :           break;
   22680          115 :         case PRAGMA_OMP_CLAUSE_PARALLEL:
   22681          115 :           clauses
   22682          115 :             = c_parser_omp_clause_cancelkind (parser, OMP_CLAUSE_PARALLEL,
   22683              :                                               clauses);
   22684          115 :           c_name = "parallel";
   22685          115 :           if (!first)
   22686              :             {
   22687            0 :              clause_not_first:
   22688            0 :               error_at (here, "%qs must be the first clause of %qs",
   22689              :                         c_name, where);
   22690            0 :               clauses = prev;
   22691              :             }
   22692              :           break;
   22693           84 :         case PRAGMA_OMP_CLAUSE_FOR:
   22694           84 :           clauses
   22695           84 :             = c_parser_omp_clause_cancelkind (parser, OMP_CLAUSE_FOR,
   22696              :                                               clauses);
   22697           84 :           c_name = "for";
   22698           84 :           if (!first)
   22699            0 :             goto clause_not_first;
   22700              :           break;
   22701           78 :         case PRAGMA_OMP_CLAUSE_SECTIONS:
   22702           78 :           clauses
   22703           78 :             = c_parser_omp_clause_cancelkind (parser, OMP_CLAUSE_SECTIONS,
   22704              :                                               clauses);
   22705           78 :           c_name = "sections";
   22706           78 :           if (!first)
   22707            0 :             goto clause_not_first;
   22708              :           break;
   22709          110 :         case PRAGMA_OMP_CLAUSE_TASKGROUP:
   22710          110 :           clauses
   22711          110 :             = c_parser_omp_clause_cancelkind (parser, OMP_CLAUSE_TASKGROUP,
   22712              :                                               clauses);
   22713          110 :           c_name = "taskgroup";
   22714          110 :           if (!first)
   22715            0 :             goto clause_not_first;
   22716              :           break;
   22717           34 :         case PRAGMA_OMP_CLAUSE_LINK:
   22718           34 :           clauses
   22719           34 :             = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_LINK, clauses);
   22720           34 :           c_name = "link";
   22721           34 :           break;
   22722           12 :         case PRAGMA_OMP_CLAUSE_LOCAL:
   22723           12 :           clauses
   22724           12 :             = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_LOCAL, clauses);
   22725           12 :           c_name = "local";
   22726           12 :           break;
   22727          571 :         case PRAGMA_OMP_CLAUSE_TO:
   22728          571 :           if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINK)) != 0)
   22729              :             {
   22730           87 :               gcc_rich_location richloc (here);
   22731           87 :               richloc.add_fixit_replace ("enter");
   22732           87 :               warning_at (&richloc, OPT_Wdeprecated_openmp,
   22733              :                           "%<to%> clause with %<declare target%> deprecated "
   22734              :                           "since OpenMP 5.2, use %<enter%>");
   22735           87 :               tree nl = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ENTER,
   22736              :                                                       clauses);
   22737          280 :               for (tree c = nl; c != clauses; c = OMP_CLAUSE_CHAIN (c))
   22738          106 :                 OMP_CLAUSE_ENTER_TO (c) = 1;
   22739           87 :               clauses = nl;
   22740           87 :             }
   22741              :           else
   22742          484 :             clauses = c_parser_omp_clause_from_to (parser, OMP_CLAUSE_TO,
   22743              :                                                    clauses);
   22744              :           c_name = "to";
   22745              :           break;
   22746         2534 :         case PRAGMA_OMP_CLAUSE_FROM:
   22747         2534 :           clauses = c_parser_omp_clause_from_to (parser, OMP_CLAUSE_FROM,
   22748              :                                                  clauses);
   22749         2534 :           c_name = "from";
   22750         2534 :           break;
   22751          117 :         case PRAGMA_OMP_CLAUSE_UNIFORM:
   22752          117 :           clauses = c_parser_omp_clause_uniform (parser, clauses);
   22753          117 :           c_name = "uniform";
   22754          117 :           break;
   22755          206 :         case PRAGMA_OMP_CLAUSE_NUM_TEAMS:
   22756          206 :           clauses = c_parser_omp_clause_num_teams (parser, clauses);
   22757          206 :           c_name = "num_teams";
   22758          206 :           break;
   22759          155 :         case PRAGMA_OMP_CLAUSE_THREAD_LIMIT:
   22760          155 :           clauses = c_parser_omp_clause_thread_limit (parser, clauses);
   22761          155 :           c_name = "thread_limit";
   22762          155 :           break;
   22763          228 :         case PRAGMA_OMP_CLAUSE_ALIGNED:
   22764          228 :           clauses = c_parser_omp_clause_aligned (parser, clauses);
   22765          228 :           c_name = "aligned";
   22766          228 :           break;
   22767          485 :         case PRAGMA_OMP_CLAUSE_ALLOCATE:
   22768          485 :           clauses = c_parser_omp_clause_allocate (parser, clauses);
   22769          485 :           c_name = "allocate";
   22770          485 :           break;
   22771          481 :         case PRAGMA_OMP_CLAUSE_LINEAR:
   22772          481 :           clauses = c_parser_omp_clause_linear (parser, clauses);
   22773          481 :           c_name = "linear";
   22774          481 :           break;
   22775           55 :         case PRAGMA_OMP_CLAUSE_USES_ALLOCATORS:
   22776           55 :           clauses = c_parser_omp_clause_uses_allocators (parser, clauses);
   22777           55 :           c_name = "uses_allocators";
   22778           55 :           break;
   22779          151 :         case PRAGMA_OMP_CLAUSE_AFFINITY:
   22780          151 :           clauses = c_parser_omp_clause_affinity (parser, clauses);
   22781          151 :           c_name = "affinity";
   22782          151 :           break;
   22783          857 :         case PRAGMA_OMP_CLAUSE_DEPEND:
   22784          857 :           clauses = c_parser_omp_clause_depend (parser, clauses, here);
   22785          857 :           c_name = "depend";
   22786          857 :           break;
   22787          145 :         case PRAGMA_OMP_CLAUSE_DOACROSS:
   22788          145 :           clauses = c_parser_omp_clause_doacross (parser, clauses);
   22789          145 :           c_name = "doacross";
   22790          145 :           break;
   22791           41 :         case PRAGMA_OMP_CLAUSE_DESTROY:
   22792           41 :           clauses = c_parser_omp_clause_destroy (parser, clauses);
   22793           41 :           c_name = "destroy";
   22794           41 :           break;
   22795           21 :         case PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE:
   22796           21 :           clauses = c_parser_omp_clause_dyn_groupprivate (parser, clauses);
   22797           21 :           c_name = "dyn_groupprivate";
   22798           21 :           break;
   22799          167 :         case PRAGMA_OMP_CLAUSE_INIT:
   22800          167 :           clauses = c_parser_omp_clause_init (parser, clauses);
   22801          167 :           c_name = "init";
   22802          167 :           break;
   22803           43 :         case PRAGMA_OMP_CLAUSE_USE:
   22804           43 :           clauses = c_parser_omp_clause_use (parser, clauses);
   22805           43 :           c_name = "use";
   22806           43 :           break;
   22807           43 :         case PRAGMA_OMP_CLAUSE_INTEROP:
   22808           43 :           clauses = c_parser_omp_clause_interop (parser, clauses);
   22809           43 :           c_name = "interop";
   22810           43 :           break;
   22811         2231 :         case PRAGMA_OMP_CLAUSE_MAP:
   22812         2231 :           clauses = c_parser_omp_clause_map (parser, clauses, false);
   22813         2231 :           c_name = "map";
   22814         2231 :           break;
   22815           10 :         case PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR:
   22816           10 :           clauses = c_parser_omp_clause_use_device_ptr (parser, clauses);
   22817           10 :           c_name = "use_device_ptr";
   22818           10 :           break;
   22819           35 :         case PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR:
   22820           35 :           clauses = c_parser_omp_clause_use_device_addr (parser, clauses);
   22821           35 :           c_name = "use_device_addr";
   22822           35 :           break;
   22823           88 :         case PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR:
   22824           88 :           clauses = c_parser_omp_clause_has_device_addr (parser, clauses);
   22825           88 :           c_name = "has_device_addr";
   22826           88 :           break;
   22827          115 :         case PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR:
   22828          115 :           clauses = c_parser_omp_clause_is_device_ptr (parser, clauses);
   22829          115 :           c_name = "is_device_ptr";
   22830          115 :           break;
   22831          388 :         case PRAGMA_OMP_CLAUSE_DEVICE:
   22832          388 :           clauses = c_parser_omp_clause_device (parser, clauses);
   22833          388 :           c_name = "device";
   22834          388 :           break;
   22835         1594 :         case PRAGMA_OMP_CLAUSE_DIST_SCHEDULE:
   22836         1594 :           clauses = c_parser_omp_clause_dist_schedule (parser, clauses);
   22837         1594 :           c_name = "dist_schedule";
   22838         1594 :           break;
   22839          195 :         case PRAGMA_OMP_CLAUSE_PROC_BIND:
   22840          195 :           clauses = c_parser_omp_clause_proc_bind (parser, clauses);
   22841          195 :           c_name = "proc_bind";
   22842          195 :           break;
   22843           53 :         case PRAGMA_OMP_CLAUSE_DEVICE_TYPE:
   22844           53 :           clauses = c_parser_omp_clause_device_type (parser, clauses);
   22845           53 :           c_name = "device_type";
   22846           53 :           break;
   22847          267 :         case PRAGMA_OMP_CLAUSE_SAFELEN:
   22848          267 :           clauses = c_parser_omp_clause_safelen (parser, clauses);
   22849          267 :           c_name = "safelen";
   22850          267 :           break;
   22851          368 :         case PRAGMA_OMP_CLAUSE_SIMDLEN:
   22852          368 :           clauses = c_parser_omp_clause_simdlen (parser, clauses);
   22853          368 :           c_name = "simdlen";
   22854          368 :           break;
   22855           18 :         case PRAGMA_OMP_CLAUSE_NOGROUP:
   22856           18 :           clauses = c_parser_omp_clause_nogroup (parser, clauses);
   22857           18 :           c_name = "nogroup";
   22858           18 :           break;
   22859           46 :         case PRAGMA_OMP_CLAUSE_THREADS:
   22860           46 :           clauses
   22861           46 :             = c_parser_omp_clause_orderedkind (parser, OMP_CLAUSE_THREADS,
   22862              :                                                clauses);
   22863           46 :           c_name = "threads";
   22864           46 :           break;
   22865           57 :         case PRAGMA_OMP_CLAUSE_SIMD:
   22866           57 :           clauses
   22867           57 :             = c_parser_omp_clause_orderedkind (parser, OMP_CLAUSE_SIMD,
   22868              :                                                clauses);
   22869           57 :           c_name = "simd";
   22870           57 :           break;
   22871           62 :         case PRAGMA_OMP_CLAUSE_ENTER:
   22872           62 :           clauses
   22873           62 :             = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ENTER,
   22874              :                                             clauses);
   22875           62 :           c_name = "enter";
   22876           62 :           break;
   22877           69 :         case PRAGMA_OMP_CLAUSE_FULL:
   22878           69 :           c_name = "full";
   22879           69 :           clauses = c_parser_omp_clause_full (parser, clauses);
   22880           69 :           break;
   22881          230 :         case PRAGMA_OMP_CLAUSE_PARTIAL:
   22882          230 :           c_name = "partial";
   22883          230 :           clauses = c_parser_omp_clause_partial (parser, clauses);
   22884          230 :           break;
   22885           24 :         case PRAGMA_OMP_CLAUSE_NOVARIANTS:
   22886           24 :           c_name = "novariants";
   22887           24 :           clauses = c_parser_omp_clause_novariants (parser, clauses);
   22888           24 :           break;
   22889           23 :         case PRAGMA_OMP_CLAUSE_NOCONTEXT:
   22890           23 :           c_name = "nocontext";
   22891           23 :           clauses = c_parser_omp_clause_nocontext (parser, clauses);
   22892           23 :           break;
   22893           70 :         default:
   22894           70 :           c_parser_error (parser, "expected an OpenMP clause");
   22895           70 :           goto saw_error;
   22896              :         }
   22897              : 
   22898        29144 :       first = false;
   22899              : 
   22900        29144 :       if (((mask >> c_kind) & 1) == 0)
   22901              :         {
   22902              :           /* Remove the invalid clause(s) from the list to avoid
   22903              :              confusing the rest of the compiler.  */
   22904           24 :           clauses = prev;
   22905           24 :           error_at (here, "%qs is not valid for %qs", c_name, where);
   22906              :         }
   22907              :     }
   22908              : 
   22909        21273 :  saw_error:
   22910        21368 :   if (!nested)
   22911        21342 :     c_parser_skip_to_pragma_eol (parser);
   22912              : 
   22913        21368 :   if (finish_p)
   22914              :     {
   22915         8681 :       if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNIFORM)) != 0)
   22916          427 :         return c_finish_omp_clauses (clauses, C_ORT_OMP_DECLARE_SIMD);
   22917         8254 :       if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_USE)) != 0)
   22918          183 :         return c_finish_omp_clauses (clauses, C_ORT_OMP_INTEROP);
   22919         8071 :       return c_finish_omp_clauses (clauses, C_ORT_OMP);
   22920              :     }
   22921              : 
   22922              :   return clauses;
   22923              : }
   22924              : 
   22925              : /* OpenACC 2.0, OpenMP 2.5:
   22926              :    structured-block:
   22927              :      statement
   22928              : 
   22929              :    In practice, we're also interested in adding the statement to an
   22930              :    outer node.  So it is convenient if we work around the fact that
   22931              :    c_parser_statement calls add_stmt.  */
   22932              : 
   22933              : static tree
   22934         7041 : c_parser_omp_structured_block (c_parser *parser, bool *if_p)
   22935              : {
   22936         7041 :   tree stmt = push_stmt_list ();
   22937         7041 :   parser->omp_attrs_forbidden_p = true;
   22938         7041 :   c_parser_statement (parser, if_p);
   22939         7041 :   return pop_stmt_list (stmt);
   22940              : }
   22941              : 
   22942              : /* OpenACC 2.0:
   22943              :    # pragma acc cache (variable-list) new-line
   22944              : 
   22945              :    OpenACC 2.7:
   22946              :    # pragma acc cache (readonly: variable-list) new-line
   22947              : 
   22948              :    LOC is the location of the #pragma token.
   22949              : */
   22950              : 
   22951              : static tree
   22952          137 : c_parser_oacc_cache (location_t loc, c_parser *parser)
   22953              : {
   22954          137 :   tree stmt, clauses = NULL_TREE;
   22955          137 :   bool readonly = false;
   22956          137 :   location_t open_loc = c_parser_peek_token (parser)->location;
   22957          137 :   matching_parens parens;
   22958          137 :   if (parens.require_open (parser))
   22959              :     {
   22960          135 :       c_token *token = c_parser_peek_token (parser);
   22961          135 :       if (token->type == CPP_NAME
   22962          131 :           && !strcmp (IDENTIFIER_POINTER (token->value), "readonly")
   22963          139 :           && c_parser_peek_2nd_token (parser)->type == CPP_COLON)
   22964              :         {
   22965            4 :           c_parser_consume_token (parser);
   22966            4 :           c_parser_consume_token (parser);
   22967            4 :           readonly = true;
   22968              :         }
   22969          135 :       clauses = c_parser_omp_variable_list (parser, open_loc,
   22970              :                                             OMP_CLAUSE__CACHE_, NULL_TREE);
   22971          135 :       parens.skip_until_found_close (parser);
   22972              :     }
   22973              : 
   22974          135 :   if (readonly)
   22975            8 :     for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
   22976            4 :       OMP_CLAUSE__CACHE__READONLY (c) = 1;
   22977              : 
   22978          137 :   clauses = c_finish_omp_clauses (clauses, C_ORT_ACC);
   22979              : 
   22980          137 :   c_parser_skip_to_pragma_eol (parser);
   22981              : 
   22982          137 :   stmt = make_node (OACC_CACHE);
   22983          137 :   TREE_TYPE (stmt) = void_type_node;
   22984          137 :   OACC_CACHE_CLAUSES (stmt) = clauses;
   22985          137 :   SET_EXPR_LOCATION (stmt, loc);
   22986          137 :   add_stmt (stmt);
   22987              : 
   22988          137 :   return stmt;
   22989              : }
   22990              : 
   22991              : /* OpenACC 2.0:
   22992              :    # pragma acc data oacc-data-clause[optseq] new-line
   22993              :      structured-block
   22994              : 
   22995              :    LOC is the location of the #pragma token.
   22996              : */
   22997              : 
   22998              : #define OACC_DATA_CLAUSE_MASK                                           \
   22999              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ATTACH)                \
   23000              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPY)          \
   23001              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN)                \
   23002              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT)               \
   23003              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE)                \
   23004              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEFAULT)               \
   23005              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR)             \
   23006              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF)                    \
   23007              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NO_CREATE)             \
   23008              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT))
   23009              : 
   23010              : static tree
   23011          497 : c_parser_oacc_data (location_t loc, c_parser *parser, bool *if_p)
   23012              : {
   23013          497 :   tree stmt, clauses, block;
   23014              : 
   23015          497 :   clauses = c_parser_oacc_all_clauses (parser, OACC_DATA_CLAUSE_MASK,
   23016              :                                        "#pragma acc data");
   23017              : 
   23018          497 :   block = c_begin_omp_parallel ();
   23019          497 :   add_stmt (c_parser_omp_structured_block (parser, if_p));
   23020              : 
   23021          497 :   stmt = c_finish_oacc_data (loc, clauses, block);
   23022              : 
   23023          497 :   return stmt;
   23024              : }
   23025              : 
   23026              : /* OpenACC 2.0:
   23027              :    # pragma acc declare oacc-data-clause[optseq] new-line
   23028              : */
   23029              : 
   23030              : #define OACC_DECLARE_CLAUSE_MASK                                        \
   23031              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPY)          \
   23032              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN)                \
   23033              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT)               \
   23034              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE)                \
   23035              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR)             \
   23036              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT)       \
   23037              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_LINK)          \
   23038              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT))
   23039              : 
   23040              : static void
   23041          144 : c_parser_oacc_declare (c_parser *parser)
   23042              : {
   23043          144 :   location_t pragma_loc = c_parser_peek_token (parser)->location;
   23044          144 :   tree clauses, stmt, t, decl;
   23045              : 
   23046          144 :   bool error = false;
   23047              : 
   23048          144 :   c_parser_consume_pragma (parser);
   23049              : 
   23050          144 :   clauses = c_parser_oacc_all_clauses (parser, OACC_DECLARE_CLAUSE_MASK,
   23051              :                                        "#pragma acc declare");
   23052          144 :   if (!clauses)
   23053              :     {
   23054            2 :       error_at (pragma_loc,
   23055              :                 "no valid clauses specified in %<#pragma acc declare%>");
   23056            2 :       return;
   23057              :     }
   23058              : 
   23059          296 :   for (t = clauses; t; t = OMP_CLAUSE_CHAIN (t))
   23060              :     {
   23061          154 :       location_t loc = OMP_CLAUSE_LOCATION (t);
   23062          154 :       decl = OMP_CLAUSE_DECL (t);
   23063          154 :       if (!DECL_P (decl))
   23064              :         {
   23065            1 :           error_at (loc, "array section in %<#pragma acc declare%>");
   23066            1 :           error = true;
   23067            1 :           continue;
   23068              :         }
   23069              : 
   23070          153 :       switch (OMP_CLAUSE_MAP_KIND (t))
   23071              :         {
   23072              :         case GOMP_MAP_FIRSTPRIVATE_POINTER:
   23073              :         case GOMP_MAP_ALLOC:
   23074              :         case GOMP_MAP_TO:
   23075              :         case GOMP_MAP_FORCE_DEVICEPTR:
   23076              :         case GOMP_MAP_DEVICE_RESIDENT:
   23077              :           break;
   23078              : 
   23079           13 :         case GOMP_MAP_LINK:
   23080           13 :           if (!global_bindings_p ()
   23081           13 :               && (TREE_STATIC (decl)
   23082            6 :                || !DECL_EXTERNAL (decl)))
   23083              :             {
   23084            2 :               error_at (loc,
   23085              :                         "%qD must be a global variable in "
   23086              :                         "%<#pragma acc declare link%>",
   23087              :                         decl);
   23088            2 :               error = true;
   23089            2 :               continue;
   23090              :             }
   23091              :           break;
   23092              : 
   23093           42 :         default:
   23094           42 :           if (global_bindings_p ())
   23095              :             {
   23096            5 :               error_at (loc, "invalid OpenACC clause at file scope");
   23097            5 :               error = true;
   23098            5 :               continue;
   23099              :             }
   23100           37 :           if (DECL_EXTERNAL (decl))
   23101              :             {
   23102           10 :               error_at (loc,
   23103              :                         "invalid use of %<extern%> variable %qD "
   23104              :                         "in %<#pragma acc declare%>", decl);
   23105           10 :               error = true;
   23106           10 :               continue;
   23107              :             }
   23108           27 :           else if (TREE_PUBLIC (decl))
   23109              :             {
   23110            2 :               error_at (loc,
   23111              :                         "invalid use of %<global%> variable %qD "
   23112              :                         "in %<#pragma acc declare%>", decl);
   23113            2 :               error = true;
   23114            2 :               continue;
   23115              :             }
   23116              :           break;
   23117              :         }
   23118              : 
   23119          134 :       if (!c_check_in_current_scope (decl))
   23120              :         {
   23121            2 :           error_at (loc,
   23122              :                     "%qD must be a variable declared in the same scope as "
   23123              :                     "%<#pragma acc declare%>", decl);
   23124            2 :           error = true;
   23125            2 :           continue;
   23126              :         }
   23127              : 
   23128          132 :       if (lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl))
   23129          250 :           || lookup_attribute ("omp declare target link",
   23130          118 :                                DECL_ATTRIBUTES (decl)))
   23131              :         {
   23132           17 :           error_at (loc, "variable %qD used more than once with "
   23133              :                     "%<#pragma acc declare%>", decl);
   23134           17 :           error = true;
   23135           17 :           continue;
   23136              :         }
   23137              : 
   23138          115 :       if (!error)
   23139              :         {
   23140          115 :           tree id;
   23141              : 
   23142          115 :           if (OMP_CLAUSE_MAP_KIND (t) == GOMP_MAP_LINK)
   23143            7 :             id = get_identifier ("omp declare target link");
   23144              :           else
   23145          108 :             id = get_identifier ("omp declare target");
   23146              : 
   23147          115 :           DECL_ATTRIBUTES (decl)
   23148          115 :                            = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (decl));
   23149              : 
   23150          115 :           if (global_bindings_p ())
   23151              :             {
   23152           45 :               symtab_node *node = symtab_node::get (decl);
   23153           45 :               if (node != NULL)
   23154              :                 {
   23155           33 :                   node->offloadable = 1;
   23156           33 :                   if (ENABLE_OFFLOADING)
   23157              :                     {
   23158              :                       g->have_offload = true;
   23159              :                       if (is_a <varpool_node *> (node))
   23160              :                         vec_safe_push (offload_vars, decl);
   23161              :                     }
   23162              :                 }
   23163              :             }
   23164              :         }
   23165              :     }
   23166              : 
   23167          142 :   if (error || global_bindings_p ())
   23168              :     return;
   23169              : 
   23170           68 :   stmt = make_node (OACC_DECLARE);
   23171           68 :   TREE_TYPE (stmt) = void_type_node;
   23172           68 :   OACC_DECLARE_CLAUSES (stmt) = clauses;
   23173           68 :   SET_EXPR_LOCATION (stmt, pragma_loc);
   23174              : 
   23175           68 :   add_stmt (stmt);
   23176              : 
   23177           68 :   return;
   23178              : }
   23179              : 
   23180              : /* OpenACC 2.0:
   23181              :    # pragma acc enter data oacc-enter-data-clause[optseq] new-line
   23182              : 
   23183              :    or
   23184              : 
   23185              :    # pragma acc exit data oacc-exit-data-clause[optseq] new-line
   23186              : 
   23187              : 
   23188              :    LOC is the location of the #pragma token.
   23189              : */
   23190              : 
   23191              : #define OACC_ENTER_DATA_CLAUSE_MASK                                     \
   23192              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF)                    \
   23193              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC)         \
   23194              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ATTACH)                \
   23195              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN)                \
   23196              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE)                \
   23197              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) )
   23198              : 
   23199              : #define OACC_EXIT_DATA_CLAUSE_MASK                                      \
   23200              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF)                    \
   23201              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC)         \
   23202              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT)               \
   23203              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DELETE)                \
   23204              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DETACH)                \
   23205              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_FINALIZE)              \
   23206              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) )
   23207              : 
   23208              : static void
   23209          261 : c_parser_oacc_enter_exit_data (c_parser *parser, bool enter)
   23210              : {
   23211          261 :   location_t loc = c_parser_peek_token (parser)->location;
   23212          261 :   tree clauses, stmt;
   23213          261 :   const char *p = "";
   23214              : 
   23215          261 :   c_parser_consume_pragma (parser);
   23216              : 
   23217          261 :   if (c_parser_next_token_is (parser, CPP_NAME))
   23218              :     {
   23219          258 :       p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   23220          258 :       c_parser_consume_token (parser);
   23221              :     }
   23222              : 
   23223          261 :   if (strcmp (p, "data") != 0)
   23224              :     {
   23225            8 :       error_at (loc, "expected %<data%> after %<#pragma acc %s%>",
   23226              :                 enter ? "enter" : "exit");
   23227            6 :       parser->error = true;
   23228            6 :       c_parser_skip_to_pragma_eol (parser);
   23229            6 :       return;
   23230              :     }
   23231              : 
   23232          255 :   if (enter)
   23233          129 :     clauses = c_parser_oacc_all_clauses (parser, OACC_ENTER_DATA_CLAUSE_MASK,
   23234              :                                          "#pragma acc enter data");
   23235              :   else
   23236          126 :     clauses = c_parser_oacc_all_clauses (parser, OACC_EXIT_DATA_CLAUSE_MASK,
   23237              :                                          "#pragma acc exit data");
   23238              : 
   23239          255 :   if (omp_find_clause (clauses, OMP_CLAUSE_MAP) == NULL_TREE)
   23240              :     {
   23241           15 :       error_at (loc, "%<#pragma acc %s data%> has no data movement clause",
   23242              :                 enter ? "enter" : "exit");
   23243           15 :       return;
   23244              :     }
   23245              : 
   23246          240 :   stmt = enter ? make_node (OACC_ENTER_DATA) : make_node (OACC_EXIT_DATA);
   23247          240 :   TREE_TYPE (stmt) = void_type_node;
   23248          240 :   OMP_STANDALONE_CLAUSES (stmt) = clauses;
   23249          240 :   SET_EXPR_LOCATION (stmt, loc);
   23250          240 :   add_stmt (stmt);
   23251              : }
   23252              : 
   23253              : 
   23254              : /* OpenACC 2.0:
   23255              :    # pragma acc host_data oacc-data-clause[optseq] new-line
   23256              :      structured-block
   23257              : */
   23258              : 
   23259              : #define OACC_HOST_DATA_CLAUSE_MASK                                      \
   23260              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_USE_DEVICE)          \
   23261              :          | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF)                  \
   23262              :          | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF_PRESENT) )
   23263              : 
   23264              : static tree
   23265           23 : c_parser_oacc_host_data (location_t loc, c_parser *parser, bool *if_p)
   23266              : {
   23267           23 :   tree stmt, clauses, block;
   23268              : 
   23269           23 :   clauses = c_parser_oacc_all_clauses (parser, OACC_HOST_DATA_CLAUSE_MASK,
   23270              :                                        "#pragma acc host_data", false);
   23271           23 :   if (!omp_find_clause (clauses, OMP_CLAUSE_USE_DEVICE_PTR))
   23272              :     {
   23273            2 :       error_at (loc, "%<host_data%> construct requires %<use_device%> clause");
   23274            2 :       return error_mark_node;
   23275              :     }
   23276           21 :   clauses = c_finish_omp_clauses (clauses, C_ORT_ACC);
   23277           21 :   block = c_begin_omp_parallel ();
   23278           21 :   add_stmt (c_parser_omp_structured_block (parser, if_p));
   23279           21 :   stmt = c_finish_oacc_host_data (loc, clauses, block);
   23280           21 :   return stmt;
   23281              : }
   23282              : 
   23283              : 
   23284              : /* OpenACC 2.0:
   23285              : 
   23286              :    # pragma acc loop oacc-loop-clause[optseq] new-line
   23287              :      structured-block
   23288              : 
   23289              :    LOC is the location of the #pragma token.
   23290              : */
   23291              : 
   23292              : #define OACC_LOOP_CLAUSE_MASK                                           \
   23293              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COLLAPSE)              \
   23294              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRIVATE)               \
   23295              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_REDUCTION)             \
   23296              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_GANG)          \
   23297              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WORKER)                \
   23298              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_VECTOR)                \
   23299              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_AUTO)          \
   23300              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_INDEPENDENT)   \
   23301              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_SEQ)                   \
   23302              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_TILE) )
   23303              : static tree
   23304         2444 : c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name,
   23305              :                     omp_clause_mask mask, tree *cclauses, bool *if_p)
   23306              : {
   23307         2444 :   bool is_parallel = ((mask >> PRAGMA_OACC_CLAUSE_REDUCTION) & 1) == 1;
   23308              : 
   23309         2444 :   strcat (p_name, " loop");
   23310         2444 :   mask |= OACC_LOOP_CLAUSE_MASK;
   23311              : 
   23312         2444 :   tree clauses = c_parser_oacc_all_clauses (parser, mask, p_name,
   23313              :                                             /*finish_p=*/cclauses == NULL,
   23314              :                                             /*target=*/is_parallel);
   23315         2444 :   if (cclauses)
   23316              :     {
   23317          673 :       clauses = c_oacc_split_loop_clauses (clauses, cclauses, is_parallel);
   23318          673 :       if (*cclauses)
   23319          152 :         *cclauses = c_finish_omp_clauses (*cclauses, C_ORT_ACC_TARGET);
   23320          673 :       if (clauses)
   23321          271 :         clauses = c_finish_omp_clauses (clauses, C_ORT_ACC);
   23322              :     }
   23323              : 
   23324         2444 :   tree block = c_begin_compound_stmt (true);
   23325         2444 :   tree stmt = c_parser_omp_for_loop (loc, parser, OACC_LOOP, clauses, NULL,
   23326              :                                      if_p);
   23327         2444 :   block = c_end_compound_stmt (loc, block, true);
   23328         2444 :   add_stmt (block);
   23329              : 
   23330         2444 :   return stmt;
   23331              : }
   23332              : 
   23333              : /* OpenACC 2.0:
   23334              :    # pragma acc kernels oacc-kernels-clause[optseq] new-line
   23335              :      structured-block
   23336              : 
   23337              :    or
   23338              : 
   23339              :    # pragma acc parallel oacc-parallel-clause[optseq] new-line
   23340              :      structured-block
   23341              : 
   23342              :    OpenACC 2.6:
   23343              : 
   23344              :    # pragma acc serial oacc-serial-clause[optseq] new-line
   23345              :      structured-block
   23346              : 
   23347              :    LOC is the location of the #pragma token.
   23348              : */
   23349              : 
   23350              : #define OACC_KERNELS_CLAUSE_MASK                                        \
   23351              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC)         \
   23352              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ATTACH)                \
   23353              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPY)          \
   23354              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN)                \
   23355              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT)               \
   23356              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE)                \
   23357              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEFAULT)               \
   23358              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR)             \
   23359              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF)                    \
   23360              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NO_CREATE)             \
   23361              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_GANGS)             \
   23362              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_WORKERS)           \
   23363              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT)               \
   23364              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_SELF)          \
   23365              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_VECTOR_LENGTH) \
   23366              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) )
   23367              : 
   23368              : #define OACC_PARALLEL_CLAUSE_MASK                                       \
   23369              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC)         \
   23370              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ATTACH)                \
   23371              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPY)          \
   23372              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN)                \
   23373              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT)               \
   23374              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE)                \
   23375              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEFAULT)               \
   23376              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR)             \
   23377              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF)                    \
   23378              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NO_CREATE)             \
   23379              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRIVATE)               \
   23380              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_FIRSTPRIVATE)  \
   23381              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_GANGS)             \
   23382              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NUM_WORKERS)           \
   23383              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT)               \
   23384              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_REDUCTION)             \
   23385              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_SELF)          \
   23386              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_VECTOR_LENGTH) \
   23387              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) )
   23388              : 
   23389              : #define OACC_SERIAL_CLAUSE_MASK                                 \
   23390              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC)         \
   23391              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ATTACH)                \
   23392              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPY)          \
   23393              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN)                \
   23394              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT)               \
   23395              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE)                \
   23396              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEFAULT)               \
   23397              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR)             \
   23398              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF)                    \
   23399              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NO_CREATE)             \
   23400              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRIVATE)               \
   23401              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_FIRSTPRIVATE)  \
   23402              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT)               \
   23403              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_REDUCTION)             \
   23404              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_SELF)          \
   23405              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) )
   23406              : 
   23407              : static tree
   23408         2154 : c_parser_oacc_compute (location_t loc, c_parser *parser,
   23409              :                        enum pragma_kind p_kind, char *p_name, bool *if_p)
   23410              : {
   23411         2154 :   omp_clause_mask mask;
   23412         2154 :   enum tree_code code;
   23413         2154 :   switch (p_kind)
   23414              :     {
   23415          522 :     case PRAGMA_OACC_KERNELS:
   23416          522 :       strcat (p_name, " kernels");
   23417          522 :       mask = OACC_KERNELS_CLAUSE_MASK;
   23418          522 :       code = OACC_KERNELS;
   23419          522 :       break;
   23420         1457 :     case PRAGMA_OACC_PARALLEL:
   23421         1457 :       strcat (p_name, " parallel");
   23422         1457 :       mask = OACC_PARALLEL_CLAUSE_MASK;
   23423         1457 :       code = OACC_PARALLEL;
   23424         1457 :       break;
   23425          175 :     case PRAGMA_OACC_SERIAL:
   23426          175 :       strcat (p_name, " serial");
   23427          175 :       mask = OACC_SERIAL_CLAUSE_MASK;
   23428          175 :       code = OACC_SERIAL;
   23429          175 :       break;
   23430            0 :     default:
   23431            0 :       gcc_unreachable ();
   23432              :     }
   23433              : 
   23434         2154 :   if (c_parser_next_token_is (parser, CPP_NAME))
   23435              :     {
   23436         1710 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   23437         1710 :       if (strcmp (p, "loop") == 0)
   23438              :         {
   23439          673 :           c_parser_consume_token (parser);
   23440          673 :           tree block = c_begin_omp_parallel ();
   23441          673 :           tree clauses;
   23442          673 :           c_parser_oacc_loop (loc, parser, p_name, mask, &clauses, if_p);
   23443          673 :           return c_finish_omp_construct (loc, code, block, clauses);
   23444              :         }
   23445              :     }
   23446              : 
   23447         1481 :   tree clauses = c_parser_oacc_all_clauses (parser, mask, p_name,
   23448              :                                             /*finish_p=*/true,
   23449              :                                             /*target=*/true);
   23450              : 
   23451         1481 :   tree block = c_begin_omp_parallel ();
   23452         1481 :   add_stmt (c_parser_omp_structured_block (parser, if_p));
   23453              : 
   23454         1481 :   return c_finish_omp_construct (loc, code, block, clauses);
   23455              : }
   23456              : 
   23457              : /* OpenACC 2.0:
   23458              :    # pragma acc routine oacc-routine-clause[optseq] new-line
   23459              :      function-definition
   23460              : 
   23461              :    # pragma acc routine ( name ) oacc-routine-clause[optseq] new-line
   23462              : */
   23463              : 
   23464              : #define OACC_ROUTINE_CLAUSE_MASK                                        \
   23465              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_GANG)          \
   23466              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WORKER)                \
   23467              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_VECTOR)                \
   23468              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_SEQ)                   \
   23469              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_NOHOST) )
   23470              : 
   23471              : /* Parse an OpenACC routine directive.  For named directives, we apply
   23472              :    immediately to the named function.  For unnamed ones we then parse
   23473              :    a declaration or definition, which must be for a function.  */
   23474              : 
   23475              : static void
   23476          345 : c_parser_oacc_routine (c_parser *parser, enum pragma_context context)
   23477              : {
   23478          345 :   gcc_checking_assert (context == pragma_external);
   23479              : 
   23480          345 :   oacc_routine_data data;
   23481          345 :   data.error_seen = false;
   23482          345 :   data.fndecl_seen = false;
   23483          345 :   data.loc = c_parser_peek_token (parser)->location;
   23484              : 
   23485          345 :   c_parser_consume_pragma (parser);
   23486              : 
   23487              :   /* Look for optional '( name )'.  */
   23488          345 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   23489              :     {
   23490          143 :       c_parser_consume_token (parser); /* '(' */
   23491              : 
   23492          143 :       tree decl = NULL_TREE;
   23493          143 :       c_token *name_token = c_parser_peek_token (parser);
   23494          143 :       location_t name_loc = name_token->location;
   23495          143 :       if (name_token->type == CPP_NAME
   23496          135 :           && (name_token->id_kind == C_ID_ID
   23497              :               || name_token->id_kind == C_ID_TYPENAME))
   23498              :         {
   23499          135 :           decl = lookup_name (name_token->value);
   23500          135 :           if (!decl)
   23501            5 :             error_at (name_loc,
   23502              :                       "%qE has not been declared", name_token->value);
   23503          135 :           c_parser_consume_token (parser);
   23504              :         }
   23505              :       else
   23506            8 :         c_parser_error (parser, "expected function name");
   23507              : 
   23508            8 :       if (!decl
   23509          135 :           || !c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
   23510              :         {
   23511           15 :           c_parser_skip_to_pragma_eol (parser, false);
   23512           43 :           return;
   23513              :         }
   23514              : 
   23515          128 :       data.clauses
   23516          128 :         = c_parser_oacc_all_clauses (parser, OACC_ROUTINE_CLAUSE_MASK,
   23517              :                                      "#pragma acc routine");
   23518              :       /* The clauses are in reverse order; fix that to make later diagnostic
   23519              :          emission easier.  */
   23520          128 :       data.clauses = nreverse (data.clauses);
   23521              : 
   23522          128 :       if (TREE_CODE (decl) != FUNCTION_DECL)
   23523              :         {
   23524            3 :           error_at (name_loc, "%qD does not refer to a function", decl);
   23525            3 :           return;
   23526              :         }
   23527              : 
   23528          125 :       c_finish_oacc_routine (&data, decl, false);
   23529              :     }
   23530              :   else /* No optional '( name )'.  */
   23531              :     {
   23532          202 :       data.clauses
   23533          202 :         = c_parser_oacc_all_clauses (parser, OACC_ROUTINE_CLAUSE_MASK,
   23534              :                                      "#pragma acc routine");
   23535              :       /* The clauses are in reverse order; fix that to make later diagnostic
   23536              :          emission easier.  */
   23537          202 :       data.clauses = nreverse (data.clauses);
   23538              : 
   23539              :       /* Emit a helpful diagnostic if there's another pragma following this
   23540              :          one.  Also don't allow a static assertion declaration, as in the
   23541              :          following we'll just parse a *single* "declaration or function
   23542              :          definition", and the static assertion counts an one.  */
   23543          202 :       if (c_parser_next_token_is (parser, CPP_PRAGMA)
   23544          395 :           || c_parser_next_token_is_keyword (parser, RID_STATIC_ASSERT))
   23545              :         {
   23546           10 :           error_at (data.loc,
   23547              :                     "%<#pragma acc routine%> not immediately followed by"
   23548              :                     " function declaration or definition");
   23549              :           /* ..., and then just keep going.  */
   23550           10 :           return;
   23551              :         }
   23552              : 
   23553              :       /* We only have to consider the pragma_external case here.  */
   23554          192 :       if (c_parser_next_token_is (parser, CPP_KEYWORD)
   23555          192 :           && c_parser_peek_token (parser)->keyword == RID_EXTENSION)
   23556              :         {
   23557            3 :           int ext = disable_extension_diagnostics ();
   23558            7 :           do
   23559            7 :             c_parser_consume_token (parser);
   23560            7 :           while (c_parser_next_token_is (parser, CPP_KEYWORD)
   23561           10 :                  && c_parser_peek_token (parser)->keyword == RID_EXTENSION);
   23562            3 :           c_parser_declaration_or_fndef (parser, true, true, true, false, true,
   23563              :                                          false, NULL, NULL, false, NULL, &data);
   23564            3 :           restore_extension_diagnostics (ext);
   23565              :         }
   23566              :       else
   23567          189 :         c_parser_declaration_or_fndef (parser, true, true, true, false, true,
   23568              :                                        false, NULL, NULL, false, NULL, &data);
   23569              :     }
   23570              : }
   23571              : 
   23572              : /* Finalize an OpenACC routine pragma, applying it to FNDECL.
   23573              :    IS_DEFN is true if we're applying it to the definition.  */
   23574              : 
   23575              : static void
   23576          327 : c_finish_oacc_routine (struct oacc_routine_data *data, tree fndecl,
   23577              :                        bool is_defn)
   23578              : {
   23579              :   /* Keep going if we're in error reporting mode.  */
   23580          327 :   if (data->error_seen
   23581          321 :       || fndecl == error_mark_node)
   23582              :     return;
   23583              : 
   23584          321 :   if (data->fndecl_seen)
   23585              :     {
   23586            4 :       error_at (data->loc,
   23587              :                 "%<#pragma acc routine%> not immediately followed by"
   23588              :                 " a single function declaration or definition");
   23589            4 :       data->error_seen = true;
   23590            4 :       return;
   23591              :     }
   23592          317 :   if (fndecl == NULL_TREE || TREE_CODE (fndecl) != FUNCTION_DECL)
   23593              :     {
   23594           10 :       error_at (data->loc,
   23595              :                 "%<#pragma acc routine%> not immediately followed by"
   23596              :                 " function declaration or definition");
   23597           10 :       data->error_seen = true;
   23598           10 :       return;
   23599              :     }
   23600              : 
   23601          307 :   int compatible
   23602          307 :     = oacc_verify_routine_clauses (fndecl, &data->clauses, data->loc,
   23603              :                                    "#pragma acc routine");
   23604          307 :   if (compatible < 0)
   23605              :     {
   23606           47 :       data->error_seen = true;
   23607           47 :       return;
   23608              :     }
   23609          260 :   if (compatible > 0)
   23610              :     {
   23611              :     }
   23612              :   else
   23613              :     {
   23614          269 :       if (TREE_USED (fndecl) || (!is_defn && DECL_SAVED_TREE (fndecl)))
   23615              :         {
   23616            3 :           error_at (data->loc,
   23617              :                     TREE_USED (fndecl)
   23618              :                     ? G_("%<#pragma acc routine%> must be applied before use")
   23619              :                     : G_("%<#pragma acc routine%> must be applied before"
   23620              :                          " definition"));
   23621            2 :           data->error_seen = true;
   23622            2 :           return;
   23623              :         }
   23624              : 
   23625              :       /* Set the routine's level of parallelism.  */
   23626          197 :       tree dims = oacc_build_routine_dims (data->clauses);
   23627          197 :       oacc_replace_fn_attrib (fndecl, dims);
   23628              : 
   23629              :       /* Add an "omp declare target" attribute.  */
   23630          197 :       DECL_ATTRIBUTES (fndecl)
   23631          394 :         = tree_cons (get_identifier ("omp declare target"),
   23632          197 :                      data->clauses, DECL_ATTRIBUTES (fndecl));
   23633              :     }
   23634              : 
   23635              :   /* Remember that we've used this "#pragma acc routine".  */
   23636          258 :   data->fndecl_seen = true;
   23637              : }
   23638              : 
   23639              : /* OpenACC 2.0:
   23640              :    # pragma acc update oacc-update-clause[optseq] new-line
   23641              : */
   23642              : 
   23643              : #define OACC_UPDATE_CLAUSE_MASK                                         \
   23644              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC)         \
   23645              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICE)                \
   23646              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_HOST)          \
   23647              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF)                    \
   23648              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF_PRESENT)            \
   23649              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_SELF)          \
   23650              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) )
   23651              : 
   23652              : static void
   23653           92 : c_parser_oacc_update (c_parser *parser)
   23654              : {
   23655           92 :   location_t loc = c_parser_peek_token (parser)->location;
   23656              : 
   23657           92 :   c_parser_consume_pragma (parser);
   23658              : 
   23659           92 :   tree clauses = c_parser_oacc_all_clauses (parser, OACC_UPDATE_CLAUSE_MASK,
   23660              :                                             "#pragma acc update");
   23661           92 :   if (omp_find_clause (clauses, OMP_CLAUSE_MAP) == NULL_TREE)
   23662              :     {
   23663            1 :       error_at (loc,
   23664              :                 "%<#pragma acc update%> must contain at least one "
   23665              :                 "%<device%> or %<host%> or %<self%> clause");
   23666            1 :       return;
   23667              :     }
   23668              : 
   23669           91 :   if (parser->error)
   23670              :     return;
   23671              : 
   23672           91 :   tree stmt = make_node (OACC_UPDATE);
   23673           91 :   TREE_TYPE (stmt) = void_type_node;
   23674           91 :   OACC_UPDATE_CLAUSES (stmt) = clauses;
   23675           91 :   SET_EXPR_LOCATION (stmt, loc);
   23676           91 :   add_stmt (stmt);
   23677              : }
   23678              : 
   23679              : /* OpenACC 2.0:
   23680              :    # pragma acc wait [(intseq)] oacc-wait-clause[optseq] new-line
   23681              : 
   23682              :    LOC is the location of the #pragma token.
   23683              : */
   23684              : 
   23685              : #define OACC_WAIT_CLAUSE_MASK                                           \
   23686              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC)         \
   23687              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) )
   23688              : 
   23689              : static tree
   23690           86 : c_parser_oacc_wait (location_t loc, c_parser *parser, char *p_name)
   23691              : {
   23692           86 :   tree clauses, list = NULL_TREE, stmt = NULL_TREE;
   23693              : 
   23694           86 :   if (c_parser_peek_token (parser)->type == CPP_OPEN_PAREN)
   23695           49 :     list = c_parser_oacc_wait_list (parser, loc, list);
   23696              : 
   23697           86 :   strcpy (p_name, " wait");
   23698           86 :   clauses = c_parser_oacc_all_clauses (parser, OACC_WAIT_CLAUSE_MASK, p_name);
   23699           86 :   stmt = c_finish_oacc_wait (loc, list, clauses);
   23700           86 :   add_stmt (stmt);
   23701              : 
   23702           86 :   return stmt;
   23703              : }
   23704              : 
   23705              : struct c_omp_loc_tree
   23706              : {
   23707              :   location_t loc;
   23708              :   tree var;
   23709              : };
   23710              : 
   23711              : /* Check whether the expression used in the allocator clause is declared or
   23712              :    modified between the variable declaration and its allocate directive.  */
   23713              : static tree
   23714           87 : c_check_omp_allocate_allocator_r (tree *tp, int *, void *data)
   23715              : {
   23716           87 :   tree var = ((struct c_omp_loc_tree *) data)->var;
   23717           87 :   location_t loc = ((struct c_omp_loc_tree *) data)->loc;
   23718           87 :   if (TREE_CODE (*tp) == VAR_DECL && c_check_in_current_scope (*tp))
   23719              :     {
   23720           19 :       if (linemap_location_before_p (line_table, DECL_SOURCE_LOCATION (var),
   23721           19 :                                      DECL_SOURCE_LOCATION (*tp)))
   23722              :         {
   23723            4 :           error_at (loc, "variable %qD used in the %<allocator%> clause must "
   23724              :                          "be declared before %qD", *tp, var);
   23725            4 :           inform (DECL_SOURCE_LOCATION (*tp), "declared here");
   23726            4 :           inform (DECL_SOURCE_LOCATION (var),
   23727              :                   "to be allocated variable declared here");
   23728            4 :           return *tp;
   23729              :         }
   23730              :       else
   23731              :         {
   23732           15 :           gcc_assert (cur_stmt_list
   23733              :                       && TREE_CODE (cur_stmt_list) == STATEMENT_LIST);
   23734              : 
   23735           15 :           tree_stmt_iterator l = tsi_last (cur_stmt_list);
   23736           19 :           while (!tsi_end_p (l))
   23737              :             {
   23738           19 :               if (linemap_location_before_p (line_table, EXPR_LOCATION (*l),
   23739           19 :                                              DECL_SOURCE_LOCATION (var)))
   23740              :                   break;
   23741            6 :               if (TREE_CODE (*l) == MODIFY_EXPR
   23742            6 :                   && TREE_OPERAND (*l, 0) == *tp)
   23743              :                 {
   23744            2 :                   error_at (loc,
   23745              :                             "variable %qD used in the %<allocator%> clause "
   23746              :                             "must not be modified between declaration of %qD "
   23747              :                             "and its %<allocate%> directive", *tp, var);
   23748            2 :                   inform (EXPR_LOCATION (*l), "modified here");
   23749            2 :                   inform (DECL_SOURCE_LOCATION (var),
   23750              :                           "to be allocated variable declared here");
   23751            2 :                   return *tp;
   23752              :                 }
   23753            4 :               --l;
   23754              :             }
   23755              :         }
   23756              :     }
   23757              :   return NULL_TREE;
   23758              : }
   23759              : 
   23760              : /* OpenMP 5.x:
   23761              :    # pragma omp allocate (list)  clauses
   23762              : 
   23763              :    OpenMP 5.0 clause:
   23764              :    allocator (omp_allocator_handle_t expression)
   23765              : 
   23766              :    OpenMP 5.1 additional clause:
   23767              :    align (constant-expression)]  */
   23768              : 
   23769              : static void
   23770          118 : c_parser_omp_allocate (c_parser *parser)
   23771              : {
   23772          118 :   tree alignment = NULL_TREE;
   23773          118 :   tree allocator = NULL_TREE;
   23774          118 :   c_parser_consume_pragma (parser);
   23775          118 :   location_t loc = c_parser_peek_token (parser)->location;
   23776          118 :   location_t allocator_loc = UNKNOWN_LOCATION;
   23777          118 :   tree nl = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ALLOCATE, NULL_TREE);
   23778          340 :   do
   23779              :     {
   23780          229 :       if (c_parser_next_token_is (parser, CPP_COMMA)
   23781          229 :           && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
   23782            9 :         c_parser_consume_token (parser);
   23783          229 :       if (!c_parser_next_token_is (parser, CPP_NAME))
   23784              :         break;
   23785          114 :       matching_parens parens;
   23786          114 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   23787          114 :       c_parser_consume_token (parser);
   23788          114 :       location_t expr_loc = c_parser_peek_token (parser)->location;
   23789          114 :       if (strcmp ("align", p) != 0 && strcmp ("allocator", p) != 0)
   23790              :         {
   23791            1 :           error_at (c_parser_peek_token (parser)->location,
   23792              :                     "expected %<allocator%> or %<align%>");
   23793            1 :           break;
   23794              :         }
   23795          113 :       if (!parens.require_open (parser))
   23796              :         break;
   23797              : 
   23798          113 :       c_expr expr = c_parser_expr_no_commas (parser, NULL);
   23799          113 :       expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
   23800          113 :       expr_loc = c_parser_peek_token (parser)->location;
   23801          113 :       if (expr.value == error_mark_node)
   23802              :         ;
   23803          112 :       else if (p[2] == 'i' && alignment)
   23804              :         {
   23805            1 :           error_at (expr_loc, "too many %qs clauses", "align");
   23806            1 :           break;
   23807              :         }
   23808          111 :       else if (p[2] == 'i')
   23809              :         {
   23810           32 :           alignment = c_fully_fold (expr.value, false, NULL);
   23811           32 :           if (TREE_CODE (alignment) != INTEGER_CST
   23812           31 :               || !INTEGRAL_TYPE_P (TREE_TYPE (alignment))
   23813           31 :               || tree_int_cst_sgn (alignment) != 1
   23814           62 :               || !integer_pow2p (alignment))
   23815              :             {
   23816            4 :               error_at (expr_loc, "%<align%> clause argument needs to be "
   23817              :                                   "positive constant power of two integer "
   23818              :                                   "expression");
   23819            4 :               alignment = NULL_TREE;
   23820              :             }
   23821              :         }
   23822           79 :       else if (allocator)
   23823              :         {
   23824            1 :           error_at (expr_loc, "too many %qs clauses", "allocator");
   23825            1 :           break;
   23826              :         }
   23827              :       else
   23828              :         {
   23829           78 :           allocator = c_fully_fold (expr.value, false, NULL);
   23830           78 :           allocator_loc = expr_loc;
   23831           78 :           tree orig_type
   23832           78 :             = expr.original_type ? expr.original_type : TREE_TYPE (allocator);
   23833           78 :           orig_type = TYPE_MAIN_VARIANT (orig_type);
   23834           79 :           if (!INTEGRAL_TYPE_P (TREE_TYPE (allocator))
   23835           78 :               || TREE_CODE (orig_type) != ENUMERAL_TYPE
   23836          232 :               || TYPE_NAME (orig_type)
   23837           77 :                  != get_identifier ("omp_allocator_handle_t"))
   23838              :             {
   23839            1 :               error_at (expr_loc,
   23840              :                         "%<allocator%> clause expression has type "
   23841              :                         "%qT rather than %<omp_allocator_handle_t%>",
   23842            1 :                         TREE_TYPE (allocator));
   23843            1 :               allocator = NULL_TREE;
   23844              :             }
   23845              :         }
   23846          111 :       parens.skip_until_found_close (parser);
   23847          111 :     } while (true);
   23848          118 :   c_parser_skip_to_pragma_eol (parser);
   23849              : 
   23850          118 :   c_mark_decl_jump_unsafe_in_current_scope ();
   23851          435 :   for (tree c = nl; c != NULL_TREE; c = OMP_CLAUSE_CHAIN (c))
   23852              :     {
   23853          199 :       tree var = OMP_CLAUSE_DECL (c);
   23854          199 :       if (TREE_CODE (var) == PARM_DECL)
   23855              :         {
   23856           24 :           error_at (OMP_CLAUSE_LOCATION (nl),
   23857              :                     "function parameter %qD may not appear as list item in an "
   23858              :                     "%<allocate%> directive", var);
   23859           24 :           continue;
   23860              :         }
   23861          175 :       if (!parser->in_omp_decl_attribute && !c_check_in_current_scope (var))
   23862              :         {
   23863            6 :           error_at (OMP_CLAUSE_LOCATION (nl),
   23864              :                     "%<allocate%> directive must be in the same scope as %qD",
   23865              :                     var);
   23866            6 :           inform (DECL_SOURCE_LOCATION (var), "declared here");
   23867            6 :           continue;
   23868              :         }
   23869          169 :       if (lookup_attribute ("omp allocate", DECL_ATTRIBUTES (var)))
   23870              :         {
   23871           41 :           error_at (OMP_CLAUSE_LOCATION (nl),
   23872              :                     "%qD already appeared as list item in an "
   23873              :                     "%<allocate%> directive", var);
   23874           41 :           continue;
   23875              :         }
   23876          128 :       if (TREE_STATIC (var))
   23877              :         {
   23878           46 :           if (allocator == NULL_TREE && allocator_loc == UNKNOWN_LOCATION)
   23879              :             {
   23880            3 :               error_at (loc,
   23881              :                         "%<allocator%> clause required for "
   23882              :                         "static variable %qD", var);
   23883            3 :               continue;
   23884              :             }
   23885           43 :           else if (allocator
   23886           43 :                    && (wi::to_widest (allocator) < 1
   23887           40 :                        || wi::to_widest (allocator) > GOMP_OMP_PREDEF_ALLOC_MAX)
   23888           56 :                    && (wi::to_widest (allocator) < GOMP_OMPX_PREDEF_ALLOC_MIN
   23889           13 :                        || wi::to_widest (allocator) > GOMP_OMPX_PREDEF_ALLOC_MAX))
   23890              :             {
   23891            8 :               error_at (allocator_loc,
   23892              :                         "%<allocator%> clause requires a predefined allocator as "
   23893              :                         "%qD is static", var);
   23894              :             }
   23895           35 :           else if (allocator
   23896           70 :                    && (wi::eq_p (wi::to_widest (allocator),
   23897           35 :                                  GOMP_OMP_PREDEF_ALLOC_CGROUP)
   23898           33 :                        || wi::eq_p (wi::to_widest (allocator),
   23899           33 :                                     GOMP_OMP_PREDEF_ALLOC_PTEAM)
   23900           31 :                        || wi::eq_p (wi::to_widest (allocator),
   23901           66 :                                     GOMP_OMP_PREDEF_ALLOC_THREAD)))
   23902              :             {
   23903            6 :               error_at (allocator_loc,
   23904              :                         "%<allocator%> clause for static variable %qD must not "
   23905              :                         "be %<omp_cgroup_mem_alloc%>, %<omp_pteam_mem_alloc%>, "
   23906              :                         "or %<omp_thread_mem_alloc%>", var);
   23907              :             }
   23908              :         }
   23909          125 :       if (allocator)
   23910              :         {
   23911           79 :           struct c_omp_loc_tree data
   23912          156 :             = {EXPR_LOC_OR_LOC (allocator, OMP_CLAUSE_LOCATION (nl)), var};
   23913           79 :           walk_tree (&allocator, c_check_omp_allocate_allocator_r, &data, NULL);
   23914              :         }
   23915          125 :       DECL_ATTRIBUTES (var) = tree_cons (get_identifier ("omp allocate"),
   23916              :                                          build_tree_list (allocator, alignment),
   23917          125 :                                          DECL_ATTRIBUTES (var));
   23918              :     }
   23919          118 : }
   23920              : 
   23921              : /* OpenMP 2.5:
   23922              :    # pragma omp atomic new-line
   23923              :      expression-stmt
   23924              : 
   23925              :    expression-stmt:
   23926              :      x binop= expr | x++ | ++x | x-- | --x
   23927              :    binop:
   23928              :      +, *, -, /, &, ^, |, <<, >>
   23929              : 
   23930              :   where x is an lvalue expression with scalar type.
   23931              : 
   23932              :    OpenMP 3.1:
   23933              :    # pragma omp atomic new-line
   23934              :      update-stmt
   23935              : 
   23936              :    # pragma omp atomic read new-line
   23937              :      read-stmt
   23938              : 
   23939              :    # pragma omp atomic write new-line
   23940              :      write-stmt
   23941              : 
   23942              :    # pragma omp atomic update new-line
   23943              :      update-stmt
   23944              : 
   23945              :    # pragma omp atomic capture new-line
   23946              :      capture-stmt
   23947              : 
   23948              :    # pragma omp atomic capture new-line
   23949              :      capture-block
   23950              : 
   23951              :    read-stmt:
   23952              :      v = x
   23953              :    write-stmt:
   23954              :      x = expr
   23955              :    update-stmt:
   23956              :      expression-stmt | x = x binop expr
   23957              :    capture-stmt:
   23958              :      v = expression-stmt
   23959              :    capture-block:
   23960              :      { v = x; update-stmt; } | { update-stmt; v = x; }
   23961              : 
   23962              :    OpenMP 4.0:
   23963              :    update-stmt:
   23964              :      expression-stmt | x = x binop expr | x = expr binop x
   23965              :    capture-stmt:
   23966              :      v = update-stmt
   23967              :    capture-block:
   23968              :      { v = x; update-stmt; } | { update-stmt; v = x; } | { v = x; x = expr; }
   23969              : 
   23970              :    OpenMP 5.1:
   23971              :    # pragma omp atomic compare new-line
   23972              :      conditional-update-atomic
   23973              : 
   23974              :    # pragma omp atomic compare capture new-line
   23975              :      conditional-update-capture-atomic
   23976              : 
   23977              :    conditional-update-atomic:
   23978              :      cond-expr-stmt | cond-update-stmt
   23979              :    cond-expr-stmt:
   23980              :      x = expr ordop x ? expr : x;
   23981              :      x = x ordop expr ? expr : x;
   23982              :      x = x == e ? d : x;
   23983              :    cond-update-stmt:
   23984              :      if (expr ordop x) { x = expr; }
   23985              :      if (x ordop expr) { x = expr; }
   23986              :      if (x == e) { x = d; }
   23987              :    ordop:
   23988              :      <, >
   23989              :    conditional-update-capture-atomic:
   23990              :      v = cond-expr-stmt
   23991              :      { v = x; cond-expr-stmt }
   23992              :      { cond-expr-stmt v = x; }
   23993              :      { v = x; cond-update-stmt }
   23994              :      { cond-update-stmt v = x; }
   23995              :      if (x == e) { x = d; } else { v = x; }
   23996              :      { r = x == e; if (r) { x = d; } }
   23997              :      { r = x == e; if (r) { x = d; } else { v = x; } }
   23998              : 
   23999              :   where x, r and v are lvalue expressions with scalar type,
   24000              :   expr, e and d are expressions with scalar type and e might be
   24001              :   the same as v.
   24002              : 
   24003              :   LOC is the location of the #pragma token.  */
   24004              : 
   24005              : static void
   24006         1776 : c_parser_omp_atomic (location_t loc, c_parser *parser, bool openacc)
   24007              : {
   24008         1776 :   tree lhs = NULL_TREE, rhs = NULL_TREE, v = NULL_TREE, r = NULL_TREE;
   24009         1776 :   tree lhs1 = NULL_TREE, rhs1 = NULL_TREE;
   24010         1776 :   tree stmt, orig_lhs, unfolded_lhs = NULL_TREE, unfolded_lhs1 = NULL_TREE;
   24011         1776 :   enum tree_code code = ERROR_MARK, opcode = NOP_EXPR;
   24012         1776 :   enum omp_memory_order memory_order = OMP_MEMORY_ORDER_UNSPECIFIED;
   24013         1776 :   struct c_expr expr;
   24014         1776 :   location_t eloc;
   24015         1776 :   bool structured_block = false;
   24016         1776 :   bool swapped = false;
   24017         1776 :   bool non_lvalue_p;
   24018         1776 :   tree clauses = NULL_TREE;
   24019         1776 :   bool capture = false;
   24020         1776 :   bool compare = false;
   24021         1776 :   bool weak = false;
   24022         1776 :   enum omp_memory_order fail = OMP_MEMORY_ORDER_UNSPECIFIED;
   24023         1776 :   bool no_semicolon = false;
   24024         1776 :   bool extra_scope = false;
   24025              : 
   24026         3312 :   while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   24027              :     {
   24028         1546 :       if (c_parser_next_token_is (parser, CPP_COMMA)
   24029         1546 :           && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
   24030           82 :         c_parser_consume_token (parser);
   24031              : 
   24032         1546 :       if (c_parser_next_token_is (parser, CPP_NAME))
   24033              :         {
   24034         1542 :           const char *p
   24035         1542 :             = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   24036         1542 :           location_t cloc = c_parser_peek_token (parser)->location;
   24037         1542 :           enum tree_code new_code = ERROR_MARK;
   24038         1542 :           enum omp_memory_order new_memory_order
   24039              :             = OMP_MEMORY_ORDER_UNSPECIFIED;
   24040         1542 :           bool new_capture = false;
   24041         1542 :           bool new_compare = false;
   24042         1542 :           bool new_weak = false;
   24043         1542 :           enum omp_memory_order new_fail = OMP_MEMORY_ORDER_UNSPECIFIED;
   24044              : 
   24045         1542 :           if (!strcmp (p, "read"))
   24046              :             new_code = OMP_ATOMIC_READ;
   24047         1271 :           else if (!strcmp (p, "write"))
   24048              :             new_code = NOP_EXPR;
   24049         1073 :           else if (!strcmp (p, "update"))
   24050              :             new_code = OMP_ATOMIC;
   24051          891 :           else if (openacc && !strcmp (p, "capture"))
   24052              :             new_code = OMP_ATOMIC_CAPTURE_NEW;
   24053            4 :           else if (openacc)
   24054              :             {
   24055            4 :               p = NULL;
   24056            4 :               error_at (cloc, "expected %<read%>, %<write%>, %<update%>, "
   24057              :                               "or %<capture%> clause");
   24058              :             }
   24059          653 :           else if (!strcmp (p, "capture"))
   24060              :             new_capture = true;
   24061          408 :           else if (!strcmp (p, "compare"))
   24062              :             new_compare = true;
   24063          235 :           else if (!strcmp (p, "weak"))
   24064              :             new_weak = true;
   24065          222 :           else if (!strcmp (p, "fail"))
   24066              :             {
   24067           33 :               matching_parens parens;
   24068              : 
   24069           33 :               c_parser_consume_token (parser);
   24070           33 :               if (!parens.require_open (parser))
   24071            1 :                 continue;
   24072              : 
   24073           32 :               if (c_parser_next_token_is (parser, CPP_NAME))
   24074              :                 {
   24075           30 :                   const char *q
   24076           30 :                     = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   24077              : 
   24078           30 :                   if (!strcmp (q, "seq_cst"))
   24079              :                     new_fail = OMP_MEMORY_ORDER_SEQ_CST;
   24080           24 :                   else if (!strcmp (q, "acquire"))
   24081              :                     new_fail = OMP_MEMORY_ORDER_ACQUIRE;
   24082           17 :                   else if (!strcmp (q, "relaxed"))
   24083              :                     new_fail = OMP_MEMORY_ORDER_RELAXED;
   24084              :                 }
   24085              : 
   24086              :               if (new_fail != OMP_MEMORY_ORDER_UNSPECIFIED)
   24087              :                 {
   24088           27 :                   c_parser_consume_token (parser);
   24089           27 :                   if (fail != OMP_MEMORY_ORDER_UNSPECIFIED)
   24090            2 :                     error_at (cloc, "too many %qs clauses", "fail");
   24091              :                   else
   24092              :                     fail = new_fail;
   24093              :                 }
   24094              :               else
   24095            5 :                 c_parser_error (parser, "expected %<seq_cst%>, %<acquire%> "
   24096              :                                         "or %<relaxed%>");
   24097           32 :               parens.skip_until_found_close (parser);
   24098           32 :               continue;
   24099           32 :             }
   24100          189 :           else if (!strcmp (p, "seq_cst"))
   24101              :             new_memory_order = OMP_MEMORY_ORDER_SEQ_CST;
   24102          112 :           else if (!strcmp (p, "acq_rel"))
   24103              :             new_memory_order = OMP_MEMORY_ORDER_ACQ_REL;
   24104          100 :           else if (!strcmp (p, "release"))
   24105              :             new_memory_order = OMP_MEMORY_ORDER_RELEASE;
   24106           70 :           else if (!strcmp (p, "acquire"))
   24107              :             new_memory_order = OMP_MEMORY_ORDER_ACQUIRE;
   24108           57 :           else if (!strcmp (p, "relaxed"))
   24109              :             new_memory_order = OMP_MEMORY_ORDER_RELAXED;
   24110           31 :           else if (!strcmp (p, "hint"))
   24111              :             {
   24112           29 :               c_parser_consume_token (parser);
   24113           29 :               clauses = c_parser_omp_clause_hint (parser, clauses);
   24114           29 :               continue;
   24115              :             }
   24116              :           else
   24117              :             {
   24118            2 :               p = NULL;
   24119            2 :               error_at (cloc, "expected %<read%>, %<write%>, %<update%>, "
   24120              :                               "%<capture%>, %<compare%>, %<weak%>, %<fail%>, "
   24121              :                               "%<seq_cst%>, %<acq_rel%>, %<release%>, "
   24122              :                               "%<relaxed%> or %<hint%> clause");
   24123              :             }
   24124            6 :           if (p)
   24125              :             {
   24126         1474 :               if (new_code != ERROR_MARK)
   24127              :                 {
   24128              :                   /* OpenACC permits 'update capture'.  */
   24129          885 :                   if (openacc
   24130          885 :                       && code == OMP_ATOMIC
   24131            4 :                       && new_code == OMP_ATOMIC_CAPTURE_NEW)
   24132              :                     code = new_code;
   24133          882 :                   else if (code != ERROR_MARK)
   24134            5 :                     error_at (cloc, "too many atomic clauses");
   24135              :                   else
   24136              :                     code = new_code;
   24137              :                 }
   24138          589 :               else if (new_memory_order != OMP_MEMORY_ORDER_UNSPECIFIED)
   24139              :                 {
   24140          158 :                   if (memory_order != OMP_MEMORY_ORDER_UNSPECIFIED)
   24141           35 :                     error_at (cloc, "too many memory order clauses");
   24142              :                   else
   24143              :                     memory_order = new_memory_order;
   24144              :                 }
   24145          431 :               else if (new_capture)
   24146              :                 {
   24147          245 :                   if (capture)
   24148            1 :                     error_at (cloc, "too many %qs clauses", "capture");
   24149              :                   else
   24150              :                     capture = true;
   24151              :                 }
   24152          186 :               else if (new_compare)
   24153              :                 {
   24154          173 :                   if (compare)
   24155            1 :                     error_at (cloc, "too many %qs clauses", "compare");
   24156              :                   else
   24157              :                     compare = true;
   24158              :                 }
   24159           13 :               else if (new_weak)
   24160              :                 {
   24161           13 :                   if (weak)
   24162            1 :                     error_at (cloc, "too many %qs clauses", "weak");
   24163              :                   else
   24164              :                     weak = true;
   24165              :                 }
   24166         1474 :               c_parser_consume_token (parser);
   24167         1474 :               continue;
   24168              :             }
   24169              :         }
   24170              :       break;
   24171              :     }
   24172         1776 :   c_parser_skip_to_pragma_eol (parser);
   24173              : 
   24174         1776 :   if (code == ERROR_MARK)
   24175          899 :     code = OMP_ATOMIC;
   24176         1776 :   if (capture)
   24177              :     {
   24178          244 :       if (code != OMP_ATOMIC)
   24179            2 :         error_at (loc, "%qs clause is incompatible with %<read%> or %<write%> "
   24180              :                        "clauses", "capture");
   24181              :       else
   24182              :         code = OMP_ATOMIC_CAPTURE_NEW;
   24183              :     }
   24184         1776 :   if (compare && code != OMP_ATOMIC && code != OMP_ATOMIC_CAPTURE_NEW)
   24185              :     {
   24186            2 :       error_at (loc, "%qs clause is incompatible with %<read%> or %<write%> "
   24187              :                       "clauses", "compare");
   24188            2 :       compare = false;
   24189              :     }
   24190         1776 :   if (fail != OMP_MEMORY_ORDER_UNSPECIFIED && !compare)
   24191              :     {
   24192            5 :       error_at (loc, "%qs clause requires %qs clause", "fail", "compare");
   24193            5 :       fail = OMP_MEMORY_ORDER_UNSPECIFIED;
   24194              :     }
   24195         1776 :   if (weak && !compare)
   24196              :     {
   24197            5 :       error_at (loc, "%qs clause requires %qs clause", "weak", "compare");
   24198            5 :       weak = false;
   24199              :     }
   24200         1776 :   if (openacc)
   24201              :     memory_order = OMP_MEMORY_ORDER_RELAXED;
   24202         1467 :   else if (memory_order == OMP_MEMORY_ORDER_UNSPECIFIED)
   24203              :     {
   24204         1344 :       omp_requires_mask
   24205         1344 :         = (enum omp_requires) (omp_requires_mask
   24206              :                                | OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER_USED);
   24207         1344 :       switch ((enum omp_memory_order)
   24208              :               (omp_requires_mask & OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER))
   24209              :         {
   24210              :         case OMP_MEMORY_ORDER_UNSPECIFIED:
   24211              :         case OMP_MEMORY_ORDER_RELAXED:
   24212              :           memory_order = OMP_MEMORY_ORDER_RELAXED;
   24213              :           break;
   24214              :         case OMP_MEMORY_ORDER_SEQ_CST:
   24215         1776 :           memory_order = OMP_MEMORY_ORDER_SEQ_CST;
   24216              :           break;
   24217            4 :         case OMP_MEMORY_ORDER_ACQUIRE:
   24218            4 :           if (code == NOP_EXPR)  /* atomic write */
   24219              :             {
   24220            1 :               error_at (loc, "%<#pragma omp atomic write%> incompatible with "
   24221              :                              "%<acquire%> clause implicitly provided by a "
   24222              :                              "%<requires%> directive");
   24223            1 :               memory_order = OMP_MEMORY_ORDER_SEQ_CST;
   24224              :             }
   24225              :           else
   24226              :             memory_order = OMP_MEMORY_ORDER_ACQUIRE;
   24227              :           break;
   24228            3 :         case OMP_MEMORY_ORDER_RELEASE:
   24229            3 :           if (code == OMP_ATOMIC_READ)
   24230              :             {
   24231            1 :               error_at (loc, "%<#pragma omp atomic read%> incompatible with "
   24232              :                              "%<release%> clause implicitly provided by a "
   24233              :                              "%<requires%> directive");
   24234            1 :               memory_order = OMP_MEMORY_ORDER_SEQ_CST;
   24235              :             }
   24236              :           else
   24237              :             memory_order = OMP_MEMORY_ORDER_RELEASE;
   24238              :           break;
   24239            9 :         case OMP_MEMORY_ORDER_ACQ_REL:
   24240            9 :           switch (code)
   24241              :             {
   24242              :             case OMP_ATOMIC_READ:
   24243              :               memory_order = OMP_MEMORY_ORDER_ACQUIRE;
   24244              :               break;
   24245              :             case NOP_EXPR: /* atomic write */
   24246            5 :               memory_order = OMP_MEMORY_ORDER_RELEASE;
   24247              :               break;
   24248              :             default:
   24249         1776 :               memory_order = OMP_MEMORY_ORDER_ACQ_REL;
   24250              :               break;
   24251              :             }
   24252              :           break;
   24253            0 :         default:
   24254            0 :           gcc_unreachable ();
   24255              :         }
   24256              :     }
   24257              :   else
   24258          123 :     switch (code)
   24259              :       {
   24260           25 :       case OMP_ATOMIC_READ:
   24261           25 :         if (memory_order == OMP_MEMORY_ORDER_RELEASE)
   24262              :           {
   24263            1 :             error_at (loc, "%<#pragma omp atomic read%> incompatible with "
   24264              :                            "%<release%> clause");
   24265            1 :             memory_order = OMP_MEMORY_ORDER_SEQ_CST;
   24266              :           }
   24267           24 :         else if (memory_order == OMP_MEMORY_ORDER_ACQ_REL)
   24268            6 :           memory_order = OMP_MEMORY_ORDER_ACQUIRE;
   24269              :         break;
   24270           16 :       case NOP_EXPR: /* atomic write */
   24271           16 :         if (memory_order == OMP_MEMORY_ORDER_ACQUIRE)
   24272              :           {
   24273            1 :             error_at (loc, "%<#pragma omp atomic write%> incompatible with "
   24274              :                            "%<acquire%> clause");
   24275            1 :             memory_order = OMP_MEMORY_ORDER_SEQ_CST;
   24276              :           }
   24277           15 :         else if (memory_order == OMP_MEMORY_ORDER_ACQ_REL)
   24278            5 :           memory_order = OMP_MEMORY_ORDER_RELEASE;
   24279              :         break;
   24280              :       default:
   24281              :         break;
   24282              :       }
   24283         1776 :   if (fail != OMP_MEMORY_ORDER_UNSPECIFIED)
   24284           20 :     memory_order
   24285           20 :       = (enum omp_memory_order) (memory_order
   24286              :                                  | (fail << OMP_FAIL_MEMORY_ORDER_SHIFT));
   24287              : 
   24288         1776 :   switch (code)
   24289              :     {
   24290          468 :     case OMP_ATOMIC_READ:
   24291          468 :     case NOP_EXPR: /* atomic write */
   24292          468 :       v = c_parser_cast_expression (parser, NULL).value;
   24293          468 :       non_lvalue_p = !lvalue_p (v);
   24294          468 :       v = c_fully_fold (v, false, NULL, true);
   24295          468 :       if (v == error_mark_node)
   24296            0 :         goto saw_error;
   24297          468 :       if (non_lvalue_p)
   24298            4 :         v = non_lvalue (v);
   24299          468 :       loc = c_parser_peek_token (parser)->location;
   24300          468 :       if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
   24301            0 :         goto saw_error;
   24302          468 :       if (code == NOP_EXPR)
   24303              :         {
   24304          197 :           eloc = c_parser_peek_token (parser)->location;
   24305          197 :           expr = c_parser_expression (parser);
   24306          197 :           expr = default_function_array_read_conversion (eloc, expr);
   24307              :           /* atomic write is represented by OMP_ATOMIC with NOP_EXPR
   24308              :              opcode.  */
   24309          197 :           code = OMP_ATOMIC;
   24310          197 :           lhs = v;
   24311          197 :           v = NULL_TREE;
   24312          197 :           rhs = c_fully_fold (expr.value, false, NULL);
   24313          197 :           if (rhs == error_mark_node)
   24314            0 :             goto saw_error;
   24315              :         }
   24316              :       else
   24317              :         {
   24318          271 :           lhs = c_parser_cast_expression (parser, NULL).value;
   24319          271 :           non_lvalue_p = !lvalue_p (lhs);
   24320          271 :           lhs = c_fully_fold (lhs, false, NULL, true);
   24321          271 :           if (lhs == error_mark_node)
   24322            0 :             goto saw_error;
   24323          271 :           if (non_lvalue_p)
   24324            2 :             lhs = non_lvalue (lhs);
   24325              :         }
   24326          468 :       goto done;
   24327          474 :     case OMP_ATOMIC_CAPTURE_NEW:
   24328          474 :       if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
   24329              :         {
   24330          314 :           c_parser_consume_token (parser);
   24331          314 :           structured_block = true;
   24332              :         }
   24333          160 :       else if (compare
   24334          189 :                && c_parser_next_token_is_keyword (parser, RID_IF))
   24335              :         break;
   24336              :       else
   24337              :         {
   24338          143 :           v = c_parser_cast_expression (parser, NULL).value;
   24339          143 :           non_lvalue_p = !lvalue_p (v);
   24340          143 :           v = c_fully_fold (v, false, NULL, true);
   24341          143 :           if (v == error_mark_node)
   24342            0 :             goto saw_error;
   24343          143 :           if (non_lvalue_p)
   24344            2 :             v = non_lvalue (v);
   24345          143 :           if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
   24346            0 :             goto saw_error;
   24347          155 :           if (compare && c_parser_next_token_is_keyword (parser, RID_IF))
   24348              :             {
   24349            1 :               eloc = c_parser_peek_token (parser)->location;
   24350            1 :               error_at (eloc, "expected expression");
   24351            1 :               goto saw_error;
   24352              :             }
   24353              :         }
   24354              :       break;
   24355              :     default:
   24356              :       break;
   24357              :     }
   24358              : 
   24359              :   /* For structured_block case we don't know yet whether
   24360              :      old or new x should be captured.  */
   24361         1307 : restart:
   24362         1699 :   if (compare && c_parser_next_token_is_keyword (parser, RID_IF))
   24363              :     {
   24364           85 :       c_parser_consume_token (parser);
   24365              : 
   24366           85 :       matching_parens parens;
   24367           85 :       if (!parens.require_open (parser))
   24368           33 :         goto saw_error;
   24369           84 :       eloc = c_parser_peek_token (parser)->location;
   24370           84 :       c_expr cmp_expr;
   24371           84 :       if (r)
   24372              :         {
   24373           17 :           cmp_expr = c_parser_cast_expression (parser, NULL);
   24374           17 :           cmp_expr = default_function_array_conversion (eloc, cmp_expr);
   24375              :         }
   24376              :       else
   24377           67 :         cmp_expr = c_parser_binary_expression (parser, NULL, void_list_node);
   24378           84 :       parens.skip_until_found_close (parser);
   24379           84 :       if (cmp_expr.value == error_mark_node)
   24380            0 :         goto saw_error;
   24381           84 :       if (r)
   24382              :         {
   24383           17 :           if (!c_tree_equal (cmp_expr.value, unfolded_lhs))
   24384            1 :             goto bad_if;
   24385           16 :           cmp_expr.value = rhs1;
   24386           16 :           rhs1 = NULL_TREE;
   24387           16 :           gcc_assert (TREE_CODE (cmp_expr.value) == EQ_EXPR);
   24388              :         }
   24389           83 :       if (TREE_CODE (cmp_expr.value) == EQ_EXPR)
   24390              :         ;
   24391           36 :       else if (!structured_block && code == OMP_ATOMIC_CAPTURE_NEW)
   24392              :         {
   24393            2 :           error_at (EXPR_LOC_OR_LOC (cmp_expr.value, eloc),
   24394              :                     "expected %<==%> comparison in %<if%> condition");
   24395            2 :           goto saw_error;
   24396              :         }
   24397           34 :       else if (TREE_CODE (cmp_expr.value) != GT_EXPR
   24398           25 :                && TREE_CODE (cmp_expr.value) != LT_EXPR)
   24399              :         {
   24400           10 :           error_at (EXPR_LOC_OR_LOC (cmp_expr.value, eloc),
   24401              :                     "expected %<==%>, %<<%> or %<>%> comparison in %<if%> "
   24402              :                     "condition");
   24403           10 :           goto saw_error;
   24404              :         }
   24405           71 :       if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
   24406            2 :         goto saw_error;
   24407              : 
   24408           69 :       extra_scope = true;
   24409           69 :       eloc = c_parser_peek_token (parser)->location;
   24410           69 :       expr = c_parser_cast_expression (parser, NULL);
   24411           69 :       lhs = expr.value;
   24412           69 :       expr = default_function_array_conversion (eloc, expr);
   24413           69 :       unfolded_lhs = expr.value;
   24414           69 :       lhs = c_fully_fold (lhs, false, NULL, true);
   24415           69 :       orig_lhs = lhs;
   24416           69 :       if (lhs == error_mark_node)
   24417            0 :         goto saw_error;
   24418           69 :       if (!lvalue_p (unfolded_lhs))
   24419            0 :         lhs = non_lvalue (lhs);
   24420           69 :       if (!c_parser_next_token_is (parser, CPP_EQ))
   24421              :         {
   24422            1 :           c_parser_error (parser, "expected %<=%>");
   24423            1 :           goto saw_error;
   24424              :         }
   24425           68 :       c_parser_consume_token (parser);
   24426           68 :       eloc = c_parser_peek_token (parser)->location;
   24427           68 :       expr = c_parser_expr_no_commas (parser, NULL);
   24428           68 :       rhs1 = expr.value;
   24429              : 
   24430           68 :       if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
   24431            1 :         goto saw_error;
   24432              : 
   24433           67 :       if (!c_parser_require (parser, CPP_CLOSE_BRACE, "expected %<}%>"))
   24434            1 :         goto saw_error;
   24435              : 
   24436           66 :       extra_scope = false;
   24437           66 :       no_semicolon = true;
   24438              : 
   24439           66 :       if (c_tree_equal (TREE_OPERAND (cmp_expr.value, 0), unfolded_lhs))
   24440              :         {
   24441           59 :           if (TREE_CODE (cmp_expr.value) == EQ_EXPR)
   24442              :             {
   24443           44 :               opcode = COND_EXPR;
   24444           44 :               rhs = c_fully_fold (TREE_OPERAND (cmp_expr.value, 1),
   24445              :                                   false, NULL, true);
   24446           44 :               rhs1 = c_fully_fold (rhs1, false, NULL, true);
   24447              :             }
   24448           15 :           else if (c_tree_equal (TREE_OPERAND (cmp_expr.value, 1), rhs1))
   24449              :             {
   24450            7 :               opcode = (TREE_CODE (cmp_expr.value) == GT_EXPR
   24451           13 :                         ? MIN_EXPR : MAX_EXPR);
   24452           13 :               rhs = c_fully_fold (rhs1, false, NULL, true);
   24453           13 :               rhs1 = c_fully_fold (TREE_OPERAND (cmp_expr.value, 0),
   24454              :                                    false, NULL, true);
   24455              :             }
   24456              :           else
   24457            2 :             goto bad_if;
   24458              :         }
   24459            7 :       else if (TREE_CODE (cmp_expr.value) == EQ_EXPR)
   24460            2 :         goto bad_if;
   24461            5 :       else if (c_tree_equal (TREE_OPERAND (cmp_expr.value, 1), unfolded_lhs)
   24462            5 :                && c_tree_equal (TREE_OPERAND (cmp_expr.value, 0), rhs1))
   24463              :         {
   24464            2 :           opcode = (TREE_CODE (cmp_expr.value) == GT_EXPR
   24465            3 :                     ? MAX_EXPR : MIN_EXPR);
   24466            3 :           rhs = c_fully_fold (rhs1, false, NULL, true);
   24467            3 :           rhs1 = c_fully_fold (TREE_OPERAND (cmp_expr.value, 1),
   24468              :                                false, NULL, true);
   24469              :         }
   24470              :       else
   24471              :         {
   24472            8 :         bad_if:
   24473            8 :           c_parser_error (parser,
   24474              :                           "invalid form of %<#pragma omp atomic compare%>");
   24475            8 :           goto saw_error;
   24476              :         }
   24477              : 
   24478           60 :       if (c_parser_next_token_is_keyword (parser, RID_ELSE))
   24479              :         {
   24480           24 :           if (code != OMP_ATOMIC_CAPTURE_NEW
   24481           22 :               || (structured_block && r == NULL_TREE)
   24482           21 :               || TREE_CODE (cmp_expr.value) != EQ_EXPR)
   24483              :             {
   24484            3 :               eloc = c_parser_peek_token (parser)->location;
   24485            3 :               error_at (eloc, "unexpected %<else%>");
   24486            3 :               goto saw_error;
   24487              :             }
   24488              : 
   24489           21 :           c_parser_consume_token (parser);
   24490              : 
   24491           21 :           if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
   24492            1 :             goto saw_error;
   24493              : 
   24494           20 :           extra_scope = true;
   24495           20 :           v = c_parser_cast_expression (parser, NULL).value;
   24496           20 :           non_lvalue_p = !lvalue_p (v);
   24497           20 :           v = c_fully_fold (v, false, NULL, true);
   24498           20 :           if (v == error_mark_node)
   24499            0 :             goto saw_error;
   24500           20 :           if (non_lvalue_p)
   24501            0 :             v = non_lvalue (v);
   24502           20 :           if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
   24503            1 :             goto saw_error;
   24504              : 
   24505           19 :           expr = c_parser_expr_no_commas (parser, NULL);
   24506              : 
   24507           19 :           if (!c_tree_equal (expr.value, unfolded_lhs))
   24508            1 :             goto bad_if;
   24509              : 
   24510           18 :           if (!c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
   24511            1 :             goto saw_error;
   24512              : 
   24513           17 :           if (!c_parser_require (parser, CPP_CLOSE_BRACE, "expected %<}%>"))
   24514            0 :             goto saw_error;
   24515              : 
   24516           17 :           extra_scope = false;
   24517           17 :           code = OMP_ATOMIC_CAPTURE_OLD;
   24518           17 :           if (r == NULL_TREE)
   24519              :             /* Signal to c_finish_omp_atomic that in
   24520              :                if (x == e) { x = d; } else { v = x; }
   24521              :                case the store to v should be conditional.  */
   24522           10 :             r = void_list_node;
   24523              :         }
   24524           36 :       else if (code == OMP_ATOMIC_CAPTURE_NEW && !structured_block)
   24525              :         {
   24526            1 :           c_parser_require_keyword (parser, RID_ELSE, "expected %<else%>");
   24527            1 :           goto saw_error;
   24528              :         }
   24529           35 :       else if (code == OMP_ATOMIC_CAPTURE_NEW
   24530           35 :                && r != NULL_TREE
   24531            9 :                && v == NULL_TREE)
   24532           52 :         code = OMP_ATOMIC;
   24533           52 :       goto stmt_done;
   24534              :     }
   24535         1406 :   eloc = c_parser_peek_token (parser)->location;
   24536         1406 :   expr = c_parser_cast_expression (parser, NULL);
   24537         1406 :   lhs = expr.value;
   24538         1406 :   expr = default_function_array_conversion (eloc, expr);
   24539         1406 :   unfolded_lhs = expr.value;
   24540         1406 :   lhs = c_fully_fold (lhs, false, NULL, true);
   24541         1406 :   orig_lhs = lhs;
   24542         1406 :   switch (TREE_CODE (lhs))
   24543              :     {
   24544            4 :     invalid_compare:
   24545            4 :       error_at (eloc, "invalid form of %<pragma omp atomic compare%>");
   24546              :       /* FALLTHRU */
   24547           84 :     case ERROR_MARK:
   24548           84 :     saw_error:
   24549           84 :       c_parser_skip_to_end_of_block_or_statement (parser);
   24550           90 :       if (extra_scope && c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
   24551            4 :         c_parser_consume_token (parser);
   24552           84 :       if (structured_block)
   24553              :         {
   24554           10 :           if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
   24555            9 :             c_parser_consume_token (parser);
   24556            1 :           else if (code == OMP_ATOMIC_CAPTURE_NEW)
   24557              :             {
   24558            1 :               c_parser_skip_to_end_of_block_or_statement (parser);
   24559            1 :               if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
   24560            1 :                 c_parser_consume_token (parser);
   24561              :             }
   24562              :         }
   24563           84 :       return;
   24564              : 
   24565          181 :     case POSTINCREMENT_EXPR:
   24566          181 :       if (code == OMP_ATOMIC_CAPTURE_NEW && !structured_block)
   24567           21 :         code = OMP_ATOMIC_CAPTURE_OLD;
   24568              :       /* FALLTHROUGH */
   24569          243 :     case PREINCREMENT_EXPR:
   24570          243 :       lhs = TREE_OPERAND (lhs, 0);
   24571          243 :       unfolded_lhs = NULL_TREE;
   24572          243 :       opcode = PLUS_EXPR;
   24573          243 :       rhs = integer_one_node;
   24574          243 :       if (compare)
   24575            2 :         goto invalid_compare;
   24576              :       break;
   24577              : 
   24578           24 :     case POSTDECREMENT_EXPR:
   24579           24 :       if (code == OMP_ATOMIC_CAPTURE_NEW && !structured_block)
   24580            2 :         code = OMP_ATOMIC_CAPTURE_OLD;
   24581              :       /* FALLTHROUGH */
   24582           52 :     case PREDECREMENT_EXPR:
   24583           52 :       lhs = TREE_OPERAND (lhs, 0);
   24584           52 :       unfolded_lhs = NULL_TREE;
   24585           52 :       opcode = MINUS_EXPR;
   24586           52 :       rhs = integer_one_node;
   24587           52 :       if (compare)
   24588            2 :         goto invalid_compare;
   24589              :       break;
   24590              : 
   24591           12 :     case COMPOUND_EXPR:
   24592           12 :       if (TREE_CODE (TREE_OPERAND (lhs, 0)) == SAVE_EXPR
   24593           12 :           && TREE_CODE (TREE_OPERAND (lhs, 1)) == COMPOUND_EXPR
   24594           12 :           && TREE_CODE (TREE_OPERAND (TREE_OPERAND (lhs, 1), 0)) == MODIFY_EXPR
   24595           12 :           && TREE_OPERAND (TREE_OPERAND (lhs, 1), 1) == TREE_OPERAND (lhs, 0)
   24596           24 :           && C_BOOLEAN_TYPE_P (TREE_TYPE (TREE_OPERAND (TREE_OPERAND
   24597              :                                               (TREE_OPERAND (lhs, 1), 0), 0))))
   24598              :         /* Undo effects of boolean_increment for post {in,de}crement.  */
   24599           12 :         lhs = TREE_OPERAND (TREE_OPERAND (lhs, 1), 0);
   24600              :       /* FALLTHRU */
   24601           24 :     case MODIFY_EXPR:
   24602           24 :       if (TREE_CODE (lhs) == MODIFY_EXPR
   24603           24 :           && C_BOOLEAN_TYPE_P (TREE_TYPE (TREE_OPERAND (lhs, 0))))
   24604              :         {
   24605              :           /* Undo effects of boolean_increment.  */
   24606           24 :           if (integer_onep (TREE_OPERAND (lhs, 1)))
   24607              :             {
   24608              :               /* This is pre or post increment.  */
   24609           12 :               rhs = TREE_OPERAND (lhs, 1);
   24610           12 :               lhs = TREE_OPERAND (lhs, 0);
   24611           12 :               unfolded_lhs = NULL_TREE;
   24612           12 :               opcode = NOP_EXPR;
   24613           12 :               if (code == OMP_ATOMIC_CAPTURE_NEW
   24614           12 :                   && !structured_block
   24615            2 :                   && TREE_CODE (orig_lhs) == COMPOUND_EXPR)
   24616            1 :                 code = OMP_ATOMIC_CAPTURE_OLD;
   24617           12 :               if (compare)
   24618            0 :                 goto invalid_compare;
   24619              :               break;
   24620              :             }
   24621           12 :           if (TREE_CODE (TREE_OPERAND (lhs, 1)) == TRUTH_NOT_EXPR
   24622           12 :               && TREE_OPERAND (lhs, 0)
   24623           12 :                  == TREE_OPERAND (TREE_OPERAND (lhs, 1), 0))
   24624              :             {
   24625              :               /* This is pre or post decrement.  */
   24626           12 :               rhs = TREE_OPERAND (lhs, 1);
   24627           12 :               lhs = TREE_OPERAND (lhs, 0);
   24628           12 :               unfolded_lhs = NULL_TREE;
   24629           12 :               opcode = NOP_EXPR;
   24630           12 :               if (code == OMP_ATOMIC_CAPTURE_NEW
   24631           12 :                   && !structured_block
   24632            2 :                   && TREE_CODE (orig_lhs) == COMPOUND_EXPR)
   24633            1 :                 code = OMP_ATOMIC_CAPTURE_OLD;
   24634           12 :               if (compare)
   24635            0 :                 goto invalid_compare;
   24636              :               break;
   24637              :             }
   24638              :         }
   24639              :       /* FALLTHRU */
   24640         1083 :     default:
   24641         1083 :       if (!lvalue_p (unfolded_lhs))
   24642            5 :         lhs = non_lvalue (lhs);
   24643         1202 :       if (compare && !c_parser_next_token_is (parser, CPP_EQ))
   24644              :         {
   24645            7 :           c_parser_error (parser, "expected %<=%>");
   24646            7 :           goto saw_error;
   24647              :         }
   24648         1076 :       switch (c_parser_peek_token (parser)->type)
   24649              :         {
   24650              :         case CPP_MULT_EQ:
   24651              :           opcode = MULT_EXPR;
   24652              :           break;
   24653              :         case CPP_DIV_EQ:
   24654              :           opcode = TRUNC_DIV_EXPR;
   24655              :           break;
   24656              :         case CPP_PLUS_EQ:
   24657              :           opcode = PLUS_EXPR;
   24658              :           break;
   24659              :         case CPP_MINUS_EQ:
   24660              :           opcode = MINUS_EXPR;
   24661              :           break;
   24662              :         case CPP_LSHIFT_EQ:
   24663              :           opcode = LSHIFT_EXPR;
   24664              :           break;
   24665              :         case CPP_RSHIFT_EQ:
   24666              :           opcode = RSHIFT_EXPR;
   24667              :           break;
   24668              :         case CPP_AND_EQ:
   24669              :           opcode = BIT_AND_EXPR;
   24670              :           break;
   24671              :         case CPP_OR_EQ:
   24672              :           opcode = BIT_IOR_EXPR;
   24673              :           break;
   24674              :         case CPP_XOR_EQ:
   24675              :           opcode = BIT_XOR_EXPR;
   24676              :           break;
   24677          556 :         case CPP_EQ:
   24678          556 :           c_parser_consume_token (parser);
   24679          556 :           eloc = c_parser_peek_token (parser)->location;
   24680          556 :           expr = c_parser_expr_no_commas (parser, NULL, unfolded_lhs);
   24681          556 :           rhs1 = expr.value;
   24682          556 :           switch (TREE_CODE (rhs1))
   24683              :             {
   24684          289 :             case MULT_EXPR:
   24685          289 :             case TRUNC_DIV_EXPR:
   24686          289 :             case RDIV_EXPR:
   24687          289 :             case PLUS_EXPR:
   24688          289 :             case MINUS_EXPR:
   24689          289 :             case LSHIFT_EXPR:
   24690          289 :             case RSHIFT_EXPR:
   24691          289 :             case BIT_AND_EXPR:
   24692          289 :             case BIT_IOR_EXPR:
   24693          289 :             case BIT_XOR_EXPR:
   24694          289 :               if (compare)
   24695              :                 break;
   24696          282 :               if (c_tree_equal (TREE_OPERAND (rhs1, 0), unfolded_lhs))
   24697              :                 {
   24698          147 :                   opcode = TREE_CODE (rhs1);
   24699          147 :                   rhs = c_fully_fold (TREE_OPERAND (rhs1, 1), false, NULL,
   24700              :                                       true);
   24701          147 :                   rhs1 = c_fully_fold (TREE_OPERAND (rhs1, 0), false, NULL,
   24702              :                                        true);
   24703          147 :                   goto stmt_done;
   24704              :                 }
   24705          135 :               if (c_tree_equal (TREE_OPERAND (rhs1, 1), unfolded_lhs))
   24706              :                 {
   24707          117 :                   opcode = TREE_CODE (rhs1);
   24708          117 :                   rhs = c_fully_fold (TREE_OPERAND (rhs1, 0), false, NULL,
   24709              :                                       true);
   24710          117 :                   rhs1 = c_fully_fold (TREE_OPERAND (rhs1, 1), false, NULL,
   24711              :                                        true);
   24712          117 :                   swapped = !commutative_tree_code (opcode);
   24713          117 :                   goto stmt_done;
   24714              :                 }
   24715              :               break;
   24716           69 :             case COND_EXPR:
   24717           69 :               if (!compare)
   24718              :                 break;
   24719           66 :               if (TREE_CODE (TREE_OPERAND (rhs1, 0)) != GT_EXPR
   24720           44 :                   && TREE_CODE (TREE_OPERAND (rhs1, 0)) != LT_EXPR
   24721           97 :                   && TREE_CODE (TREE_OPERAND (rhs1, 0)) != EQ_EXPR)
   24722              :                 break;
   24723           63 :               if (!TREE_OPERAND (rhs1, 1))
   24724              :                 break;
   24725           63 :               if (!c_tree_equal (TREE_OPERAND (rhs1, 2), unfolded_lhs))
   24726              :                 break;
   24727           58 :               if (c_tree_equal (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 0),
   24728              :                                 unfolded_lhs))
   24729              :                 {
   24730           39 :                   if (TREE_CODE (TREE_OPERAND (rhs1, 0)) == EQ_EXPR)
   24731              :                     {
   24732           23 :                       opcode = COND_EXPR;
   24733           23 :                       rhs = c_fully_fold (TREE_OPERAND (TREE_OPERAND (rhs1,
   24734              :                                                                       0), 1),
   24735              :                                           false, NULL, true);
   24736           23 :                       rhs1 = c_fully_fold (TREE_OPERAND (rhs1, 1), false,
   24737              :                                            NULL, true);
   24738           23 :                       goto stmt_done;
   24739              :                     }
   24740           16 :                   if (c_tree_equal (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 1),
   24741           16 :                                     TREE_OPERAND (rhs1, 1)))
   24742              :                     {
   24743           21 :                       opcode = (TREE_CODE (TREE_OPERAND (rhs1, 0)) == GT_EXPR
   24744           14 :                                 ? MIN_EXPR : MAX_EXPR);
   24745           14 :                       rhs = c_fully_fold (TREE_OPERAND (rhs1, 1), false, NULL,
   24746              :                                           true);
   24747           14 :                       rhs1 = c_fully_fold (TREE_OPERAND (TREE_OPERAND (rhs1,
   24748              :                                                                        0), 0),
   24749              :                                            false, NULL, true);
   24750           14 :                       goto stmt_done;
   24751              :                     }
   24752              :                 }
   24753           19 :               else if (TREE_CODE (TREE_OPERAND (rhs1, 0)) == EQ_EXPR)
   24754              :                 break;
   24755           17 :               else if (c_tree_equal (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 1),
   24756              :                                      unfolded_lhs))
   24757              :                 {
   24758           15 :                   if (c_tree_equal (TREE_OPERAND (TREE_OPERAND (rhs1, 0), 0),
   24759           15 :                                     TREE_OPERAND (rhs1, 1)))
   24760              :                     {
   24761           18 :                       opcode = (TREE_CODE (TREE_OPERAND (rhs1, 0)) == GT_EXPR
   24762           15 :                                 ? MAX_EXPR : MIN_EXPR);
   24763           15 :                       rhs = c_fully_fold (TREE_OPERAND (rhs1, 1), false, NULL,
   24764              :                                           true);
   24765           15 :                       rhs1 = c_fully_fold (TREE_OPERAND (TREE_OPERAND (rhs1,
   24766              :                                                                        0), 1),
   24767              :                                            false, NULL, true);
   24768           15 :                       goto stmt_done;
   24769              :                     }
   24770              :                 }
   24771              :               break;
   24772           17 :             case EQ_EXPR:
   24773           17 :               if (!compare
   24774           17 :                   || code != OMP_ATOMIC_CAPTURE_NEW
   24775           17 :                   || !structured_block
   24776           17 :                   || v
   24777           17 :                   || r)
   24778              :                 break;
   24779           17 :               if (c_parser_next_token_is (parser, CPP_SEMICOLON)
   24780           17 :                   && c_parser_peek_2nd_token (parser)->keyword == RID_IF)
   24781              :                 {
   24782           17 :                   r = lhs;
   24783           17 :                   lhs = NULL_TREE;
   24784           17 :                   c_parser_consume_token (parser);
   24785           17 :                   goto restart;
   24786              :                 }
   24787              :               break;
   24788            0 :             case ERROR_MARK:
   24789            0 :               goto saw_error;
   24790              :             default:
   24791              :               break;
   24792              :             }
   24793          223 :           if (c_parser_peek_token (parser)->type == CPP_SEMICOLON)
   24794              :             {
   24795          223 :               if (structured_block && code == OMP_ATOMIC_CAPTURE_NEW)
   24796              :                 {
   24797          167 :                   code = OMP_ATOMIC_CAPTURE_OLD;
   24798          167 :                   v = lhs;
   24799          167 :                   lhs = NULL_TREE;
   24800          167 :                   expr = default_function_array_read_conversion (eloc, expr);
   24801          167 :                   unfolded_lhs1 = expr.value;
   24802          167 :                   lhs1 = c_fully_fold (unfolded_lhs1, false, NULL, true);
   24803          167 :                   rhs1 = NULL_TREE;
   24804          167 :                   c_parser_consume_token (parser);
   24805          167 :                   goto restart;
   24806              :                 }
   24807           56 :               if (structured_block && !compare)
   24808              :                 {
   24809           26 :                   opcode = NOP_EXPR;
   24810           26 :                   expr = default_function_array_read_conversion (eloc, expr);
   24811           26 :                   rhs = c_fully_fold (expr.value, false, NULL, true);
   24812           26 :                   rhs1 = NULL_TREE;
   24813           26 :                   goto stmt_done;
   24814              :                 }
   24815              :             }
   24816           30 :           c_parser_error (parser, "invalid form of %<#pragma omp atomic%>");
   24817           30 :           goto saw_error;
   24818            5 :         default:
   24819            5 :           c_parser_error (parser,
   24820              :                           "invalid operator for %<#pragma omp atomic%>");
   24821            5 :           goto saw_error;
   24822              :         }
   24823              : 
   24824              :       /* Arrange to pass the location of the assignment operator to
   24825              :          c_finish_omp_atomic.  */
   24826          515 :       loc = c_parser_peek_token (parser)->location;
   24827          515 :       c_parser_consume_token (parser);
   24828          515 :       eloc = c_parser_peek_token (parser)->location;
   24829          515 :       expr = c_parser_expression (parser);
   24830          515 :       expr = default_function_array_read_conversion (eloc, expr);
   24831          515 :       rhs = expr.value;
   24832          515 :       rhs = c_fully_fold (rhs, false, NULL, true);
   24833          515 :       break;
   24834              :     }
   24835         1224 : stmt_done:
   24836         1224 :   if (structured_block && code == OMP_ATOMIC_CAPTURE_NEW && r == NULL_TREE)
   24837              :     {
   24838          129 :       if (!no_semicolon
   24839          129 :           && !c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
   24840            0 :         goto saw_error;
   24841          129 :       no_semicolon = false;
   24842          129 :       v = c_parser_cast_expression (parser, NULL).value;
   24843          129 :       non_lvalue_p = !lvalue_p (v);
   24844          129 :       v = c_fully_fold (v, false, NULL, true);
   24845          129 :       if (v == error_mark_node)
   24846            0 :         goto saw_error;
   24847          129 :       if (non_lvalue_p)
   24848            2 :         v = non_lvalue (v);
   24849          129 :       if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
   24850            0 :         goto saw_error;
   24851          129 :       eloc = c_parser_peek_token (parser)->location;
   24852          129 :       expr = c_parser_cast_expression (parser, NULL);
   24853          129 :       lhs1 = expr.value;
   24854          129 :       expr = default_function_array_read_conversion (eloc, expr);
   24855          129 :       unfolded_lhs1 = expr.value;
   24856          129 :       lhs1 = c_fully_fold (lhs1, false, NULL, true);
   24857          129 :       if (lhs1 == error_mark_node)
   24858            0 :         goto saw_error;
   24859          129 :       if (!lvalue_p (unfolded_lhs1))
   24860            2 :         lhs1 = non_lvalue (lhs1);
   24861              :     }
   24862         1224 :   if (structured_block)
   24863              :     {
   24864          304 :       if (!no_semicolon)
   24865          280 :         c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   24866          304 :       c_parser_require (parser, CPP_CLOSE_BRACE, "expected %<}%>");
   24867              :     }
   24868          920 : done:
   24869         1692 :   if (weak && opcode != COND_EXPR)
   24870              :     {
   24871            1 :       error_at (loc, "%<weak%> clause requires atomic equality comparison");
   24872            1 :       weak = false;
   24873              :     }
   24874         1692 :   if (unfolded_lhs && unfolded_lhs1
   24875         1692 :       && !c_tree_equal (unfolded_lhs, unfolded_lhs1))
   24876              :     {
   24877            5 :       error ("%<#pragma omp atomic capture%> uses two different "
   24878              :              "expressions for memory");
   24879            5 :       stmt = error_mark_node;
   24880              :     }
   24881              :   else
   24882         1687 :     stmt = c_finish_omp_atomic (loc, code, opcode, lhs, rhs, v, lhs1, rhs1, r,
   24883              :                                 swapped, memory_order, weak);
   24884         1692 :   if (stmt != error_mark_node)
   24885         1662 :     add_stmt (stmt);
   24886              : 
   24887         1692 :   if (!structured_block && !no_semicolon)
   24888         1369 :     c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   24889              : }
   24890              : 
   24891              : 
   24892              : /* OpenMP 2.5:
   24893              :    # pragma omp barrier new-line
   24894              : */
   24895              : 
   24896              : static void
   24897          362 : c_parser_omp_barrier (c_parser *parser)
   24898              : {
   24899          362 :   location_t loc = c_parser_peek_token (parser)->location;
   24900          362 :   c_parser_consume_pragma (parser);
   24901          362 :   c_parser_skip_to_pragma_eol (parser);
   24902              : 
   24903          362 :   c_finish_omp_barrier (loc);
   24904          362 : }
   24905              : 
   24906              : /* OpenMP 2.5:
   24907              :    # pragma omp critical [(name)] new-line
   24908              :      structured-block
   24909              : 
   24910              :    OpenMP 4.5:
   24911              :    # pragma omp critical [(name) [hint(expression)]] new-line
   24912              : 
   24913              :   LOC is the location of the #pragma itself.  */
   24914              : 
   24915              : #define OMP_CRITICAL_CLAUSE_MASK                \
   24916              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_HINT) )
   24917              : 
   24918              : static tree
   24919          144 : c_parser_omp_critical (location_t loc, c_parser *parser, bool *if_p)
   24920              : {
   24921          144 :   tree stmt, name = NULL_TREE, clauses = NULL_TREE;
   24922              : 
   24923          144 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   24924              :     {
   24925           49 :       c_parser_consume_token (parser);
   24926           49 :       if (c_parser_next_token_is (parser, CPP_NAME))
   24927              :         {
   24928           48 :           name = c_parser_peek_token (parser)->value;
   24929           48 :           c_parser_consume_token (parser);
   24930           48 :           c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>");
   24931              :         }
   24932              :       else
   24933            1 :         c_parser_error (parser, "expected identifier");
   24934              : 
   24935           49 :       if (c_parser_next_token_is (parser, CPP_COMMA)
   24936           49 :           && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
   24937            4 :         c_parser_consume_token (parser);
   24938              :     }
   24939          144 :   clauses = c_parser_omp_all_clauses (parser, OMP_CRITICAL_CLAUSE_MASK,
   24940              :                                       "#pragma omp critical");
   24941          144 :   stmt = c_parser_omp_structured_block (parser, if_p);
   24942          144 :   return c_finish_omp_critical (loc, stmt, name, clauses);
   24943              : }
   24944              : 
   24945              : /* OpenMP 5.0:
   24946              :    # pragma omp depobj ( depobj ) depobj-clause new-line
   24947              : 
   24948              :    depobj-clause:
   24949              :      depend (dependence-type : locator)
   24950              :      destroy
   24951              :      update (dependence-type)
   24952              : 
   24953              :    OpenMP 5.2 additionally:
   24954              :      destroy ( depobj )
   24955              : 
   24956              :    dependence-type:
   24957              :      in
   24958              :      out
   24959              :      inout
   24960              :      mutexinout  */
   24961              : 
   24962              : static void
   24963           75 : c_parser_omp_depobj (c_parser *parser)
   24964              : {
   24965           75 :   location_t loc = c_parser_peek_token (parser)->location;
   24966           75 :   c_parser_consume_pragma (parser);
   24967           75 :   matching_parens parens;
   24968           75 :   if (!parens.require_open (parser))
   24969              :     {
   24970            3 :       c_parser_skip_to_pragma_eol (parser);
   24971            3 :       return;
   24972              :     }
   24973              : 
   24974           72 :   tree depobj = c_parser_expr_no_commas (parser, NULL).value;
   24975           72 :   if (depobj != error_mark_node)
   24976              :     {
   24977           71 :       if (!lvalue_p (depobj))
   24978              :         {
   24979            1 :           error_at (EXPR_LOC_OR_LOC (depobj, loc),
   24980              :                     "%<depobj%> expression is not lvalue expression");
   24981            1 :           depobj = error_mark_node;
   24982              :         }
   24983              :       else
   24984              :         {
   24985           70 :           tree addr = build_unary_op (EXPR_LOC_OR_LOC (depobj, loc), ADDR_EXPR,
   24986              :                                       depobj, false);
   24987           70 :           if (addr == error_mark_node)
   24988              :             depobj = error_mark_node;
   24989              :           else
   24990           70 :             depobj = build_indirect_ref (EXPR_LOC_OR_LOC (depobj, loc),
   24991              :                                          addr, RO_UNARY_STAR);
   24992              :         }
   24993              :     }
   24994              : 
   24995           72 :   parens.skip_until_found_close (parser);
   24996           72 :   tree clause = NULL_TREE;
   24997           72 :   enum omp_clause_depend_kind kind = OMP_CLAUSE_DEPEND_INVALID;
   24998           72 :   if (c_parser_next_token_is (parser, CPP_COMMA))
   24999            3 :     c_parser_consume_token (parser);
   25000           72 :   location_t c_loc = c_parser_peek_token (parser)->location;
   25001           72 :   if (c_parser_next_token_is (parser, CPP_NAME))
   25002              :     {
   25003           71 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   25004              : 
   25005           71 :       c_parser_consume_token (parser);
   25006           71 :       if (!strcmp ("depend", p))
   25007              :         {
   25008           38 :           clause = c_parser_omp_clause_depend (parser, NULL_TREE, c_loc);
   25009           38 :           clause = c_finish_omp_clauses (clause, C_ORT_OMP);
   25010           38 :           if (!clause)
   25011            2 :             clause = error_mark_node;
   25012              :         }
   25013           33 :       else if (!strcmp ("destroy", p))
   25014              :         {
   25015           22 :           matching_parens c_parens;
   25016           22 :           kind = OMP_CLAUSE_DEPEND_LAST;
   25017           22 :           if (c_parser_next_token_is (parser, CPP_OPEN_PAREN)
   25018           22 :               && c_parens.require_open (parser))
   25019              :             {
   25020            7 :               tree destobj = c_parser_expr_no_commas (parser, NULL).value;
   25021            7 :               if (!lvalue_p (destobj))
   25022            1 :                 error_at (EXPR_LOC_OR_LOC (destobj, c_loc),
   25023              :                           "%<destroy%> expression is not lvalue expression");
   25024            6 :               else if (depobj != error_mark_node
   25025            6 :                        && !operand_equal_p (destobj, depobj,
   25026              :                                             OEP_MATCH_SIDE_EFFECTS
   25027              :                                             | OEP_LEXICOGRAPHIC))
   25028            2 :                 warning_at (EXPR_LOC_OR_LOC (destobj, c_loc), OPT_Wopenmp,
   25029              :                             "the %<destroy%> expression %qE should be the same "
   25030              :                             "as the %<depobj%> argument %qE", destobj, depobj);
   25031            7 :               c_parens.skip_until_found_close (parser);
   25032              :             }
   25033              :         }
   25034           11 :       else if (!strcmp ("update", p))
   25035              :         {
   25036           10 :           matching_parens c_parens;
   25037           10 :           if (c_parens.require_open (parser))
   25038              :             {
   25039           10 :               location_t c2_loc = c_parser_peek_token (parser)->location;
   25040           10 :               if (c_parser_next_token_is (parser, CPP_NAME))
   25041              :                 {
   25042           10 :                   const char *p2
   25043           10 :                     = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   25044              : 
   25045           10 :                   c_parser_consume_token (parser);
   25046           10 :                   if (!strcmp ("in", p2))
   25047              :                     kind = OMP_CLAUSE_DEPEND_IN;
   25048            8 :                   else if (!strcmp ("out", p2))
   25049              :                     kind = OMP_CLAUSE_DEPEND_OUT;
   25050            7 :                   else if (!strcmp ("inout", p2))
   25051              :                     kind = OMP_CLAUSE_DEPEND_INOUT;
   25052            4 :                   else if (!strcmp ("mutexinoutset", p2))
   25053              :                     kind = OMP_CLAUSE_DEPEND_MUTEXINOUTSET;
   25054            3 :                   else if (!strcmp ("inoutset", p2))
   25055              :                     kind = OMP_CLAUSE_DEPEND_INOUTSET;
   25056              :                 }
   25057              :               if (kind == OMP_CLAUSE_DEPEND_INVALID)
   25058              :                 {
   25059            1 :                   clause = error_mark_node;
   25060            1 :                   error_at (c2_loc, "expected %<in%>, %<out%>, %<inout%>, "
   25061              :                                     "%<mutexinoutset%> or %<inoutset%>");
   25062              :                 }
   25063           10 :               c_parens.skip_until_found_close (parser);
   25064              :             }
   25065              :           else
   25066            0 :             clause = error_mark_node;
   25067              :         }
   25068              :     }
   25069           72 :   if (!clause && kind == OMP_CLAUSE_DEPEND_INVALID)
   25070              :     {
   25071            2 :       clause = error_mark_node;
   25072            2 :       error_at (c_loc, "expected %<depend%>, %<destroy%> or %<update%> clause");
   25073              :     }
   25074           72 :   c_parser_skip_to_pragma_eol (parser);
   25075              : 
   25076           72 :   c_finish_omp_depobj (loc, depobj, kind, clause);
   25077              : }
   25078              : 
   25079              : 
   25080              : /* OpenMP 2.5:
   25081              :    # pragma omp flush flush-vars[opt] new-line
   25082              : 
   25083              :    flush-vars:
   25084              :      ( variable-list )
   25085              : 
   25086              :    OpenMP 5.0:
   25087              :    # pragma omp flush memory-order-clause new-line  */
   25088              : 
   25089              : static void
   25090           59 : c_parser_omp_flush (c_parser *parser)
   25091              : {
   25092           59 :   location_t loc = c_parser_peek_token (parser)->location;
   25093           59 :   c_parser_consume_pragma (parser);
   25094           59 :   enum memmodel mo = MEMMODEL_LAST;
   25095           59 :   if (c_parser_next_token_is (parser, CPP_COMMA)
   25096           59 :       && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
   25097            8 :     c_parser_consume_token (parser);
   25098           59 :   if (c_parser_next_token_is (parser, CPP_NAME))
   25099              :     {
   25100           27 :       const char *p
   25101           27 :         = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   25102              : 
   25103           27 :       if (!strcmp (p, "seq_cst"))
   25104              :         mo = MEMMODEL_SEQ_CST;
   25105           21 :       else if (!strcmp (p, "acq_rel"))
   25106              :         mo = MEMMODEL_ACQ_REL;
   25107           15 :       else if (!strcmp (p, "release"))
   25108              :         mo = MEMMODEL_RELEASE;
   25109            9 :       else if (!strcmp (p, "acquire"))
   25110              :         mo = MEMMODEL_ACQUIRE;
   25111              :       else
   25112            3 :         error_at (c_parser_peek_token (parser)->location,
   25113              :                   "expected %<seq_cst%>, %<acq_rel%>, %<release%> or "
   25114              :                   "%<acquire%>");
   25115           27 :       c_parser_consume_token (parser);
   25116              :     }
   25117           59 :   if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   25118              :     {
   25119           20 :       if (mo != MEMMODEL_LAST)
   25120            4 :         error_at (c_parser_peek_token (parser)->location,
   25121              :                   "%<flush%> list specified together with memory order "
   25122              :                   "clause");
   25123           20 :       c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ERROR, NULL);
   25124              :     }
   25125           39 :   else if (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   25126            1 :     c_parser_error (parser, "expected %<(%> or end of line");
   25127           59 :   c_parser_skip_to_pragma_eol (parser);
   25128              : 
   25129           59 :   c_finish_omp_flush (loc, mo);
   25130           59 : }
   25131              : 
   25132              : /* Return true if next tokens contain a standard attribute that contains
   25133              :    omp::directive (DIRECTIVE).  */
   25134              : 
   25135              : static bool
   25136          365 : c_parser_omp_section_scan (c_parser *parser, const char *directive,
   25137              :                            bool tentative)
   25138              : {
   25139          365 :   if (!c_parser_nth_token_starts_std_attributes (parser, 1))
   25140              :     return false;
   25141           36 :   unsigned int n = 3;
   25142           36 :   if (!c_parser_check_balanced_raw_token_sequence (parser, &n))
   25143              :     return false;
   25144           36 :   c_token *token = c_parser_peek_nth_token_raw (parser, n);
   25145           36 :   if (token->type != CPP_CLOSE_SQUARE)
   25146              :     return false;
   25147           36 :   token = c_parser_peek_nth_token_raw (parser, n + 1);
   25148           36 :   if (token->type != CPP_CLOSE_SQUARE)
   25149              :     return false;
   25150           36 :   if (n < 9)
   25151              :     return false;
   25152           35 :   if (c_parser_peek_nth_token_raw (parser, 3)->type == CPP_NAME
   25153           35 :       && c_parser_peek_nth_token_raw (parser, 4)->type == CPP_OPEN_PAREN
   25154           35 :       && c_parser_peek_nth_token_raw (parser, 5)->type == CPP_NAME)
   25155              :     {
   25156            0 :       tree first = c_parser_peek_nth_token_raw (parser, 3)->value;
   25157            0 :       tree second = c_parser_peek_nth_token_raw (parser, 5)->value;
   25158            0 :       if (strcmp (IDENTIFIER_POINTER (first), "directive")
   25159            0 :           && strcmp (IDENTIFIER_POINTER (first), "__directive__"))
   25160              :         return false;
   25161            0 :       if (strcmp (IDENTIFIER_POINTER (second), directive))
   25162              :         return false;
   25163              :     }
   25164           35 :   if (tentative)
   25165              :     return true;
   25166           32 :   location_t first_loc = c_parser_peek_token (parser)->location;
   25167           32 :   location_t last_loc = c_parser_peek_nth_token_raw (parser, n + 1)->location;
   25168           32 :   location_t middle_loc = UNKNOWN_LOCATION;
   25169           32 :   tree std_attrs = c_parser_std_attribute_specifier_sequence (parser);
   25170           32 :   bool seen = false;
   25171           32 :   int cnt = 0;
   25172           67 :   for (tree attr = std_attrs; attr; attr = TREE_CHAIN (attr))
   25173           35 :     if (is_attribute_namespace_p ("omp", attr)
   25174           35 :         && is_attribute_p ("directive", get_attribute_name (attr)))
   25175              :       {
   25176           68 :         for (tree a = TREE_VALUE (attr); a; a = TREE_CHAIN (a))
   25177              :           {
   25178           36 :             tree d = TREE_VALUE (a);
   25179           36 :             gcc_assert (TREE_CODE (d) == C_TOKEN_VEC);
   25180           36 :             c_token *first = C_TOKEN_VEC_TOKENS (d)->address ();
   25181           36 :             cnt++;
   25182           36 :             if (first->type == CPP_NAME
   25183           36 :                 && strcmp (IDENTIFIER_POINTER (first->value),
   25184              :                            directive) == 0)
   25185              :               {
   25186           31 :                 seen = true;
   25187           31 :                 if (middle_loc == UNKNOWN_LOCATION)
   25188           31 :                   middle_loc = first->location;
   25189              :               }
   25190              :           }
   25191              :       }
   25192           32 :   if (!seen)
   25193              :     return false;
   25194           31 :   if (cnt != 1 || TREE_CHAIN (std_attrs))
   25195              :     {
   25196            7 :       error_at (make_location (first_loc, last_loc, middle_loc),
   25197              :                 "%<[[omp::directive(%s)]]%> must be the only specified "
   25198              :                 "attribute on a statement", directive);
   25199            7 :       return false;
   25200              :     }
   25201           24 :   c_parser_handle_statement_omp_attributes (parser, std_attrs, NULL);
   25202           24 :   return true;
   25203              : }
   25204              : 
   25205              : /* Parse an OpenMP structured block sequence.  KIND is the corresponding
   25206              :    separating directive.  */
   25207              : 
   25208              : static tree
   25209          825 : c_parser_omp_structured_block_sequence (c_parser *parser,
   25210              :                                         enum pragma_kind kind)
   25211              : {
   25212          825 :   tree stmt = push_stmt_list ();
   25213          825 :   c_parser_statement (parser, NULL);
   25214          919 :   do
   25215              :     {
   25216          872 :       if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
   25217              :         break;
   25218          465 :       if (c_parser_next_token_is (parser, CPP_EOF))
   25219              :         break;
   25220              : 
   25221          465 :       if (kind != PRAGMA_NONE
   25222          465 :           && c_parser_peek_token (parser)->pragma_kind == kind)
   25223              :         break;
   25224              : 
   25225           69 :       if (kind != PRAGMA_NONE
   25226          104 :           && c_parser_omp_section_scan (parser,
   25227              :                                         kind == PRAGMA_OMP_SCAN
   25228              :                                         ? "scan" : "section", false))
   25229              :         break;
   25230              : 
   25231           47 :       c_parser_statement (parser, NULL);
   25232              :     }
   25233              :   while (1);
   25234          825 :   return pop_stmt_list (stmt);
   25235              : }
   25236              : 
   25237              : /* OpenMP 5.0:
   25238              : 
   25239              :    scan-loop-body:
   25240              :      { structured-block scan-directive structured-block }  */
   25241              : 
   25242              : static void
   25243          268 : c_parser_omp_scan_loop_body (c_parser *parser, bool open_brace_parsed)
   25244              : {
   25245          268 :   tree substmt;
   25246          268 :   location_t loc;
   25247          268 :   tree clauses = NULL_TREE;
   25248          268 :   bool found_scan = false;
   25249              : 
   25250          268 :   loc = c_parser_peek_token (parser)->location;
   25251          268 :   if (!open_brace_parsed
   25252          268 :       && !c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
   25253              :     {
   25254              :       /* Avoid skipping until the end of the block.  */
   25255            1 :       parser->error = false;
   25256            1 :       return;
   25257              :     }
   25258              : 
   25259          267 :   if (c_parser_peek_token (parser)->pragma_kind != PRAGMA_OMP_SCAN)
   25260          265 :     substmt = c_parser_omp_structured_block_sequence (parser, PRAGMA_OMP_SCAN);
   25261              :   else
   25262              :     {
   25263            2 :       warning_at (c_parser_peek_token (parser)->location, OPT_Wopenmp,
   25264              :                   "%<#pragma omp scan%> with zero preceding executable "
   25265              :                   "statements");
   25266            2 :       substmt = build_empty_stmt (loc);
   25267              :     }
   25268          267 :   substmt = build2 (OMP_SCAN, void_type_node, substmt, NULL_TREE);
   25269          267 :   SET_EXPR_LOCATION (substmt, loc);
   25270          267 :   add_stmt (substmt);
   25271              : 
   25272          267 :   loc = c_parser_peek_token (parser)->location;
   25273          267 :   if (c_parser_peek_token (parser)->pragma_kind == PRAGMA_OMP_SCAN)
   25274              :     {
   25275          260 :       enum omp_clause_code clause = OMP_CLAUSE_ERROR;
   25276          260 :       found_scan = true;
   25277              : 
   25278          260 :       c_parser_consume_pragma (parser);
   25279              : 
   25280          260 :       if (c_parser_next_token_is (parser, CPP_COMMA))
   25281            4 :         c_parser_consume_token (parser);
   25282              : 
   25283          260 :       if (c_parser_next_token_is (parser, CPP_NAME))
   25284              :         {
   25285          258 :           const char *p
   25286          258 :             = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   25287          258 :           if (strcmp (p, "inclusive") == 0)
   25288              :             clause = OMP_CLAUSE_INCLUSIVE;
   25289          126 :           else if (strcmp (p, "exclusive") == 0)
   25290              :             clause = OMP_CLAUSE_EXCLUSIVE;
   25291              :         }
   25292              :       if (clause != OMP_CLAUSE_ERROR)
   25293              :         {
   25294          258 :           c_parser_consume_token (parser);
   25295          258 :           clauses = c_parser_omp_var_list_parens (parser, clause, NULL_TREE);
   25296              :         }
   25297              :       else
   25298            2 :         c_parser_error (parser, "expected %<inclusive%> or "
   25299              :                                 "%<exclusive%> clause");
   25300          260 :       c_parser_skip_to_pragma_eol (parser);
   25301              :     }
   25302              :   else
   25303            7 :     error ("expected %<#pragma omp scan%>");
   25304              : 
   25305          267 :   clauses = c_finish_omp_clauses (clauses, C_ORT_OMP);
   25306          267 :   if (!c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
   25307          258 :     substmt = c_parser_omp_structured_block_sequence (parser, PRAGMA_NONE);
   25308              :   else
   25309              :     {
   25310            9 :       if (found_scan)
   25311            2 :         warning_at (loc, OPT_Wopenmp,
   25312              :                     "%<#pragma omp scan%> with zero succeeding executable "
   25313              :                     "statements");
   25314            9 :       substmt = build_empty_stmt (loc);
   25315              :     }
   25316          267 :   substmt = build2 (OMP_SCAN, void_type_node, substmt, clauses);
   25317          267 :   SET_EXPR_LOCATION (substmt, loc);
   25318          267 :   add_stmt (substmt);
   25319              : 
   25320          267 :   c_parser_skip_until_found (parser, CPP_CLOSE_BRACE,
   25321              :                              "expected %<}%>");
   25322              : }
   25323              : 
   25324              : 
   25325              : /* Check if the next tokens can start a canonical loop.  Return true if yes,
   25326              :    otherwise diagnose an error if ERROR_P is true, and return false.  */
   25327              : static bool
   25328        18309 : c_parser_omp_next_tokens_can_be_canon_loop (c_parser *parser,
   25329              :                                             enum tree_code code,
   25330              :                                             bool error_p)
   25331              : {
   25332        18309 :   if (code == OACC_LOOP)
   25333              :     {
   25334         2581 :       if (c_parser_next_token_is_keyword (parser, RID_FOR))
   25335              :         return true;
   25336           27 :       if (error_p)
   25337            4 :         c_parser_error (parser, "for statement expected");
   25338              :     }
   25339              :   else
   25340              :     {
   25341        15728 :       if (c_parser_next_token_is_keyword (parser, RID_FOR))
   25342              :         return true;
   25343              : 
   25344          897 :       if (c_parser_next_token_is (parser, CPP_PRAGMA))
   25345          582 :         switch (c_parser_peek_token (parser)->pragma_kind)
   25346              :           {
   25347              :           case PRAGMA_OMP_UNROLL:
   25348              :           case PRAGMA_OMP_TILE:
   25349              :             return true;
   25350              :           default:
   25351              :             break;
   25352              :           }
   25353              : 
   25354              :       /* Skip standard attributes on next for in case they are
   25355              :          [[omp::directive (unroll partial (4))]] or
   25356              :          [[omp::directive (tile sizes (1, 2, 3))]] etc.  */
   25357          329 :       size_t n = c_parser_skip_std_attribute_spec_seq (parser, 1);
   25358          329 :       c_token *token = c_parser_peek_nth_token_raw (parser, n);
   25359              :       /* TOKEN is a raw token that hasn't been converted to a keyword yet,
   25360              :          we have to do the lookup explicitly.  */
   25361          329 :       if (token->type == CPP_NAME
   25362          108 :           && C_IS_RESERVED_WORD (token->value)
   25363          341 :           && C_RID_CODE (token->value) == RID_FOR)
   25364              :         return true;
   25365          317 :       if (error_p)
   25366            7 :         c_parser_error (parser, "loop nest expected");
   25367              :     }
   25368              : 
   25369              :   return false;
   25370              : }
   25371              : 
   25372              : static tree c_parser_omp_tile (location_t, c_parser *, bool *);
   25373              : static tree c_parser_omp_unroll (location_t, c_parser *, bool *);
   25374              : 
   25375              : /* This function parses a single level of a loop nest, invoking itself
   25376              :    recursively if necessary.
   25377              : 
   25378              :    loop-nest :: for (...) loop-body
   25379              :    loop-body :: loop-nest
   25380              :              |  { [intervening-code] loop-body [intervening-code] }
   25381              :              |  final-loop-body
   25382              :    intervening-code :: structured-block-sequence
   25383              :    final-loop-body :: structured-block
   25384              : 
   25385              :    For a collapsed loop nest, only a single OMP_FOR is built, pulling out
   25386              :    all the iterator information from the inner loops into the
   25387              :    parser->omp_for_parse_state structure.
   25388              : 
   25389              :    The iterator decl, init, cond, and incr are stored in vectors.
   25390              : 
   25391              :    Initialization code for iterator variables is collected into
   25392              :    parser->omp_for_parse_state->pre_body and ends up inserted directly
   25393              :    into the OMP_FOR structure.  */
   25394              : 
   25395              : static tree
   25396        17965 : c_parser_omp_loop_nest (c_parser *parser, bool *if_p)
   25397              : {
   25398        17965 :   tree decl = NULL_TREE, cond = NULL_TREE, incr = NULL_TREE, init = NULL_TREE;
   25399        17965 :   tree body = NULL_TREE;
   25400        17965 :   matching_parens parens;
   25401        17965 :   bool moreloops;
   25402        17965 :   unsigned char save_in_statement;
   25403        17965 :   tree loop_scope;
   25404        17965 :   location_t loc;
   25405        17965 :   struct omp_for_parse_data *omp_for_parse_state
   25406              :     = parser->omp_for_parse_state;
   25407        17965 :   gcc_assert (omp_for_parse_state);
   25408        17965 :   int depth = omp_for_parse_state->depth;
   25409              : 
   25410              :   /* Arrange for C23 standard attribute syntax to be parsed as regular
   25411              :      pragmas.  */
   25412        17965 :   if (c_parser_nth_token_starts_std_attributes (parser, 1))
   25413              :     {
   25414           12 :       tree std_attrs = c_parser_std_attribute_specifier_sequence (parser);
   25415           12 :       c_parser_handle_statement_omp_attributes (parser, std_attrs, NULL);
   25416           12 :       if (std_attrs)
   25417            0 :         error_at (c_parser_peek_token (parser)->location,
   25418              :                   "attributes other than OpenMP directives "
   25419              :                   "are not allowed on %<for%> in loop nest");
   25420              :     }
   25421              : 
   25422        17965 :   loc = c_parser_peek_token (parser)->location;
   25423              : 
   25424              :   /* Handle loop transformations first.  */
   25425        17965 :   if (c_parser_next_token_is (parser, CPP_PRAGMA))
   25426              :     {
   25427          576 :       tree transform = NULL_TREE, sizes, body = NULL_TREE;
   25428          576 :       int count = 0;
   25429          576 :       switch (c_parser_peek_token (parser)->pragma_kind)
   25430              :         {
   25431          208 :         case PRAGMA_OMP_UNROLL:
   25432          208 :           c_parser_consume_pragma (parser);
   25433          208 :           body = push_stmt_list ();
   25434          208 :           transform = c_parser_omp_unroll (loc, parser, if_p);
   25435          208 :           body = pop_stmt_list (body);
   25436          208 :           if (transform == NULL_TREE || transform == error_mark_node)
   25437              :             {
   25438            7 :               transform = error_mark_node;
   25439            7 :               break;
   25440              :             }
   25441          201 :           gcc_assert (TREE_CODE (transform) == OMP_UNROLL);
   25442          201 :           if (omp_find_clause (OMP_FOR_CLAUSES (transform),
   25443              :                                OMP_CLAUSE_PARTIAL))
   25444              :             {
   25445          172 :               if (omp_for_parse_state->count - depth > 1)
   25446              :                 {
   25447           10 :                   error_at (loc, "%<unroll%> construct with %<partial%> "
   25448              :                                  "clause generates just one loop with "
   25449              :                                  "canonical form but %d loops are needed",
   25450              :                             omp_for_parse_state->count - depth);
   25451           10 :                   transform = error_mark_node;
   25452              :                 }
   25453              :               else
   25454          576 :                 count = 1;
   25455              :             }
   25456              :           else
   25457              :             {
   25458           29 :               error_at (loc, "generated loop of %<unroll%> construct "
   25459              :                              "without %<partial%> clause does not have "
   25460              :                              "canonical form");
   25461           29 :               transform = error_mark_node;
   25462              :             }
   25463              :           break;
   25464          366 :         case PRAGMA_OMP_TILE:
   25465          366 :           c_parser_consume_pragma (parser);
   25466          366 :           body = push_stmt_list ();
   25467          366 :           transform = c_parser_omp_tile (loc, parser, if_p);
   25468          366 :           body = pop_stmt_list (body);
   25469          366 :           if (transform == NULL_TREE || transform == error_mark_node)
   25470              :             {
   25471           40 :               transform = error_mark_node;
   25472           40 :               break;
   25473              :             }
   25474          326 :           gcc_assert (TREE_CODE (transform) == OMP_TILE);
   25475          326 :           sizes = omp_find_clause (OMP_FOR_CLAUSES (transform),
   25476              :                                    OMP_CLAUSE_SIZES);
   25477          326 :           gcc_assert (sizes);
   25478          326 :           count = list_length (OMP_CLAUSE_SIZES_LIST (sizes));
   25479          326 :           if (depth + count < omp_for_parse_state->count)
   25480              :             {
   25481           16 :               error_at (loc, "%<tile%> construct generates %d loops "
   25482              :                              "with canonical form but %d loops are needed",
   25483              :                         count, omp_for_parse_state->count - depth);
   25484           16 :               transform = error_mark_node;
   25485              :             }
   25486              :           break;
   25487            2 :         default:
   25488            2 :           c_parser_pragma (parser, pragma_stmt, NULL, void_list_node);
   25489            2 :           break;
   25490              :         }
   25491          576 :       if (transform == NULL_TREE)
   25492            2 :         error_at (loc, "expected %<for%> loop or OpenMP loop "
   25493              :                        "transformation construct");
   25494          576 :       if (transform == NULL_TREE || transform == error_mark_node)
   25495              :         {
   25496          104 :           omp_for_parse_state->fail = true;
   25497          104 :           return NULL_TREE;
   25498              :         }
   25499         1030 :       for (count = omp_for_parse_state->count; depth < count; ++depth)
   25500              :         {
   25501          558 :           TREE_VEC_ELT (omp_for_parse_state->declv, depth) = NULL_TREE;
   25502          558 :           TREE_VEC_ELT (omp_for_parse_state->initv, depth) = NULL_TREE;
   25503          558 :           TREE_VEC_ELT (omp_for_parse_state->condv, depth) = NULL_TREE;
   25504          558 :           TREE_VEC_ELT (omp_for_parse_state->incrv, depth) = NULL_TREE;
   25505              :         }
   25506          472 :       omp_for_parse_state->want_nested_loop = false;
   25507          472 :       return body;
   25508              :     }
   25509              : 
   25510              :   /* We have already matched the FOR token but not consumed it yet.  */
   25511        17389 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_FOR));
   25512        17389 :   c_parser_consume_token (parser);
   25513              : 
   25514              :   /* Forbid break/continue in the loop initializer, condition, and
   25515              :      increment expressions.  */
   25516        17389 :   save_in_statement = in_statement;
   25517        17389 :   in_statement = IN_OMP_BLOCK;
   25518              : 
   25519              :   /* We are not in intervening code now.  */
   25520        17389 :   omp_for_parse_state->in_intervening_code = false;
   25521              : 
   25522        17389 :   if (!parens.require_open (parser))
   25523              :     {
   25524            0 :       omp_for_parse_state->fail = true;
   25525            0 :       return NULL_TREE;
   25526              :     }
   25527              : 
   25528              :   /* An implicit scope block surrounds each level of FOR loop, for
   25529              :      declarations of iteration variables at this loop depth.  */
   25530        17389 :   loop_scope = c_begin_compound_stmt (true);
   25531              : 
   25532              :   /* Parse the initialization declaration or expression.  */
   25533        17389 :   if (c_parser_next_tokens_start_declaration (parser))
   25534              :     {
   25535              :       /* This is a declaration, which must be added to the pre_body code.  */
   25536         5470 :       tree this_pre_body = push_stmt_list ();
   25537         5470 :       c_in_omp_for = true;
   25538         5470 :       c_parser_declaration_or_fndef (parser, true, true, true, true, true,
   25539              :                                      false);
   25540         5470 :       c_in_omp_for = false;
   25541         5470 :       this_pre_body = pop_stmt_list (this_pre_body);
   25542         5470 :       append_to_statement_list_force (this_pre_body,
   25543              :                                       &(omp_for_parse_state->pre_body));
   25544         5470 :       decl = check_for_loop_decls (omp_for_parse_state->for_loc, flag_isoc99);
   25545         5470 :       if (decl == NULL)
   25546            0 :         goto error_init;
   25547         5470 :       if (DECL_INITIAL (decl) == error_mark_node)
   25548            1 :         decl = error_mark_node;
   25549              :       init = decl;
   25550              :     }
   25551        11919 :   else if (c_parser_next_token_is (parser, CPP_NAME)
   25552        11919 :            && c_parser_peek_2nd_token (parser)->type == CPP_EQ)
   25553              :     {
   25554        11917 :       struct c_expr decl_exp;
   25555        11917 :       struct c_expr init_exp;
   25556        11917 :       location_t init_loc;
   25557              : 
   25558        11917 :       decl_exp = c_parser_postfix_expression (parser);
   25559        11917 :       decl = decl_exp.value;
   25560              : 
   25561        11917 :       c_parser_require (parser, CPP_EQ, "expected %<=%>");
   25562              : 
   25563        11917 :       init_loc = c_parser_peek_token (parser)->location;
   25564        11917 :       init_exp = c_parser_expr_no_commas (parser, NULL);
   25565        11917 :       init_exp = default_function_array_read_conversion (init_loc,
   25566              :                                                          init_exp);
   25567        11917 :       c_in_omp_for = true;
   25568        11917 :       init = build_modify_expr (init_loc, decl, decl_exp.original_type,
   25569              :                                 NOP_EXPR, init_loc, init_exp.value,
   25570              :                                 init_exp.original_type);
   25571        11917 :       c_in_omp_for = false;
   25572        11917 :       init = c_process_expr_stmt (init_loc, init);
   25573              : 
   25574        11917 :       c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   25575              :     }
   25576              :   else
   25577              :     {
   25578            2 :     error_init:
   25579            2 :       c_parser_error (parser,
   25580              :                       "expected iteration declaration or initialization");
   25581            2 :       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
   25582              :                                  "expected %<)%>");
   25583            2 :       omp_for_parse_state->fail = true;
   25584            2 :       goto parse_next;
   25585              :     }
   25586              : 
   25587              :   /* Parse the loop condition.  */
   25588        17387 :   if (c_parser_next_token_is_not (parser, CPP_SEMICOLON))
   25589              :     {
   25590        17385 :       location_t cond_loc = c_parser_peek_token (parser)->location;
   25591        17385 :       c_in_omp_for = true;
   25592        17385 :       struct c_expr cond_expr
   25593        17385 :         = c_parser_binary_expression (parser, NULL, NULL_TREE);
   25594        17385 :       c_in_omp_for = false;
   25595              : 
   25596        17385 :       cond = cond_expr.value;
   25597        17385 :       cond = c_objc_common_truthvalue_conversion (cond_loc, cond);
   25598        17385 :       switch (cond_expr.original_code)
   25599              :         {
   25600              :         case GT_EXPR:
   25601              :         case GE_EXPR:
   25602              :         case LT_EXPR:
   25603              :         case LE_EXPR:
   25604              :           break;
   25605         2428 :         case NE_EXPR:
   25606         2428 :           if (omp_for_parse_state->code != OACC_LOOP)
   25607              :             break;
   25608              :           /* FALLTHRU.  */
   25609            7 :         default:
   25610              :           /* Can't be cond = error_mark_node, because we want to preserve
   25611              :              the location until c_finish_omp_for.  */
   25612            7 :           cond = build1 (NOP_EXPR, boolean_type_node, error_mark_node);
   25613            7 :           break;
   25614              :         }
   25615        17385 :       protected_set_expr_location (cond, cond_loc);
   25616              :     }
   25617        17387 :   c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   25618              : 
   25619              :   /* Parse the increment expression.  */
   25620        17387 :   if (c_parser_next_token_is_not (parser, CPP_CLOSE_PAREN))
   25621              :     {
   25622        17387 :       location_t incr_loc = c_parser_peek_token (parser)->location;
   25623              : 
   25624        17387 :       incr = c_process_expr_stmt (incr_loc,
   25625        34774 :                                   c_parser_expression (parser).value);
   25626              :     }
   25627        17387 :   parens.skip_until_found_close (parser);
   25628              : 
   25629        17387 :   if (decl == NULL || decl == error_mark_node || init == error_mark_node)
   25630            3 :     omp_for_parse_state->fail = true;
   25631              :   else
   25632              :     {
   25633        17384 :       TREE_VEC_ELT (omp_for_parse_state->declv, depth) = decl;
   25634        17384 :       TREE_VEC_ELT (omp_for_parse_state->initv, depth) = init;
   25635        17384 :       TREE_VEC_ELT (omp_for_parse_state->condv, depth) = cond;
   25636        17384 :       TREE_VEC_ELT (omp_for_parse_state->incrv, depth) = incr;
   25637              :     }
   25638              : 
   25639        17389 : parse_next:
   25640        17389 :   moreloops = depth < omp_for_parse_state->count - 1;
   25641        17389 :   omp_for_parse_state->want_nested_loop = moreloops;
   25642        17389 :   if (moreloops
   25643        17389 :       && c_parser_omp_next_tokens_can_be_canon_loop (parser,
   25644              :                                                      omp_for_parse_state->code,
   25645              :                                                      false))
   25646              :     {
   25647         5802 :       omp_for_parse_state->depth++;
   25648         5802 :       body = c_parser_omp_loop_nest (parser, if_p);
   25649         5802 :       omp_for_parse_state->depth--;
   25650              :     }
   25651        11733 :   else if (moreloops && c_parser_next_token_is (parser, CPP_OPEN_BRACE))
   25652              :     {
   25653              :       /* This is the open brace in the loop-body grammar production.  Rather
   25654              :          than trying to special-case braces, just parse it as a compound
   25655              :          statement and handle the nested loop-body case there.  Note that
   25656              :          when we see a further open brace inside the compound statement
   25657              :          loop-body, we don't know whether it is the start of intervening
   25658              :          code that is a compound statement, or a level of braces
   25659              :          surrounding a nested loop-body.  Use the WANT_NESTED_LOOP state
   25660              :          bit to ensure we have only one nested loop at each level.  */
   25661          127 :       omp_for_parse_state->in_intervening_code = true;
   25662          127 :       body = c_parser_compound_statement (parser, NULL);
   25663          127 :       omp_for_parse_state->in_intervening_code = false;
   25664          127 :       if (omp_for_parse_state->want_nested_loop)
   25665              :         {
   25666              :           /* We have already parsed the whole loop body and not found a
   25667              :              nested loop.  */
   25668           11 :           error_at (omp_for_parse_state->for_loc,
   25669              :                     "not enough nested loops");
   25670           11 :           omp_for_parse_state->fail = true;
   25671              :         }
   25672        17389 :       if_p = NULL;
   25673              :     }
   25674              :   else
   25675              :     {
   25676              :       /* This is the final-loop-body case in the grammar: we have
   25677              :          something that is not a FOR and not an open brace.  */
   25678        11460 :       if (moreloops)
   25679              :         {
   25680              :           /* If we were expecting a nested loop, give an error and mark
   25681              :              that parsing has failed, and try to recover by parsing the
   25682              :              body as regular code without further collapsing.  */
   25683           19 :           error_at (omp_for_parse_state->for_loc,
   25684              :                     "not enough nested loops");
   25685           19 :           omp_for_parse_state->fail = true;
   25686              :         }
   25687        11460 :       in_statement = IN_OMP_FOR;
   25688        11460 :       parser->omp_for_parse_state = NULL;
   25689        11460 :       body = push_stmt_list ();
   25690        11460 :       if (omp_for_parse_state->inscan)
   25691          268 :         c_parser_omp_scan_loop_body (parser, false);
   25692              :       else
   25693        11192 :         add_stmt (c_parser_c99_block_statement (parser, if_p));
   25694        11460 :       body = pop_stmt_list (body);
   25695        11460 :       parser->omp_for_parse_state = omp_for_parse_state;
   25696              :     }
   25697        17389 :   in_statement = save_in_statement;
   25698        17389 :   omp_for_parse_state->want_nested_loop = false;
   25699        17389 :   omp_for_parse_state->in_intervening_code = true;
   25700              : 
   25701              :   /* Pop and return the implicit scope surrounding this level of loop.
   25702              :      If the iteration variable at this depth was bound in the for loop,
   25703              :      pull out and save the binding.  Later in c_parser_omp_for_loop,
   25704              :      these bindings will be moved to the scope surrounding the entire
   25705              :      OMP_FOR.  That keeps the gimplifier happy later on, and meanwhile
   25706              :      we have already resolved all references to the iteration variable
   25707              :      in its true scope.  */
   25708        17389 :   if (body)
   25709        17383 :     add_stmt (body);
   25710        17389 :   body = c_end_compound_stmt (loc, loop_scope, true);
   25711        17389 :   if (decl && TREE_CODE (body) == BIND_EXPR)
   25712              :     {
   25713         5856 :       tree t = BIND_EXPR_VARS (body);
   25714         5856 :       tree prev = NULL_TREE, next = NULL_TREE;
   25715         6292 :       while (t)
   25716              :         {
   25717         5905 :           next = DECL_CHAIN (t);
   25718         5905 :           if (t == decl)
   25719              :             {
   25720         5469 :               if (prev)
   25721            0 :                 DECL_CHAIN (prev) = next;
   25722              :               else
   25723              :                 {
   25724         5469 :                   BIND_EXPR_VARS (body) = next;
   25725         5469 :                   BLOCK_VARS (BIND_EXPR_BLOCK (body)) = next;
   25726              :                 }
   25727         5469 :               DECL_CHAIN (t) = omp_for_parse_state->bindings;
   25728         5469 :               omp_for_parse_state->bindings = t;
   25729         5469 :               break;
   25730              :             }
   25731              :           else
   25732              :             {
   25733              :               prev = t;
   25734              :               t = next;
   25735              :             }
   25736              :         }
   25737         5856 :       if (BIND_EXPR_VARS (body) == NULL_TREE)
   25738         5469 :         body = BIND_EXPR_BODY (body);
   25739              :     }
   25740              : 
   25741              :   return body;
   25742              : }
   25743              : 
   25744              : /* Parse the restricted form of loop statements allowed by OpenACC and OpenMP.
   25745              :    The real trick here is to determine the loop control variable early
   25746              :    so that we can push a new decl if necessary to make it private.
   25747              :    LOC is the location of the "acc" or "omp" in "#pragma acc" or "#pragma omp",
   25748              :    respectively.  */
   25749              : 
   25750              : static tree
   25751        12058 : c_parser_omp_for_loop (location_t loc, c_parser *parser, enum tree_code code,
   25752              :                        tree clauses, tree *cclauses, bool *if_p)
   25753              : {
   25754        12058 :   tree body, stmt, cl;
   25755        12058 :   tree ret = NULL_TREE;
   25756        12058 :   tree ordered_cl = NULL_TREE;
   25757        12058 :   int i, collapse = 1, ordered = 0, count;
   25758        12058 :   bool oacc_tiling = false;
   25759        12058 :   bool inscan = false;
   25760        12058 :   struct omp_for_parse_data data;
   25761        12058 :   struct omp_for_parse_data *save_data = parser->omp_for_parse_state;
   25762              : 
   25763        28728 :   for (cl = clauses; cl; cl = OMP_CLAUSE_CHAIN (cl))
   25764        16670 :     if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_COLLAPSE)
   25765         3399 :       collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (cl));
   25766        13271 :     else if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_TILE)
   25767              :       {
   25768          111 :         oacc_tiling = true;
   25769          111 :         collapse = list_length (OMP_CLAUSE_TILE_LIST (cl));
   25770              :       }
   25771        13160 :     else if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_SIZES)
   25772          464 :       collapse = list_length (OMP_CLAUSE_SIZES_LIST (cl));
   25773        12696 :     else if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_ORDERED
   25774        12696 :              && OMP_CLAUSE_ORDERED_EXPR (cl))
   25775              :       {
   25776          161 :         ordered_cl = cl;
   25777          161 :         ordered = tree_to_shwi (OMP_CLAUSE_ORDERED_EXPR (cl));
   25778              :       }
   25779        12535 :     else if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_REDUCTION
   25780         2228 :              && OMP_CLAUSE_REDUCTION_INSCAN (cl)
   25781        12924 :              && (code == OMP_SIMD || code == OMP_FOR))
   25782              :       inscan = true;
   25783              : 
   25784        12058 :   if (ordered && ordered < collapse)
   25785              :     {
   25786            2 :       error_at (OMP_CLAUSE_LOCATION (ordered_cl),
   25787              :                 "%<ordered%> clause parameter is less than %<collapse%>");
   25788            2 :       OMP_CLAUSE_ORDERED_EXPR (ordered_cl)
   25789            2 :         = build_int_cst (integer_type_node, collapse);
   25790            2 :       ordered = collapse;
   25791              :     }
   25792              : 
   25793        12058 :   gcc_assert (oacc_tiling || (collapse >= 1 && ordered >= 0));
   25794        12058 :   count = ordered ? ordered : collapse;
   25795              : 
   25796        12058 :   if (!c_parser_omp_next_tokens_can_be_canon_loop (parser, code, true))
   25797              :     return NULL;
   25798              : 
   25799              :   /* Initialize parse state for recursive descent.  */
   25800        12047 :   data.declv = make_tree_vec (count);
   25801        12047 :   data.initv = make_tree_vec (count);
   25802        12047 :   data.condv = make_tree_vec (count);
   25803        12047 :   data.incrv = make_tree_vec (count);
   25804        12047 :   data.pre_body = NULL_TREE;
   25805        12047 :   data.bindings = NULL_TREE;
   25806        12047 :   data.for_loc = c_parser_peek_token (parser)->location;
   25807        12047 :   data.count = count;
   25808        12047 :   data.depth = 0;
   25809        12047 :   data.want_nested_loop = true;
   25810        12047 :   data.ordered = ordered > 0;
   25811        12047 :   data.in_intervening_code = false;
   25812        12047 :   data.perfect_nesting_fail = false;
   25813        12047 :   data.fail = false;
   25814        12047 :   data.inscan = inscan;
   25815        12047 :   data.saw_intervening_code = false;
   25816        12047 :   data.code = code;
   25817        12047 :   parser->omp_for_parse_state = &data;
   25818              : 
   25819        12047 :   body = c_parser_omp_loop_nest (parser, if_p);
   25820              : 
   25821              :   /* Add saved bindings for iteration variables that were declared in
   25822              :      the nested for loop to the scope surrounding the entire loop.  */
   25823        17516 :   for (tree t = data.bindings; t; )
   25824              :     {
   25825         5469 :       tree n = TREE_CHAIN (t);
   25826         5469 :       TREE_CHAIN (t) = NULL_TREE;
   25827         5469 :       pushdecl (t);
   25828         5469 :       t = n;
   25829              :     }
   25830              : 
   25831              :   /* Only bother calling c_finish_omp_for if we haven't already generated
   25832              :      an error from the initialization parsing.  */
   25833        12047 :   if (!data.fail)
   25834              :     {
   25835        11884 :       c_in_omp_for = true;
   25836        11884 :       stmt = c_finish_omp_for (loc, code, data.declv, NULL, data.initv,
   25837              :                                data.condv, data.incrv,
   25838              :                                body, data.pre_body, true);
   25839        11884 :       c_in_omp_for = false;
   25840              : 
   25841              :       /* Check for iterators appearing in lb, b or incr expressions.  */
   25842        11884 :       if (stmt && !c_omp_check_loop_iv (stmt, data.declv, NULL))
   25843              :         stmt = NULL_TREE;
   25844              : 
   25845              :       /* Check for errors involving lb/ub/incr expressions referencing
   25846              :          variables declared in intervening code.  */
   25847        11884 :       if (data.saw_intervening_code
   25848           42 :           && stmt
   25849        11926 :           && !c_omp_check_loop_binding_exprs (stmt, NULL))
   25850              :         stmt = NULL_TREE;
   25851              : 
   25852        11874 :       if (stmt)
   25853              :         {
   25854        11729 :           add_stmt (stmt);
   25855              : 
   25856        40545 :           for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (stmt)); i++)
   25857              :             {
   25858        17545 :               tree init = TREE_VEC_ELT (OMP_FOR_INIT (stmt), i);
   25859        17545 :               if (init == NULL_TREE)
   25860              :                 break;
   25861        17087 :               gcc_assert (TREE_CODE (init) == MODIFY_EXPR);
   25862        17087 :               tree decl = TREE_OPERAND (init, 0);
   25863        17087 :               tree cond = TREE_VEC_ELT (OMP_FOR_COND (stmt), i);
   25864        17087 :               gcc_assert (COMPARISON_CLASS_P (cond));
   25865        17087 :               gcc_assert (TREE_OPERAND (cond, 0) == decl);
   25866              : 
   25867        17087 :               tree op0 = TREE_OPERAND (init, 1);
   25868        17087 :               if (!OMP_FOR_NON_RECTANGULAR (stmt)
   25869        17087 :                   || TREE_CODE (op0) != TREE_VEC)
   25870        16897 :                 TREE_OPERAND (init, 1) = c_fully_fold (op0, false, NULL);
   25871              :               else
   25872              :                 {
   25873          190 :                   TREE_VEC_ELT (op0, 1)
   25874          190 :                     = c_fully_fold (TREE_VEC_ELT (op0, 1), false, NULL);
   25875          190 :                   TREE_VEC_ELT (op0, 2)
   25876          380 :                     = c_fully_fold (TREE_VEC_ELT (op0, 2), false, NULL);
   25877              :                 }
   25878              : 
   25879        17087 :               tree op1 = TREE_OPERAND (cond, 1);
   25880        17087 :               if (!OMP_FOR_NON_RECTANGULAR (stmt)
   25881        17087 :                   || TREE_CODE (op1) != TREE_VEC)
   25882        16881 :                 TREE_OPERAND (cond, 1) = c_fully_fold (op1, false, NULL);
   25883              :               else
   25884              :                 {
   25885          206 :                   TREE_VEC_ELT (op1, 1)
   25886          206 :                     = c_fully_fold (TREE_VEC_ELT (op1, 1), false, NULL);
   25887          206 :                   TREE_VEC_ELT (op1, 2)
   25888          412 :                     = c_fully_fold (TREE_VEC_ELT (op1, 2), false, NULL);
   25889              :                 }
   25890              :             }
   25891              : 
   25892        11729 :           if (cclauses != NULL
   25893         5599 :               && cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL] != NULL)
   25894              :             {
   25895          915 :               tree *c;
   25896         3673 :               for (c = &cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL]; *c ; )
   25897         2758 :                 if (OMP_CLAUSE_CODE (*c) != OMP_CLAUSE_FIRSTPRIVATE
   25898         2758 :                     && OMP_CLAUSE_CODE (*c) != OMP_CLAUSE_LASTPRIVATE)
   25899         1987 :                   c = &OMP_CLAUSE_CHAIN (*c);
   25900              :                 else
   25901              :                   {
   25902         1632 :                     for (i = 0; i < count; i++)
   25903         1057 :                       if (TREE_VEC_ELT (data.declv, i) == OMP_CLAUSE_DECL (*c))
   25904              :                         break;
   25905          771 :                     if (i == count)
   25906          575 :                       c = &OMP_CLAUSE_CHAIN (*c);
   25907          196 :                     else if (OMP_CLAUSE_CODE (*c) == OMP_CLAUSE_FIRSTPRIVATE)
   25908              :                       {
   25909            1 :                         error_at (loc,
   25910              :                                   "iteration variable %qD should not be firstprivate",
   25911            1 :                                   OMP_CLAUSE_DECL (*c));
   25912            1 :                         *c = OMP_CLAUSE_CHAIN (*c);
   25913              :                       }
   25914              :                     else
   25915              :                       {
   25916              :                         /* Move lastprivate (decl) clause to
   25917              :                            OMP_FOR_CLAUSES.  */
   25918          195 :                         tree l = *c;
   25919          195 :                         *c = OMP_CLAUSE_CHAIN (*c);
   25920          195 :                         if (code == OMP_SIMD)
   25921              :                           {
   25922           60 :                             OMP_CLAUSE_CHAIN (l)
   25923           60 :                               = cclauses[C_OMP_CLAUSE_SPLIT_FOR];
   25924           60 :                             cclauses[C_OMP_CLAUSE_SPLIT_FOR] = l;
   25925              :                           }
   25926              :                         else
   25927              :                           {
   25928          135 :                             OMP_CLAUSE_CHAIN (l) = clauses;
   25929          135 :                             clauses = l;
   25930              :                           }
   25931              :                       }
   25932              :                   }
   25933              :             }
   25934        11729 :           OMP_FOR_CLAUSES (stmt) = clauses;
   25935              :         }
   25936              :       ret = stmt;
   25937              :     }
   25938              : 
   25939        12047 :   parser->omp_for_parse_state = save_data;
   25940        12047 :   return ret;
   25941              : }
   25942              : 
   25943              : /* Helper function for OpenMP parsing, split clauses and call
   25944              :    finish_omp_clauses on each of the set of clauses afterwards.  */
   25945              : 
   25946              : static void
   25947         6919 : omp_split_clauses (location_t loc, enum tree_code code,
   25948              :                    omp_clause_mask mask, tree clauses, tree *cclauses)
   25949              : {
   25950         6919 :   int i;
   25951         6919 :   c_omp_split_clauses (loc, code, mask, clauses, cclauses);
   25952        55352 :   for (i = 0; i < C_OMP_CLAUSE_SPLIT_COUNT; i++)
   25953        41514 :     if (cclauses[i])
   25954        23024 :       cclauses[i] = c_finish_omp_clauses (cclauses[i],
   25955              :                                           i == C_OMP_CLAUSE_SPLIT_TARGET
   25956              :                                           ? C_ORT_OMP_TARGET : C_ORT_OMP);
   25957         6919 : }
   25958              : 
   25959              : /* OpenMP 5.0:
   25960              :    #pragma omp loop loop-clause[optseq] new-line
   25961              :      for-loop
   25962              : 
   25963              :    LOC is the location of the #pragma token.
   25964              : */
   25965              : 
   25966              : #define OMP_LOOP_CLAUSE_MASK                                    \
   25967              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   25968              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LASTPRIVATE)    \
   25969              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION)      \
   25970              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COLLAPSE)       \
   25971              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_BIND)           \
   25972              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ORDER))
   25973              : 
   25974              : static tree
   25975          241 : c_parser_omp_loop (location_t loc, c_parser *parser,
   25976              :                    char *p_name, omp_clause_mask mask, tree *cclauses,
   25977              :                    bool *if_p)
   25978              : {
   25979          241 :   tree block, clauses, ret;
   25980              : 
   25981          241 :   strcat (p_name, " loop");
   25982          241 :   mask |= OMP_LOOP_CLAUSE_MASK;
   25983              : 
   25984          241 :   clauses = c_parser_omp_all_clauses (parser, mask, p_name, cclauses == NULL);
   25985          241 :   if (cclauses)
   25986              :     {
   25987           77 :       omp_split_clauses (loc, OMP_LOOP, mask, clauses, cclauses);
   25988           77 :       clauses = cclauses[C_OMP_CLAUSE_SPLIT_LOOP];
   25989              :     }
   25990              : 
   25991          241 :   block = c_begin_compound_stmt (true);
   25992          241 :   ret = c_parser_omp_for_loop (loc, parser, OMP_LOOP, clauses, cclauses, if_p);
   25993          241 :   block = c_end_compound_stmt (loc, block, true);
   25994          241 :   add_stmt (block);
   25995              : 
   25996          241 :   return ret;
   25997              : }
   25998              : 
   25999              : /* OpenMP 4.0:
   26000              :    #pragma omp simd simd-clause[optseq] new-line
   26001              :      for-loop
   26002              : 
   26003              :    LOC is the location of the #pragma token.
   26004              : */
   26005              : 
   26006              : #define OMP_SIMD_CLAUSE_MASK                                    \
   26007              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SAFELEN)        \
   26008              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SIMDLEN)        \
   26009              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINEAR) \
   26010              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALIGNED)        \
   26011              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   26012              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LASTPRIVATE)    \
   26013              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION)      \
   26014              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COLLAPSE)       \
   26015              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF)             \
   26016              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NONTEMPORAL)    \
   26017              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ORDER))
   26018              : 
   26019              : static tree
   26020         3992 : c_parser_omp_simd (location_t loc, c_parser *parser,
   26021              :                    char *p_name, omp_clause_mask mask, tree *cclauses,
   26022              :                    bool *if_p)
   26023              : {
   26024         3992 :   tree block, clauses, ret;
   26025              : 
   26026         3992 :   strcat (p_name, " simd");
   26027         3992 :   mask |= OMP_SIMD_CLAUSE_MASK;
   26028              : 
   26029         3992 :   clauses = c_parser_omp_all_clauses (parser, mask, p_name, cclauses == NULL);
   26030         3992 :   if (cclauses)
   26031              :     {
   26032         3120 :       omp_split_clauses (loc, OMP_SIMD, mask, clauses, cclauses);
   26033         3120 :       clauses = cclauses[C_OMP_CLAUSE_SPLIT_SIMD];
   26034              :     }
   26035              : 
   26036         3992 :   block = c_begin_compound_stmt (true);
   26037         3992 :   ret = c_parser_omp_for_loop (loc, parser, OMP_SIMD, clauses, cclauses, if_p);
   26038         3992 :   block = c_end_compound_stmt (loc, block, true);
   26039         3992 :   add_stmt (block);
   26040              : 
   26041         3992 :   return ret;
   26042              : }
   26043              : 
   26044              : /* OpenMP 2.5:
   26045              :    #pragma omp for for-clause[optseq] new-line
   26046              :      for-loop
   26047              : 
   26048              :    OpenMP 4.0:
   26049              :    #pragma omp for simd for-simd-clause[optseq] new-line
   26050              :      for-loop
   26051              : 
   26052              :    LOC is the location of the #pragma token.
   26053              : */
   26054              : 
   26055              : #define OMP_FOR_CLAUSE_MASK                                     \
   26056              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   26057              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)   \
   26058              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LASTPRIVATE)    \
   26059              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINEAR) \
   26060              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION)      \
   26061              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ORDERED)        \
   26062              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SCHEDULE)       \
   26063              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COLLAPSE)       \
   26064              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT) \
   26065              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE)       \
   26066              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ORDER))
   26067              : 
   26068              : static tree
   26069         6520 : c_parser_omp_for (location_t loc, c_parser *parser,
   26070              :                   char *p_name, omp_clause_mask mask, tree *cclauses,
   26071              :                   bool *if_p)
   26072              : {
   26073         6520 :   tree block, clauses, ret;
   26074              : 
   26075         6520 :   strcat (p_name, " for");
   26076         6520 :   mask |= OMP_FOR_CLAUSE_MASK;
   26077              :   /* parallel for{, simd} disallows nowait clause, but for
   26078              :      target {teams distribute ,}parallel for{, simd} it should be accepted.  */
   26079         6520 :   if (cclauses && (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)) == 0)
   26080         3307 :     mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT);
   26081              :   /* Composite distribute parallel for{, simd} disallows ordered clause.  */
   26082         6520 :   if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) != 0)
   26083         3024 :     mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ORDERED);
   26084              : 
   26085         6520 :   if (c_parser_next_token_is (parser, CPP_NAME))
   26086              :     {
   26087         5769 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   26088              : 
   26089         5769 :       if (strcmp (p, "simd") == 0)
   26090              :         {
   26091         2514 :           tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   26092         2514 :           if (cclauses == NULL)
   26093          301 :             cclauses = cclauses_buf;
   26094              : 
   26095         2514 :           c_parser_consume_token (parser);
   26096         2514 :           if (!flag_openmp)  /* flag_openmp_simd  */
   26097           14 :             return c_parser_omp_simd (loc, parser, p_name, mask, cclauses,
   26098           14 :                                       if_p);
   26099         2500 :           block = c_begin_compound_stmt (true);
   26100         2500 :           ret = c_parser_omp_simd (loc, parser, p_name, mask, cclauses, if_p);
   26101         2500 :           block = c_end_compound_stmt (loc, block, true);
   26102         2500 :           if (ret == NULL_TREE)
   26103              :             return ret;
   26104         2489 :           ret = make_node (OMP_FOR);
   26105         2489 :           TREE_TYPE (ret) = void_type_node;
   26106         2489 :           OMP_FOR_BODY (ret) = block;
   26107         2489 :           OMP_FOR_CLAUSES (ret) = cclauses[C_OMP_CLAUSE_SPLIT_FOR];
   26108         2489 :           SET_EXPR_LOCATION (ret, loc);
   26109         2489 :           add_stmt (ret);
   26110         2489 :           return ret;
   26111              :         }
   26112              :     }
   26113         4006 :   if (!flag_openmp)  /* flag_openmp_simd  */
   26114              :     {
   26115            9 :       c_parser_skip_to_pragma_eol (parser, false);
   26116            9 :       return NULL_TREE;
   26117              :     }
   26118              : 
   26119              :   /* Composite distribute parallel for disallows linear clause.  */
   26120         3997 :   if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) != 0)
   26121         1371 :     mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINEAR);
   26122              : 
   26123         3997 :   clauses = c_parser_omp_all_clauses (parser, mask, p_name, cclauses == NULL);
   26124         3997 :   if (cclauses)
   26125              :     {
   26126         2465 :       omp_split_clauses (loc, OMP_FOR, mask, clauses, cclauses);
   26127         2465 :       clauses = cclauses[C_OMP_CLAUSE_SPLIT_FOR];
   26128              :     }
   26129              : 
   26130         3997 :   block = c_begin_compound_stmt (true);
   26131         3997 :   ret = c_parser_omp_for_loop (loc, parser, OMP_FOR, clauses, cclauses, if_p);
   26132         3997 :   block = c_end_compound_stmt (loc, block, true);
   26133         3997 :   add_stmt (block);
   26134              : 
   26135         3997 :   return ret;
   26136              : }
   26137              : 
   26138              : static tree c_parser_omp_taskloop (location_t, c_parser *, char *,
   26139              :                                    omp_clause_mask, tree *, bool *);
   26140              : 
   26141              : /* OpenMP 2.5:
   26142              :    # pragma omp master new-line
   26143              :      structured-block
   26144              : 
   26145              :    LOC is the location of the #pragma token.
   26146              : */
   26147              : 
   26148              : static tree
   26149          228 : c_parser_omp_master (location_t loc, c_parser *parser,
   26150              :                      char *p_name, omp_clause_mask mask, tree *cclauses,
   26151              :                      bool *if_p, location_t master_loc)
   26152              : {
   26153          228 :   tree block, clauses, ret;
   26154          228 :   gcc_rich_location richloc (loc);
   26155          228 :   if (master_loc != UNKNOWN_LOCATION)
   26156           91 :     richloc.add_fixit_replace (master_loc, "masked");
   26157          228 :   warning_at (&richloc, OPT_Wdeprecated_openmp,
   26158              :               "%<master%> construct deprecated since OpenMP 5.1, use "
   26159              :               "%<masked%>");
   26160              : 
   26161          228 :   strcat (p_name, " master");
   26162              : 
   26163          228 :   if (c_parser_next_token_is (parser, CPP_NAME))
   26164              :     {
   26165          123 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   26166              : 
   26167          123 :       if (strcmp (p, "taskloop") == 0)
   26168              :         {
   26169           94 :           tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   26170           94 :           if (cclauses == NULL)
   26171           47 :             cclauses = cclauses_buf;
   26172              : 
   26173           94 :           c_parser_consume_token (parser);
   26174           94 :           if (!flag_openmp)  /* flag_openmp_simd  */
   26175            4 :             return c_parser_omp_taskloop (loc, parser, p_name, mask, cclauses,
   26176            4 :                                           if_p);
   26177           90 :           block = c_begin_compound_stmt (true);
   26178           90 :           ret = c_parser_omp_taskloop (loc, parser, p_name, mask, cclauses,
   26179              :                                        if_p);
   26180           90 :           block = c_end_compound_stmt (loc, block, true);
   26181           90 :           if (ret == NULL_TREE)
   26182              :             return ret;
   26183           90 :           ret = c_finish_omp_master (loc, block);
   26184           90 :           OMP_MASTER_COMBINED (ret) = 1;
   26185           90 :           return ret;
   26186              :         }
   26187              :     }
   26188          134 :   if (!flag_openmp)  /* flag_openmp_simd  */
   26189              :     {
   26190            2 :       c_parser_skip_to_pragma_eol (parser, false);
   26191            2 :       return NULL_TREE;
   26192              :     }
   26193              : 
   26194          132 :   if (cclauses)
   26195              :     {
   26196           43 :       clauses = c_parser_omp_all_clauses (parser, mask, p_name, false);
   26197           43 :       omp_split_clauses (loc, OMP_MASTER, mask, clauses, cclauses);
   26198              :     }
   26199              :   else
   26200           89 :     c_parser_skip_to_pragma_eol (parser);
   26201              : 
   26202          132 :   return c_finish_omp_master (loc, c_parser_omp_structured_block (parser,
   26203          132 :                                                                   if_p));
   26204          228 : }
   26205              : 
   26206              : /* OpenMP 5.1:
   26207              :    # pragma omp masked masked-clauses new-line
   26208              :      structured-block
   26209              : 
   26210              :    LOC is the location of the #pragma token.
   26211              : */
   26212              : 
   26213              : #define OMP_MASKED_CLAUSE_MASK                                  \
   26214              :         (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FILTER)
   26215              : 
   26216              : static tree
   26217          130 : c_parser_omp_masked (location_t loc, c_parser *parser,
   26218              :                      char *p_name, omp_clause_mask mask, tree *cclauses,
   26219              :                      bool *if_p)
   26220              : {
   26221          130 :   tree block, clauses, ret;
   26222              : 
   26223          130 :   strcat (p_name, " masked");
   26224          130 :   mask |= OMP_MASKED_CLAUSE_MASK;
   26225              : 
   26226          130 :   if (c_parser_next_token_is (parser, CPP_NAME))
   26227              :     {
   26228           87 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   26229              : 
   26230           87 :       if (strcmp (p, "taskloop") == 0)
   26231              :         {
   26232           68 :           tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   26233           68 :           if (cclauses == NULL)
   26234           21 :             cclauses = cclauses_buf;
   26235              : 
   26236           68 :           c_parser_consume_token (parser);
   26237           68 :           if (!flag_openmp)  /* flag_openmp_simd  */
   26238            0 :             return c_parser_omp_taskloop (loc, parser, p_name, mask, cclauses,
   26239            0 :                                           if_p);
   26240           68 :           block = c_begin_compound_stmt (true);
   26241           68 :           ret = c_parser_omp_taskloop (loc, parser, p_name, mask, cclauses,
   26242              :                                        if_p);
   26243           68 :           block = c_end_compound_stmt (loc, block, true);
   26244           68 :           if (ret == NULL_TREE)
   26245              :             return ret;
   26246           68 :           ret = c_finish_omp_masked (loc, block,
   26247              :                                      cclauses[C_OMP_CLAUSE_SPLIT_MASKED]);
   26248           68 :           OMP_MASKED_COMBINED (ret) = 1;
   26249           68 :           return ret;
   26250              :         }
   26251              :     }
   26252           62 :   if (!flag_openmp)  /* flag_openmp_simd  */
   26253              :     {
   26254            0 :       c_parser_skip_to_pragma_eol (parser, false);
   26255            0 :       return NULL_TREE;
   26256              :     }
   26257              : 
   26258           62 :   clauses = c_parser_omp_all_clauses (parser, mask, p_name, cclauses == NULL);
   26259           62 :   if (cclauses)
   26260              :     {
   26261            9 :       omp_split_clauses (loc, OMP_MASKED, mask, clauses, cclauses);
   26262            9 :       clauses = cclauses[C_OMP_CLAUSE_SPLIT_MASKED];
   26263              :     }
   26264              : 
   26265           62 :   return c_finish_omp_masked (loc, c_parser_omp_structured_block (parser,
   26266              :                                                                   if_p),
   26267           62 :                               clauses);
   26268              : }
   26269              : 
   26270              : /* OpenMP 5.1:
   26271              :    # pragma omp interop clauses[opt] new-line */
   26272              : 
   26273              : #define OMP_INTEROP_CLAUSE_MASK                                 \
   26274              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
   26275              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DESTROY)        \
   26276              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE) \
   26277              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_INIT)           \
   26278              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT) \
   26279              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_USE))
   26280              : 
   26281              : static void
   26282          183 : c_parser_omp_interop (c_parser *parser)
   26283              : {
   26284          183 :   location_t loc = c_parser_peek_token (parser)->location;
   26285          183 :   c_parser_consume_pragma (parser);
   26286          366 :   tree clauses = c_parser_omp_all_clauses (parser,
   26287          183 :                                            OMP_INTEROP_CLAUSE_MASK,
   26288              :                                            "#pragma omp interop");
   26289          183 :   tree stmt = make_node (OMP_INTEROP);
   26290          183 :   TREE_TYPE (stmt) = void_type_node;
   26291          183 :   OMP_INTEROP_CLAUSES (stmt) = clauses;
   26292          183 :   SET_EXPR_LOCATION (stmt, loc);
   26293          183 :   add_stmt (stmt);
   26294          183 : }
   26295              : 
   26296              : /* OpenMP 2.5:
   26297              :    # pragma omp ordered new-line
   26298              :      structured-block
   26299              : 
   26300              :    OpenMP 4.5:
   26301              :    # pragma omp ordered ordered-clauses new-line
   26302              :      structured-block
   26303              : 
   26304              :    # pragma omp ordered depend-clauses new-line
   26305              : 
   26306              :    OpenMP 5.2
   26307              :    # pragma omp ordered doacross-clauses new-line  */
   26308              : 
   26309              : #define OMP_ORDERED_CLAUSE_MASK                                 \
   26310              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_THREADS)        \
   26311              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SIMD))
   26312              : 
   26313              : #define OMP_ORDERED_DEPEND_CLAUSE_MASK                          \
   26314              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
   26315              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DOACROSS))
   26316              : 
   26317              : static bool
   26318          545 : c_parser_omp_ordered (c_parser *parser, enum pragma_context context,
   26319              :                       bool *if_p)
   26320              : {
   26321          545 :   location_t loc = c_parser_peek_token (parser)->location;
   26322          545 :   c_parser_consume_pragma (parser);
   26323              : 
   26324          545 :   if (context != pragma_stmt && context != pragma_compound)
   26325              :     {
   26326            1 :       c_parser_error (parser, "expected declaration specifiers");
   26327            1 :       c_parser_skip_to_pragma_eol (parser, false);
   26328            1 :       return false;
   26329              :     }
   26330              : 
   26331          544 :   int n = 1;
   26332          544 :   if (c_parser_next_token_is (parser, CPP_COMMA))
   26333            8 :     n = 2;
   26334              : 
   26335          544 :   if (c_parser_peek_nth_token (parser, n)->type == CPP_NAME)
   26336              :     {
   26337          433 :       const char *p
   26338          433 :         = IDENTIFIER_POINTER (c_parser_peek_nth_token (parser, n)->value);
   26339              : 
   26340          433 :       if (!strcmp ("depend", p) || !strcmp ("doacross", p))
   26341              :         {
   26342          349 :           if (!flag_openmp)     /* flag_openmp_simd  */
   26343              :             {
   26344            2 :               c_parser_skip_to_pragma_eol (parser, false);
   26345            2 :               return false;
   26346              :             }
   26347          347 :           if (context == pragma_stmt)
   26348              :             {
   26349           16 :               error_at (loc,
   26350              :                         "%<#pragma omp ordered%> with %qs clause may "
   26351              :                         "only be used in compound statements", p);
   26352           16 :               c_parser_skip_to_pragma_eol (parser, false);
   26353           16 :               return true;
   26354              :             }
   26355              : 
   26356          331 :           tree clauses
   26357          662 :             = c_parser_omp_all_clauses (parser,
   26358          331 :                                         OMP_ORDERED_DEPEND_CLAUSE_MASK,
   26359              :                                         "#pragma omp ordered");
   26360          331 :           c_finish_omp_ordered (loc, clauses, NULL_TREE);
   26361          331 :           return false;
   26362              :         }
   26363              :     }
   26364              : 
   26365          195 :   tree clauses = c_parser_omp_all_clauses (parser, OMP_ORDERED_CLAUSE_MASK,
   26366              :                                            "#pragma omp ordered");
   26367              : 
   26368          195 :   if (!flag_openmp      /* flag_openmp_simd  */
   26369          195 :       && omp_find_clause (clauses, OMP_CLAUSE_SIMD) == NULL_TREE)
   26370              :     return false;
   26371              : 
   26372          193 :   c_finish_omp_ordered (loc, clauses,
   26373              :                         c_parser_omp_structured_block (parser, if_p));
   26374          193 :   return true;
   26375              : }
   26376              : 
   26377              : /* OpenMP 2.5:
   26378              : 
   26379              :    section-scope:
   26380              :      { section-sequence }
   26381              : 
   26382              :    section-sequence:
   26383              :      section-directive[opt] structured-block
   26384              :      section-sequence section-directive structured-block
   26385              : 
   26386              :    OpenMP 5.1 allows structured-block-sequence instead of structured-block.
   26387              : 
   26388              :     SECTIONS_LOC is the location of the #pragma omp sections.  */
   26389              : 
   26390              : static tree
   26391          144 : c_parser_omp_sections_scope (location_t sections_loc, c_parser *parser)
   26392              : {
   26393          144 :   tree stmt, substmt;
   26394          144 :   bool error_suppress = false;
   26395          144 :   location_t loc;
   26396              : 
   26397          144 :   loc = c_parser_peek_token (parser)->location;
   26398          144 :   if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
   26399              :     {
   26400              :       /* Avoid skipping until the end of the block.  */
   26401            2 :       parser->error = false;
   26402            2 :       return NULL_TREE;
   26403              :     }
   26404              : 
   26405          142 :   stmt = push_stmt_list ();
   26406              : 
   26407          142 :   if (c_parser_peek_token (parser)->pragma_kind != PRAGMA_OMP_SECTION
   26408          142 :       && !c_parser_omp_section_scan (parser, "section", true))
   26409              :     {
   26410           83 :       substmt = c_parser_omp_structured_block_sequence (parser,
   26411              :                                                         PRAGMA_OMP_SECTION);
   26412           83 :       substmt = build1 (OMP_SECTION, void_type_node, substmt);
   26413           83 :       SET_EXPR_LOCATION (substmt, loc);
   26414           83 :       add_stmt (substmt);
   26415              :     }
   26416              : 
   26417          580 :   while (1)
   26418              :     {
   26419          361 :       if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
   26420              :         break;
   26421          219 :       if (c_parser_next_token_is (parser, CPP_EOF))
   26422              :         break;
   26423              : 
   26424          219 :       loc = c_parser_peek_token (parser)->location;
   26425          219 :       c_parser_omp_section_scan (parser, "section", false);
   26426          219 :       if (c_parser_peek_token (parser)->pragma_kind == PRAGMA_OMP_SECTION)
   26427              :         {
   26428          218 :           c_parser_consume_pragma (parser);
   26429          218 :           c_parser_skip_to_pragma_eol (parser);
   26430          218 :           error_suppress = false;
   26431              :         }
   26432            1 :       else if (!error_suppress)
   26433              :         {
   26434            1 :           error_at (loc, "expected %<#pragma omp section%> or %<}%>");
   26435            1 :           error_suppress = true;
   26436              :         }
   26437              : 
   26438          219 :       substmt = c_parser_omp_structured_block_sequence (parser,
   26439              :                                                         PRAGMA_OMP_SECTION);
   26440          219 :       substmt = build1 (OMP_SECTION, void_type_node, substmt);
   26441          219 :       SET_EXPR_LOCATION (substmt, loc);
   26442          219 :       add_stmt (substmt);
   26443              :     }
   26444          142 :   c_parser_skip_until_found (parser, CPP_CLOSE_BRACE,
   26445              :                              "expected %<#pragma omp section%> or %<}%>");
   26446              : 
   26447          142 :   substmt = pop_stmt_list (stmt);
   26448              : 
   26449          142 :   stmt = make_node (OMP_SECTIONS);
   26450          142 :   SET_EXPR_LOCATION (stmt, sections_loc);
   26451          142 :   TREE_TYPE (stmt) = void_type_node;
   26452          142 :   OMP_SECTIONS_BODY (stmt) = substmt;
   26453              : 
   26454          142 :   return add_stmt (stmt);
   26455              : }
   26456              : 
   26457              : /* OpenMP 2.5:
   26458              :    # pragma omp sections sections-clause[optseq] newline
   26459              :      sections-scope
   26460              : 
   26461              :    LOC is the location of the #pragma token.
   26462              : */
   26463              : 
   26464              : #define OMP_SECTIONS_CLAUSE_MASK                                \
   26465              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   26466              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)   \
   26467              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LASTPRIVATE)    \
   26468              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION)      \
   26469              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE)       \
   26470              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
   26471              : 
   26472              : static tree
   26473          144 : c_parser_omp_sections (location_t loc, c_parser *parser,
   26474              :                        char *p_name, omp_clause_mask mask, tree *cclauses)
   26475              : {
   26476          144 :   tree block, clauses, ret;
   26477              : 
   26478          144 :   strcat (p_name, " sections");
   26479          144 :   mask |= OMP_SECTIONS_CLAUSE_MASK;
   26480          144 :   if (cclauses)
   26481           36 :     mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT);
   26482              : 
   26483          144 :   clauses = c_parser_omp_all_clauses (parser, mask, p_name, cclauses == NULL);
   26484          144 :   if (cclauses)
   26485              :     {
   26486           36 :       omp_split_clauses (loc, OMP_SECTIONS, mask, clauses, cclauses);
   26487           36 :       clauses = cclauses[C_OMP_CLAUSE_SPLIT_SECTIONS];
   26488              :     }
   26489              : 
   26490          144 :   block = c_begin_compound_stmt (true);
   26491          144 :   ret = c_parser_omp_sections_scope (loc, parser);
   26492          144 :   if (ret)
   26493          142 :     OMP_SECTIONS_CLAUSES (ret) = clauses;
   26494          144 :   block = c_end_compound_stmt (loc, block, true);
   26495          144 :   add_stmt (block);
   26496              : 
   26497          144 :   return ret;
   26498              : }
   26499              : 
   26500              : /* OpenMP 2.5:
   26501              :    # pragma omp parallel parallel-clause[optseq] new-line
   26502              :      structured-block
   26503              :    # pragma omp parallel for parallel-for-clause[optseq] new-line
   26504              :      structured-block
   26505              :    # pragma omp parallel sections parallel-sections-clause[optseq] new-line
   26506              :      structured-block
   26507              : 
   26508              :    OpenMP 4.0:
   26509              :    # pragma omp parallel for simd parallel-for-simd-clause[optseq] new-line
   26510              :      structured-block
   26511              : 
   26512              :    LOC is the location of the #pragma token.
   26513              : */
   26514              : 
   26515              : #define OMP_PARALLEL_CLAUSE_MASK                                \
   26516              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF)             \
   26517              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   26518              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)   \
   26519              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULT)        \
   26520              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SHARED) \
   26521              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COPYIN) \
   26522              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION)      \
   26523              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS)    \
   26524              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE)       \
   26525              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PROC_BIND))
   26526              : 
   26527              : static tree
   26528         6060 : c_parser_omp_parallel (location_t loc, c_parser *parser,
   26529              :                        char *p_name, omp_clause_mask mask, tree *cclauses,
   26530              :                        bool *if_p)
   26531              : {
   26532         6060 :   tree stmt, clauses, block;
   26533              : 
   26534         6060 :   strcat (p_name, " parallel");
   26535         6060 :   mask |= OMP_PARALLEL_CLAUSE_MASK;
   26536              :   /* #pragma omp target parallel{, for, for simd} disallow copyin clause.  */
   26537         6060 :   if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)) != 0
   26538         1422 :       && (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) == 0)
   26539          500 :     mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COPYIN);
   26540              : 
   26541         6060 :   if (c_parser_next_token_is_keyword (parser, RID_FOR))
   26542              :     {
   26543         4686 :       tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   26544         4686 :       if (cclauses == NULL)
   26545         1205 :         cclauses = cclauses_buf;
   26546              : 
   26547         4686 :       c_parser_consume_token (parser);
   26548         4686 :       if (!flag_openmp)  /* flag_openmp_simd  */
   26549           20 :         return c_parser_omp_for (loc, parser, p_name, mask, cclauses, if_p);
   26550         4666 :       block = c_begin_omp_parallel ();
   26551         4666 :       tree ret = c_parser_omp_for (loc, parser, p_name, mask, cclauses, if_p);
   26552         4666 :       stmt
   26553         4666 :         = c_finish_omp_parallel (loc, cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL],
   26554              :                                  block);
   26555         4666 :       if (ret == NULL_TREE)
   26556              :         return ret;
   26557         4605 :       OMP_PARALLEL_COMBINED (stmt) = 1;
   26558         4605 :       return stmt;
   26559              :     }
   26560              :   /* When combined with distribute, parallel has to be followed by for.
   26561              :      #pragma omp target parallel is allowed though.  */
   26562         1374 :   else if (cclauses
   26563         1374 :            && (mask & (OMP_CLAUSE_MASK_1
   26564           43 :                        << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) != 0)
   26565              :     {
   26566            0 :       error_at (loc, "expected %<for%> after %qs", p_name);
   26567            0 :       c_parser_skip_to_pragma_eol (parser);
   26568            0 :       return NULL_TREE;
   26569              :     }
   26570         1374 :   else if (c_parser_next_token_is (parser, CPP_NAME))
   26571              :     {
   26572          756 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   26573          756 :       location_t ploc = c_parser_peek_token (parser)->location;
   26574          756 :       if (cclauses == NULL && strcmp (p, "masked") == 0)
   26575              :         {
   26576           56 :           tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   26577           56 :           cclauses = cclauses_buf;
   26578              : 
   26579           56 :           c_parser_consume_token (parser);
   26580           56 :           if (!flag_openmp)  /* flag_openmp_simd  */
   26581            0 :             return c_parser_omp_masked (loc, parser, p_name, mask, cclauses,
   26582            0 :                                         if_p);
   26583           56 :           block = c_begin_omp_parallel ();
   26584           56 :           tree ret = c_parser_omp_masked (loc, parser, p_name, mask, cclauses,
   26585              :                                           if_p);
   26586           56 :           stmt = c_finish_omp_parallel (loc,
   26587              :                                         cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL],
   26588              :                                         block);
   26589           56 :           if (ret == NULL)
   26590              :             return ret;
   26591              :           /* masked does have just filter clause, but during gimplification
   26592              :              isn't represented by a gimplification omp context, so for
   26593              :              #pragma omp parallel masked don't set OMP_PARALLEL_COMBINED,
   26594              :              so that
   26595              :              #pragma omp parallel masked
   26596              :              #pragma omp taskloop simd lastprivate (x)
   26597              :              isn't confused with
   26598              :              #pragma omp parallel masked taskloop simd lastprivate (x)  */
   26599           56 :           if (OMP_MASKED_COMBINED (ret))
   26600           47 :             OMP_PARALLEL_COMBINED (stmt) = 1;
   26601              :           return stmt;
   26602              :         }
   26603          662 :       else if (cclauses == NULL && strcmp (p, "master") == 0)
   26604              :         {
   26605           91 :           tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   26606           91 :           cclauses = cclauses_buf;
   26607              : 
   26608           91 :           c_parser_consume_token (parser);
   26609           91 :           if (!flag_openmp)  /* flag_openmp_simd  */
   26610            3 :             return c_parser_omp_master (loc, parser, p_name, mask, cclauses,
   26611            3 :                                         if_p, ploc);
   26612           88 :           block = c_begin_omp_parallel ();
   26613           88 :           tree ret = c_parser_omp_master (loc, parser, p_name, mask, cclauses,
   26614              :                                           if_p, ploc);
   26615           88 :           stmt = c_finish_omp_parallel (loc,
   26616              :                                         cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL],
   26617              :                                         block);
   26618           88 :           if (ret == NULL)
   26619              :             return ret;
   26620              :           /* master doesn't have any clauses and during gimplification
   26621              :              isn't represented by a gimplification omp context, so for
   26622              :              #pragma omp parallel master don't set OMP_PARALLEL_COMBINED,
   26623              :              so that
   26624              :              #pragma omp parallel master
   26625              :              #pragma omp taskloop simd lastprivate (x)
   26626              :              isn't confused with
   26627              :              #pragma omp parallel master taskloop simd lastprivate (x)  */
   26628           88 :           if (OMP_MASTER_COMBINED (ret))
   26629           45 :             OMP_PARALLEL_COMBINED (stmt) = 1;
   26630              :           return stmt;
   26631              :         }
   26632          609 :       else if (strcmp (p, "loop") == 0)
   26633              :         {
   26634           43 :           tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   26635           43 :           if (cclauses == NULL)
   26636           24 :             cclauses = cclauses_buf;
   26637              : 
   26638           43 :           c_parser_consume_token (parser);
   26639           43 :           if (!flag_openmp)  /* flag_openmp_simd  */
   26640            2 :             return c_parser_omp_loop (loc, parser, p_name, mask, cclauses,
   26641            2 :                                       if_p);
   26642           41 :           block = c_begin_omp_parallel ();
   26643           41 :           tree ret = c_parser_omp_loop (loc, parser, p_name, mask, cclauses,
   26644              :                                         if_p);
   26645           41 :           stmt
   26646           41 :             = c_finish_omp_parallel (loc,
   26647              :                                      cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL],
   26648              :                                      block);
   26649           41 :           if (ret == NULL_TREE)
   26650              :             return ret;
   26651           41 :           OMP_PARALLEL_COMBINED (stmt) = 1;
   26652           41 :           return stmt;
   26653              :         }
   26654          566 :       else if (!flag_openmp)  /* flag_openmp_simd  */
   26655              :         {
   26656            1 :           c_parser_skip_to_pragma_eol (parser, false);
   26657            1 :           return NULL_TREE;
   26658              :         }
   26659          565 :       else if (cclauses == NULL && strcmp (p, "sections") == 0)
   26660              :         {
   26661           36 :           tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   26662           36 :           cclauses = cclauses_buf;
   26663              : 
   26664           36 :           c_parser_consume_token (parser);
   26665           36 :           block = c_begin_omp_parallel ();
   26666           36 :           c_parser_omp_sections (loc, parser, p_name, mask, cclauses);
   26667           36 :           stmt = c_finish_omp_parallel (loc,
   26668              :                                         cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL],
   26669              :                                         block);
   26670           36 :           OMP_PARALLEL_COMBINED (stmt) = 1;
   26671           36 :           return stmt;
   26672              :         }
   26673              :     }
   26674          618 :   else if (!flag_openmp)  /* flag_openmp_simd  */
   26675              :     {
   26676            1 :       c_parser_skip_to_pragma_eol (parser, false);
   26677            1 :       return NULL_TREE;
   26678              :     }
   26679              : 
   26680         1146 :   clauses = c_parser_omp_all_clauses (parser, mask, p_name, cclauses == NULL);
   26681         1146 :   if (cclauses)
   26682              :     {
   26683           23 :       omp_split_clauses (loc, OMP_PARALLEL, mask, clauses, cclauses);
   26684           23 :       clauses = cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL];
   26685              :     }
   26686              : 
   26687         1146 :   block = c_begin_omp_parallel ();
   26688         1146 :   parser->omp_attrs_forbidden_p = true;
   26689         1146 :   c_parser_statement (parser, if_p);
   26690         1146 :   stmt = c_finish_omp_parallel (loc, clauses, block);
   26691              : 
   26692         1146 :   return stmt;
   26693              : }
   26694              : 
   26695              : /* OpenMP 2.5:
   26696              :    # pragma omp single single-clause[optseq] new-line
   26697              :      structured-block
   26698              : 
   26699              :    LOC is the location of the #pragma.
   26700              : */
   26701              : 
   26702              : #define OMP_SINGLE_CLAUSE_MASK                                  \
   26703              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   26704              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)   \
   26705              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COPYPRIVATE)    \
   26706              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE)       \
   26707              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
   26708              : 
   26709              : static tree
   26710          230 : c_parser_omp_single (location_t loc, c_parser *parser, bool *if_p)
   26711              : {
   26712          230 :   tree stmt = make_node (OMP_SINGLE);
   26713          230 :   SET_EXPR_LOCATION (stmt, loc);
   26714          230 :   TREE_TYPE (stmt) = void_type_node;
   26715              : 
   26716          230 :   OMP_SINGLE_CLAUSES (stmt)
   26717          230 :     = c_parser_omp_all_clauses (parser, OMP_SINGLE_CLAUSE_MASK,
   26718              :                                 "#pragma omp single");
   26719          230 :   OMP_SINGLE_BODY (stmt) = c_parser_omp_structured_block (parser, if_p);
   26720              : 
   26721          230 :   return add_stmt (stmt);
   26722              : }
   26723              : 
   26724              : /* OpenMP 5.1:
   26725              :    # pragma omp scope scope-clause[optseq] new-line
   26726              :      structured-block
   26727              : 
   26728              :    LOC is the location of the #pragma.
   26729              : */
   26730              : 
   26731              : #define OMP_SCOPE_CLAUSE_MASK                                   \
   26732              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   26733              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)   \
   26734              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION)      \
   26735              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE)       \
   26736              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
   26737              : 
   26738              : static tree
   26739           68 : c_parser_omp_scope (location_t loc, c_parser *parser, bool *if_p)
   26740              : {
   26741           68 :   tree stmt = make_node (OMP_SCOPE);
   26742           68 :   SET_EXPR_LOCATION (stmt, loc);
   26743           68 :   TREE_TYPE (stmt) = void_type_node;
   26744              : 
   26745           68 :   OMP_SCOPE_CLAUSES (stmt)
   26746           68 :     = c_parser_omp_all_clauses (parser, OMP_SCOPE_CLAUSE_MASK,
   26747              :                                 "#pragma omp scope");
   26748           68 :   OMP_SCOPE_BODY (stmt) = c_parser_omp_structured_block (parser, if_p);
   26749              : 
   26750           68 :   return add_stmt (stmt);
   26751              : }
   26752              : 
   26753              : /* Parse a function dispatch structured block:
   26754              : 
   26755              :     lvalue-expression = target-call ( [expression-list] );
   26756              :     or
   26757              :     target-call ( [expression-list] );
   26758              : 
   26759              :    Adapted from c_parser_expr_no_commas and c_parser_postfix_expression
   26760              :    (CPP_NAME/C_ID_ID) for the function name.
   26761              : */
   26762              : static tree
   26763          155 : c_parser_omp_dispatch_body (c_parser *parser)
   26764              : {
   26765          155 :   struct c_expr lhs, rhs, ret;
   26766          155 :   location_t expr_loc = c_parser_peek_token (parser)->location;
   26767          155 :   source_range tok_range = c_parser_peek_token (parser)->get_range ();
   26768              : 
   26769          155 :   lhs = c_parser_conditional_expression (parser, NULL, NULL);
   26770          155 :   if (TREE_CODE (lhs.value) == CALL_EXPR)
   26771              :     return lhs.value;
   26772              : 
   26773           56 :   location_t op_location = c_parser_peek_token (parser)->location;
   26774           56 :   if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
   26775            4 :     return error_mark_node;
   26776              : 
   26777              :   /* Parse function name.  */
   26778           52 :   if (!c_parser_next_token_is (parser, CPP_NAME))
   26779              :     {
   26780            1 :       c_parser_error (parser, "expected a function name");
   26781            1 :       return error_mark_node;
   26782              :     }
   26783           51 :   expr_loc = c_parser_peek_token (parser)->location;
   26784           51 :   tree id = c_parser_peek_token (parser)->value;
   26785           51 :   c_parser_consume_token (parser);
   26786           51 :   if (!c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   26787              :     {
   26788            1 :       c_parser_error (parser, "expected a function name");
   26789            1 :       return error_mark_node;
   26790              :     }
   26791              : 
   26792           50 :   rhs.value = build_external_ref (expr_loc, id, true, &rhs.original_type);
   26793           50 :   set_c_expr_source_range (&rhs, tok_range);
   26794              : 
   26795              :   /* Parse argument list.  */
   26796           50 :   rhs = c_parser_postfix_expression_after_primary (
   26797           50 :     parser, EXPR_LOC_OR_LOC (rhs.value, expr_loc), rhs);
   26798           50 :   if (TREE_CODE (rhs.value) != CALL_EXPR)
   26799              :     {
   26800            0 :       error_at (EXPR_LOC_OR_LOC (rhs.value, expr_loc),
   26801              :                 "expected target-function call");
   26802            0 :       return error_mark_node;
   26803              :     }
   26804              : 
   26805              :   /* Build assignment. */
   26806           50 :   rhs = convert_lvalue_to_rvalue (expr_loc, rhs, true, true);
   26807           50 :   ret.value
   26808           50 :     = build_modify_expr (op_location, lhs.value, lhs.original_type, NOP_EXPR,
   26809              :                          expr_loc, rhs.value, rhs.original_type);
   26810           50 :   ret.m_decimal = 0;
   26811           50 :   set_c_expr_source_range (&ret, lhs.get_start (), rhs.get_finish ());
   26812           50 :   ret.original_code = MODIFY_EXPR;
   26813           50 :   ret.original_type = NULL;
   26814           50 :   return ret.value;
   26815              : }
   26816              : 
   26817              : /* OpenMP 5.1:
   26818              :    # pragma omp dispatch dispatch-clause[optseq] new-line
   26819              :      expression-stmt
   26820              : 
   26821              :    LOC is the location of the #pragma.
   26822              : */
   26823              : 
   26824              : #define OMP_DISPATCH_CLAUSE_MASK                                               \
   26825              :   ((OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE)                             \
   26826              :    | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND)                           \
   26827              :    | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOVARIANTS)                       \
   26828              :    | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOCONTEXT)                        \
   26829              :    | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR)                  \
   26830              :    | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_INTEROP)                          \
   26831              :    | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR)                    \
   26832              :    | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
   26833              : 
   26834              : static tree
   26835          155 : c_parser_omp_dispatch (location_t loc, c_parser *parser)
   26836              : {
   26837          155 :   tree stmt = make_node (OMP_DISPATCH);
   26838          155 :   SET_EXPR_LOCATION (stmt, loc);
   26839          155 :   TREE_TYPE (stmt) = void_type_node;
   26840              : 
   26841          155 :   OMP_DISPATCH_CLAUSES (stmt)
   26842          155 :     = c_parser_omp_all_clauses (parser, OMP_DISPATCH_CLAUSE_MASK,
   26843              :                                 "#pragma omp dispatch");
   26844              : 
   26845              :   // Extract depend clauses and create taskwait
   26846          155 :   tree depend_clauses = NULL_TREE;
   26847          155 :   tree *depend_clauses_ptr = &depend_clauses;
   26848          342 :   for (tree c = OMP_DISPATCH_CLAUSES (stmt); c; c = OMP_CLAUSE_CHAIN (c))
   26849              :     {
   26850          187 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND)
   26851              :         {
   26852            5 :           *depend_clauses_ptr = c;
   26853            5 :           depend_clauses_ptr = &OMP_CLAUSE_CHAIN (c);
   26854              :         }
   26855              :     }
   26856          155 :   if (depend_clauses != NULL_TREE)
   26857              :     {
   26858            5 :       tree stmt = make_node (OMP_TASK);
   26859            5 :       TREE_TYPE (stmt) = void_node;
   26860            5 :       OMP_TASK_CLAUSES (stmt) = depend_clauses;
   26861            5 :       OMP_TASK_BODY (stmt) = NULL_TREE;
   26862            5 :       SET_EXPR_LOCATION (stmt, loc);
   26863            5 :       add_stmt (stmt);
   26864              :     }
   26865              : 
   26866              :   // Parse body as expression statement
   26867          155 :   loc = c_parser_peek_token (parser)->location;
   26868          155 :   tree dispatch_body = c_parser_omp_dispatch_body (parser);
   26869          155 :   if (dispatch_body == error_mark_node)
   26870              :     {
   26871            6 :       inform (loc, "%<#pragma omp dispatch%> must be followed by a function "
   26872              :                    "call with optional assignment");
   26873            6 :       c_parser_skip_to_end_of_block_or_statement (parser);
   26874            6 :       return NULL_TREE;
   26875              :     }
   26876              : 
   26877              :   // Walk the tree to find the dispatch function call and wrap it into an IFN
   26878          149 :   gcc_assert (TREE_CODE (dispatch_body) == CALL_EXPR
   26879              :               || TREE_CODE (dispatch_body) == MODIFY_EXPR);
   26880          149 :   tree *dispatch_call = TREE_CODE (dispatch_body) == MODIFY_EXPR
   26881          149 :                           ? &TREE_OPERAND (dispatch_body, 1)
   26882          149 :                           : &dispatch_body;
   26883          154 :   while (TREE_CODE (*dispatch_call) == FLOAT_EXPR
   26884              :          || TREE_CODE (*dispatch_call) == CONVERT_EXPR
   26885          154 :          || TREE_CODE (*dispatch_call) == NOP_EXPR)
   26886            5 :     dispatch_call = &TREE_OPERAND (*dispatch_call, 0);
   26887          149 :   *dispatch_call = build_call_expr_internal_loc (
   26888              :     loc, IFN_GOMP_DISPATCH,
   26889          149 :     TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (*dispatch_call))), 1, *dispatch_call);
   26890              : 
   26891          149 :   c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
   26892          149 :   OMP_DISPATCH_BODY (stmt) = dispatch_body;
   26893              : 
   26894          149 :   return add_stmt (stmt);
   26895              : }
   26896              : 
   26897              : /* OpenMP 3.0:
   26898              :    # pragma omp task task-clause[optseq] new-line
   26899              : 
   26900              :    LOC is the location of the #pragma.
   26901              : */
   26902              : 
   26903              : #define OMP_TASK_CLAUSE_MASK                                    \
   26904              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF)             \
   26905              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNTIED) \
   26906              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULT)        \
   26907              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   26908              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)   \
   26909              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SHARED) \
   26910              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FINAL)  \
   26911              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MERGEABLE)      \
   26912              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
   26913              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIORITY)       \
   26914              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE)       \
   26915              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IN_REDUCTION)   \
   26916              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DETACH) \
   26917              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_AFFINITY))
   26918              : 
   26919              : static tree
   26920          918 : c_parser_omp_task (location_t loc, c_parser *parser, bool *if_p)
   26921              : {
   26922          918 :   tree clauses, block;
   26923              : 
   26924          918 :   clauses = c_parser_omp_all_clauses (parser, OMP_TASK_CLAUSE_MASK,
   26925              :                                       "#pragma omp task");
   26926              : 
   26927          918 :   block = c_begin_omp_task ();
   26928          918 :   parser->omp_attrs_forbidden_p = true;
   26929          918 :   c_parser_statement (parser, if_p);
   26930          918 :   return c_finish_omp_task (loc, clauses, block);
   26931              : }
   26932              : 
   26933              : /* OpenMP 3.0:
   26934              :    # pragma omp taskwait new-line
   26935              : 
   26936              :    OpenMP 5.0:
   26937              :    # pragma omp taskwait taskwait-clause[optseq] new-line
   26938              : */
   26939              : 
   26940              : #define OMP_TASKWAIT_CLAUSE_MASK                                        \
   26941              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND)         \
   26942              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
   26943              : 
   26944              : static void
   26945           95 : c_parser_omp_taskwait (c_parser *parser)
   26946              : {
   26947           95 :   location_t loc = c_parser_peek_token (parser)->location;
   26948           95 :   c_parser_consume_pragma (parser);
   26949              : 
   26950           95 :   tree clauses
   26951           95 :     = c_parser_omp_all_clauses (parser, OMP_TASKWAIT_CLAUSE_MASK,
   26952              :                                 "#pragma omp taskwait");
   26953              : 
   26954           95 :   if (clauses)
   26955              :     {
   26956           21 :       tree stmt = make_node (OMP_TASK);
   26957           21 :       TREE_TYPE (stmt) = void_node;
   26958           21 :       OMP_TASK_CLAUSES (stmt) = clauses;
   26959           21 :       OMP_TASK_BODY (stmt) = NULL_TREE;
   26960           21 :       SET_EXPR_LOCATION (stmt, loc);
   26961           21 :       add_stmt (stmt);
   26962              :     }
   26963              :   else
   26964           74 :     c_finish_omp_taskwait (loc);
   26965           95 : }
   26966              : 
   26967              : /* OpenMP 3.1:
   26968              :    # pragma omp taskyield new-line
   26969              : */
   26970              : 
   26971              : static void
   26972            6 : c_parser_omp_taskyield (c_parser *parser)
   26973              : {
   26974            6 :   location_t loc = c_parser_peek_token (parser)->location;
   26975            6 :   c_parser_consume_pragma (parser);
   26976            6 :   c_parser_skip_to_pragma_eol (parser);
   26977              : 
   26978            6 :   c_finish_omp_taskyield (loc);
   26979            6 : }
   26980              : 
   26981              : /* OpenMP 4.0:
   26982              :    # pragma omp taskgroup new-line
   26983              : 
   26984              :    OpenMP 5.0:
   26985              :    # pragma omp taskgroup taskgroup-clause[optseq] new-line
   26986              : */
   26987              : 
   26988              : #define OMP_TASKGROUP_CLAUSE_MASK                               \
   26989              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE)       \
   26990              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TASK_REDUCTION))
   26991              : 
   26992              : static tree
   26993          138 : c_parser_omp_taskgroup (location_t loc, c_parser *parser, bool *if_p)
   26994              : {
   26995          138 :   tree clauses = c_parser_omp_all_clauses (parser, OMP_TASKGROUP_CLAUSE_MASK,
   26996              :                                            "#pragma omp taskgroup");
   26997              : 
   26998          138 :   tree body = c_parser_omp_structured_block (parser, if_p);
   26999          138 :   return c_finish_omp_taskgroup (loc, body, clauses);
   27000              : }
   27001              : 
   27002              : /* OpenMP 4.0:
   27003              :    # pragma omp cancel cancel-clause[optseq] new-line
   27004              : 
   27005              :    LOC is the location of the #pragma.
   27006              : */
   27007              : 
   27008              : #define OMP_CANCEL_CLAUSE_MASK                                  \
   27009              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PARALLEL)       \
   27010              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FOR)            \
   27011              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SECTIONS)       \
   27012              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TASKGROUP)      \
   27013              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF))
   27014              : 
   27015              : static void
   27016          221 : c_parser_omp_cancel (c_parser *parser)
   27017              : {
   27018          221 :   location_t loc = c_parser_peek_token (parser)->location;
   27019              : 
   27020          221 :   c_parser_consume_pragma (parser);
   27021          221 :   tree clauses = c_parser_omp_all_clauses (parser, OMP_CANCEL_CLAUSE_MASK,
   27022              :                                            "#pragma omp cancel");
   27023              : 
   27024          221 :   c_finish_omp_cancel (loc, clauses);
   27025          221 : }
   27026              : 
   27027              : /* OpenMP 4.0:
   27028              :    # pragma omp cancellation point cancelpt-clause[optseq] new-line
   27029              : 
   27030              :    LOC is the location of the #pragma.
   27031              : */
   27032              : 
   27033              : #define OMP_CANCELLATION_POINT_CLAUSE_MASK                      \
   27034              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PARALLEL)       \
   27035              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FOR)            \
   27036              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SECTIONS)       \
   27037              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TASKGROUP))
   27038              : 
   27039              : static bool
   27040          179 : c_parser_omp_cancellation_point (c_parser *parser, enum pragma_context context)
   27041              : {
   27042          179 :   location_t loc = c_parser_peek_token (parser)->location;
   27043          179 :   tree clauses;
   27044          179 :   bool point_seen = false;
   27045              : 
   27046          179 :   c_parser_consume_pragma (parser);
   27047          179 :   if (c_parser_next_token_is (parser, CPP_NAME))
   27048              :     {
   27049          179 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   27050          179 :       if (strcmp (p, "point") == 0)
   27051              :         {
   27052          177 :           c_parser_consume_token (parser);
   27053          177 :           point_seen = true;
   27054              :         }
   27055              :     }
   27056          177 :   if (!point_seen)
   27057              :     {
   27058            2 :       c_parser_error (parser, "expected %<point%>");
   27059            2 :       c_parser_skip_to_pragma_eol (parser);
   27060            2 :       return false;
   27061              :     }
   27062              : 
   27063          177 :   if (context != pragma_compound)
   27064              :     {
   27065           10 :       if (context == pragma_stmt)
   27066            9 :         error_at (loc,
   27067              :                   "%<#pragma %s%> may only be used in compound statements",
   27068              :                   "omp cancellation point");
   27069              :       else
   27070            1 :         c_parser_error (parser, "expected declaration specifiers");
   27071           10 :       c_parser_skip_to_pragma_eol (parser, false);
   27072           10 :       return true;
   27073              :     }
   27074              : 
   27075          167 :   clauses
   27076          167 :     = c_parser_omp_all_clauses (parser, OMP_CANCELLATION_POINT_CLAUSE_MASK,
   27077              :                                 "#pragma omp cancellation point");
   27078              : 
   27079          167 :   c_finish_omp_cancellation_point (loc, clauses);
   27080          167 :   return true;
   27081              : }
   27082              : 
   27083              : /* OpenMP 4.0:
   27084              :    #pragma omp distribute distribute-clause[optseq] new-line
   27085              :      for-loop  */
   27086              : 
   27087              : #define OMP_DISTRIBUTE_CLAUSE_MASK                              \
   27088              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   27089              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)   \
   27090              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LASTPRIVATE)    \
   27091              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)\
   27092              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE)       \
   27093              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COLLAPSE)       \
   27094              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ORDER))
   27095              : 
   27096              : static tree
   27097         3735 : c_parser_omp_distribute (location_t loc, c_parser *parser,
   27098              :                          char *p_name, omp_clause_mask mask, tree *cclauses,
   27099              :                          bool *if_p)
   27100              : {
   27101         3735 :   tree clauses, block, ret;
   27102              : 
   27103         3735 :   strcat (p_name, " distribute");
   27104         3735 :   mask |= OMP_DISTRIBUTE_CLAUSE_MASK;
   27105              : 
   27106         3735 :   if (c_parser_next_token_is (parser, CPP_NAME))
   27107              :     {
   27108         3635 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   27109         3635 :       bool simd = false;
   27110         3635 :       bool parallel = false;
   27111              : 
   27112         3635 :       if (strcmp (p, "simd") == 0)
   27113              :         simd = true;
   27114              :       else
   27115         3295 :         parallel = strcmp (p, "parallel") == 0;
   27116         3295 :       if (parallel || simd)
   27117              :         {
   27118         3364 :           tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   27119         3364 :           if (cclauses == NULL)
   27120         1147 :             cclauses = cclauses_buf;
   27121         3364 :           c_parser_consume_token (parser);
   27122         3364 :           if (!flag_openmp)  /* flag_openmp_simd  */
   27123              :             {
   27124           15 :               if (simd)
   27125            6 :                 return c_parser_omp_simd (loc, parser, p_name, mask, cclauses,
   27126            6 :                                           if_p);
   27127              :               else
   27128            9 :                 return c_parser_omp_parallel (loc, parser, p_name, mask,
   27129            9 :                                               cclauses, if_p);
   27130              :             }
   27131         3349 :           block = c_begin_compound_stmt (true);
   27132         3349 :           if (simd)
   27133          334 :             ret = c_parser_omp_simd (loc, parser, p_name, mask, cclauses,
   27134              :                                      if_p);
   27135              :           else
   27136         3015 :             ret = c_parser_omp_parallel (loc, parser, p_name, mask, cclauses,
   27137              :                                          if_p);
   27138         3349 :           block = c_end_compound_stmt (loc, block, true);
   27139         3349 :           if (ret == NULL)
   27140              :             return ret;
   27141         3344 :           ret = make_node (OMP_DISTRIBUTE);
   27142         3344 :           TREE_TYPE (ret) = void_type_node;
   27143         3344 :           OMP_FOR_BODY (ret) = block;
   27144         3344 :           OMP_FOR_CLAUSES (ret) = cclauses[C_OMP_CLAUSE_SPLIT_DISTRIBUTE];
   27145         3344 :           SET_EXPR_LOCATION (ret, loc);
   27146         3344 :           add_stmt (ret);
   27147         3344 :           return ret;
   27148              :         }
   27149              :     }
   27150          371 :   if (!flag_openmp)  /* flag_openmp_simd  */
   27151              :     {
   27152            2 :       c_parser_skip_to_pragma_eol (parser, false);
   27153            2 :       return NULL_TREE;
   27154              :     }
   27155              : 
   27156          369 :   clauses = c_parser_omp_all_clauses (parser, mask, p_name, cclauses == NULL);
   27157          369 :   if (cclauses)
   27158              :     {
   27159          194 :       omp_split_clauses (loc, OMP_DISTRIBUTE, mask, clauses, cclauses);
   27160          194 :       clauses = cclauses[C_OMP_CLAUSE_SPLIT_DISTRIBUTE];
   27161              :     }
   27162              : 
   27163          369 :   block = c_begin_compound_stmt (true);
   27164          369 :   ret = c_parser_omp_for_loop (loc, parser, OMP_DISTRIBUTE, clauses, NULL,
   27165              :                                if_p);
   27166          369 :   block = c_end_compound_stmt (loc, block, true);
   27167          369 :   add_stmt (block);
   27168              : 
   27169          369 :   return ret;
   27170              : }
   27171              : 
   27172              : /* OpenMP 4.0:
   27173              :    # pragma omp teams teams-clause[optseq] new-line
   27174              :      structured-block  */
   27175              : 
   27176              : #define OMP_TEAMS_CLAUSE_MASK                                   \
   27177              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   27178              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)   \
   27179              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SHARED) \
   27180              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION)      \
   27181              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS)      \
   27182              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_THREAD_LIMIT)   \
   27183              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE)       \
   27184              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULT))
   27185              : 
   27186              : static tree
   27187         3984 : c_parser_omp_teams (location_t loc, c_parser *parser,
   27188              :                     char *p_name, omp_clause_mask mask, tree *cclauses,
   27189              :                     bool *if_p)
   27190              : {
   27191         3984 :   tree clauses, block, ret;
   27192              : 
   27193         3984 :   strcat (p_name, " teams");
   27194         3984 :   mask |= OMP_TEAMS_CLAUSE_MASK;
   27195              : 
   27196         3984 :   if (c_parser_next_token_is (parser, CPP_NAME))
   27197              :     {
   27198         2646 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   27199         2646 :       if (strcmp (p, "distribute") == 0)
   27200              :         {
   27201         2413 :           tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   27202         2413 :           if (cclauses == NULL)
   27203         1325 :             cclauses = cclauses_buf;
   27204              : 
   27205         2413 :           c_parser_consume_token (parser);
   27206         2413 :           if (!flag_openmp)  /* flag_openmp_simd  */
   27207           12 :             return c_parser_omp_distribute (loc, parser, p_name, mask,
   27208           12 :                                             cclauses, if_p);
   27209         2401 :           block = c_begin_omp_parallel ();
   27210         2401 :           ret = c_parser_omp_distribute (loc, parser, p_name, mask, cclauses,
   27211              :                                          if_p);
   27212         2401 :           block = c_end_compound_stmt (loc, block, true);
   27213         2401 :           if (ret == NULL)
   27214              :             return ret;
   27215         2401 :           clauses = cclauses[C_OMP_CLAUSE_SPLIT_TEAMS];
   27216         2401 :           ret = make_node (OMP_TEAMS);
   27217         2401 :           TREE_TYPE (ret) = void_type_node;
   27218         2401 :           OMP_TEAMS_CLAUSES (ret) = clauses;
   27219         2401 :           OMP_TEAMS_BODY (ret) = block;
   27220         2401 :           OMP_TEAMS_COMBINED (ret) = 1;
   27221         2401 :           SET_EXPR_LOCATION (ret, loc);
   27222         2401 :           return add_stmt (ret);
   27223              :         }
   27224          233 :       else if (strcmp (p, "loop") == 0)
   27225              :         {
   27226           34 :           tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   27227           34 :           if (cclauses == NULL)
   27228           16 :             cclauses = cclauses_buf;
   27229              : 
   27230           34 :           c_parser_consume_token (parser);
   27231           34 :           if (!flag_openmp)  /* flag_openmp_simd  */
   27232            2 :             return c_parser_omp_loop (loc, parser, p_name, mask, cclauses,
   27233            2 :                                       if_p);
   27234           32 :           block = c_begin_omp_parallel ();
   27235           32 :           ret = c_parser_omp_loop (loc, parser, p_name, mask, cclauses, if_p);
   27236           32 :           block = c_end_compound_stmt (loc, block, true);
   27237           32 :           if (ret == NULL)
   27238              :             return ret;
   27239           32 :           clauses = cclauses[C_OMP_CLAUSE_SPLIT_TEAMS];
   27240           32 :           ret = make_node (OMP_TEAMS);
   27241           32 :           TREE_TYPE (ret) = void_type_node;
   27242           32 :           OMP_TEAMS_CLAUSES (ret) = clauses;
   27243           32 :           OMP_TEAMS_BODY (ret) = block;
   27244           32 :           OMP_TEAMS_COMBINED (ret) = 1;
   27245           32 :           SET_EXPR_LOCATION (ret, loc);
   27246           32 :           return add_stmt (ret);
   27247              :         }
   27248              :     }
   27249         1537 :   if (!flag_openmp)  /* flag_openmp_simd  */
   27250              :     {
   27251            2 :       c_parser_skip_to_pragma_eol (parser, false);
   27252            2 :       return NULL_TREE;
   27253              :     }
   27254              : 
   27255         1535 :   clauses = c_parser_omp_all_clauses (parser, mask, p_name, cclauses == NULL);
   27256         1535 :   if (cclauses)
   27257              :     {
   27258          886 :       omp_split_clauses (loc, OMP_TEAMS, mask, clauses, cclauses);
   27259          886 :       clauses = cclauses[C_OMP_CLAUSE_SPLIT_TEAMS];
   27260              :     }
   27261              : 
   27262         1535 :   tree stmt = make_node (OMP_TEAMS);
   27263         1535 :   TREE_TYPE (stmt) = void_type_node;
   27264         1535 :   OMP_TEAMS_CLAUSES (stmt) = clauses;
   27265         1535 :   block = c_begin_omp_parallel ();
   27266         1535 :   add_stmt (c_parser_omp_structured_block (parser, if_p));
   27267         1535 :   OMP_TEAMS_BODY (stmt) = c_end_compound_stmt (loc, block, true);
   27268         1535 :   SET_EXPR_LOCATION (stmt, loc);
   27269              : 
   27270         1535 :   return add_stmt (stmt);
   27271              : }
   27272              : 
   27273              : /* OpenMP 4.0:
   27274              :    # pragma omp target data target-data-clause[optseq] new-line
   27275              :      structured-block  */
   27276              : 
   27277              : #define OMP_TARGET_DATA_CLAUSE_MASK                             \
   27278              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE) \
   27279              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)            \
   27280              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF)             \
   27281              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR) \
   27282              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR))
   27283              : 
   27284              : static tree
   27285          160 : c_parser_omp_target_data (location_t loc, c_parser *parser, bool *if_p)
   27286              : {
   27287          160 :   if (flag_openmp)
   27288          160 :     omp_requires_mask
   27289          160 :       = (enum omp_requires) (omp_requires_mask | OMP_REQUIRES_TARGET_USED);
   27290              : 
   27291          160 :   tree clauses
   27292          160 :     = c_parser_omp_all_clauses (parser, OMP_TARGET_DATA_CLAUSE_MASK,
   27293              :                                 "#pragma omp target data", false);
   27294          160 :   clauses = c_omp_instantiate_mappers (clauses, C_ORT_OMP);
   27295          160 :   clauses = c_finish_omp_clauses (clauses, C_ORT_OMP);
   27296          160 :   c_omp_adjust_map_clauses (clauses, false);
   27297          160 :   int map_seen = 0;
   27298          632 :   for (tree *pc = &clauses; *pc;)
   27299              :     {
   27300          312 :       if (OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_MAP)
   27301          230 :         switch (OMP_CLAUSE_MAP_KIND (*pc))
   27302              :           {
   27303              :           case GOMP_MAP_TO:
   27304              :           case GOMP_MAP_ALWAYS_TO:
   27305              :           case GOMP_MAP_PRESENT_TO:
   27306              :           case GOMP_MAP_ALWAYS_PRESENT_TO:
   27307              :           case GOMP_MAP_FROM:
   27308              :           case GOMP_MAP_ALWAYS_FROM:
   27309              :           case GOMP_MAP_PRESENT_FROM:
   27310              :           case GOMP_MAP_ALWAYS_PRESENT_FROM:
   27311              :           case GOMP_MAP_TOFROM:
   27312              :           case GOMP_MAP_ALWAYS_TOFROM:
   27313              :           case GOMP_MAP_PRESENT_TOFROM:
   27314              :           case GOMP_MAP_ALWAYS_PRESENT_TOFROM:
   27315              :           case GOMP_MAP_ALLOC:
   27316              :           case GOMP_MAP_PRESENT_ALLOC:
   27317          312 :             map_seen = 3;
   27318              :             break;
   27319              :           case GOMP_MAP_FIRSTPRIVATE_POINTER:
   27320              :           case GOMP_MAP_ALWAYS_POINTER:
   27321              :           case GOMP_MAP_ATTACH_DETACH:
   27322              :           case GOMP_MAP_ATTACH:
   27323              :             break;
   27324            0 :           default:
   27325            0 :             map_seen |= 1;
   27326            0 :             error_at (OMP_CLAUSE_LOCATION (*pc),
   27327              :                       "%<#pragma omp target data%> with map-type other "
   27328              :                       "than %<to%>, %<from%>, %<tofrom%> or %<alloc%> "
   27329              :                       "on %<map%> clause");
   27330            0 :             *pc = OMP_CLAUSE_CHAIN (*pc);
   27331            0 :             continue;
   27332              :           }
   27333           82 :       else if (OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_USE_DEVICE_PTR
   27334           82 :                || OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_USE_DEVICE_ADDR)
   27335              :         map_seen = 3;
   27336          312 :       pc = &OMP_CLAUSE_CHAIN (*pc);
   27337              :     }
   27338              : 
   27339          160 :   if (map_seen != 3)
   27340              :     {
   27341            3 :       if (map_seen == 0)
   27342            3 :         error_at (loc,
   27343              :                   "%<#pragma omp target data%> must contain at least "
   27344              :                   "one %<map%>, %<use_device_ptr%> or %<use_device_addr%> "
   27345              :                   "clause");
   27346              :       return NULL_TREE;
   27347              :     }
   27348              : 
   27349          157 :   tree stmt = make_node (OMP_TARGET_DATA);
   27350          157 :   TREE_TYPE (stmt) = void_type_node;
   27351          157 :   OMP_TARGET_DATA_CLAUSES (stmt) = clauses;
   27352          157 :   keep_next_level ();
   27353          157 :   tree block = c_begin_compound_stmt (true);
   27354          157 :   add_stmt (c_parser_omp_structured_block (parser, if_p));
   27355          157 :   OMP_TARGET_DATA_BODY (stmt) = c_end_compound_stmt (loc, block, true);
   27356              : 
   27357          157 :   SET_EXPR_LOCATION (stmt, loc);
   27358          157 :   return add_stmt (stmt);
   27359              : }
   27360              : 
   27361              : /* OpenMP 4.0:
   27362              :    # pragma omp target update target-update-clause[optseq] new-line */
   27363              : 
   27364              : #define OMP_TARGET_UPDATE_CLAUSE_MASK                           \
   27365              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FROM)           \
   27366              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TO)             \
   27367              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE) \
   27368              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF)             \
   27369              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
   27370              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
   27371              : 
   27372              : static bool
   27373         3013 : c_parser_omp_target_update (location_t loc, c_parser *parser,
   27374              :                             enum pragma_context context)
   27375              : {
   27376         3013 :   if (context == pragma_stmt)
   27377              :     {
   27378            8 :       error_at (loc, "%<#pragma %s%> may only be used in compound statements",
   27379              :                 "omp target update");
   27380            8 :       c_parser_skip_to_pragma_eol (parser, false);
   27381            8 :       return true;
   27382              :     }
   27383              : 
   27384         3005 :   tree clauses
   27385         3005 :     = c_parser_omp_all_clauses (parser, OMP_TARGET_UPDATE_CLAUSE_MASK,
   27386              :                                 "#pragma omp target update",
   27387              :                                 /* finish_p = */ false);
   27388         3005 :   clauses = c_omp_instantiate_mappers (clauses, C_ORT_OMP_UPDATE);
   27389         3005 :   clauses = c_finish_omp_clauses (clauses, C_ORT_OMP_UPDATE);
   27390              : 
   27391         3005 :   if (omp_find_clause (clauses, OMP_CLAUSE_TO) == NULL_TREE
   27392         3005 :       && omp_find_clause (clauses, OMP_CLAUSE_FROM) == NULL_TREE)
   27393              :     {
   27394            5 :       error_at (loc,
   27395              :                 "%<#pragma omp target update%> must contain at least one "
   27396              :                 "%<from%> or %<to%> clauses");
   27397            5 :       return false;
   27398              :     }
   27399              : 
   27400         3000 :   if (flag_openmp)
   27401         3000 :     omp_requires_mask
   27402         3000 :       = (enum omp_requires) (omp_requires_mask | OMP_REQUIRES_TARGET_USED);
   27403              : 
   27404         3000 :   tree stmt = make_node (OMP_TARGET_UPDATE);
   27405         3000 :   TREE_TYPE (stmt) = void_type_node;
   27406         3000 :   OMP_TARGET_UPDATE_CLAUSES (stmt) = clauses;
   27407         3000 :   SET_EXPR_LOCATION (stmt, loc);
   27408         3000 :   add_stmt (stmt);
   27409         3000 :   return false;
   27410              : }
   27411              : 
   27412              : /* OpenMP 4.5:
   27413              :    # pragma omp target enter data target-data-clause[optseq] new-line  */
   27414              : 
   27415              : #define OMP_TARGET_ENTER_DATA_CLAUSE_MASK                       \
   27416              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE) \
   27417              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)            \
   27418              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF)             \
   27419              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
   27420              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
   27421              : 
   27422              : static bool
   27423          152 : c_parser_omp_target_enter_data (location_t loc, c_parser *parser,
   27424              :                                 enum pragma_context context)
   27425              : {
   27426          152 :   bool data_seen = false;
   27427          152 :   if (c_parser_next_token_is (parser, CPP_NAME))
   27428              :     {
   27429          152 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   27430          152 :       if (strcmp (p, "data") == 0)
   27431              :         {
   27432          152 :           c_parser_consume_token (parser);
   27433          152 :           data_seen = true;
   27434              :         }
   27435              :     }
   27436          152 :   if (!data_seen)
   27437              :     {
   27438            0 :       c_parser_error (parser, "expected %<data%>");
   27439            0 :       c_parser_skip_to_pragma_eol (parser);
   27440            0 :       return false;
   27441              :     }
   27442              : 
   27443          152 :   if (context == pragma_stmt)
   27444              :     {
   27445            8 :       error_at (loc, "%<#pragma %s%> may only be used in compound statements",
   27446              :                 "omp target enter data");
   27447            8 :       c_parser_skip_to_pragma_eol (parser, false);
   27448            8 :       return true;
   27449              :     }
   27450              : 
   27451          144 :   if (flag_openmp)
   27452          144 :     omp_requires_mask
   27453          144 :       = (enum omp_requires) (omp_requires_mask | OMP_REQUIRES_TARGET_USED);
   27454              : 
   27455          144 :   tree clauses
   27456          144 :     = c_parser_omp_all_clauses (parser, OMP_TARGET_ENTER_DATA_CLAUSE_MASK,
   27457              :                                 "#pragma omp target enter data", false);
   27458          144 :   clauses = c_omp_instantiate_mappers (clauses, C_ORT_OMP);
   27459          144 :   clauses = c_finish_omp_clauses (clauses, C_ORT_OMP);
   27460          144 :   c_omp_adjust_map_clauses (clauses, false);
   27461          144 :   int map_seen = 0;
   27462          640 :   for (tree *pc = &clauses; *pc;)
   27463              :     {
   27464          352 :       if (OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_MAP)
   27465          301 :         switch (OMP_CLAUSE_MAP_KIND (*pc))
   27466              :           {
   27467              :           case GOMP_MAP_TO:
   27468              :           case GOMP_MAP_ALWAYS_TO:
   27469              :           case GOMP_MAP_PRESENT_TO:
   27470              :           case GOMP_MAP_ALWAYS_PRESENT_TO:
   27471              :           case GOMP_MAP_ALLOC:
   27472              :           case GOMP_MAP_PRESENT_ALLOC:
   27473          350 :             map_seen = 3;
   27474              :             break;
   27475           36 :           case GOMP_MAP_TOFROM:
   27476           36 :             OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_TO);
   27477           36 :             map_seen = 3;
   27478           36 :             break;
   27479            3 :           case GOMP_MAP_ALWAYS_TOFROM:
   27480            3 :             OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_ALWAYS_TO);
   27481            3 :             map_seen = 3;
   27482            3 :             break;
   27483            2 :           case GOMP_MAP_PRESENT_TOFROM:
   27484            2 :             OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_PRESENT_TO);
   27485            2 :             map_seen = 3;
   27486            2 :             break;
   27487            2 :           case GOMP_MAP_ALWAYS_PRESENT_TOFROM:
   27488            2 :             OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_ALWAYS_PRESENT_TO);
   27489            2 :             map_seen = 3;
   27490            2 :             break;
   27491              :           case GOMP_MAP_FIRSTPRIVATE_POINTER:
   27492              :           case GOMP_MAP_ALWAYS_POINTER:
   27493              :           case GOMP_MAP_ATTACH_DETACH:
   27494              :           case GOMP_MAP_ATTACH:
   27495              :             break;
   27496            2 :           default:
   27497            2 :             map_seen |= 1;
   27498            2 :             error_at (OMP_CLAUSE_LOCATION (*pc),
   27499              :                       "%<#pragma omp target enter data%> with map-type other "
   27500              :                       "than %<to%>, %<tofrom%> or %<alloc%> on %<map%> clause");
   27501            2 :             *pc = OMP_CLAUSE_CHAIN (*pc);
   27502            2 :             continue;
   27503              :           }
   27504          350 :       pc = &OMP_CLAUSE_CHAIN (*pc);
   27505              :     }
   27506              : 
   27507          144 :   if (map_seen != 3)
   27508              :     {
   27509            4 :       if (map_seen == 0)
   27510            2 :         error_at (loc,
   27511              :                   "%<#pragma omp target enter data%> must contain at least "
   27512              :                   "one %<map%> clause");
   27513              :       return true;
   27514              :     }
   27515              : 
   27516          140 :   tree stmt = make_node (OMP_TARGET_ENTER_DATA);
   27517          140 :   TREE_TYPE (stmt) = void_type_node;
   27518          140 :   OMP_TARGET_ENTER_DATA_CLAUSES (stmt) = clauses;
   27519          140 :   SET_EXPR_LOCATION (stmt, loc);
   27520          140 :   add_stmt (stmt);
   27521          140 :   return true;
   27522              : }
   27523              : 
   27524              : /* OpenMP 4.5:
   27525              :    # pragma omp target exit data target-data-clause[optseq] new-line  */
   27526              : 
   27527              : #define OMP_TARGET_EXIT_DATA_CLAUSE_MASK                        \
   27528              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE) \
   27529              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)            \
   27530              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF)             \
   27531              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
   27532              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
   27533              : 
   27534              : static bool
   27535          130 : c_parser_omp_target_exit_data (location_t loc, c_parser *parser,
   27536              :                                enum pragma_context context)
   27537              : {
   27538          130 :   bool data_seen = false;
   27539          130 :   if (c_parser_next_token_is (parser, CPP_NAME))
   27540              :     {
   27541          130 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   27542          130 :       if (strcmp (p, "data") == 0)
   27543              :         {
   27544          130 :           c_parser_consume_token (parser);
   27545          130 :           data_seen = true;
   27546              :         }
   27547              :     }
   27548          130 :   if (!data_seen)
   27549              :     {
   27550            0 :       c_parser_error (parser, "expected %<data%>");
   27551            0 :       c_parser_skip_to_pragma_eol (parser);
   27552            0 :       return false;
   27553              :     }
   27554              : 
   27555          130 :   if (context == pragma_stmt)
   27556              :     {
   27557            8 :       error_at (loc, "%<#pragma %s%> may only be used in compound statements",
   27558              :                 "omp target exit data");
   27559            8 :       c_parser_skip_to_pragma_eol (parser, false);
   27560            8 :       return true;
   27561              :     }
   27562              : 
   27563          122 :   if (flag_openmp)
   27564          122 :     omp_requires_mask
   27565          122 :       = (enum omp_requires) (omp_requires_mask | OMP_REQUIRES_TARGET_USED);
   27566              : 
   27567          122 :   tree clauses
   27568          122 :     = c_parser_omp_all_clauses (parser, OMP_TARGET_EXIT_DATA_CLAUSE_MASK,
   27569              :                                 "#pragma omp target exit data", false);
   27570          122 :   clauses = c_omp_instantiate_mappers (clauses, C_ORT_OMP_EXIT_DATA);
   27571          122 :   clauses = c_finish_omp_clauses (clauses, C_ORT_OMP_EXIT_DATA);
   27572          122 :   c_omp_adjust_map_clauses (clauses, false);
   27573          122 :   int map_seen = 0;
   27574          546 :   for (tree *pc = &clauses; *pc;)
   27575              :     {
   27576          302 :       if (OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_MAP)
   27577          251 :         switch (OMP_CLAUSE_MAP_KIND (*pc))
   27578              :           {
   27579              :           case GOMP_MAP_FROM:
   27580              :           case GOMP_MAP_ALWAYS_FROM:
   27581              :           case GOMP_MAP_PRESENT_FROM:
   27582              :           case GOMP_MAP_ALWAYS_PRESENT_FROM:
   27583              :           case GOMP_MAP_RELEASE:
   27584              :           case GOMP_MAP_DELETE:
   27585          300 :             map_seen = 3;
   27586              :             break;
   27587           30 :           case GOMP_MAP_TOFROM:
   27588           30 :             OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_FROM);
   27589           30 :             map_seen = 3;
   27590           30 :             break;
   27591            1 :           case GOMP_MAP_ALWAYS_TOFROM:
   27592            1 :             OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_ALWAYS_FROM);
   27593            1 :             map_seen = 3;
   27594            1 :             break;
   27595            0 :           case GOMP_MAP_PRESENT_TOFROM:
   27596            0 :             OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_PRESENT_FROM);
   27597            0 :             map_seen = 3;
   27598            0 :             break;
   27599            0 :           case GOMP_MAP_ALWAYS_PRESENT_TOFROM:
   27600            0 :             OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_ALWAYS_PRESENT_FROM);
   27601            0 :             map_seen = 3;
   27602            0 :             break;
   27603              :           case GOMP_MAP_FIRSTPRIVATE_POINTER:
   27604              :           case GOMP_MAP_ALWAYS_POINTER:
   27605              :           case GOMP_MAP_ATTACH_DETACH:
   27606              :           case GOMP_MAP_DETACH:
   27607              :             break;
   27608            2 :           default:
   27609            2 :             map_seen |= 1;
   27610            2 :             error_at (OMP_CLAUSE_LOCATION (*pc),
   27611              :                       "%<#pragma omp target exit data%> with map-type other "
   27612              :                       "than %<from%>, %<tofrom%>, %<release%> or %<delete%> "
   27613              :                       "on %<map%> clause");
   27614            2 :             *pc = OMP_CLAUSE_CHAIN (*pc);
   27615            2 :             continue;
   27616              :           }
   27617          300 :       pc = &OMP_CLAUSE_CHAIN (*pc);
   27618              :     }
   27619              : 
   27620          122 :   if (map_seen != 3)
   27621              :     {
   27622            2 :       if (map_seen == 0)
   27623            0 :         error_at (loc,
   27624              :                   "%<#pragma omp target exit data%> must contain at least one "
   27625              :                   "%<map%> clause");
   27626              :       return true;
   27627              :     }
   27628              : 
   27629          120 :   tree stmt = make_node (OMP_TARGET_EXIT_DATA);
   27630          120 :   TREE_TYPE (stmt) = void_type_node;
   27631          120 :   OMP_TARGET_EXIT_DATA_CLAUSES (stmt) = clauses;
   27632          120 :   SET_EXPR_LOCATION (stmt, loc);
   27633          120 :   add_stmt (stmt);
   27634          120 :   return true;
   27635              : }
   27636              : 
   27637              : /* OpenMP 4.0:
   27638              :    # pragma omp target target-clause[optseq] new-line
   27639              :      structured-block  */
   27640              : 
   27641              : #define OMP_TARGET_CLAUSE_MASK                                  \
   27642              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE)       \
   27643              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULTMAP)     \
   27644              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
   27645              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE) \
   27646              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE_TYPE)    \
   27647              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE) \
   27648              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)   \
   27649              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR) \
   27650              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF)             \
   27651              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IN_REDUCTION)   \
   27652              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR)\
   27653              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)            \
   27654              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT) \
   27655              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   27656              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_THREAD_LIMIT)   \
   27657              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_USES_ALLOCATORS))
   27658              : 
   27659              : static bool
   27660         8376 : c_parser_omp_target (c_parser *parser, enum pragma_context context, bool *if_p)
   27661              : {
   27662         8376 :   location_t loc = c_parser_peek_token (parser)->location;
   27663         8376 :   c_parser_consume_pragma (parser);
   27664         8376 :   tree *pc = NULL, stmt, block, body, clauses;
   27665              : 
   27666         8376 :   if (context != pragma_stmt && context != pragma_compound)
   27667              :     {
   27668            2 :       c_parser_error (parser, "expected declaration specifiers");
   27669            2 :       c_parser_skip_to_pragma_eol (parser);
   27670            2 :       return false;
   27671              :     }
   27672              : 
   27673         8374 :   if (flag_openmp)
   27674         8360 :     omp_requires_mask
   27675         8360 :       = (enum omp_requires) (omp_requires_mask | OMP_REQUIRES_TARGET_USED);
   27676              : 
   27677         8374 :   if (c_parser_next_token_is (parser, CPP_NAME))
   27678              :     {
   27679         7353 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   27680         7353 :       enum tree_code ccode = ERROR_MARK;
   27681              : 
   27682         7353 :       if (strcmp (p, "teams") == 0)
   27683              :         ccode = OMP_TEAMS;
   27684         5360 :       else if (strcmp (p, "parallel") == 0)
   27685              :         ccode = OMP_PARALLEL;
   27686         4860 :       else if (strcmp (p, "simd") == 0)
   27687              :         ccode = OMP_SIMD;
   27688         4772 :       if (ccode != ERROR_MARK)
   27689              :         {
   27690         2581 :           tree cclauses[C_OMP_CLAUSE_SPLIT_COUNT];
   27691         2581 :           char p_name[sizeof ("#pragma omp target teams distribute "
   27692              :                               "parallel for simd")];
   27693              : 
   27694         2581 :           c_parser_consume_token (parser);
   27695         2581 :           strcpy (p_name, "#pragma omp target");
   27696         2581 :           if (!flag_openmp)  /* flag_openmp_simd  */
   27697              :             {
   27698           13 :               tree stmt;
   27699           13 :               switch (ccode)
   27700              :                 {
   27701            8 :                 case OMP_TEAMS:
   27702            8 :                   stmt = c_parser_omp_teams (loc, parser, p_name,
   27703            8 :                                              OMP_TARGET_CLAUSE_MASK,
   27704              :                                              cclauses, if_p);
   27705            8 :                   break;
   27706            4 :                 case OMP_PARALLEL:
   27707            4 :                   stmt = c_parser_omp_parallel (loc, parser, p_name,
   27708            4 :                                                 OMP_TARGET_CLAUSE_MASK,
   27709              :                                                 cclauses, if_p);
   27710            4 :                   break;
   27711            1 :                 case OMP_SIMD:
   27712            1 :                   stmt = c_parser_omp_simd (loc, parser, p_name,
   27713            1 :                                             OMP_TARGET_CLAUSE_MASK,
   27714              :                                             cclauses, if_p);
   27715            1 :                   break;
   27716              :                 default:
   27717              :                   gcc_unreachable ();
   27718              :                 }
   27719           21 :               return stmt != NULL_TREE;
   27720              :             }
   27721         2568 :           keep_next_level ();
   27722         2568 :           tree block = c_begin_compound_stmt (true), ret;
   27723         2568 :           switch (ccode)
   27724              :             {
   27725         1985 :             case OMP_TEAMS:
   27726         1985 :               ret = c_parser_omp_teams (loc, parser, p_name,
   27727         1985 :                                         OMP_TARGET_CLAUSE_MASK, cclauses,
   27728              :                                         if_p);
   27729         1985 :               break;
   27730          496 :             case OMP_PARALLEL:
   27731          496 :               ret = c_parser_omp_parallel (loc, parser, p_name,
   27732          496 :                                            OMP_TARGET_CLAUSE_MASK, cclauses,
   27733              :                                            if_p);
   27734          496 :               break;
   27735           87 :             case OMP_SIMD:
   27736           87 :               ret = c_parser_omp_simd (loc, parser, p_name,
   27737           87 :                                        OMP_TARGET_CLAUSE_MASK, cclauses,
   27738              :                                        if_p);
   27739           87 :               break;
   27740              :             default:
   27741              :               gcc_unreachable ();
   27742              :             }
   27743         2568 :           block = c_end_compound_stmt (loc, block, true);
   27744         2568 :           if (ret == NULL_TREE)
   27745              :             return false;
   27746         2560 :           if (ccode == OMP_TEAMS)
   27747              :             /* For combined target teams, ensure the num_teams and
   27748              :                thread_limit clause expressions are evaluated on the host,
   27749              :                before entering the target construct.  */
   27750         2639 :             for (tree c = cclauses[C_OMP_CLAUSE_SPLIT_TEAMS];
   27751         2639 :                  c; c = OMP_CLAUSE_CHAIN (c))
   27752          654 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_TEAMS
   27753          654 :                   || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_THREAD_LIMIT)
   27754          235 :                 for (int i = 0;
   27755          382 :                      i <= (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_TEAMS); ++i)
   27756          235 :                   if (OMP_CLAUSE_OPERAND (c, i)
   27757          235 :                       && TREE_CODE (OMP_CLAUSE_OPERAND (c, i)) != INTEGER_CST)
   27758              :                     {
   27759          133 :                       tree expr = OMP_CLAUSE_OPERAND (c, i);
   27760          133 :                       tree tmp = create_tmp_var_raw (TREE_TYPE (expr));
   27761          133 :                       expr = build4 (TARGET_EXPR, TREE_TYPE (expr), tmp,
   27762              :                                      expr, NULL_TREE, NULL_TREE);
   27763          133 :                       add_stmt (expr);
   27764          133 :                       OMP_CLAUSE_OPERAND (c, i) = expr;
   27765          133 :                       tree tc = build_omp_clause (OMP_CLAUSE_LOCATION (c),
   27766              :                                                   OMP_CLAUSE_FIRSTPRIVATE);
   27767          133 :                       OMP_CLAUSE_DECL (tc) = tmp;
   27768          133 :                       OMP_CLAUSE_CHAIN (tc)
   27769          133 :                         = cclauses[C_OMP_CLAUSE_SPLIT_TARGET];
   27770          133 :                       cclauses[C_OMP_CLAUSE_SPLIT_TARGET] = tc;
   27771              :                     }
   27772         2560 :           tree stmt = make_node (OMP_TARGET);
   27773         2560 :           TREE_TYPE (stmt) = void_type_node;
   27774         2560 :           OMP_TARGET_CLAUSES (stmt) = cclauses[C_OMP_CLAUSE_SPLIT_TARGET];
   27775         2560 :           c_omp_adjust_map_clauses (OMP_TARGET_CLAUSES (stmt), true);
   27776         2560 :           OMP_TARGET_BODY (stmt) = block;
   27777         2560 :           OMP_TARGET_COMBINED (stmt) = 1;
   27778         2560 :           SET_EXPR_LOCATION (stmt, loc);
   27779         2560 :           add_stmt (stmt);
   27780         2560 :           pc = &OMP_TARGET_CLAUSES (stmt);
   27781         2560 :           goto check_clauses;
   27782              :         }
   27783         4772 :       else if (!flag_openmp)  /* flag_openmp_simd  */
   27784              :         {
   27785            0 :           c_parser_skip_to_pragma_eol (parser, false);
   27786            0 :           return false;
   27787              :         }
   27788         4772 :       else if (strcmp (p, "data") == 0)
   27789              :         {
   27790          160 :           c_parser_consume_token (parser);
   27791          160 :           c_parser_omp_target_data (loc, parser, if_p);
   27792          160 :           return true;
   27793              :         }
   27794         4612 :       else if (strcmp (p, "enter") == 0)
   27795              :         {
   27796          152 :           c_parser_consume_token (parser);
   27797          152 :           return c_parser_omp_target_enter_data (loc, parser, context);
   27798              :         }
   27799         4460 :       else if (strcmp (p, "exit") == 0)
   27800              :         {
   27801          130 :           c_parser_consume_token (parser);
   27802          130 :           return c_parser_omp_target_exit_data (loc, parser, context);
   27803              :         }
   27804         4330 :       else if (strcmp (p, "update") == 0)
   27805              :         {
   27806         3013 :           c_parser_consume_token (parser);
   27807         3013 :           return c_parser_omp_target_update (loc, parser, context);
   27808              :         }
   27809              :     }
   27810         2338 :   if (!flag_openmp) /* flag_openmp_simd  */
   27811              :     {
   27812            1 :       c_parser_skip_to_pragma_eol (parser, false);
   27813            1 :       return false;
   27814              :     }
   27815              : 
   27816         2337 :   stmt = make_node (OMP_TARGET);
   27817         2337 :   TREE_TYPE (stmt) = void_type_node;
   27818              : 
   27819         2337 :   clauses = c_parser_omp_all_clauses (parser, OMP_TARGET_CLAUSE_MASK,
   27820              :                                       "#pragma omp target", false);
   27821         4796 :   for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
   27822         2459 :     if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IN_REDUCTION)
   27823              :       {
   27824           50 :         tree nc = build_omp_clause (OMP_CLAUSE_LOCATION (c), OMP_CLAUSE_MAP);
   27825           50 :         OMP_CLAUSE_DECL (nc) = OMP_CLAUSE_DECL (c);
   27826           50 :         OMP_CLAUSE_SET_MAP_KIND (nc, GOMP_MAP_ALWAYS_TOFROM);
   27827           50 :         OMP_CLAUSE_CHAIN (nc) = OMP_CLAUSE_CHAIN (c);
   27828           50 :         OMP_CLAUSE_CHAIN (c) = nc;
   27829              :       }
   27830         2337 :   clauses = c_omp_instantiate_mappers (clauses, C_ORT_OMP_TARGET);
   27831         2337 :   clauses  = c_finish_omp_clauses (clauses, C_ORT_OMP_TARGET);
   27832         2337 :   c_omp_adjust_map_clauses (clauses, true);
   27833              : 
   27834         2337 :   keep_next_level ();
   27835         2337 :   block = c_begin_compound_stmt (true);
   27836         2337 :   body = c_parser_omp_structured_block (parser, if_p);
   27837              : 
   27838         2337 :   c_omp_scan_mapper_bindings (loc, &clauses, body);
   27839              : 
   27840         2337 :   add_stmt (body);
   27841         2337 :   OMP_TARGET_CLAUSES (stmt) = clauses;
   27842         2337 :   pc = &OMP_TARGET_CLAUSES (stmt);
   27843         2337 :   OMP_TARGET_BODY (stmt) = c_end_compound_stmt (loc, block, true);
   27844              : 
   27845         2337 :   SET_EXPR_LOCATION (stmt, loc);
   27846         2337 :   add_stmt (stmt);
   27847              : 
   27848         4897 : check_clauses:
   27849         9500 :   while (*pc)
   27850              :     {
   27851         4603 :       if (OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_MAP)
   27852         2726 :         switch (OMP_CLAUSE_MAP_KIND (*pc))
   27853              :           {
   27854              :           case GOMP_MAP_TO:
   27855              :           case GOMP_MAP_ALWAYS_TO:
   27856              :           case GOMP_MAP_PRESENT_TO:
   27857              :           case GOMP_MAP_ALWAYS_PRESENT_TO:
   27858              :           case GOMP_MAP_FROM:
   27859              :           case GOMP_MAP_ALWAYS_FROM:
   27860              :           case GOMP_MAP_PRESENT_FROM:
   27861              :           case GOMP_MAP_ALWAYS_PRESENT_FROM:
   27862              :           case GOMP_MAP_TOFROM:
   27863              :           case GOMP_MAP_ALWAYS_TOFROM:
   27864              :           case GOMP_MAP_PRESENT_TOFROM:
   27865              :           case GOMP_MAP_ALWAYS_PRESENT_TOFROM:
   27866              :           case GOMP_MAP_ALLOC:
   27867              :           case GOMP_MAP_PRESENT_ALLOC:
   27868              :           case GOMP_MAP_FIRSTPRIVATE_POINTER:
   27869              :           case GOMP_MAP_ALWAYS_POINTER:
   27870              :           case GOMP_MAP_POINTER:
   27871              :           case GOMP_MAP_ATTACH_DETACH:
   27872              :           case GOMP_MAP_ATTACH:
   27873              :             break;
   27874            1 :           default:
   27875            1 :             error_at (OMP_CLAUSE_LOCATION (*pc),
   27876              :                       "%<#pragma omp target%> with map-type other "
   27877              :                       "than %<to%>, %<from%>, %<tofrom%> or %<alloc%> "
   27878              :                       "on %<map%> clause");
   27879            1 :             *pc = OMP_CLAUSE_CHAIN (*pc);
   27880            1 :             continue;
   27881              :           }
   27882         4602 :       pc = &OMP_CLAUSE_CHAIN (*pc);
   27883              :     }
   27884         4897 :   cfun->has_omp_target = true;
   27885         4897 :   return true;
   27886              : }
   27887              : 
   27888              : /* OpenMP 4.0:
   27889              :    # pragma omp declare simd declare-simd-clauses[optseq] new-line
   27890              : 
   27891              :    OpenMP 5.0:
   27892              :    # pragma omp declare variant (identifier) match(context-selector) new-line
   27893              : 
   27894              :    OpenMP 5.1
   27895              :    # pragma omp declare variant (identifier) match(context-selector) \
   27896              :       adjust_args(adjust-op:argument-list) append_args(interop-list) new-line
   27897              :    */
   27898              : 
   27899              : #define OMP_DECLARE_SIMD_CLAUSE_MASK                            \
   27900              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SIMDLEN)        \
   27901              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINEAR) \
   27902              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALIGNED)        \
   27903              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNIFORM)        \
   27904              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_INBRANCH)       \
   27905              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOTINBRANCH))
   27906              : 
   27907              : static void
   27908          817 : c_parser_omp_declare_simd (c_parser *parser, enum pragma_context context)
   27909              : {
   27910          817 :   c_token *token = c_parser_peek_token (parser);
   27911          817 :   gcc_assert (token->type == CPP_NAME);
   27912          817 :   tree kind = token->value;
   27913          817 :   gcc_assert (strcmp (IDENTIFIER_POINTER (kind), "simd") == 0
   27914              :               || strcmp (IDENTIFIER_POINTER (kind), "variant") == 0);
   27915              : 
   27916          817 :   auto_vec<c_token> clauses;
   27917        13108 :   while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   27918              :     {
   27919        12291 :       c_token *token = c_parser_peek_token (parser);
   27920        12291 :       if (token->type == CPP_EOF)
   27921              :         {
   27922            0 :           c_parser_skip_to_pragma_eol (parser);
   27923            0 :           return;
   27924              :         }
   27925        12291 :       clauses.safe_push (*token);
   27926        12291 :       c_parser_consume_token (parser);
   27927              :     }
   27928          817 :   clauses.safe_push (*c_parser_peek_token (parser));
   27929          817 :   c_parser_skip_to_pragma_eol (parser);
   27930              : 
   27931         1936 :   while (c_parser_next_token_is (parser, CPP_PRAGMA))
   27932              :     {
   27933          304 :       if (c_parser_peek_token (parser)->pragma_kind != PRAGMA_OMP_DECLARE
   27934          302 :           || c_parser_peek_2nd_token (parser)->type != CPP_NAME
   27935          606 :           || c_parser_peek_2nd_token (parser)->value != kind)
   27936              :         {
   27937            2 :           error ("%<#pragma omp declare %s%> must be followed by "
   27938              :                  "function declaration or definition or another "
   27939              :                  "%<#pragma omp declare %s%>",
   27940            2 :                  IDENTIFIER_POINTER (kind), IDENTIFIER_POINTER (kind));
   27941            2 :           return;
   27942              :         }
   27943          302 :       c_parser_consume_pragma (parser);
   27944         6574 :       while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   27945              :         {
   27946         5970 :           c_token *token = c_parser_peek_token (parser);
   27947         5970 :           if (token->type == CPP_EOF)
   27948              :             {
   27949            0 :               c_parser_skip_to_pragma_eol (parser);
   27950            0 :               return;
   27951              :             }
   27952         5970 :           clauses.safe_push (*token);
   27953         5970 :           c_parser_consume_token (parser);
   27954              :         }
   27955          302 :       clauses.safe_push (*c_parser_peek_token (parser));
   27956          302 :       c_parser_skip_to_pragma_eol (parser);
   27957              :     }
   27958              : 
   27959              :   /* Make sure nothing tries to read past the end of the tokens.  */
   27960          815 :   c_token eof_token;
   27961          815 :   memset (&eof_token, 0, sizeof (eof_token));
   27962          815 :   eof_token.type = CPP_EOF;
   27963          815 :   clauses.safe_push (eof_token);
   27964          815 :   clauses.safe_push (eof_token);
   27965              : 
   27966          815 :   switch (context)
   27967              :     {
   27968          798 :     case pragma_external:
   27969          798 :       if (c_parser_next_token_is (parser, CPP_KEYWORD)
   27970          798 :           && c_parser_peek_token (parser)->keyword == RID_EXTENSION)
   27971              :         {
   27972            1 :           int ext = disable_extension_diagnostics ();
   27973            1 :           do
   27974            1 :             c_parser_consume_token (parser);
   27975            1 :           while (c_parser_next_token_is (parser, CPP_KEYWORD)
   27976            2 :                  && c_parser_peek_token (parser)->keyword == RID_EXTENSION);
   27977            1 :           c_parser_declaration_or_fndef (parser, true, true, true, false, true,
   27978              :                                          false, NULL, &clauses);
   27979            1 :           restore_extension_diagnostics (ext);
   27980              :         }
   27981              :       else
   27982          797 :         c_parser_declaration_or_fndef (parser, true, true, true, false, true,
   27983              :                                        false, NULL, &clauses);
   27984              :       break;
   27985            6 :     case pragma_struct:
   27986            6 :     case pragma_param:
   27987            6 :     case pragma_stmt:
   27988            6 :       error ("%<#pragma omp declare %s%> must be followed by "
   27989              :              "function declaration or definition",
   27990            6 :              IDENTIFIER_POINTER (kind));
   27991            6 :       break;
   27992           11 :     case pragma_compound:
   27993           11 :       bool have_std_attrs;
   27994           11 :       tree std_attrs;
   27995           11 :       have_std_attrs = c_parser_nth_token_starts_std_attributes (parser, 1);
   27996           11 :       if (have_std_attrs)
   27997            1 :         std_attrs = c_parser_std_attribute_specifier_sequence (parser);
   27998              :       else
   27999              :         std_attrs = NULL_TREE;
   28000           11 :       if (c_parser_next_token_is (parser, CPP_KEYWORD)
   28001           11 :           && c_parser_peek_token (parser)->keyword == RID_EXTENSION)
   28002              :         {
   28003            1 :           int ext = disable_extension_diagnostics ();
   28004            3 :           do
   28005            3 :             c_parser_consume_token (parser);
   28006            3 :           while (c_parser_next_token_is (parser, CPP_KEYWORD)
   28007            4 :                  && c_parser_peek_token (parser)->keyword == RID_EXTENSION);
   28008            1 :           if (c_parser_next_tokens_start_declaration (parser)
   28009            1 :               || c_parser_nth_token_starts_std_attributes (parser, 1))
   28010              :             {
   28011            1 :               c_parser_declaration_or_fndef (parser, true, true, true, true,
   28012              :                                              true, false, NULL, &clauses,
   28013              :                                              have_std_attrs, std_attrs);
   28014            1 :               restore_extension_diagnostics (ext);
   28015            1 :               break;
   28016              :             }
   28017            0 :           restore_extension_diagnostics (ext);
   28018              :         }
   28019           10 :       else if (c_parser_next_tokens_start_declaration (parser))
   28020              :         {
   28021           10 :           c_parser_declaration_or_fndef (parser, true, true, true, true, true,
   28022              :                                          false, NULL, &clauses, have_std_attrs,
   28023              :                                          std_attrs);
   28024           10 :           break;
   28025              :         }
   28026            0 :       error ("%<#pragma omp declare %s%> must be followed by "
   28027              :              "function declaration or definition",
   28028            0 :              IDENTIFIER_POINTER (kind));
   28029            0 :       break;
   28030            0 :     default:
   28031            0 :       gcc_unreachable ();
   28032              :     }
   28033          817 : }
   28034              : 
   28035              : /* OpenMP 5.0:
   28036              : 
   28037              :    trait-selector:
   28038              :      trait-selector-name[([trait-score:]trait-property[,trait-property[,...]])]
   28039              : 
   28040              :    trait-score:
   28041              :      score(score-expression)
   28042              : 
   28043              :    Note that this function returns a list of trait selectors for the
   28044              :    trait-selector-set SET.  */
   28045              : 
   28046              : static tree
   28047         1302 : c_parser_omp_context_selector (c_parser *parser, enum omp_tss_code set,
   28048              :                                tree parms)
   28049              : {
   28050         1302 :   tree ret = NULL_TREE;
   28051         1484 :   do
   28052              :     {
   28053         1484 :       tree selector;
   28054         1484 :       if (c_parser_next_token_is (parser, CPP_KEYWORD)
   28055         2907 :           || c_parser_next_token_is (parser, CPP_NAME))
   28056         1482 :         selector = c_parser_peek_token (parser)->value;
   28057              :       else
   28058              :         {
   28059            2 :           c_parser_error (parser, "expected trait selector name");
   28060            2 :           return error_mark_node;
   28061              :         }
   28062         1482 :       enum omp_ts_code sel
   28063         1482 :         = omp_lookup_ts_code (set, IDENTIFIER_POINTER (selector));
   28064              : 
   28065         1482 :       if (sel == OMP_TRAIT_INVALID)
   28066              :         {
   28067              :           /* Per the spec, "Implementations can ignore specified selectors
   28068              :              that are not those described in this section"; however, we
   28069              :              must record such selectors because they cause match failures.  */
   28070           18 :           warning_at (c_parser_peek_token (parser)->location, OPT_Wopenmp,
   28071              :                       "unknown selector %qs for context selector set %qs",
   28072           18 :                       IDENTIFIER_POINTER (selector),  omp_tss_map[set]);
   28073           18 :           c_parser_consume_token (parser);
   28074           18 :           ret = make_trait_selector (sel, NULL_TREE, NULL_TREE, ret);
   28075           18 :           if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   28076            5 :             c_parser_balanced_token_sequence (parser);
   28077           18 :           if (c_parser_next_token_is (parser, CPP_COMMA))
   28078              :             {
   28079            1 :               c_parser_consume_token (parser);
   28080            1 :               continue;
   28081              :             }
   28082              :           else
   28083              :             break;
   28084              :         }
   28085              : 
   28086         1464 :       c_parser_consume_token (parser);
   28087              : 
   28088         1464 :       tree properties = NULL_TREE;
   28089         1464 :       tree scoreval = NULL_TREE;
   28090         1464 :       enum omp_tp_type property_kind = omp_ts_map[sel].tp_type;
   28091         1464 :       bool allow_score = omp_ts_map[sel].allow_score;
   28092         1464 :       tree t;
   28093              : 
   28094         1464 :       if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   28095              :         {
   28096          836 :           if (property_kind == OMP_TRAIT_PROPERTY_NONE)
   28097              :             {
   28098           12 :               error_at (c_parser_peek_token (parser)->location,
   28099              :                         "selector %qs does not accept any properties",
   28100            6 :                         IDENTIFIER_POINTER (selector));
   28101           16 :               return error_mark_node;
   28102              :             }
   28103              : 
   28104          830 :           matching_parens parens;
   28105          830 :           parens.require_open (parser);
   28106              : 
   28107          830 :           c_token *token = c_parser_peek_token (parser);
   28108          830 :           if (c_parser_next_token_is (parser, CPP_NAME)
   28109          637 :               && strcmp (IDENTIFIER_POINTER (token->value), "score") == 0
   28110          923 :               && c_parser_peek_2nd_token (parser)->type == CPP_OPEN_PAREN)
   28111              :             {
   28112           93 :               c_parser_consume_token (parser);
   28113              : 
   28114           93 :               matching_parens parens2;
   28115           93 :               parens2.require_open (parser);
   28116           93 :               tree score = c_parser_expr_no_commas (parser, NULL).value;
   28117           93 :               parens2.skip_until_found_close (parser);
   28118           93 :               c_parser_require (parser, CPP_COLON, "expected %<:%>");
   28119           93 :               if (!allow_score)
   28120           13 :                 error_at (token->location,
   28121              :                           "%<score%> cannot be specified in traits "
   28122              :                           "in the %qs trait-selector-set",
   28123              :                           omp_tss_map[set]);
   28124           80 :               else if (score != error_mark_node)
   28125              :                 {
   28126           80 :                   mark_exp_read (score);
   28127           80 :                   score = c_fully_fold (score, false, NULL);
   28128          160 :                   if (!INTEGRAL_TYPE_P (TREE_TYPE (score))
   28129          159 :                       || TREE_CODE (score) != INTEGER_CST)
   28130            1 :                     error_at (token->location, "%<score%> argument must "
   28131              :                               "be constant integer expression");
   28132           79 :                   else if (tree_int_cst_sgn (score) < 0)
   28133            1 :                     error_at (token->location, "%<score%> argument must "
   28134              :                               "be non-negative");
   28135              :                   else
   28136              :                     scoreval = score;
   28137              :                 }
   28138           93 :               token = c_parser_peek_token (parser);
   28139              :             }
   28140              : 
   28141          830 :           switch (property_kind)
   28142              :             {
   28143           25 :             case OMP_TRAIT_PROPERTY_ID:
   28144           25 :               if (c_parser_next_token_is (parser, CPP_KEYWORD)
   28145           50 :                   || c_parser_next_token_is (parser, CPP_NAME))
   28146              :                 {
   28147           24 :                   tree prop = c_parser_peek_token (parser)->value;
   28148           24 :                   c_parser_consume_token (parser);
   28149           24 :                   properties = make_trait_property (prop, NULL_TREE,
   28150              :                                                     properties);
   28151              :                 }
   28152              :               else
   28153              :                 {
   28154            1 :                   c_parser_error (parser, "expected identifier");
   28155            1 :                   return error_mark_node;
   28156              :                 }
   28157           24 :               break;
   28158          711 :             case OMP_TRAIT_PROPERTY_NAME_LIST:
   28159          769 :               do
   28160              :                 {
   28161          711 :                   tree prop = OMP_TP_NAMELIST_NODE;
   28162          711 :                   tree value = NULL_TREE;
   28163          711 :                   if (c_parser_next_token_is (parser, CPP_KEYWORD)
   28164         1422 :                       || c_parser_next_token_is (parser, CPP_NAME))
   28165              :                     {
   28166          546 :                       value = c_parser_peek_token (parser)->value;
   28167          546 :                       c_parser_consume_token (parser);
   28168              :                     }
   28169          165 :                   else if (c_parser_next_token_is (parser, CPP_STRING))
   28170          160 :                     value = c_parser_string_literal (parser, false,
   28171              :                                                      false).value;
   28172              :                   else
   28173              :                     {
   28174            5 :                       c_parser_error (parser, "expected identifier or "
   28175              :                                               "string literal");
   28176            5 :                       return error_mark_node;
   28177              :                     }
   28178              : 
   28179          706 :                   properties = make_trait_property (prop, value, properties);
   28180              : 
   28181          706 :                   if (c_parser_next_token_is (parser, CPP_COMMA))
   28182           58 :                     c_parser_consume_token (parser);
   28183              :                   else
   28184              :                     break;
   28185           58 :                 }
   28186              :               while (1);
   28187              :               break;
   28188          126 :             case OMP_TRAIT_PROPERTY_DEV_NUM_EXPR:
   28189          126 :             case OMP_TRAIT_PROPERTY_BOOL_EXPR:
   28190          126 :               {
   28191          126 :                 c_expr texpr = c_parser_expr_no_commas (parser, NULL);
   28192          126 :                 texpr = convert_lvalue_to_rvalue (token->location, texpr,
   28193              :                                                   true, true);
   28194          126 :                 t = texpr.value;
   28195              :               }
   28196          126 :               if (t == error_mark_node)
   28197              :                 return error_mark_node;
   28198          124 :               mark_exp_read (t);
   28199          124 :               if (property_kind == OMP_TRAIT_PROPERTY_BOOL_EXPR)
   28200              :                 {
   28201          101 :                   t = c_objc_common_truthvalue_conversion (token->location,
   28202              :                                                            t,
   28203              :                                                            boolean_type_node);
   28204          101 :                   if (t == error_mark_node)
   28205              :                     return error_mark_node;
   28206              :                 }
   28207           23 :               else if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
   28208              :                 {
   28209            0 :                   error_at (token->location,
   28210              :                             "property must be integer expression");
   28211            0 :                   return error_mark_node;
   28212              :                 }
   28213          122 :               t = c_fully_fold (t, false, NULL);
   28214          122 :               properties = make_trait_property (NULL_TREE, t, properties);
   28215          122 :               break;
   28216           26 :             case OMP_TRAIT_PROPERTY_CLAUSE_LIST:
   28217           26 :               if (sel == OMP_TRAIT_CONSTRUCT_SIMD)
   28218              :                 {
   28219           26 :                   if (parms == NULL_TREE)
   28220              :                     {
   28221            0 :                       error_at (token->location, "properties for %<simd%> "
   28222              :                                 "selector may not be specified in "
   28223              :                                 "%<metadirective%>");
   28224            0 :                       return error_mark_node;
   28225              :                     }
   28226           26 :                   tree c;
   28227           52 :                   c = c_parser_omp_all_clauses (parser,
   28228           26 :                                                 OMP_DECLARE_SIMD_CLAUSE_MASK,
   28229              :                                                 "simd", true, 2);
   28230           52 :                   c = c_omp_declare_simd_clauses_to_numbers (parms
   28231           26 :                                                              == error_mark_node
   28232              :                                                              ? NULL_TREE : parms,
   28233              :                                                              c);
   28234           26 :                   properties = c;
   28235              :                 }
   28236            0 :               else if (sel == OMP_TRAIT_IMPLEMENTATION_REQUIRES)
   28237              :                 {
   28238              :                   /* FIXME: The "requires" selector was added in OpenMP 5.1.
   28239              :                      Currently only the now-deprecated syntax
   28240              :                      from OpenMP 5.0 is supported.  */
   28241            0 :                   sorry_at (token->location,
   28242              :                             "%<requires%> selector is not supported yet");
   28243            0 :                   return error_mark_node;
   28244              :                 }
   28245              :               else
   28246            0 :                 gcc_unreachable ();
   28247           26 :               break;
   28248            0 :             default:
   28249            0 :               gcc_unreachable ();
   28250              :             }
   28251              : 
   28252          820 :           parens.skip_until_found_close (parser);
   28253          820 :           properties = nreverse (properties);
   28254              :         }
   28255          628 :       else if (property_kind != OMP_TRAIT_PROPERTY_NONE
   28256          628 :                && property_kind != OMP_TRAIT_PROPERTY_CLAUSE_LIST
   28257            8 :                && property_kind != OMP_TRAIT_PROPERTY_EXTENSION)
   28258              :         {
   28259            8 :           c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>");
   28260            8 :           return error_mark_node;
   28261              :         }
   28262              : 
   28263         1440 :       ret = make_trait_selector (sel, scoreval, properties, ret);
   28264              : 
   28265         1440 :       if (c_parser_next_token_is (parser, CPP_COMMA))
   28266          181 :         c_parser_consume_token (parser);
   28267              :       else
   28268              :         break;
   28269              :     }
   28270              :   while (1);
   28271              : 
   28272         1276 :   return nreverse (ret);
   28273              : }
   28274              : 
   28275              : /* OpenMP 5.0:
   28276              : 
   28277              :    trait-set-selector[,trait-set-selector[,...]]
   28278              : 
   28279              :    trait-set-selector:
   28280              :      trait-set-selector-name = { trait-selector[, trait-selector[, ...]] }
   28281              : 
   28282              :    trait-set-selector-name:
   28283              :      constructor
   28284              :      device
   28285              :      implementation
   28286              :      user  */
   28287              : 
   28288              : static tree
   28289          938 : c_parser_omp_context_selector_specification (c_parser *parser, tree parms)
   28290              : {
   28291          938 :   tree ret = NULL_TREE;
   28292         1686 :   do
   28293              :     {
   28294         1312 :       const char *setp = "";
   28295         1312 :       if (c_parser_next_token_is (parser, CPP_NAME))
   28296         1310 :         setp = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   28297         1312 :       enum omp_tss_code set = omp_lookup_tss_code (setp);
   28298              : 
   28299         1312 :       if (set == OMP_TRAIT_SET_INVALID)
   28300              :         {
   28301            6 :           c_parser_error (parser, "expected context selector set name");
   28302           10 :           return error_mark_node;
   28303              :         }
   28304              : 
   28305         1306 :       c_parser_consume_token (parser);
   28306              : 
   28307         1306 :       if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
   28308            1 :         return error_mark_node;
   28309              : 
   28310         1305 :       matching_braces braces;
   28311         1305 :       if (!braces.require_open (parser))
   28312            3 :         return error_mark_node;
   28313              : 
   28314         1302 :       tree selectors = c_parser_omp_context_selector (parser, set, parms);
   28315         1302 :       if (selectors == error_mark_node)
   28316              :         {
   28317           26 :           c_parser_skip_to_closing_brace (parser);
   28318           26 :           ret = error_mark_node;
   28319              :         }
   28320         1276 :       else if (ret != error_mark_node)
   28321         1276 :         ret = make_trait_set_selector (set, selectors, ret);
   28322              : 
   28323         1302 :       braces.require_close (parser);
   28324              : 
   28325         1302 :       if (c_parser_next_token_is (parser, CPP_COMMA))
   28326          374 :         c_parser_consume_token (parser);
   28327              :       else
   28328              :         break;
   28329          374 :     }
   28330              :   while (1);
   28331              : 
   28332          928 :   if (ret == error_mark_node)
   28333              :     return ret;
   28334          902 :   return nreverse (ret);
   28335              : }
   28336              : 
   28337              : /* Finalize #pragma omp declare variant after FNDECL has been parsed, and put
   28338              :    that into "omp declare variant base" attribute.  */
   28339              : 
   28340              : static void
   28341          787 : c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms)
   28342              : {
   28343          787 :   matching_parens parens;
   28344          787 :   if (!parens.require_open (parser))
   28345              :     {
   28346            3 :      fail:
   28347           50 :       c_parser_skip_to_pragma_eol (parser, false);
   28348           50 :       return;
   28349              :     }
   28350              : 
   28351          784 :   if (c_parser_next_token_is_not (parser, CPP_NAME)
   28352          784 :       || c_parser_peek_token (parser)->id_kind != C_ID_ID)
   28353              :     {
   28354            3 :       c_parser_error (parser, "expected identifier");
   28355            3 :       goto fail;
   28356              :     }
   28357              : 
   28358          781 :   c_token *token = c_parser_peek_token (parser);
   28359          781 :   tree variant = lookup_name (token->value);
   28360              : 
   28361          781 :   if (variant == NULL_TREE)
   28362              :     {
   28363            3 :       undeclared_variable (token->location, token->value);
   28364            3 :       variant = error_mark_node;
   28365              :     }
   28366          778 :   else if (TREE_CODE (variant) != FUNCTION_DECL)
   28367              :     {
   28368            1 :       error_at (token->location, "variant %qD is not a function",
   28369              :                 variant);
   28370            1 :       variant = error_mark_node;
   28371              :     }
   28372          777 :   else if (fndecl_built_in_p (variant)
   28373          777 :            && (strncmp (IDENTIFIER_POINTER (DECL_NAME (variant)),
   28374              :                         "__builtin_", strlen ("__builtin_")) == 0
   28375            0 :                || strncmp (IDENTIFIER_POINTER (DECL_NAME (variant)),
   28376              :                            "__sync_", strlen ("__sync_")) == 0
   28377            0 :                || strncmp (IDENTIFIER_POINTER (DECL_NAME (variant)),
   28378              :                            "__atomic_", strlen ("__atomic_")) == 0))
   28379              :     {
   28380            1 :       error_at (token->location, "variant %qD is a built-in",
   28381              :                 variant);
   28382            1 :       variant = error_mark_node;
   28383              :     }
   28384          776 :   else if (variant == fndecl)
   28385              :     {
   28386            2 :       error_at (token->location, "variant %qD is the same as base function",
   28387              :                 variant);
   28388            2 :       variant = error_mark_node;
   28389              :     }
   28390              : 
   28391          781 :   c_parser_consume_token (parser);
   28392              : 
   28393          781 :   parens.require_close (parser);
   28394              : 
   28395          781 :   tree append_args_tree = NULL_TREE;
   28396          781 :   tree append_args_last;
   28397          781 :   vec<tree> adjust_args_list = vNULL;
   28398          781 :   bool has_match = false, has_adjust_args = false;
   28399          781 :   location_t adjust_args_loc = UNKNOWN_LOCATION;
   28400          781 :   location_t append_args_loc = UNKNOWN_LOCATION;
   28401          781 :   location_t match_loc = UNKNOWN_LOCATION;
   28402          781 :   tree need_device_ptr_list = NULL_TREE;
   28403          781 :   tree ctx = error_mark_node;
   28404              : 
   28405          880 :   do
   28406              :     {
   28407          880 :       if (c_parser_next_token_is (parser, CPP_COMMA)
   28408          880 :           && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
   28409            9 :         c_parser_consume_token (parser);
   28410              : 
   28411          880 :       const char *clause = "";
   28412          880 :       location_t loc = c_parser_peek_token (parser)->location;
   28413          880 :       if (c_parser_next_token_is (parser, CPP_NAME))
   28414          879 :         clause = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   28415              : 
   28416          880 :       enum clause
   28417              :       {
   28418              :         match,
   28419              :         adjust_args,
   28420              :         append_args
   28421              :       } ccode;
   28422              : 
   28423          880 :       if (strcmp (clause, "match") == 0)
   28424              :         {
   28425              :           ccode = match;
   28426              :           match_loc = loc;
   28427              :         }
   28428          102 :       else if (strcmp (clause, "adjust_args") == 0)
   28429              :         {
   28430              :           ccode = adjust_args;
   28431              :           adjust_args_loc = loc;
   28432              :         }
   28433           50 :       else if (strcmp (clause, "append_args") == 0)
   28434              :         {
   28435              :           ccode = append_args;
   28436              :           append_args_loc = loc;
   28437              :         }
   28438              :       else
   28439              :         {
   28440            2 :           c_parser_error (parser, "expected %<match%>, %<adjust_args%> or "
   28441              :                                   "%<append_args%> clause");
   28442            2 :           goto fail;
   28443              :         }
   28444              : 
   28445          878 :       c_parser_consume_token (parser);
   28446              : 
   28447          878 :       if (!parens.require_open (parser))
   28448            1 :         goto fail;
   28449              : 
   28450          877 :       if (parms == NULL_TREE)
   28451          615 :         parms = error_mark_node;
   28452              : 
   28453          877 :       if (ccode == match)
   28454              :         {
   28455          777 :           if (has_match)
   28456            1 :             error_at (match_loc, "too many %<match%> clauses");
   28457          777 :           has_match = true;
   28458          777 :           ctx  = c_parser_omp_context_selector_specification (parser, parms);
   28459          777 :           if (ctx == error_mark_node)
   28460           32 :             goto fail;
   28461          745 :           ctx = omp_check_context_selector (match_loc, ctx,
   28462              :                                             OMP_CTX_DECLARE_VARIANT);
   28463              : 
   28464              :           /* The OpenMP spec says the merging rules for enclosing
   28465              :              "begin declare variant" contexts apply to "declare variant
   28466              :              directives" -- the term it uses to refer to both directive
   28467              :              forms.  */
   28468          745 :           if (ctx != error_mark_node
   28469          745 :               && !vec_safe_is_empty (current_omp_declare_variant_attribute))
   28470              :             {
   28471            2 :               c_omp_declare_variant_attr a
   28472            2 :                 = current_omp_declare_variant_attribute->last ();
   28473            2 :               tree outer_ctx = a.selector;
   28474            2 :               ctx = omp_merge_context_selectors (match_loc, outer_ctx, ctx,
   28475              :                                                  OMP_CTX_DECLARE_VARIANT);
   28476              :             }
   28477              :         }
   28478          100 :       else if (ccode == adjust_args)
   28479              :         {
   28480           52 :           has_adjust_args = true;
   28481           52 :           if (c_parser_next_token_is (parser, CPP_NAME)
   28482           52 :               && c_parser_peek_2nd_token (parser)->type == CPP_COLON)
   28483              :             {
   28484           50 :               const char *p
   28485           50 :                 = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   28486           50 :               if (strcmp (p, "need_device_ptr") == 0
   28487           15 :                   || strcmp (p, "nothing") == 0)
   28488              :                 {
   28489           48 :                   c_parser_consume_token (parser); // need_device_ptr
   28490           48 :                   c_parser_consume_token (parser); // :
   28491              : 
   28492           48 :                   loc = c_parser_peek_token (parser)->location;
   28493           48 :                   tree list
   28494           48 :                     = c_parser_omp_variable_list (parser, loc, OMP_CLAUSE_ERROR,
   28495              :                                                   NULL_TREE);
   28496              : 
   28497           48 :                   tree arg;
   28498           48 :                   if (variant != error_mark_node)
   28499          103 :                     for (tree c = list; c != NULL_TREE; c = TREE_CHAIN (c))
   28500              :                       {
   28501           61 :                         tree decl = TREE_PURPOSE (c);
   28502           61 :                         location_t arg_loc = EXPR_LOCATION (TREE_VALUE (c));
   28503           61 :                         int idx;
   28504          111 :                         for (arg = parms, idx = 0; arg != NULL;
   28505           50 :                              arg = TREE_CHAIN (arg), idx++)
   28506          110 :                           if (arg == decl)
   28507              :                             break;
   28508           61 :                         if (arg == NULL_TREE)
   28509              :                           {
   28510            1 :                             error_at (arg_loc,
   28511              :                                       "%qD is not a function argument",
   28512              :                                       decl);
   28513            5 :                             goto fail;
   28514              :                           }
   28515           60 :                         if (adjust_args_list.contains (arg))
   28516              :                           {
   28517            3 :                             error_at (arg_loc,
   28518              :                                       "%qD is specified more than once",
   28519              :                                       decl);
   28520            3 :                             goto fail;
   28521              :                           }
   28522           57 :                         if (strcmp (p, "need_device_ptr") == 0
   28523           57 :                             && TREE_CODE (TREE_TYPE (arg)) != POINTER_TYPE)
   28524              :                           {
   28525            1 :                             error_at (loc, "%qD is not of pointer type", decl);
   28526            1 :                             goto fail;
   28527              :                           }
   28528           56 :                         adjust_args_list.safe_push (arg);
   28529           56 :                         if (strcmp (p, "need_device_ptr") == 0)
   28530              :                           {
   28531           46 :                             need_device_ptr_list = chainon (
   28532              :                               need_device_ptr_list,
   28533              :                               build_tree_list (
   28534              :                                 NULL_TREE,
   28535              :                                 build_int_cst (
   28536              :                                   integer_type_node,
   28537           46 :                                   idx))); // Store 0-based argument index,
   28538              :                                           // as in gimplify_call_expr
   28539              :                           }
   28540              :                       }
   28541              :                 }
   28542              :               else
   28543              :                 {
   28544            2 :                   error_at (c_parser_peek_token (parser)->location,
   28545              :                             "expected %<nothing%> or %<need_device_ptr%>");
   28546            2 :                   if (strcmp (p, "need_device_addr") == 0)
   28547            1 :                     inform (c_parser_peek_token (parser)->location,
   28548              :                             "%<need_device_addr%> is not valid for C");
   28549            2 :                   goto fail;
   28550              :                 }
   28551              :             }
   28552              :           else
   28553              :             {
   28554            2 :               error_at (c_parser_peek_token (parser)->location,
   28555              :                         "expected %<nothing%> or %<need_device_ptr%> "
   28556              :                         "followed by %<:%>");
   28557            2 :               goto fail;
   28558              :             }
   28559              :         }
   28560           48 :       else if (ccode == append_args)
   28561              :         {
   28562           48 :           if (append_args_tree)
   28563              :             {
   28564            1 :               error_at (append_args_loc, "too many %qs clauses", "append_args");
   28565            1 :               append_args_tree = NULL_TREE;
   28566              :             }
   28567           86 :           do
   28568              :             {
   28569           67 :               location_t loc = c_parser_peek_token (parser)->location;
   28570           67 :               if (!c_parser_next_token_is (parser, CPP_NAME)
   28571           67 :                   || strcmp ("interop",
   28572           67 :                              IDENTIFIER_POINTER (
   28573              :                                c_parser_peek_token (parser)->value)))
   28574              :                 {
   28575            0 :                   error_at (loc, "expected %<interop%>");
   28576            0 :                   goto fail;
   28577              :                 }
   28578           67 :               c_parser_consume_token (parser);
   28579              : 
   28580           67 :               if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
   28581            0 :                 goto fail;
   28582           67 :               bool target = false;
   28583           67 :               bool targetsync = false;
   28584           67 :               tree prefer_type_tree = NULL_TREE;
   28585           67 :               if (!c_parser_omp_clause_init_modifiers (parser, &target,
   28586              :                                                        &targetsync,
   28587              :                                                        &prefer_type_tree)
   28588           67 :                   || !c_parser_require (parser, CPP_CLOSE_PAREN,
   28589              :                                         "expected %<)%> or %<,%>"))
   28590            0 :                 goto fail;
   28591           67 :               if (!target && !targetsync)
   28592            3 :                 error_at (loc,
   28593              :                           "missing required %<target%> and/or "
   28594              :                           "%<targetsync%> modifier");
   28595           67 :               tree t = build_tree_list (target ? boolean_true_node
   28596              :                                                : boolean_false_node,
   28597              :                                         targetsync ? boolean_true_node
   28598              :                                                    : boolean_false_node);
   28599           67 :               t = build1_loc (loc, NOP_EXPR, void_type_node, t);
   28600           67 :               t = build_tree_list (t, prefer_type_tree);
   28601           67 :               if (append_args_tree)
   28602              :                 {
   28603           19 :                   TREE_CHAIN (append_args_last) = t;
   28604           19 :                   append_args_last = t;
   28605              :                 }
   28606              :               else
   28607              :                 append_args_tree = append_args_last = t;
   28608           67 :               if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
   28609              :                 break;
   28610           19 :               if (!c_parser_require (parser, CPP_COMMA, "expected %<)%> or %<,%>"))
   28611            0 :                 goto fail;
   28612           19 :             }
   28613              :           while (true);
   28614              :         }
   28615              : 
   28616          836 :       parens.require_close (parser);
   28617          836 :   } while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL));
   28618          737 :   if (variant != error_mark_node && !has_match)
   28619              :     {
   28620            1 :       c_parser_error (parser, "expected %<match%> clause");
   28621            1 :       variant = error_mark_node;
   28622              :     }
   28623          737 :   c_parser_skip_to_pragma_eol (parser);
   28624              : 
   28625              :   /* At this point, we have completed parsing of the pragma, now it's
   28626              :      on to error checking.  */
   28627          737 :   if (variant == error_mark_node || ctx == error_mark_node)
   28628              :     /* Previously diagnosed error.  */
   28629              :     return;
   28630              : 
   28631          707 :   if ((has_adjust_args || append_args_tree)
   28632          707 :       && !omp_get_context_selector (ctx, OMP_TRAIT_SET_CONSTRUCT,
   28633              :                                     OMP_TRAIT_CONSTRUCT_DISPATCH))
   28634              :     {
   28635            1 :       error_at (has_adjust_args ? adjust_args_loc : append_args_loc,
   28636              :                 "an %qs clause can only be specified if the "
   28637              :                 "%<dispatch%> selector of the %<construct%> selector "
   28638              :                 "set appears in the %<match%> clause",
   28639              :                 has_adjust_args ? "adjust_args" : "append_args");
   28640            1 :       return;
   28641              :     }
   28642              : 
   28643          706 :   if (!omp_get_context_selector (ctx, OMP_TRAIT_SET_CONSTRUCT,
   28644              :                                  OMP_TRAIT_CONSTRUCT_SIMD))
   28645              :     /* Check that the base and variant have compatible types.  */
   28646              :     {
   28647          680 :       tree base_type = TREE_TYPE (fndecl);
   28648          680 :       tree variant_type = TREE_TYPE (variant);
   28649          680 :       bool unprototyped_variant
   28650          680 :         = (TYPE_ARG_TYPES (variant_type) == NULL_TREE
   28651          680 :            && !TYPE_NO_NAMED_ARGS_STDARG_P (variant_type));
   28652              : 
   28653          680 :       if (append_args_tree
   28654           47 :           && TYPE_ARG_TYPES (base_type) == NULL_TREE
   28655          688 :           && !TYPE_NO_NAMED_ARGS_STDARG_P (base_type))
   28656              :         {
   28657              :           /* The base function is a pre-C23 unprototyped function.  Without
   28658              :              a prototype, we don't know the offset where the append_args go.
   28659              :              That offset needs to be stored with the append_args in the
   28660              :              variant function attributes, so we cannot presently handle
   28661              :              this case.  */
   28662            6 :           sorry_at (append_args_loc,
   28663              :                     "%<append_args%> with unprototyped base function "
   28664              :                     "is not supported yet");
   28665            6 :           inform (DECL_SOURCE_LOCATION (fndecl),
   28666              :                   "base function %qD declared here", fndecl);
   28667            6 :           return;
   28668              :         }
   28669          674 :       else if (append_args_tree)
   28670              :         {
   28671              :           /* Find nbase_args, the number of fixed arguments in the base
   28672              :              function.  */
   28673           41 :           int nappend_args = 0;
   28674           41 :           int nbase_args = 0;
   28675           41 :           for (tree t = TYPE_ARG_TYPES (base_type);
   28676          183 :                t && TREE_VALUE (t) != void_type_node; t = TREE_CHAIN (t))
   28677           55 :             nbase_args++;
   28678          101 :           for (tree t = append_args_tree; t; t = TREE_CHAIN (t))
   28679           60 :             nappend_args++;
   28680              : 
   28681              :           /* Store as purpose = arg number after which to append
   28682              :              and value = list of interop items.  */
   28683           41 :           append_args_tree = build_tree_list (build_int_cst (integer_type_node,
   28684           41 :                                                              nbase_args),
   28685              :                                               append_args_tree);
   28686              : 
   28687              :           /* Give a specific diagnostic if the append_args parameters
   28688              :              of the variant are of the wrong type, or missing.  The
   28689              :              compatible types test below could fail to detect this if
   28690              :              the variant is a varargs function.  */
   28691           41 :           if (!unprototyped_variant)
   28692              :             {
   28693           39 :               tree args = TYPE_ARG_TYPES (variant_type);
   28694           90 :               for (int i = 0; args && i < nbase_args;
   28695           51 :                    i++, args = TREE_CHAIN (args))
   28696              :                 ;
   28697           89 :               for (int i = 0; i < nappend_args; i++, args = TREE_CHAIN (args))
   28698          109 :                 if (!args || !c_omp_interop_t_p (TREE_VALUE (args)))
   28699              :                   {
   28700            5 :                     error_at (DECL_SOURCE_LOCATION (variant),
   28701              :                               "argument %d of %qD must be of "
   28702              :                               "%<omp_interop_t%>",
   28703            5 :                               nbase_args + i + 1, variant);
   28704            5 :                     inform (append_args_loc,
   28705              :                             "%<append_args%> specified here");
   28706          100 :                     return;
   28707              :                   }
   28708              :             }
   28709              : 
   28710              :           /* Perform the "implementation defined transformation" on the type
   28711              :              of the base function to add the append_args before checking it
   28712              :              for compatibility with the function variant's type.  */
   28713           36 :           tree args = TYPE_ARG_TYPES (base_type);
   28714           36 :           tree newargs = NULL_TREE;
   28715           36 :           tree lastarg = NULL_TREE;
   28716           89 :           for (int j = 0; j < nbase_args; j++, args = TREE_CHAIN (args))
   28717              :             {
   28718           53 :               tree t = tree_cons (TREE_PURPOSE (args),
   28719           53 :                                   TREE_VALUE (args), NULL_TREE);
   28720           53 :               if (lastarg)
   28721           31 :                 TREE_CHAIN (lastarg) = t;
   28722              :               else
   28723              :                 newargs = t;
   28724           53 :               lastarg = t;
   28725              :             }
   28726           36 :           tree type = lookup_name (get_identifier ("omp_interop_t"));
   28727           36 :           type = type ? TREE_TYPE (type) : pointer_sized_int_node;
   28728           87 :           for (int j = 0; j < nappend_args; j++)
   28729              :             {
   28730           51 :               tree t = tree_cons (NULL_TREE, type, NULL_TREE);
   28731           51 :               if (lastarg)
   28732           37 :                 TREE_CHAIN (lastarg) = t;
   28733              :               else
   28734              :                 newargs = t;
   28735           51 :               lastarg = t;
   28736              :             }
   28737           36 :           TREE_CHAIN (lastarg) = args;
   28738              : 
   28739              :           /* Temporarily stuff newargs into the original base_type.  */
   28740           36 :           tree saveargs = TYPE_ARG_TYPES (base_type);
   28741           36 :           TYPE_ARG_TYPES (base_type) = newargs;
   28742           36 :           bool fail = !comptypes (base_type, variant_type);
   28743           36 :           TYPE_ARG_TYPES (base_type) = saveargs;
   28744              : 
   28745           36 :           if (fail)
   28746              :             {
   28747            2 :               error_at (token->location,
   28748              :                         "variant %qD and base %qD have incompatible types "
   28749              :                         "after %<append_args%> adjustment",
   28750              :                         variant, fndecl);
   28751            2 :               inform (DECL_SOURCE_LOCATION (variant),
   28752              :                       "%<declare variant%> candidate %qD declared here",
   28753              :                       variant);
   28754            2 :               return;
   28755              :             }
   28756           34 :           else if (unprototyped_variant)
   28757              :             /* If we've got an unprototyped variant, copy the transformed
   28758              :                base arg types to the variant.  This is needed later by
   28759              :                modify_call_for_omp_dispatch.  */
   28760            2 :             TYPE_ARG_TYPES (variant_type) = newargs;
   28761              :         }
   28762              :       else  /* No append_args present.  */
   28763              :         {
   28764          633 :           if (!comptypes (base_type, variant_type))
   28765              :             {
   28766            1 :               error_at (token->location,
   28767              :                         "variant %qD and base %qD have incompatible types",
   28768              :                         variant, fndecl);
   28769            1 :               inform (DECL_SOURCE_LOCATION (variant),
   28770              :                       "%<declare variant%> candidate %qD declared here",
   28771              :                       variant);
   28772            1 :               return;
   28773              :             }
   28774          632 :           else if (TYPE_ARG_TYPES (variant_type) == NULL_TREE
   28775            3 :                    && !TYPE_NO_NAMED_ARGS_STDARG_P (variant_type)
   28776          634 :                    && TYPE_ARG_TYPES (base_type) != NULL_TREE)
   28777              :             /* If we've got an unprototyped variant but the base has
   28778              :                a prototype, copy the base arg types to the variant.  */
   28779            1 :             TYPE_ARG_TYPES (variant_type) = TYPE_ARG_TYPES (base_type);
   28780              :         }
   28781              :     }
   28782              : 
   28783              :   /* If we made it here, store the parsed information.  */
   28784          692 :   C_DECL_USED (variant) = 1;
   28785          692 :   tree construct = omp_get_context_selector_list (ctx,
   28786              :                                                   OMP_TRAIT_SET_CONSTRUCT);
   28787          692 :   omp_mark_declare_variant (match_loc, variant, construct);
   28788          692 :   if (omp_context_selector_matches (ctx, NULL_TREE, false))
   28789              :     {
   28790          248 :       tree attr = tree_cons (get_identifier ("omp declare variant base"),
   28791              :                              build_tree_list (variant, ctx),
   28792          248 :                              DECL_ATTRIBUTES (fndecl));
   28793          248 :       DECL_ATTRIBUTES (fndecl) = attr;
   28794              :     }
   28795              : 
   28796          692 :   if (need_device_ptr_list || append_args_tree)
   28797              :     {
   28798           49 :       tree variant_decl = tree_strip_nop_conversions (variant);
   28799           49 :       tree t = build_tree_list (need_device_ptr_list,
   28800              :                                 NULL_TREE /* need_device_addr */);
   28801           49 :       TREE_CHAIN (t) = append_args_tree;
   28802           49 :       DECL_ATTRIBUTES (variant_decl)
   28803           98 :         = tree_cons (get_identifier ("omp declare variant variant args"), t,
   28804           49 :                      DECL_ATTRIBUTES (variant_decl));
   28805              :     }
   28806              : }
   28807              : 
   28808              : /* Finalize #pragma omp declare simd or #pragma omp declare variant
   28809              :    clauses after FNDECL has been parsed, and put that into "omp declare simd"
   28810              :    or "omp declare variant base" attribute.  */
   28811              : 
   28812              : static void
   28813          889 : c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms,
   28814              :                            vec<c_token> *pclauses)
   28815              : {
   28816          889 :   vec<c_token> &clauses = *pclauses;
   28817              : 
   28818              :   /* Normally first token is CPP_NAME "simd" or "variant".  CPP_EOF there
   28819              :      indicates error has been reported and CPP_PRAGMA that
   28820              :      c_finish_omp_declare_simd has already processed the tokens.  */
   28821         1778 :   if (clauses.exists () && clauses[0].type == CPP_EOF)
   28822              :     return;
   28823          885 :   const char *kind = "simd";
   28824          885 :   if (clauses.exists ()
   28825         1770 :       && (clauses[0].type == CPP_NAME || clauses[0].type == CPP_PRAGMA))
   28826          885 :     kind = IDENTIFIER_POINTER (clauses[0].value);
   28827          885 :   gcc_assert (strcmp (kind, "simd") == 0 || strcmp (kind, "variant") == 0);
   28828          885 :   if (fndecl == NULL_TREE || TREE_CODE (fndecl) != FUNCTION_DECL)
   28829              :     {
   28830           15 :       error ("%<#pragma omp declare %s%> not immediately followed by "
   28831              :              "a function declaration or definition", kind);
   28832           15 :       clauses[0].type = CPP_EOF;
   28833           15 :       return;
   28834              :     }
   28835         1740 :   if (clauses.exists () && clauses[0].type != CPP_NAME)
   28836              :     {
   28837            2 :       error_at (DECL_SOURCE_LOCATION (fndecl),
   28838              :                 "%<#pragma omp declare %s%> not immediately followed by "
   28839              :                 "a single function declaration or definition", kind);
   28840            2 :       clauses[0].type = CPP_EOF;
   28841            2 :       return;
   28842              :     }
   28843          868 :   if (DECL_FUNCTION_VERSIONED (fndecl))
   28844              :     {
   28845            0 :       error_at (DECL_SOURCE_LOCATION (fndecl),
   28846              :                 "%<#pragma omp declare %s%> cannot be used with function "
   28847              :                 "multi-versioning", kind);
   28848            0 :       return;
   28849              :     }
   28850              : 
   28851          868 :   if (parms == NULL_TREE)
   28852          605 :     parms = DECL_ARGUMENTS (fndecl);
   28853              : 
   28854          868 :   unsigned int tokens_avail = parser->tokens_avail;
   28855          868 :   gcc_assert (parser->tokens == &parser->tokens_buf[0]);
   28856              : 
   28857          868 :   parser->tokens = clauses.address ();
   28858          868 :   parser->tokens_avail = clauses.length ();
   28859              : 
   28860              :   /* c_parser_omp_declare_simd pushed 2 extra CPP_EOF tokens at the end.  */
   28861         2056 :   while (parser->tokens_avail > 3)
   28862              :     {
   28863         1188 :       c_token *token = c_parser_peek_token (parser);
   28864         1188 :       gcc_assert (token->type == CPP_NAME);
   28865         1188 :       kind = IDENTIFIER_POINTER (token->value);
   28866         1188 :       c_parser_consume_token (parser);
   28867         1188 :       parser->in_pragma = true;
   28868              : 
   28869         1188 :       if (strcmp (kind, "simd") == 0)
   28870              :         {
   28871          401 :           tree c;
   28872          401 :           c = c_parser_omp_all_clauses (parser, OMP_DECLARE_SIMD_CLAUSE_MASK,
   28873              :                                         "#pragma omp declare simd");
   28874          401 :           c = c_omp_declare_simd_clauses_to_numbers (parms, c);
   28875          401 :           if (c != NULL_TREE)
   28876          292 :             c = tree_cons (NULL_TREE, c, NULL_TREE);
   28877          401 :           c = build_tree_list (get_identifier ("omp declare simd"), c);
   28878          401 :           TREE_CHAIN (c) = DECL_ATTRIBUTES (fndecl);
   28879          401 :           DECL_ATTRIBUTES (fndecl) = c;
   28880              :         }
   28881              :       else
   28882              :         {
   28883          787 :           gcc_assert (strcmp (kind, "variant") == 0);
   28884          787 :           c_finish_omp_declare_variant (parser, fndecl, parms);
   28885              :         }
   28886              :     }
   28887              : 
   28888          868 :   parser->tokens = &parser->tokens_buf[0];
   28889          868 :   parser->tokens_avail = tokens_avail;
   28890          868 :   if (clauses.exists ())
   28891          868 :     clauses[0].type = CPP_PRAGMA;
   28892              : }
   28893              : 
   28894              : /* This is consistent with the C++ front end.  */
   28895              : 
   28896              : #if !defined (NO_DOT_IN_LABEL)
   28897              : #define JOIN_STR "."
   28898              : #elif !defined (NO_DOLLAR_IN_LABEL)
   28899              : #define JOIN_STR "$"
   28900              : #else
   28901              : #define JOIN_STR "_"
   28902              : #endif
   28903              : 
   28904              : /* Helper function for OpenMP "begin declare variant" directives.
   28905              :    Function definitions inside the construct need to have their names
   28906              :    mangled according to the context selector CTX.  The DECLARATOR is
   28907              :    modified in place to point to a new identifier; the original name of
   28908              :    the function is returned.  */
   28909              : static tree
   28910           26 : omp_start_variant_function (c_declarator *declarator, tree ctx)
   28911              : {
   28912           26 :   c_declarator *id = declarator;
   28913           52 :   while (id->kind != cdk_id)
   28914              :     {
   28915           26 :       id = id->declarator;
   28916           26 :       gcc_assert (id);
   28917              :     }
   28918           26 :   tree name = id->u.id.id;
   28919           26 :   id->u.id.id = omp_mangle_variant_name (name, ctx, JOIN_STR);
   28920           26 :   return name;
   28921              : }
   28922              : 
   28923              : /* Helper function for OpenMP "begin declare variant" directives.  Now
   28924              :    that we have a DECL for the variant function, and BASE_NAME for the
   28925              :    base function, add an "omp declare variant base" attribute pointing
   28926              :    at CTX to the base decl, and an "omp declare variant variant"
   28927              :    attribute to the variant DECL.  */
   28928              : static void
   28929           26 : omp_finish_variant_function (tree decl, tree base_name, tree ctx)
   28930              : {
   28931              :   /* First look up BASE_NAME and ensure it matches DECL.  */
   28932           26 :   tree base_decl = lookup_name (base_name);
   28933           26 :   if (base_decl == error_mark_node)
   28934              :     base_decl = NULL_TREE;
   28935           26 :   if (!base_decl)
   28936              :     {
   28937            1 :       error_at (DECL_SOURCE_LOCATION (decl),
   28938              :                 "no declaration of base function %qs",
   28939            1 :                 IDENTIFIER_POINTER (base_name));
   28940            1 :       return;
   28941              :     }
   28942              : 
   28943           25 :   if (!comptypes (TREE_TYPE (decl), TREE_TYPE (base_decl)))
   28944              :     {
   28945            2 :       error_at (DECL_SOURCE_LOCATION (decl),
   28946              :                 "variant function definition does not match "
   28947              :                 "declaration of %qE", base_decl);
   28948            2 :       inform (DECL_SOURCE_LOCATION (base_decl),
   28949              :               "%qE declared here", base_decl);
   28950            2 :       return;
   28951              :     }
   28952              : 
   28953              :   /* Now set the attributes on the base and variant decls for the middle
   28954              :      end.  */
   28955           23 :   omp_check_for_duplicate_variant (DECL_SOURCE_LOCATION (decl),
   28956              :                                    base_decl, ctx);
   28957           23 :   tree construct
   28958           23 :     = omp_get_context_selector_list (ctx, OMP_TRAIT_SET_CONSTRUCT);
   28959           23 :   omp_mark_declare_variant (DECL_SOURCE_LOCATION (decl), decl, construct);
   28960           23 :   tree attrs = DECL_ATTRIBUTES (base_decl);
   28961           23 :   tree match_loc_node
   28962           23 :     = maybe_wrap_with_location (integer_zero_node,
   28963           23 :                                 DECL_SOURCE_LOCATION (base_decl));
   28964           23 :   tree loc_node = tree_cons (match_loc_node, integer_zero_node,
   28965              :                              build_tree_list (match_loc_node,
   28966              :                                               integer_zero_node));
   28967           23 :   attrs = tree_cons (get_identifier ("omp declare variant base"),
   28968              :                      tree_cons (decl, ctx, loc_node), attrs);
   28969           23 :   DECL_ATTRIBUTES (base_decl) = attrs;
   28970              : 
   28971              :   /* Variant functions are essentially anonymous and cannot be referenced
   28972              :      outside the compilation unit.  */
   28973           23 :   TREE_PUBLIC (decl) = 0;
   28974           23 :   DECL_COMDAT (decl) = 0;
   28975              : }
   28976              : 
   28977              : 
   28978              : /* D should be C_TOKEN_VEC from omp::decl attribute.  If it contains
   28979              :    a threadprivate, groupprivate, allocate or declare target directive,
   28980              :    return true and parse it for DECL.  */
   28981              : 
   28982              : bool
   28983           43 : c_maybe_parse_omp_decl (tree decl, tree d)
   28984              : {
   28985           43 :   gcc_assert (TREE_CODE (d) == C_TOKEN_VEC);
   28986           43 :   vec<c_token, va_gc> *toks = C_TOKEN_VEC_TOKENS (d);
   28987           43 :   c_token *first = toks->address ();
   28988           43 :   c_token *last = first + toks->length ();
   28989           43 :   const char *directive[3] = {};
   28990          119 :   for (int j = 0; j < 3; j++)
   28991              :     {
   28992          107 :       tree id = NULL_TREE;
   28993          107 :       if (first + j == last)
   28994              :         break;
   28995           86 :       if (first[j].type == CPP_NAME)
   28996           76 :         id = first[j].value;
   28997           10 :       else if (first[j].type == CPP_KEYWORD)
   28998            0 :         id = ridpointers[(int) first[j].keyword];
   28999              :       else
   29000              :         break;
   29001           76 :       directive[j] = IDENTIFIER_POINTER (id);
   29002              :     }
   29003           43 :   const c_omp_directive *dir = NULL;
   29004           43 :   if (directive[0])
   29005           43 :     dir = c_omp_categorize_directive (directive[0], directive[1],
   29006              :                                       directive[2]);
   29007           43 :   if (dir == NULL)
   29008              :     {
   29009            0 :       error_at (first->location,
   29010              :                 "unknown OpenMP directive name in "
   29011              :                 "%qs attribute argument", "omp::decl");
   29012            0 :       return false;
   29013              :     }
   29014           43 :   if (dir->id != PRAGMA_OMP_THREADPRIVATE
   29015           28 :       && dir->id != PRAGMA_OMP_GROUPPRIVATE
   29016           23 :       && dir->id != PRAGMA_OMP_ALLOCATE
   29017           21 :       && (dir->id != PRAGMA_OMP_DECLARE
   29018           21 :           || strcmp (directive[1], "target") != 0))
   29019              :     return false;
   29020              : 
   29021           43 :   if (!flag_openmp && !dir->simd)
   29022              :     return true;
   29023              : 
   29024           43 :   c_parser *parser = the_parser;
   29025           43 :   unsigned int tokens_avail = parser->tokens_avail;
   29026           43 :   gcc_assert (parser->tokens == &parser->tokens_buf[0]);
   29027           43 :   toks = NULL;
   29028           43 :   vec_safe_reserve (toks, last - first + 2, true);
   29029           43 :   c_token tok = {};
   29030           43 :   tok.type = CPP_PRAGMA;
   29031           43 :   tok.keyword = RID_MAX;
   29032           43 :   tok.pragma_kind = pragma_kind (dir->id);
   29033           43 :   tok.location = first->location;
   29034           43 :   toks->quick_push (tok);
   29035          201 :   while (++first < last)
   29036          115 :     toks->quick_push (*first);
   29037           43 :   tok = {};
   29038           43 :   tok.type = CPP_PRAGMA_EOL;
   29039           43 :   tok.keyword = RID_MAX;
   29040           43 :   tok.location = last[-1].location;
   29041           43 :   toks->quick_push (tok);
   29042           43 :   tok = {};
   29043           43 :   tok.type = CPP_EOF;
   29044           43 :   tok.keyword = RID_MAX;
   29045           43 :   tok.location = last[-1].location;
   29046           43 :   toks->quick_push (tok);
   29047           43 :   parser->in_omp_decl_attribute = decl;
   29048           43 :   gcc_assert (!parser->in_omp_attribute_pragma);
   29049           43 :   parser->in_omp_attribute_pragma = ggc_alloc<omp_attribute_pragma_state> ();
   29050           43 :   parser->in_omp_attribute_pragma->token_vec = toks;
   29051           43 :   parser->in_omp_attribute_pragma->save_tokens = parser->tokens;
   29052           43 :   parser->in_omp_attribute_pragma->save_tokens_avail = tokens_avail;
   29053           43 :   parser->tokens = toks->address ();
   29054           43 :   parser->tokens_avail = toks->length ();
   29055           43 :   c_parser_pragma (parser, pragma_external, NULL, NULL_TREE);
   29056           43 :   parser->in_omp_decl_attribute = NULL_TREE;
   29057           43 :   return true;
   29058              : }
   29059              : 
   29060              : /* OpenMP 4.0:
   29061              :    # pragma omp declare target new-line
   29062              :    declarations and definitions
   29063              :    # pragma omp end declare target new-line
   29064              : 
   29065              :    OpenMP 4.5:
   29066              :    # pragma omp declare target ( extended-list ) new-line
   29067              : 
   29068              :    # pragma omp declare target declare-target-clauses[seq] new-line  */
   29069              : 
   29070              : #define OMP_DECLARE_TARGET_CLAUSE_MASK                          \
   29071              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TO)             \
   29072              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ENTER)  \
   29073              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINK)           \
   29074              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LOCAL)  \
   29075              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE_TYPE)    \
   29076              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_INDIRECT))
   29077              : 
   29078              : static void
   29079          298 : c_parser_omp_declare_target (c_parser *parser)
   29080              : {
   29081          298 :   tree clauses = NULL_TREE;
   29082          298 :   int device_type = 0;
   29083          298 :   bool indirect = false;
   29084          298 :   bool only_device_type_or_indirect = true;
   29085          298 :   if (flag_openmp)
   29086          298 :     omp_requires_mask
   29087          298 :       = (enum omp_requires) (omp_requires_mask | OMP_REQUIRES_TARGET_USED);
   29088          298 :   if (c_parser_next_token_is (parser, CPP_NAME)
   29089          424 :       || (c_parser_next_token_is (parser, CPP_COMMA)
   29090            5 :           && c_parser_peek_2nd_token (parser)->type == CPP_NAME))
   29091          176 :     clauses = c_parser_omp_all_clauses (parser, OMP_DECLARE_TARGET_CLAUSE_MASK,
   29092              :                                         "#pragma omp declare target");
   29093          122 :   else if (parser->in_omp_decl_attribute
   29094          238 :            || c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   29095              :     {
   29096           20 :       clauses = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ENTER,
   29097              :                                               clauses);
   29098           20 :       clauses = c_finish_omp_clauses (clauses, C_ORT_OMP);
   29099           20 :       c_parser_skip_to_pragma_eol (parser);
   29100              :     }
   29101              :   else
   29102              :     {
   29103          102 :       warning_at (c_parser_peek_token (parser)->location,
   29104          102 :                   OPT_Wdeprecated_openmp,
   29105              :                   "use of %<omp declare target%> as a synonym for "
   29106              :                   "%<omp begin declare target%> has been deprecated since "
   29107              :                   "OpenMP 5.2");
   29108          102 :       bool attr_syntax = parser->in_omp_attribute_pragma != NULL;
   29109          102 :       c_parser_skip_to_pragma_eol (parser);
   29110          102 :       c_omp_declare_target_attr attr = { attr_syntax, -1, 0 };
   29111          102 :       vec_safe_push (current_omp_declare_target_attribute, attr);
   29112          102 :       return;
   29113              :     }
   29114          496 :   for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
   29115              :     {
   29116          300 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEVICE_TYPE)
   29117           27 :         device_type |= OMP_CLAUSE_DEVICE_TYPE_KIND (c);
   29118          300 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_INDIRECT)
   29119           16 :         indirect |= !integer_zerop (OMP_CLAUSE_INDIRECT_EXPR (c));
   29120              :     }
   29121          496 :   for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
   29122              :     {
   29123          300 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEVICE_TYPE
   29124          300 :           || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_INDIRECT)
   29125           43 :         continue;
   29126          257 :       tree t = OMP_CLAUSE_DECL (c), id;
   29127          257 :       tree at1 = lookup_attribute ("omp declare target", DECL_ATTRIBUTES (t));
   29128          257 :       tree at2 = lookup_attribute ("omp declare target link",
   29129          257 :                                    DECL_ATTRIBUTES (t));
   29130          257 :       only_device_type_or_indirect = false;
   29131          257 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINK)
   29132              :         {
   29133           34 :           id = get_identifier ("omp declare target link");
   29134           34 :           std::swap (at1, at2);
   29135              :         }
   29136              :       else
   29137          223 :         id = get_identifier ("omp declare target");
   29138          257 :       if (at2)
   29139              :         {
   29140            8 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   29141            3 :             error_at (OMP_CLAUSE_LOCATION (c),
   29142              :                       "%qD specified both in declare target %<link%> and %qs"
   29143            3 :                       " clauses", t, OMP_CLAUSE_ENTER_TO (c) ? "to" : "enter");
   29144            5 :           else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LOCAL
   29145            5 :                    || value_member (get_identifier ("local"), TREE_VALUE (at2)))
   29146            2 :             error_at (OMP_CLAUSE_LOCATION (c),
   29147              :                       "%qD specified both in declare target %<link%> and "
   29148              :                       "%<local%> clauses", t);
   29149              :           else
   29150            3 :             error_at (OMP_CLAUSE_LOCATION (c),
   29151              :                       "%qD specified both in declare target %<link%> and "
   29152              :                       "%<to%> or %<enter%> clauses", t);
   29153            8 :           continue;
   29154              :         }
   29155          249 :       if (!at1)
   29156              :         {
   29157          216 :           DECL_ATTRIBUTES (t) = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (t));
   29158          216 :           if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LOCAL)
   29159            7 :             TREE_VALUE (DECL_ATTRIBUTES (t))
   29160           14 :               = tree_cons (NULL_TREE, get_identifier ("local"),
   29161            7 :                            TREE_VALUE (DECL_ATTRIBUTES (t)));
   29162              : 
   29163          216 :           if (TREE_CODE (t) != FUNCTION_DECL && !is_global_var (t))
   29164            1 :             continue;
   29165              : 
   29166          215 :           symtab_node *node = symtab_node::get (t);
   29167          215 :           if (node != NULL)
   29168              :             {
   29169          167 :               node->offloadable = 1;
   29170          167 :               if (ENABLE_OFFLOADING)
   29171              :                 {
   29172              :                   g->have_offload = true;
   29173              :                   if (is_a <varpool_node *> (node)
   29174              :                       && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_LOCAL)
   29175              :                     vec_safe_push (offload_vars, t);
   29176              :                 }
   29177              :             }
   29178              :         }
   29179              :       else
   29180              :         {
   29181           33 :           bool saw_local = value_member (get_identifier ("local"),
   29182           33 :                                          TREE_VALUE (at1));
   29183           35 :           if (saw_local && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
   29184              :             {
   29185            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   29186              :                         "%qD specified both in declare target %<local%> and "
   29187              :                         "%qs clauses", t,
   29188            2 :                         OMP_CLAUSE_ENTER_TO (c) ? "to" : "enter");
   29189            2 :               continue;
   29190              :             }
   29191           62 :           else if (!saw_local && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LOCAL)
   29192              :             {
   29193            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   29194              :                         "%qD specified both in declare target %<local%> and "
   29195              :                         "%<to%> or %<enter%> clauses", t);
   29196            2 :               continue;
   29197              :             }
   29198              :         }
   29199          244 :       if (TREE_CODE (t) != FUNCTION_DECL)
   29200          162 :         continue;
   29201           82 :       if ((device_type & OMP_CLAUSE_DEVICE_TYPE_HOST) != 0)
   29202              :         {
   29203           13 :           tree at3 = lookup_attribute ("omp declare target host",
   29204           13 :                                        DECL_ATTRIBUTES (t));
   29205           13 :           if (at3 == NULL_TREE)
   29206              :             {
   29207           11 :               id = get_identifier ("omp declare target host");
   29208           11 :               DECL_ATTRIBUTES (t)
   29209           22 :                 = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (t));
   29210              :             }
   29211              :         }
   29212           82 :       if ((device_type & OMP_CLAUSE_DEVICE_TYPE_NOHOST) != 0)
   29213              :         {
   29214           13 :           tree at3 = lookup_attribute ("omp declare target nohost",
   29215           13 :                                        DECL_ATTRIBUTES (t));
   29216           13 :           if (at3 == NULL_TREE)
   29217              :             {
   29218           11 :               id = get_identifier ("omp declare target nohost");
   29219           11 :               DECL_ATTRIBUTES (t)
   29220           22 :                 = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (t));
   29221              :             }
   29222              :         }
   29223           82 :       if (indirect)
   29224              :         {
   29225            9 :           tree at4 = lookup_attribute ("omp declare target indirect",
   29226            9 :                                        DECL_ATTRIBUTES (t));
   29227            9 :           if (at4 == NULL_TREE)
   29228              :             {
   29229            9 :               id = get_identifier ("omp declare target indirect");
   29230            9 :               DECL_ATTRIBUTES (t)
   29231           18 :                 = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (t));
   29232              :             }
   29233              :         }
   29234              :     }
   29235          196 :   if ((device_type || indirect) && only_device_type_or_indirect)
   29236            3 :     error_at (OMP_CLAUSE_LOCATION (clauses),
   29237              :               "directive with only %<device_type%> or %<indirect%> clauses");
   29238          196 :   if (indirect && device_type && device_type != OMP_CLAUSE_DEVICE_TYPE_ANY)
   29239            1 :     error_at (OMP_CLAUSE_LOCATION (clauses),
   29240              :               "%<device_type%> clause must specify 'any' when used with "
   29241              :               "an %<indirect%> clause");
   29242              : }
   29243              : 
   29244              : /* OpenMP 5.1
   29245              :    #pragma omp begin assumes clauses[optseq] new-line
   29246              : 
   29247              :    #pragma omp begin declare target clauses[optseq] new-line
   29248              : 
   29249              :    #pragma omp begin declare variant match (context-selector) new-line  */
   29250              : 
   29251              : #define OMP_BEGIN_DECLARE_TARGET_CLAUSE_MASK                    \
   29252              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE_TYPE)    \
   29253              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_INDIRECT))
   29254              : 
   29255              : static void
   29256          141 : c_parser_omp_begin (c_parser *parser)
   29257              : {
   29258          141 :   const char *p = "";
   29259          141 :   c_parser_consume_pragma (parser);
   29260          141 :   if (c_parser_next_token_is (parser, CPP_NAME))
   29261          141 :     p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   29262          141 :   if (strcmp (p, "declare") == 0)
   29263              :     {
   29264           95 :       c_parser_consume_token (parser);
   29265           95 :       p = "";
   29266           95 :       if (c_parser_next_token_is (parser, CPP_NAME))
   29267           95 :         p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   29268           95 :       if (strcmp (p, "target") == 0)
   29269              :         {
   29270           63 :           c_parser_consume_token (parser);
   29271           63 :           bool attr_syntax = parser->in_omp_attribute_pragma != NULL;
   29272           63 :           tree clauses
   29273           63 :             = c_parser_omp_all_clauses (parser,
   29274           63 :                                         OMP_BEGIN_DECLARE_TARGET_CLAUSE_MASK,
   29275              :                                         "#pragma omp begin declare target");
   29276           63 :           int device_type = 0;
   29277           63 :           int indirect = 0;
   29278          150 :           for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
   29279              :             {
   29280           24 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEVICE_TYPE)
   29281           15 :                 device_type |= OMP_CLAUSE_DEVICE_TYPE_KIND (c);
   29282           24 :               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_INDIRECT)
   29283            9 :                 indirect |= !integer_zerop (OMP_CLAUSE_INDIRECT_EXPR (c));
   29284              :             }
   29285           63 :           c_omp_declare_target_attr attr = { attr_syntax, device_type,
   29286           63 :                                              indirect };
   29287           63 :           vec_safe_push (current_omp_declare_target_attribute, attr);
   29288              :         }
   29289           32 :       else if (strcmp (p, "variant") == 0)
   29290              :         {
   29291           32 :           c_parser_consume_token (parser);
   29292           32 :           const char *clause = "";
   29293           32 :           matching_parens parens;
   29294           32 :           location_t match_loc = c_parser_peek_token (parser)->location;
   29295           32 :           if (c_parser_next_token_is (parser, CPP_COMMA))
   29296            1 :             c_parser_consume_token (parser);
   29297           32 :           if (c_parser_next_token_is (parser, CPP_NAME))
   29298              :             {
   29299           32 :               tree id = c_parser_peek_token (parser)->value;
   29300           32 :               clause = IDENTIFIER_POINTER (id);
   29301              :             }
   29302           32 :           if (strcmp (clause, "match") != 0)
   29303              :             {
   29304            0 :               c_parser_error (parser, "expected %<match%>");
   29305            0 :               c_parser_skip_to_pragma_eol (parser);
   29306            6 :               return;
   29307              :             }
   29308              : 
   29309           32 :           c_parser_consume_token (parser);
   29310              : 
   29311           32 :           if (!parens.require_open (parser))
   29312              :             {
   29313            0 :               c_parser_skip_to_pragma_eol (parser, false);
   29314            0 :               return;
   29315              :             }
   29316              : 
   29317           32 :           tree ctx =
   29318           32 :             c_parser_omp_context_selector_specification (parser, NULL_TREE);
   29319           32 :           if (ctx != error_mark_node)
   29320           30 :             ctx = omp_check_context_selector (match_loc, ctx,
   29321              :                                               OMP_CTX_BEGIN_DECLARE_VARIANT);
   29322              : 
   29323           32 :           if (ctx != error_mark_node
   29324           32 :               && !vec_safe_is_empty (current_omp_declare_variant_attribute))
   29325              :             {
   29326            7 :               c_omp_declare_variant_attr a
   29327            7 :                 = current_omp_declare_variant_attribute->last ();
   29328            7 :               tree outer_ctx = a.selector;
   29329            7 :               ctx = omp_merge_context_selectors (match_loc, outer_ctx, ctx,
   29330              :                                                  OMP_CTX_BEGIN_DECLARE_VARIANT);
   29331              :             }
   29332              : 
   29333           32 :           if (ctx == error_mark_node
   29334           32 :               || !omp_context_selector_matches (ctx, NULL_TREE, false, true))
   29335              :             {
   29336              :               /* The context is either invalid or cannot possibly match.
   29337              :                  In the latter case the spec says all code in the begin/end
   29338              :                  sequence will be elided.  In the former case we'll get bogus
   29339              :                  errors from trying to parse it without a valid context to
   29340              :                  use for name-mangling, so elide that too.  */
   29341            6 :               c_parser_skip_to_pragma_eol (parser, false);
   29342            6 :               c_parser_skip_to_pragma_omp_end_declare_variant (parser);
   29343            6 :               return;
   29344              :             }
   29345              :           else
   29346              :             {
   29347           26 :               bool attr_syntax = parser->in_omp_attribute_pragma != NULL;
   29348           26 :               c_omp_declare_variant_attr a = { attr_syntax, ctx };
   29349           26 :               vec_safe_push (current_omp_declare_variant_attribute, a);
   29350              :             }
   29351              : 
   29352           26 :           parens.require_close (parser);
   29353           26 :           c_parser_skip_to_pragma_eol (parser);
   29354              :         }
   29355              :       else
   29356              :         {
   29357            0 :           c_parser_error (parser, "expected %<target%> or %<variant%>");
   29358            0 :           c_parser_skip_to_pragma_eol (parser, false);
   29359              :         }
   29360              :     }
   29361           46 :   else if (strcmp (p, "assumes") == 0)
   29362              :     {
   29363           46 :       c_parser_consume_token (parser);
   29364           46 :       bool attr_syntax = parser->in_omp_attribute_pragma != NULL;
   29365           46 :       c_parser_omp_assumption_clauses (parser, false);
   29366           46 :       struct c_omp_begin_assumes_data a = { attr_syntax };
   29367           46 :       vec_safe_push (current_omp_begin_assumes, a);
   29368              :     }
   29369              :   else
   29370              :     {
   29371            0 :       c_parser_error (parser, "expected %<declare target%>, "
   29372              :                       "%<declare variant%>, or %<assumes%>");
   29373            0 :       c_parser_skip_to_pragma_eol (parser);
   29374              :     }
   29375              : }
   29376              : 
   29377              : /* OpenMP 4.0
   29378              :    #pragma omp end declare target
   29379              : 
   29380              :    OpenMP 5.1
   29381              :    #pragma omp end assumes
   29382              :    #pragma omp end declare variant  */
   29383              : 
   29384              : static void
   29385          235 : c_parser_omp_end (c_parser *parser)
   29386              : {
   29387          235 :   location_t loc = c_parser_peek_token (parser)->location;
   29388          235 :   const char *p = "";
   29389          235 :   c_parser_consume_pragma (parser);
   29390          235 :   if (c_parser_next_token_is (parser, CPP_NAME))
   29391          235 :     p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   29392          235 :   if (strcmp (p, "declare") == 0)
   29393              :     {
   29394          189 :       c_parser_consume_token (parser);
   29395          189 :       p = "";
   29396          189 :       if (c_parser_next_token_is (parser, CPP_NAME))
   29397          189 :         p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   29398          189 :       if (strcmp (p, "target") == 0)
   29399              :         {
   29400          163 :           c_parser_consume_token (parser);
   29401          163 :           bool attr_syntax = parser->in_omp_attribute_pragma != NULL;
   29402          163 :           c_parser_skip_to_pragma_eol (parser);
   29403          163 :           if (!vec_safe_length (current_omp_declare_target_attribute))
   29404            2 :             error_at (loc, "%<#pragma omp end declare target%> without "
   29405              :                       "corresponding %<#pragma omp declare target%> or "
   29406              :                       "%<#pragma omp begin declare target%>");
   29407              :           else
   29408              :             {
   29409          161 :               c_omp_declare_target_attr
   29410          161 :                 a = current_omp_declare_target_attribute->pop ();
   29411          161 :               if (a.attr_syntax != attr_syntax)
   29412              :                 {
   29413           16 :                   if (a.attr_syntax)
   29414           12 :                     error_at (loc,
   29415              :                               "%qs in attribute syntax terminated "
   29416              :                               "with %qs in pragma syntax",
   29417              :                               a.device_type >= 0 ? "begin declare target"
   29418              :                                                  : "declare target",
   29419              :                               "end declare target");
   29420              :                   else
   29421           12 :                     error_at (loc,
   29422              :                               "%qs in pragma syntax terminated "
   29423              :                               "with %qs in attribute syntax",
   29424              :                               a.device_type >= 0 ? "begin declare target"
   29425              :                                                  : "declare target",
   29426              :                               "end declare target");
   29427              :                 }
   29428              :             }
   29429              :         }
   29430           26 :       else if (strcmp (p, "variant") == 0)
   29431              :         {
   29432           26 :           c_parser_consume_token (parser);
   29433           26 :           bool attr_syntax = parser->in_omp_attribute_pragma != NULL;
   29434           26 :           c_parser_skip_to_pragma_eol (parser);
   29435           26 :           if (!vec_safe_length (current_omp_declare_variant_attribute))
   29436            0 :             error_at (loc, "%<#pragma omp end declare variant%> without "
   29437              :                       "corresponding %<#pragma omp begin declare variant%>");
   29438              :           else
   29439              :             {
   29440           26 :               c_omp_declare_variant_attr
   29441           26 :                 a = current_omp_declare_variant_attribute->pop ();
   29442           26 :               if (a.attr_syntax != attr_syntax)
   29443              :                 {
   29444            2 :                   if (a.attr_syntax)
   29445            1 :                     error_at (loc,
   29446              :                               "%<begin declare variant%> in attribute syntax "
   29447              :                               "terminated with "
   29448              :                               "%<end declare variant%> in pragma syntax");
   29449              :                   else
   29450            1 :                     error_at (loc,
   29451              :                               "%<begin declare variant%> in pragma syntax "
   29452              :                               "terminated with "
   29453              :                               "%<end declare variant%> in attribute syntax");
   29454              :                 }
   29455              :             }
   29456              :         }
   29457              :       else
   29458              :         {
   29459            0 :           c_parser_error (parser, "expected %<target%> or %<variant%>");
   29460            0 :           c_parser_skip_to_pragma_eol (parser);
   29461            0 :           return;
   29462              :         }
   29463              :     }
   29464           46 :   else if (strcmp (p, "assumes") == 0)
   29465              :     {
   29466           46 :       c_parser_consume_token (parser);
   29467           46 :       bool attr_syntax = parser->in_omp_attribute_pragma != NULL;
   29468           46 :       c_parser_skip_to_pragma_eol (parser);
   29469           46 :       if (!vec_safe_length (current_omp_begin_assumes))
   29470            1 :         error_at (loc, "%qs without corresponding %qs",
   29471              :                   "#pragma omp end assumes", "#pragma omp begin assumes");
   29472              :       else
   29473              :         {
   29474           45 :           c_omp_begin_assumes_data
   29475           45 :             a = current_omp_begin_assumes->pop ();
   29476           45 :           if (a.attr_syntax != attr_syntax)
   29477              :             {
   29478            8 :               if (a.attr_syntax)
   29479            4 :                 error_at (loc,
   29480              :                           "%qs in attribute syntax terminated "
   29481              :                           "with %qs in pragma syntax",
   29482              :                           "begin assumes", "end assumes");
   29483              :               else
   29484            4 :                 error_at (loc,
   29485              :                           "%qs in pragma syntax terminated "
   29486              :                           "with %qs in attribute syntax",
   29487              :                           "begin assumes", "end assumes");
   29488              :             }
   29489              :         }
   29490              :     }
   29491              :   else
   29492              :     {
   29493            0 :       c_parser_error (parser, "expected %<declare%> or %<assumes%>");
   29494            0 :       c_parser_skip_to_pragma_eol (parser);
   29495              :     }
   29496              : }
   29497              : 
   29498              : /* OpenMP 5.0
   29499              :    #pragma omp declare mapper ([mapper-identifier :] type var) \
   29500              :                               [clause [ [,] clause ] ... ] new-line  */
   29501              : 
   29502              : static void
   29503           77 : c_parser_omp_declare_mapper (c_parser *parser, enum pragma_context context)
   29504              : {
   29505           77 :   tree type, mapper_name = NULL_TREE, var = NULL_TREE, stmt, stmtlist;
   29506           77 :   tree maplist = NULL_TREE, mapper_id, mapper_decl, t;
   29507           77 :   c_token *token;
   29508              : 
   29509           77 :   if (context == pragma_struct || context == pragma_param)
   29510              :     {
   29511            2 :       error ("%<#pragma omp declare mapper%> not at file or block scope");
   29512            2 :       goto fail;
   29513              :     }
   29514              : 
   29515           75 :   if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
   29516            0 :     goto fail;
   29517              : 
   29518           75 :   token = c_parser_peek_token (parser);
   29519              : 
   29520           75 :   if (c_parser_peek_2nd_token (parser)->type == CPP_COLON)
   29521              :     {
   29522           24 :       switch (token->type)
   29523              :         {
   29524           17 :         case CPP_NAME:
   29525           17 :           mapper_name = token->value;
   29526           17 :           c_parser_consume_token (parser);
   29527           17 :           break;
   29528            7 :         case CPP_KEYWORD:
   29529            7 :           if (token->keyword == RID_DEFAULT)
   29530              :             {
   29531            6 :               mapper_name = NULL_TREE;
   29532            6 :               c_parser_consume_token (parser);
   29533            6 :               break;
   29534              :             }
   29535              :           /* Fallthrough.  */
   29536            1 :         default:
   29537            1 :           error_at (token->location, "expected identifier or %<default%>");
   29538            1 :           c_parser_skip_to_pragma_eol (parser, false);
   29539            1 :           return;
   29540              :         }
   29541              : 
   29542           23 :       if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   29543            0 :         goto fail;
   29544              :     }
   29545              : 
   29546           74 :   mapper_id = c_omp_mapper_id (mapper_name);
   29547           74 :   mapper_decl = c_omp_mapper_decl (mapper_id);
   29548              : 
   29549           74 :   {
   29550           74 :     location_t loc = c_parser_peek_token (parser)->location;
   29551           74 :     struct c_type_name *ctype = c_parser_type_name (parser);
   29552           74 :     type = groktypename (ctype, NULL, NULL);
   29553           74 :     if (type == error_mark_node)
   29554            3 :       goto fail;
   29555           71 :     if (!RECORD_OR_UNION_TYPE_P (type))
   29556              :       {
   29557            5 :         error_at (loc, "%qT is not a struct or union type in "
   29558              :                   "%<#pragma omp declare mapper%>", type);
   29559            5 :         c_parser_skip_to_pragma_eol (parser, false);
   29560            5 :         return;
   29561              :       }
   29562           76 :     for (tree t = DECL_INITIAL (mapper_decl); t; t = TREE_CHAIN (t))
   29563           17 :       if (comptypes (TREE_PURPOSE (t), type))
   29564              :         {
   29565            7 :           error_at (loc, "redeclaration of %qs %<#pragma omp declare "
   29566            7 :                     "mapper%> for type %qT", IDENTIFIER_POINTER (mapper_id)
   29567              :                       + sizeof ("omp declare mapper ") - 1,
   29568              :                     type);
   29569            7 :           tree prevmapper = TREE_VALUE (t);
   29570              :           /* Hmm, this location might not be very accurate.  */
   29571            7 :           location_t ploc
   29572            7 :             = DECL_SOURCE_LOCATION (OMP_DECLARE_MAPPER_DECL (prevmapper));
   29573            7 :           inform (ploc, "%<#pragma omp declare mapper%> "
   29574              :                         "previously declared here");
   29575            7 :           c_parser_skip_to_pragma_eol (parser, false);
   29576            7 :           return;
   29577              :         }
   29578              :   }
   29579              : 
   29580           59 :   token = c_parser_peek_token (parser);
   29581           59 :   if (token->type == CPP_NAME)
   29582              :     {
   29583           57 :       var = build_decl (token->location, VAR_DECL, token->value, type);
   29584           57 :       c_parser_consume_token (parser);
   29585           57 :       DECL_ARTIFICIAL (var) = 1;
   29586              :     }
   29587              :   else
   29588              :     {
   29589            2 :       error_at (token->location, "expected identifier");
   29590            2 :       goto fail;
   29591              :     }
   29592              : 
   29593           57 :   if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
   29594            0 :     goto fail;
   29595              : 
   29596           57 :   push_scope ();
   29597           57 :   stmtlist = push_stmt_list ();
   29598           57 :   pushdecl (var);
   29599           57 :   DECL_CONTEXT (var) = current_function_decl;
   29600              : 
   29601          146 :   while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   29602              :     {
   29603           90 :       location_t here;
   29604           90 :       pragma_omp_clause c_kind;
   29605           90 :       here = c_parser_peek_token (parser)->location;
   29606           90 :       c_kind = c_parser_omp_clause_name (parser);
   29607           90 :       if (c_kind != PRAGMA_OMP_CLAUSE_MAP)
   29608              :         {
   29609            1 :           error_at (here, "unexpected clause");
   29610            1 :           goto fail;
   29611              :         }
   29612           89 :       maplist = c_parser_omp_clause_map (parser, maplist, true);
   29613              :     }
   29614              : 
   29615           56 :   if (maplist == NULL_TREE)
   29616              :     {
   29617            1 :       error_at (input_location, "missing %<map%> clause");
   29618            1 :       goto fail;
   29619              :     }
   29620              :   tree list;
   29621           61 :   for (list = maplist; list; list = OMP_CLAUSE_CHAIN (list))
   29622              :     {
   29623           57 :       tree dvar = OMP_CLAUSE_DECL (list);
   29624          133 :       while (!DECL_P (dvar) && TREE_OPERAND_LENGTH (dvar))
   29625           76 :         dvar = TREE_OPERAND (dvar, 0);
   29626           57 :       if (dvar == var)
   29627              :         break;
   29628              :     }
   29629           55 :   if (!list)
   29630            4 :     error_at (input_location, "at least one %<map%> clause must map %qD or an "
   29631              :                               "element of it", var);
   29632              : 
   29633           55 :   stmt = make_node (OMP_DECLARE_MAPPER);
   29634           55 :   TREE_TYPE (stmt) = type;
   29635           55 :   OMP_DECLARE_MAPPER_ID (stmt) = mapper_name;
   29636           55 :   OMP_DECLARE_MAPPER_DECL (stmt) = var;
   29637           55 :   OMP_DECLARE_MAPPER_CLAUSES (stmt) = maplist;
   29638              : 
   29639           55 :   add_stmt (stmt);
   29640              : 
   29641           55 :   pop_stmt_list (stmtlist);
   29642           55 :   pop_scope ();
   29643              : 
   29644           55 :   c_parser_skip_to_pragma_eol (parser);
   29645              : 
   29646           55 :   t = tree_cons (type, stmt, DECL_INITIAL (mapper_decl));
   29647           55 :   DECL_INITIAL (mapper_decl) = t;
   29648              : 
   29649           55 :   return;
   29650              : 
   29651            9 :  fail:
   29652            9 :   c_parser_skip_to_pragma_eol (parser);
   29653              : }
   29654              : 
   29655              : /* OpenMP 4.0
   29656              :    #pragma omp declare reduction (reduction-id : typename-list : expression) \
   29657              :       initializer-clause[opt] new-line
   29658              : 
   29659              :    initializer-clause:
   29660              :       initializer (omp_priv = initializer)
   29661              :       initializer (function-name (argument-list))  */
   29662              : 
   29663              : static void
   29664          167 : c_parser_omp_declare_reduction (c_parser *parser, enum pragma_context context)
   29665              : {
   29666          167 :   unsigned int tokens_avail = 0, i;
   29667          167 :   c_token *saved_tokens = NULL;
   29668          167 :   vec<tree> types = vNULL;
   29669          167 :   vec<c_token> clauses = vNULL;
   29670          167 :   enum tree_code reduc_code = ERROR_MARK;
   29671          167 :   tree reduc_id = NULL_TREE;
   29672          167 :   tree type;
   29673          167 :   location_t rloc = c_parser_peek_token (parser)->location;
   29674              : 
   29675          167 :   if (context == pragma_struct || context == pragma_param)
   29676              :     {
   29677            2 :       error ("%<#pragma omp declare reduction%> not at file or block scope");
   29678            2 :       goto fail;
   29679              :     }
   29680              : 
   29681          165 :   if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
   29682            1 :     goto fail;
   29683              : 
   29684          164 :   switch (c_parser_peek_token (parser)->type)
   29685              :     {
   29686              :     case CPP_PLUS:
   29687              :       reduc_code = PLUS_EXPR;
   29688              :       break;
   29689           14 :     case CPP_MULT:
   29690           14 :       reduc_code = MULT_EXPR;
   29691           14 :       break;
   29692            0 :     case CPP_MINUS:
   29693            0 :       reduc_code = MINUS_EXPR;
   29694            0 :       break;
   29695            4 :     case CPP_AND:
   29696            4 :       reduc_code = BIT_AND_EXPR;
   29697            4 :       break;
   29698            0 :     case CPP_XOR:
   29699            0 :       reduc_code = BIT_XOR_EXPR;
   29700            0 :       break;
   29701           10 :     case CPP_OR:
   29702           10 :       reduc_code = BIT_IOR_EXPR;
   29703           10 :       break;
   29704            0 :     case CPP_AND_AND:
   29705            0 :       reduc_code = TRUTH_ANDIF_EXPR;
   29706            0 :       break;
   29707            0 :     case CPP_OR_OR:
   29708            0 :       reduc_code = TRUTH_ORIF_EXPR;
   29709            0 :       break;
   29710           91 :     case CPP_NAME:
   29711           91 :       const char *p;
   29712           91 :       p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   29713           91 :       if (strcmp (p, "min") == 0)
   29714              :         {
   29715              :           reduc_code = MIN_EXPR;
   29716              :           break;
   29717              :         }
   29718           85 :       if (strcmp (p, "max") == 0)
   29719              :         {
   29720              :           reduc_code = MAX_EXPR;
   29721              :           break;
   29722              :         }
   29723           85 :       reduc_id = c_parser_peek_token (parser)->value;
   29724           85 :       break;
   29725            0 :     default:
   29726            0 :       c_parser_error (parser,
   29727              :                       "expected %<+%>, %<*%>, %<-%>, %<&%>, "
   29728              :                       "%<^%>, %<|%>, %<&&%>, %<||%> or identifier");
   29729            0 :       goto fail;
   29730              :     }
   29731              : 
   29732          164 :   tree orig_reduc_id, reduc_decl;
   29733          164 :   orig_reduc_id = reduc_id;
   29734          164 :   reduc_id = c_omp_reduction_id (reduc_code, reduc_id);
   29735          164 :   reduc_decl = c_omp_reduction_decl (reduc_id);
   29736          164 :   c_parser_consume_token (parser);
   29737              : 
   29738          164 :   if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
   29739            0 :     goto fail;
   29740              : 
   29741          168 :   while (true)
   29742              :     {
   29743          166 :       location_t loc = c_parser_peek_token (parser)->location;
   29744          166 :       struct c_type_name *ctype = c_parser_type_name (parser);
   29745          166 :       if (ctype != NULL)
   29746              :         {
   29747          166 :           type = groktypename (ctype, NULL, NULL);
   29748          166 :           if (type == error_mark_node)
   29749              :             ;
   29750          166 :           else if ((INTEGRAL_TYPE_P (type)
   29751          166 :                     || SCALAR_FLOAT_TYPE_P (type)
   29752           99 :                     || TREE_CODE (type) == COMPLEX_TYPE)
   29753           71 :                    && orig_reduc_id == NULL_TREE)
   29754            8 :             error_at (loc, "predeclared arithmetic type in "
   29755              :                            "%<#pragma omp declare reduction%>");
   29756          158 :           else if (TREE_CODE (type) == FUNCTION_TYPE
   29757          153 :                    || TREE_CODE (type) == ARRAY_TYPE)
   29758            8 :             error_at (loc, "function or array type in "
   29759              :                       "%<#pragma omp declare reduction%>");
   29760          150 :           else if (TYPE_ATOMIC (type))
   29761            1 :             error_at (loc, "%<_Atomic%> qualified type in "
   29762              :                            "%<#pragma omp declare reduction%>");
   29763          149 :           else if (TYPE_QUALS_NO_ADDR_SPACE (type))
   29764            8 :             error_at (loc, "const, volatile or restrict qualified type in "
   29765              :                            "%<#pragma omp declare reduction%>");
   29766              :           else
   29767              :             {
   29768          141 :               tree t;
   29769          203 :               for (t = DECL_INITIAL (reduc_decl); t; t = TREE_CHAIN (t))
   29770           66 :                 if (comptypes (TREE_PURPOSE (t), type))
   29771              :                   {
   29772            4 :                     error_at (loc, "redeclaration of %qs "
   29773              :                                    "%<#pragma omp declare reduction%> for "
   29774              :                                    "type %qT",
   29775            4 :                                    IDENTIFIER_POINTER (reduc_id)
   29776              :                                    + sizeof ("omp declare reduction ") - 1,
   29777              :                                    type);
   29778            4 :                     location_t ploc
   29779            4 :                       = DECL_SOURCE_LOCATION (TREE_VEC_ELT (TREE_VALUE (t),
   29780              :                                                             0));
   29781            4 :                     inform (ploc, "%<#pragma omp declare reduction%> "
   29782              :                                   "previously declared here");
   29783            4 :                     break;
   29784              :                   }
   29785            4 :               if (t == NULL_TREE)
   29786          137 :                 types.safe_push (type);
   29787              :             }
   29788          166 :           if (c_parser_next_token_is (parser, CPP_COMMA))
   29789            2 :             c_parser_consume_token (parser);
   29790              :           else
   29791              :             break;
   29792              :         }
   29793              :       else
   29794              :         break;
   29795            2 :     }
   29796              : 
   29797          164 :   if (!c_parser_require (parser, CPP_COLON, "expected %<:%>")
   29798          164 :       || types.is_empty ())
   29799              :     {
   29800           34 :      fail:
   29801           34 :       clauses.release ();
   29802           34 :       types.release ();
   29803          460 :       while (true)
   29804              :         {
   29805          247 :           c_token *token = c_parser_peek_token (parser);
   29806          247 :           if (token->type == CPP_EOF || token->type == CPP_PRAGMA_EOL)
   29807              :             break;
   29808          213 :           c_parser_consume_token (parser);
   29809          213 :         }
   29810           34 :       c_parser_skip_to_pragma_eol (parser);
   29811           34 :       return;
   29812              :     }
   29813              : 
   29814          135 :   if (types.length () > 1)
   29815              :     {
   29816           13 :       while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   29817              :         {
   29818           12 :           c_token *token = c_parser_peek_token (parser);
   29819           12 :           if (token->type == CPP_EOF)
   29820            0 :             goto fail;
   29821           12 :           clauses.safe_push (*token);
   29822           12 :           c_parser_consume_token (parser);
   29823              :         }
   29824            1 :       clauses.safe_push (*c_parser_peek_token (parser));
   29825            1 :       c_parser_skip_to_pragma_eol (parser);
   29826              : 
   29827              :       /* Make sure nothing tries to read past the end of the tokens.  */
   29828            1 :       c_token eof_token;
   29829            1 :       memset (&eof_token, 0, sizeof (eof_token));
   29830            1 :       eof_token.type = CPP_EOF;
   29831            1 :       clauses.safe_push (eof_token);
   29832            1 :       clauses.safe_push (eof_token);
   29833              :     }
   29834              : 
   29835          135 :   int errs = errorcount;
   29836          244 :   FOR_EACH_VEC_ELT (types, i, type)
   29837              :     {
   29838          137 :       saved_tokens = parser->tokens;
   29839          137 :       tokens_avail = parser->tokens_avail;
   29840          137 :       if (!clauses.is_empty ())
   29841              :         {
   29842            3 :           parser->tokens = clauses.address ();
   29843            3 :           parser->tokens_avail = clauses.length ();
   29844            3 :           parser->in_pragma = true;
   29845              :         }
   29846              : 
   29847          137 :       bool nested = current_function_decl != NULL_TREE;
   29848          137 :       if (nested)
   29849           27 :         c_push_function_context ();
   29850          137 :       tree fndecl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
   29851              :                                 reduc_id, default_function_type);
   29852          137 :       current_function_decl = fndecl;
   29853          137 :       allocate_struct_function (fndecl, true);
   29854          137 :       push_scope ();
   29855          137 :       tree stmt = push_stmt_list ();
   29856              :       /* Intentionally BUILTINS_LOCATION, so that -Wshadow doesn't
   29857              :          warn about these.  */
   29858          137 :       tree omp_out = build_decl (BUILTINS_LOCATION, VAR_DECL,
   29859              :                                  get_identifier ("omp_out"), type);
   29860          137 :       DECL_ARTIFICIAL (omp_out) = 1;
   29861          137 :       DECL_CONTEXT (omp_out) = fndecl;
   29862          137 :       pushdecl (omp_out);
   29863          137 :       tree omp_in = build_decl (BUILTINS_LOCATION, VAR_DECL,
   29864              :                                 get_identifier ("omp_in"), type);
   29865          137 :       DECL_ARTIFICIAL (omp_in) = 1;
   29866          137 :       DECL_CONTEXT (omp_in) = fndecl;
   29867          137 :       pushdecl (omp_in);
   29868          137 :       struct c_expr combiner = c_parser_expression (parser);
   29869          137 :       struct c_expr initializer;
   29870          137 :       tree omp_priv = NULL_TREE, omp_orig = NULL_TREE;
   29871          137 :       bool bad = false;
   29872          137 :       initializer.set_error ();
   29873          137 :       if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
   29874              :         bad = true;
   29875          137 :       else if (c_parser_next_token_is (parser, CPP_COMMA)
   29876          137 :                && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
   29877            2 :         c_parser_consume_token (parser);
   29878            2 :       if (!bad
   29879          137 :           && (c_parser_next_token_is (parser, CPP_NAME)
   29880           80 :               && strcmp (IDENTIFIER_POINTER
   29881              :                                 (c_parser_peek_token (parser)->value),
   29882              :                           "initializer") == 0))
   29883              :         {
   29884           80 :           c_parser_consume_token (parser);
   29885           80 :           pop_scope ();
   29886           80 :           push_scope ();
   29887           80 :           omp_priv = build_decl (BUILTINS_LOCATION, VAR_DECL,
   29888              :                                  get_identifier ("omp_priv"), type);
   29889           80 :           DECL_ARTIFICIAL (omp_priv) = 1;
   29890           80 :           DECL_INITIAL (omp_priv) = error_mark_node;
   29891           80 :           DECL_CONTEXT (omp_priv) = fndecl;
   29892           80 :           pushdecl (omp_priv);
   29893           80 :           omp_orig = build_decl (BUILTINS_LOCATION, VAR_DECL,
   29894              :                                  get_identifier ("omp_orig"), type);
   29895           80 :           DECL_ARTIFICIAL (omp_orig) = 1;
   29896           80 :           DECL_CONTEXT (omp_orig) = fndecl;
   29897           80 :           pushdecl (omp_orig);
   29898           80 :           if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
   29899              :             bad = true;
   29900           80 :           else if (!c_parser_next_token_is (parser, CPP_NAME))
   29901              :             {
   29902            0 :               c_parser_error (parser, "expected %<omp_priv%> or "
   29903              :                                       "function-name");
   29904            0 :               bad = true;
   29905              :             }
   29906           80 :           else if (strcmp (IDENTIFIER_POINTER
   29907              :                                 (c_parser_peek_token (parser)->value),
   29908              :                            "omp_priv") != 0)
   29909              :             {
   29910           20 :               if (c_parser_peek_2nd_token (parser)->type != CPP_OPEN_PAREN
   29911           20 :                   || c_parser_peek_token (parser)->id_kind != C_ID_ID)
   29912              :                 {
   29913            0 :                   c_parser_error (parser, "expected function-name %<(%>");
   29914            0 :                   bad = true;
   29915              :                 }
   29916              :               else
   29917           20 :                 initializer = c_parser_postfix_expression (parser);
   29918           20 :               if (initializer.value
   29919           20 :                   && TREE_CODE (initializer.value) == CALL_EXPR)
   29920              :                 {
   29921              :                   int j;
   29922              :                   tree c = initializer.value;
   29923           21 :                   for (j = 0; j < call_expr_nargs (c); j++)
   29924              :                     {
   29925           20 :                       tree a = CALL_EXPR_ARG (c, j);
   29926           20 :                       STRIP_NOPS (a);
   29927           20 :                       if (TREE_CODE (a) == ADDR_EXPR
   29928           20 :                           && TREE_OPERAND (a, 0) == omp_priv)
   29929              :                         break;
   29930              :                     }
   29931           20 :                   if (j == call_expr_nargs (c))
   29932            1 :                     error ("one of the initializer call arguments should be "
   29933              :                            "%<&omp_priv%>");
   29934              :                 }
   29935              :             }
   29936              :           else
   29937              :             {
   29938           60 :               c_parser_consume_token (parser);
   29939           60 :               if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
   29940              :                 bad = true;
   29941              :               else
   29942              :                 {
   29943           58 :                   tree st = push_stmt_list ();
   29944           58 :                   location_t loc = c_parser_peek_token (parser)->location;
   29945           58 :                   rich_location richloc (line_table, loc);
   29946           58 :                   start_init (omp_priv, NULL_TREE, false, false, &richloc);
   29947           58 :                   struct c_expr init = c_parser_initializer (parser, omp_priv);
   29948           58 :                   finish_init ();
   29949           58 :                   finish_decl (omp_priv, loc, init.value,
   29950              :                                init.original_type, NULL_TREE);
   29951           58 :                   pop_stmt_list (st);
   29952           58 :                 }
   29953              :             }
   29954            0 :           if (!bad
   29955           78 :               && !c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
   29956              :             bad = true;
   29957              :         }
   29958              : 
   29959          137 :       if (!bad)
   29960              :         {
   29961          135 :           c_parser_skip_to_pragma_eol (parser);
   29962              : 
   29963          192 :           tree t = tree_cons (type, make_tree_vec (omp_priv ? 6 : 3),
   29964          135 :                               DECL_INITIAL (reduc_decl));
   29965          135 :           DECL_INITIAL (reduc_decl) = t;
   29966          135 :           DECL_SOURCE_LOCATION (omp_out) = rloc;
   29967          135 :           TREE_VEC_ELT (TREE_VALUE (t), 0) = omp_out;
   29968          135 :           TREE_VEC_ELT (TREE_VALUE (t), 1) = omp_in;
   29969          135 :           TREE_VEC_ELT (TREE_VALUE (t), 2) = combiner.value;
   29970          135 :           walk_tree (&combiner.value, c_check_omp_declare_reduction_r,
   29971              :                      &TREE_VEC_ELT (TREE_VALUE (t), 0), NULL);
   29972          135 :           if (omp_priv)
   29973              :             {
   29974           78 :               DECL_SOURCE_LOCATION (omp_priv) = rloc;
   29975           78 :               TREE_VEC_ELT (TREE_VALUE (t), 3) = omp_priv;
   29976           78 :               TREE_VEC_ELT (TREE_VALUE (t), 4) = omp_orig;
   29977           78 :               TREE_VEC_ELT (TREE_VALUE (t), 5) = initializer.value;
   29978           78 :               walk_tree (&initializer.value, c_check_omp_declare_reduction_r,
   29979              :                          &TREE_VEC_ELT (TREE_VALUE (t), 3), NULL);
   29980           78 :               walk_tree (&DECL_INITIAL (omp_priv),
   29981              :                          c_check_omp_declare_reduction_r,
   29982              :                          &TREE_VEC_ELT (TREE_VALUE (t), 3), NULL);
   29983              :             }
   29984              :         }
   29985              : 
   29986          137 :       pop_stmt_list (stmt);
   29987          137 :       pop_scope ();
   29988          137 :       if (cfun->language != NULL)
   29989              :         {
   29990            0 :           ggc_free (cfun->language);
   29991            0 :           cfun->language = NULL;
   29992              :         }
   29993          137 :       set_cfun (NULL);
   29994          137 :       current_function_decl = NULL_TREE;
   29995          137 :       if (nested)
   29996           27 :         c_pop_function_context ();
   29997              : 
   29998          137 :       if (!clauses.is_empty ())
   29999              :         {
   30000            3 :           parser->tokens = saved_tokens;
   30001            3 :           parser->tokens_avail = tokens_avail;
   30002              :         }
   30003          137 :       if (bad)
   30004            2 :         goto fail;
   30005          135 :       if (errs != errorcount)
   30006              :         break;
   30007              :     }
   30008              : 
   30009          133 :   clauses.release ();
   30010          133 :   types.release ();
   30011              : }
   30012              : 
   30013              : /* OpenMP 4.0
   30014              :    #pragma omp declare simd declare-simd-clauses[optseq] new-line
   30015              :    #pragma omp declare reduction (reduction-id : typename-list : expression) \
   30016              :       initializer-clause[opt] new-line
   30017              :    #pragma omp declare target new-line
   30018              : 
   30019              :    OpenMP 5.0
   30020              :    #pragma omp declare variant (identifier) match (context-selector)
   30021              : 
   30022              :    OpenMP 5.1
   30023              :    #pragma omp declare variant (identifier) match (context-selector) \
   30024              :       adjust_args(adjust-op:argument-list)  */
   30025              : 
   30026              : static bool
   30027         1359 : c_parser_omp_declare (c_parser *parser, enum pragma_context context)
   30028              : {
   30029         1359 :   c_parser_consume_pragma (parser);
   30030         1359 :   if (c_parser_next_token_is (parser, CPP_NAME))
   30031              :     {
   30032         1359 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   30033         1359 :       if (strcmp (p, "simd") == 0)
   30034              :         {
   30035              :           /* c_parser_consume_token (parser); done in
   30036              :              c_parser_omp_declare_simd.  */
   30037          305 :           c_parser_omp_declare_simd (parser, context);
   30038          305 :           return true;
   30039              :         }
   30040         1054 :       if (strcmp (p, "reduction") == 0)
   30041              :         {
   30042          167 :           c_parser_consume_token (parser);
   30043          167 :           c_parser_omp_declare_reduction (parser, context);
   30044          167 :           return false;
   30045              :         }
   30046          887 :       if (strcmp (p, "mapper") == 0)
   30047              :         {
   30048           77 :           c_parser_consume_token (parser);
   30049           77 :           c_parser_omp_declare_mapper (parser, context);
   30050           77 :           return false;
   30051              :         }
   30052          810 :       if (!flag_openmp)  /* flag_openmp_simd  */
   30053              :         {
   30054            0 :           c_parser_skip_to_pragma_eol (parser, false);
   30055            0 :           return false;
   30056              :         }
   30057          810 :       if (strcmp (p, "target") == 0)
   30058              :         {
   30059          298 :           c_parser_consume_token (parser);
   30060          298 :           c_parser_omp_declare_target (parser);
   30061          298 :           return false;
   30062              :         }
   30063          512 :       if (strcmp (p, "variant") == 0)
   30064              :         {
   30065              :           /* c_parser_consume_token (parser); done in
   30066              :              c_parser_omp_declare_simd.  */
   30067          512 :           c_parser_omp_declare_simd (parser, context);
   30068          512 :           return true;
   30069              :         }
   30070              :     }
   30071              : 
   30072            0 :   c_parser_error (parser, "expected %<simd%>, %<reduction%>, "
   30073              :                           "%<target%> or %<variant%>");
   30074            0 :   c_parser_skip_to_pragma_eol (parser);
   30075            0 :   return false;
   30076              : }
   30077              : 
   30078              : /* OpenMP 5.0
   30079              :    #pragma omp requires clauses[optseq] new-line  */
   30080              : 
   30081              : static void
   30082           64 : c_parser_omp_requires (c_parser *parser)
   30083              : {
   30084           64 :   enum omp_requires new_req = (enum omp_requires) 0;
   30085              : 
   30086           64 :   c_parser_consume_pragma (parser);
   30087              : 
   30088           64 :   location_t loc = c_parser_peek_token (parser)->location;
   30089          142 :   while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   30090              :     {
   30091           82 :       if (c_parser_next_token_is (parser, CPP_COMMA)
   30092           82 :           && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
   30093           14 :         c_parser_consume_token (parser);
   30094              : 
   30095           82 :       if (c_parser_next_token_is (parser, CPP_NAME))
   30096              :         {
   30097           81 :           const char *p
   30098           81 :             = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   30099           81 :           location_t cloc = c_parser_peek_token (parser)->location;
   30100           81 :           enum omp_requires this_req = (enum omp_requires) 0;
   30101              : 
   30102           81 :           if (!strcmp (p, "unified_address"))
   30103              :             this_req = OMP_REQUIRES_UNIFIED_ADDRESS;
   30104           67 :           else if (!strcmp (p, "unified_shared_memory"))
   30105              :             this_req = OMP_REQUIRES_UNIFIED_SHARED_MEMORY;
   30106           55 :           else if (!strcmp (p, "self_maps"))
   30107              :             this_req = OMP_REQUIRES_SELF_MAPS;
   30108           49 :           else if (!strcmp (p, "dynamic_allocators"))
   30109              :             this_req = OMP_REQUIRES_DYNAMIC_ALLOCATORS;
   30110           38 :           else if (!strcmp (p, "reverse_offload"))
   30111              :             this_req = OMP_REQUIRES_REVERSE_OFFLOAD;
   30112           21 :           else if (!strcmp (p, "atomic_default_mem_order"))
   30113              :             {
   30114           20 :               c_parser_consume_token (parser);
   30115              : 
   30116           20 :               matching_parens parens;
   30117           20 :               if (parens.require_open (parser))
   30118              :                 {
   30119           20 :                   if (c_parser_next_token_is (parser, CPP_NAME))
   30120              :                     {
   30121           19 :                       tree v = c_parser_peek_token (parser)->value;
   30122           19 :                       p = IDENTIFIER_POINTER (v);
   30123              : 
   30124           19 :                       if (!strcmp (p, "seq_cst"))
   30125              :                         this_req
   30126              :                           = (enum omp_requires) OMP_MEMORY_ORDER_SEQ_CST;
   30127           10 :                       else if (!strcmp (p, "relaxed"))
   30128              :                         this_req
   30129              :                           = (enum omp_requires) OMP_MEMORY_ORDER_RELAXED;
   30130            9 :                       else if (!strcmp (p, "release"))
   30131              :                         this_req
   30132              :                           = (enum omp_requires) OMP_MEMORY_ORDER_RELEASE;
   30133            7 :                       else if (!strcmp (p, "acq_rel"))
   30134              :                         this_req
   30135              :                           = (enum omp_requires) OMP_MEMORY_ORDER_ACQ_REL;
   30136            4 :                       else if (!strcmp (p, "acquire"))
   30137              :                         this_req
   30138              :                           = (enum omp_requires) OMP_MEMORY_ORDER_ACQUIRE;
   30139              :                     }
   30140              :                   if (this_req == 0)
   30141              :                     {
   30142            2 :                       error_at (c_parser_peek_token (parser)->location,
   30143              :                                 "expected %<acq_rel%>, %<acquire%>, "
   30144              :                                 "%<relaxed%>, %<release%> or %<seq_cst%>");
   30145            2 :                       switch (c_parser_peek_token (parser)->type)
   30146              :                         {
   30147              :                         case CPP_EOF:
   30148              :                         case CPP_PRAGMA_EOL:
   30149              :                         case CPP_CLOSE_PAREN:
   30150              :                           break;
   30151            1 :                         default:
   30152            1 :                           if (c_parser_peek_2nd_token (parser)->type
   30153              :                               == CPP_CLOSE_PAREN)
   30154            1 :                             c_parser_consume_token (parser);
   30155              :                           break;
   30156              :                         }
   30157              :                     }
   30158              :                   else
   30159           18 :                     c_parser_consume_token (parser);
   30160              : 
   30161           20 :                   parens.skip_until_found_close (parser);
   30162           20 :                   if (this_req == 0)
   30163              :                     {
   30164            2 :                       c_parser_skip_to_pragma_eol (parser, false);
   30165            2 :                       return;
   30166              :                     }
   30167              :                 }
   30168           18 :               p = NULL;
   30169              :             }
   30170              :           else
   30171              :             {
   30172            1 :               error_at (cloc, "expected %<unified_address%>, "
   30173              :                               "%<unified_shared_memory%>, "
   30174              :                               "%<self_maps%>, "
   30175              :                               "%<dynamic_allocators%>, "
   30176              :                                "%<reverse_offload%> "
   30177              :                                "or %<atomic_default_mem_order%> clause");
   30178            1 :               c_parser_skip_to_pragma_eol (parser, false);
   30179            1 :               return;
   30180              :             }
   30181           18 :           if (p)
   30182           60 :             c_parser_consume_token (parser);
   30183           78 :           if (this_req)
   30184              :             {
   30185           78 :               if ((this_req & ~OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER) != 0)
   30186              :                 {
   30187           60 :                   if ((this_req & new_req) != 0)
   30188            4 :                     error_at (cloc, "too many %qs clauses", p);
   30189           60 :                   if (this_req != OMP_REQUIRES_DYNAMIC_ALLOCATORS
   30190           49 :                       && (omp_requires_mask & OMP_REQUIRES_TARGET_USED) != 0)
   30191            4 :                     error_at (cloc, "%qs clause used lexically after first "
   30192              :                                     "target construct or offloading API", p);
   30193              :                 }
   30194           18 :               else if ((new_req & OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER) != 0)
   30195              :                 {
   30196            1 :                   error_at (cloc, "too many %qs clauses",
   30197              :                             "atomic_default_mem_order");
   30198            1 :                   this_req = (enum omp_requires) 0;
   30199              :                 }
   30200           17 :               else if ((omp_requires_mask
   30201              :                         & OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER) != 0)
   30202              :                 {
   30203            2 :                   error_at (cloc, "more than one %<atomic_default_mem_order%>"
   30204              :                                   " clause in a single compilation unit");
   30205            2 :                   this_req
   30206            2 :                     = (enum omp_requires)
   30207            2 :                        (omp_requires_mask
   30208              :                         & OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER);
   30209              :                 }
   30210           15 :               else if ((omp_requires_mask
   30211              :                         & OMP_REQUIRES_ATOMIC_DEFAULT_MEM_ORDER_USED) != 0)
   30212            1 :                 error_at (cloc, "%<atomic_default_mem_order%> clause used "
   30213              :                                 "lexically after first %<atomic%> construct "
   30214              :                                 "without memory order clause");
   30215           78 :               new_req = (enum omp_requires) (new_req | this_req);
   30216           78 :               omp_requires_mask
   30217           78 :                 = (enum omp_requires) (omp_requires_mask | this_req);
   30218           78 :               continue;
   30219              :             }
   30220              :         }
   30221              :       break;
   30222              :     }
   30223           61 :   c_parser_skip_to_pragma_eol (parser);
   30224              : 
   30225           61 :   if (new_req == 0)
   30226            1 :     error_at (loc, "%<pragma omp requires%> requires at least one clause");
   30227              : }
   30228              : 
   30229              : /* Helper function for c_parser_omp_taskloop.
   30230              :    Disallow zero sized or potentially zero sized task reductions.  */
   30231              : 
   30232              : static tree
   30233          413 : c_finish_taskloop_clauses (tree clauses)
   30234              : {
   30235          413 :   tree *pc = &clauses;
   30236         2064 :   for (tree c = clauses; c; c = *pc)
   30237              :     {
   30238         1651 :       bool remove = false;
   30239         1651 :       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION)
   30240              :         {
   30241          143 :           tree type = strip_array_types (TREE_TYPE (OMP_CLAUSE_DECL (c)));
   30242          143 :           if (integer_zerop (TYPE_SIZE_UNIT (type)))
   30243              :             {
   30244            2 :               error_at (OMP_CLAUSE_LOCATION (c),
   30245              :                         "zero sized type %qT in %<reduction%> clause", type);
   30246            2 :               remove = true;
   30247              :             }
   30248          141 :           else if (TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST)
   30249              :             {
   30250            0 :               error_at (OMP_CLAUSE_LOCATION (c),
   30251              :                         "variable sized type %qT in %<reduction%> clause",
   30252              :                         type);
   30253            0 :               remove = true;
   30254              :             }
   30255              :         }
   30256            2 :       if (remove)
   30257            2 :         *pc = OMP_CLAUSE_CHAIN (c);
   30258              :       else
   30259         1649 :         pc = &OMP_CLAUSE_CHAIN (c);
   30260              :     }
   30261          413 :   return clauses;
   30262              : }
   30263              : 
   30264              : /* OpenMP 4.5:
   30265              :    #pragma omp taskloop taskloop-clause[optseq] new-line
   30266              :      for-loop
   30267              : 
   30268              :    #pragma omp taskloop simd taskloop-simd-clause[optseq] new-line
   30269              :      for-loop  */
   30270              : 
   30271              : #define OMP_TASKLOOP_CLAUSE_MASK                                \
   30272              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_SHARED) \
   30273              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)        \
   30274              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)   \
   30275              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LASTPRIVATE)    \
   30276              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULT)        \
   30277              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_GRAINSIZE)      \
   30278              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TASKS)      \
   30279              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_COLLAPSE)       \
   30280              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_UNTIED) \
   30281              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF)             \
   30282              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FINAL)  \
   30283              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MERGEABLE)      \
   30284              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOGROUP)        \
   30285              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIORITY)       \
   30286              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE)       \
   30287              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION)      \
   30288              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IN_REDUCTION))
   30289              : 
   30290              : static tree
   30291          418 : c_parser_omp_taskloop (location_t loc, c_parser *parser,
   30292              :                        char *p_name, omp_clause_mask mask, tree *cclauses,
   30293              :                        bool *if_p)
   30294              : {
   30295          418 :   tree clauses, block, ret;
   30296              : 
   30297          418 :   strcat (p_name, " taskloop");
   30298          418 :   mask |= OMP_TASKLOOP_CLAUSE_MASK;
   30299              :   /* #pragma omp parallel master taskloop{, simd} disallow in_reduction
   30300              :      clause.  */
   30301          418 :   if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_THREADS)) != 0)
   30302           94 :     mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IN_REDUCTION);
   30303              : 
   30304          418 :   if (c_parser_next_token_is (parser, CPP_NAME))
   30305              :     {
   30306          342 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   30307              : 
   30308          342 :       if (strcmp (p, "simd") == 0)
   30309              :         {
   30310          178 :           tree cclauses_buf[C_OMP_CLAUSE_SPLIT_COUNT];
   30311          178 :           if (cclauses == NULL)
   30312           84 :             cclauses = cclauses_buf;
   30313          178 :           c_parser_consume_token (parser);
   30314          178 :           if (!flag_openmp)  /* flag_openmp_simd  */
   30315            3 :             return c_parser_omp_simd (loc, parser, p_name, mask, cclauses,
   30316            3 :                                       if_p);
   30317          175 :           block = c_begin_compound_stmt (true);
   30318          175 :           ret = c_parser_omp_simd (loc, parser, p_name, mask, cclauses, if_p);
   30319          175 :           block = c_end_compound_stmt (loc, block, true);
   30320          175 :           if (ret == NULL)
   30321              :             return ret;
   30322          175 :           ret = make_node (OMP_TASKLOOP);
   30323          175 :           TREE_TYPE (ret) = void_type_node;
   30324          175 :           OMP_FOR_BODY (ret) = block;
   30325          175 :           OMP_FOR_CLAUSES (ret) = cclauses[C_OMP_CLAUSE_SPLIT_TASKLOOP];
   30326          175 :           OMP_FOR_CLAUSES (ret)
   30327          175 :             = c_finish_taskloop_clauses (OMP_FOR_CLAUSES (ret));
   30328          175 :           SET_EXPR_LOCATION (ret, loc);
   30329          175 :           add_stmt (ret);
   30330          175 :           return ret;
   30331              :         }
   30332              :     }
   30333          240 :   if (!flag_openmp)  /* flag_openmp_simd  */
   30334              :     {
   30335            2 :       c_parser_skip_to_pragma_eol (parser, false);
   30336            2 :       return NULL_TREE;
   30337              :     }
   30338              : 
   30339          238 :   clauses = c_parser_omp_all_clauses (parser, mask, p_name, cclauses == NULL);
   30340          238 :   if (cclauses)
   30341              :     {
   30342           66 :       omp_split_clauses (loc, OMP_TASKLOOP, mask, clauses, cclauses);
   30343           66 :       clauses = cclauses[C_OMP_CLAUSE_SPLIT_TASKLOOP];
   30344              :     }
   30345              : 
   30346          238 :   clauses = c_finish_taskloop_clauses (clauses);
   30347          238 :   block = c_begin_compound_stmt (true);
   30348          238 :   ret = c_parser_omp_for_loop (loc, parser, OMP_TASKLOOP, clauses, NULL, if_p);
   30349          238 :   block = c_end_compound_stmt (loc, block, true);
   30350          238 :   add_stmt (block);
   30351              : 
   30352          238 :   return ret;
   30353              : }
   30354              : 
   30355              : /* OpenMP 5.1: Parse sizes list for "omp tile sizes"
   30356              :    sizes ( size-expr-list ) */
   30357              : static tree
   30358          476 : c_parser_omp_tile_sizes (c_parser *parser, location_t loc)
   30359              : {
   30360          476 :   tree sizes = NULL_TREE;
   30361              : 
   30362          476 :   if (c_parser_next_token_is (parser, CPP_COMMA))
   30363            2 :     c_parser_consume_token (parser);
   30364              : 
   30365          476 :   c_token *tok = c_parser_peek_token (parser);
   30366          476 :   if (tok->type != CPP_NAME
   30367          476 :       || strcmp ("sizes", IDENTIFIER_POINTER (tok->value)))
   30368              :     {
   30369            1 :       c_parser_error (parser, "expected %<sizes%>");
   30370            1 :       return error_mark_node;
   30371              :     }
   30372          475 :   c_parser_consume_token (parser);
   30373              : 
   30374          475 :   matching_parens parens;
   30375          475 :   if (!parens.require_open (parser))
   30376            4 :     return error_mark_node;
   30377              : 
   30378          471 :   vec<tree, va_gc> *sizes_vec
   30379          471 :     = c_parser_expr_list (parser, true, true, NULL, NULL, NULL, NULL);
   30380          471 :   sizes = build_tree_list_vec (sizes_vec);
   30381          471 :   release_tree_vector (sizes_vec);
   30382              : 
   30383         1669 :   for (tree s = sizes; s; s = TREE_CHAIN (s))
   30384              :     {
   30385          734 :       tree expr = TREE_VALUE (s);
   30386          734 :       if (expr == error_mark_node)
   30387              :         {
   30388            7 :           parens.skip_until_found_close (parser);
   30389            7 :           return error_mark_node;
   30390              :         }
   30391              : 
   30392          727 :       HOST_WIDE_INT n;
   30393         1454 :       if (!INTEGRAL_TYPE_P (TREE_TYPE (expr))
   30394          724 :           || !tree_fits_shwi_p (expr)
   30395          722 :           || (n = tree_to_shwi (expr)) <= 0
   30396         1440 :           || (int) n != n)
   30397              :         {
   30398           14 :           c_parser_error (parser, "%<sizes%> argument needs positive"
   30399              :                                   " integral constant");
   30400           14 :           TREE_VALUE (s) = integer_one_node;
   30401              :         }
   30402              :     }
   30403          464 :   parens.require_close (parser);
   30404              : 
   30405          464 :   gcc_assert (sizes);
   30406          464 :   tree c = build_omp_clause (loc, OMP_CLAUSE_SIZES);
   30407          464 :   OMP_CLAUSE_SIZES_LIST (c) = sizes;
   30408              : 
   30409          464 :   return c;
   30410              : }
   30411              : 
   30412              : /* OpenMP 5.1:
   30413              :    #pragma omp tile sizes ( size-expr-list ) new-line
   30414              :      for-loop
   30415              : 
   30416              :    LOC is the location of the #pragma token.  */
   30417              : 
   30418              : static tree
   30419          476 : c_parser_omp_tile (location_t loc, c_parser *parser, bool *if_p)
   30420              : {
   30421          476 :   tree clauses = c_parser_omp_tile_sizes (parser, loc);
   30422          476 :   c_parser_skip_to_pragma_eol (parser);
   30423              : 
   30424          476 :   if (!clauses || clauses == error_mark_node)
   30425           12 :     return error_mark_node;
   30426              : 
   30427          464 :   tree block = c_begin_compound_stmt (true);
   30428          464 :   tree ret = c_parser_omp_for_loop (loc, parser, OMP_TILE, clauses,
   30429              :                                     NULL, if_p);
   30430          464 :   block = c_end_compound_stmt (loc, block, true);
   30431          464 :   add_stmt (block);
   30432              : 
   30433          464 :   return ret;
   30434              : }
   30435              : 
   30436              : #define OMP_UNROLL_CLAUSE_MASK                                  \
   30437              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PARTIAL)        \
   30438              :         | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FULL))
   30439              : 
   30440              : /* OpenMP 5.1
   30441              :    #pragma omp unroll unroll-clause[optseq] new-line
   30442              :      for-loop
   30443              : 
   30444              :    LOC is the location of the #pragma token.  */
   30445              : 
   30446              : static tree
   30447          313 : c_parser_omp_unroll (location_t loc, c_parser *parser, bool *if_p)
   30448              : {
   30449          313 :   tree clauses = c_parser_omp_all_clauses (parser, OMP_UNROLL_CLAUSE_MASK,
   30450              :                                            "#pragma omp unroll", true);
   30451              : 
   30452          313 :   tree block = c_begin_compound_stmt (true);
   30453          313 :   tree ret = c_parser_omp_for_loop (loc, parser, OMP_UNROLL, clauses,
   30454              :                                     NULL, if_p);
   30455          313 :   block = c_end_compound_stmt (loc, block, true);
   30456          313 :   add_stmt (block);
   30457              : 
   30458          313 :   return ret;
   30459              : }
   30460              : 
   30461              : /* OpenMP 5.1
   30462              :    #pragma omp nothing new-line  */
   30463              : 
   30464              : static void
   30465           79 : c_parser_omp_nothing (c_parser *parser)
   30466              : {
   30467           79 :   c_parser_consume_pragma (parser);
   30468           79 :   c_parser_skip_to_pragma_eol (parser);
   30469           79 : }
   30470              : 
   30471              : /* OpenMP 5.1
   30472              :    #pragma omp error clauses[optseq] new-line  */
   30473              : 
   30474              : static bool
   30475          126 : c_parser_omp_error (c_parser *parser, enum pragma_context context)
   30476              : {
   30477          126 :   int at_compilation = -1;
   30478          126 :   int severity_fatal = -1;
   30479          126 :   tree message = NULL_TREE;
   30480          126 :   bool bad = false;
   30481          126 :   location_t loc = c_parser_peek_token (parser)->location;
   30482              : 
   30483          126 :   c_parser_consume_pragma (parser);
   30484              : 
   30485          463 :   while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   30486              :     {
   30487          214 :       if (c_parser_next_token_is (parser, CPP_COMMA)
   30488          214 :           && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
   30489           21 :         c_parser_consume_token (parser);
   30490              : 
   30491          214 :       if (!c_parser_next_token_is (parser, CPP_NAME))
   30492              :         break;
   30493              : 
   30494          213 :       const char *p
   30495          213 :         = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   30496          213 :       location_t cloc = c_parser_peek_token (parser)->location;
   30497          213 :       static const char *args[] = {
   30498              :         "execution", "compilation", "warning", "fatal"
   30499              :       };
   30500          213 :       int *v = NULL;
   30501          213 :       int idx = 0, n = -1;
   30502          213 :       tree m = NULL_TREE;
   30503              : 
   30504          213 :       if (!strcmp (p, "at"))
   30505              :         v = &at_compilation;
   30506          127 :       else if (!strcmp (p, "severity"))
   30507              :         {
   30508              :           v = &severity_fatal;
   30509              :           idx += 2;
   30510              :         }
   30511           82 :       else if (strcmp (p, "message"))
   30512              :         {
   30513            2 :           error_at (cloc,
   30514              :                     "expected %<at%>, %<severity%> or %<message%> clause");
   30515            2 :           c_parser_skip_to_pragma_eol (parser, false);
   30516            2 :           return false;
   30517              :         }
   30518              : 
   30519          211 :       c_parser_consume_token (parser);
   30520              : 
   30521          211 :       matching_parens parens;
   30522          211 :       if (parens.require_open (parser))
   30523              :         {
   30524          208 :           if (v == NULL)
   30525              :             {
   30526           79 :               location_t expr_loc = c_parser_peek_token (parser)->location;
   30527           79 :               c_expr expr = c_parser_expr_no_commas (parser, NULL);
   30528           79 :               expr = convert_lvalue_to_rvalue (expr_loc, expr, true, true);
   30529           79 :               m = convert (const_string_type_node, expr.value);
   30530           79 :               m = c_fully_fold (m, false, NULL);
   30531              :             }
   30532              :           else
   30533              :             {
   30534          129 :               if (c_parser_next_token_is (parser, CPP_NAME))
   30535              :                 {
   30536          125 :                   tree val = c_parser_peek_token (parser)->value;
   30537          125 :                   const char *q = IDENTIFIER_POINTER (val);
   30538              : 
   30539          125 :                   if (!strcmp (q, args[idx]))
   30540              :                     n = 0;
   30541           41 :                   else if (!strcmp (q, args[idx + 1]))
   30542              :                     n = 1;
   30543              :                 }
   30544              :               if (n == -1)
   30545              :                 {
   30546            6 :                   error_at (c_parser_peek_token (parser)->location,
   30547            6 :                             "expected %qs or %qs", args[idx], args[idx + 1]);
   30548            6 :                   bad = true;
   30549            6 :                   switch (c_parser_peek_token (parser)->type)
   30550              :                     {
   30551              :                     case CPP_EOF:
   30552              :                     case CPP_PRAGMA_EOL:
   30553              :                     case CPP_CLOSE_PAREN:
   30554              :                       break;
   30555            4 :                     default:
   30556            4 :                       if (c_parser_peek_2nd_token (parser)->type
   30557              :                           == CPP_CLOSE_PAREN)
   30558            2 :                         c_parser_consume_token (parser);
   30559              :                       break;
   30560              :                     }
   30561              :                 }
   30562              :               else
   30563          123 :                 c_parser_consume_token (parser);
   30564              :             }
   30565              : 
   30566          208 :           parens.skip_until_found_close (parser);
   30567              : 
   30568          208 :           if (v == NULL)
   30569              :             {
   30570           79 :               if (message)
   30571              :                 {
   30572            1 :                   error_at (cloc, "too many %qs clauses", p);
   30573            1 :                   bad = true;
   30574              :                 }
   30575              :               else
   30576              :                 message = m;
   30577              :             }
   30578          129 :           else if (n != -1)
   30579              :             {
   30580          123 :               if (*v != -1)
   30581              :                 {
   30582            2 :                   error_at (cloc, "too many %qs clauses", p);
   30583            2 :                   bad = true;
   30584              :                 }
   30585              :               else
   30586          121 :                 *v = n;
   30587              :             }
   30588              :         }
   30589              :       else
   30590              :         bad = true;
   30591              :     }
   30592          124 :   c_parser_skip_to_pragma_eol (parser);
   30593          124 :   if (bad)
   30594              :     return true;
   30595              : 
   30596          112 :   if (at_compilation == -1)
   30597           33 :     at_compilation = 1;
   30598          112 :   if (severity_fatal == -1)
   30599           74 :     severity_fatal = 1;
   30600          112 :   if (!at_compilation)
   30601              :     {
   30602           58 :       if (context != pragma_compound)
   30603              :         {
   30604            7 :           error_at (loc, "%<#pragma omp error%> with %<at(execution)%> clause "
   30605              :                          "may only be used in compound statements");
   30606            7 :           return true;
   30607              :         }
   30608           51 :       if (parser->omp_for_parse_state
   30609            1 :           && parser->omp_for_parse_state->in_intervening_code)
   30610              :         {
   30611            1 :           error_at (loc, "%<#pragma omp error%> with %<at(execution)%> clause "
   30612              :                          "may not be used in intervening code");
   30613            1 :           parser->omp_for_parse_state->fail = true;
   30614            1 :           return true;
   30615              :         }
   30616           50 :       tree fndecl
   30617           58 :         = builtin_decl_explicit (severity_fatal ? BUILT_IN_GOMP_ERROR
   30618              :                                                 : BUILT_IN_GOMP_WARNING);
   30619           50 :       if (!message)
   30620            4 :         message = build_zero_cst (const_string_type_node);
   30621           50 :       tree stmt = build_call_expr_loc (loc, fndecl, 2, message,
   30622              :                                        build_all_ones_cst (size_type_node));
   30623           50 :       add_stmt (stmt);
   30624           50 :       return true;
   30625              :     }
   30626           54 :   const char *msg = NULL;
   30627           54 :   if (message)
   30628              :     {
   30629           27 :       msg = c_getstr (message);
   30630           27 :       if (msg == NULL)
   30631            6 :         msg = _("<message unknown at compile time>");
   30632              :     }
   30633           15 :   const enum diagnostics::kind diag_kind = (severity_fatal
   30634           54 :                                             ? diagnostics::kind::error
   30635              :                                             : diagnostics::kind::warning);
   30636           54 :   if (msg)
   30637           27 :     emit_diagnostic (diag_kind, loc, 0,
   30638              :                      "%<pragma omp error%> encountered: %s", msg);
   30639              :   else
   30640           27 :     emit_diagnostic (diag_kind, loc, 0,
   30641              :                      "%<pragma omp error%> encountered");
   30642              :   return false;
   30643              : }
   30644              : 
   30645              : /* Assumption clauses
   30646              :    OpenMP 5.1:
   30647              :    absent (directive-name-list)
   30648              :    contains (directive-name-list)
   30649              :    holds (expression)
   30650              :    no_openmp
   30651              :    no_openmp_routines
   30652              :    no_parallelism
   30653              : 
   30654              :    OpenMP 6.0:
   30655              :    no_openmp_constructs  */
   30656              : 
   30657              : static void
   30658          130 : c_parser_omp_assumption_clauses (c_parser *parser, bool is_assume)
   30659              : {
   30660          130 :   bool no_openmp = false;
   30661          130 :   bool no_openmp_constructs = false;
   30662          130 :   bool no_openmp_routines = false;
   30663          130 :   bool no_parallelism = false;
   30664          130 :   bitmap_head absent_head, contains_head;
   30665              : 
   30666          130 :   bitmap_obstack_initialize (NULL);
   30667          130 :   bitmap_initialize (&absent_head, &bitmap_default_obstack);
   30668          130 :   bitmap_initialize (&contains_head, &bitmap_default_obstack);
   30669              : 
   30670          130 :   if (c_parser_next_token_is (parser, CPP_PRAGMA_EOL))
   30671            3 :     error_at (c_parser_peek_token (parser)->location,
   30672              :               "expected at least one assumption clause");
   30673              : 
   30674          359 :   while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   30675              :     {
   30676          233 :       if (c_parser_next_token_is (parser, CPP_COMMA)
   30677          233 :           && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
   30678           53 :         c_parser_consume_token (parser);
   30679              : 
   30680          233 :       if (!c_parser_next_token_is (parser, CPP_NAME))
   30681              :         break;
   30682              : 
   30683          233 :       const char *p
   30684          233 :         = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   30685          233 :       location_t cloc = c_parser_peek_token (parser)->location;
   30686              : 
   30687          233 :       if (!strcmp (p, "no_openmp"))
   30688              :         {
   30689           18 :           c_parser_consume_token (parser);
   30690           18 :           if (no_openmp)
   30691            3 :             error_at (cloc, "too many %qs clauses", "no_openmp");
   30692          229 :           no_openmp = true;
   30693              :         }
   30694          215 :       else if (!strcmp (p, "no_openmp_constructs"))
   30695              :         {
   30696            4 :           c_parser_consume_token (parser);
   30697            4 :           if (no_openmp_constructs)
   30698            1 :             error_at (cloc, "too many %qs clauses", "no_openmp_constructs");
   30699          229 :           no_openmp_constructs = true;
   30700              :         }
   30701          211 :       else if (!strcmp (p, "no_openmp_routines"))
   30702              :         {
   30703           17 :           c_parser_consume_token (parser);
   30704           17 :           if (no_openmp_routines)
   30705            3 :             error_at (cloc, "too many %qs clauses", "no_openmp_routines");
   30706          229 :           no_openmp_routines = true;
   30707              :         }
   30708          194 :       else if (!strcmp (p, "no_parallelism"))
   30709              :         {
   30710           19 :           c_parser_consume_token (parser);
   30711           19 :           if (no_parallelism)
   30712            3 :             error_at (cloc, "too many %qs clauses", "no_parallelism");
   30713          229 :           no_parallelism = true;
   30714              :         }
   30715          175 :       else if (!strcmp (p, "holds"))
   30716              :         {
   30717           19 :           c_parser_consume_token (parser);
   30718           19 :           matching_parens parens;
   30719           19 :           if (parens.require_open (parser))
   30720              :             {
   30721           19 :               location_t eloc = c_parser_peek_token (parser)->location;
   30722           19 :               c_expr expr = c_parser_expr_no_commas (parser, NULL);
   30723           19 :               tree t = convert_lvalue_to_rvalue (eloc, expr, true, true).value;
   30724           19 :               t = c_objc_common_truthvalue_conversion (eloc, t);
   30725           19 :               t = c_fully_fold (t, false, NULL);
   30726           19 :               if (is_assume && t != error_mark_node)
   30727              :                 {
   30728           11 :                   tree fn = build_call_expr_internal_loc (eloc, IFN_ASSUME,
   30729              :                                                           void_type_node, 1,
   30730              :                                                           t);
   30731           11 :                   add_stmt (fn);
   30732              :                 }
   30733           19 :               parens.skip_until_found_close (parser);
   30734              :             }
   30735              :         }
   30736          156 :       else if (!strcmp (p, "absent") || !strcmp (p, "contains"))
   30737              :         {
   30738          146 :           c_parser_consume_token (parser);
   30739          146 :           matching_parens parens;
   30740          146 :           if (parens.require_open (parser))
   30741              :             {
   30742          604 :               do
   30743              :                 {
   30744          375 :                   const char *directive[3] = {};
   30745          375 :                   int i;
   30746          375 :                   location_t dloc = c_parser_peek_token (parser)->location;
   30747          844 :                   for (i = 0; i < 3; i++)
   30748              :                     {
   30749          811 :                       tree id;
   30750          811 :                       if (c_parser_peek_nth_token (parser, i + 1)->type
   30751              :                           == CPP_NAME)
   30752          457 :                         id = c_parser_peek_nth_token (parser, i + 1)->value;
   30753          354 :                       else if (c_parser_peek_nth_token (parser, i + 1)->keyword
   30754              :                                != RID_MAX)
   30755              :                         {
   30756           12 :                           enum rid rid
   30757           12 :                             = c_parser_peek_nth_token (parser, i + 1)->keyword;
   30758           12 :                           id = ridpointers[rid];
   30759              :                         }
   30760              :                       else
   30761              :                         break;
   30762          469 :                       directive[i] = IDENTIFIER_POINTER (id);
   30763              :                     }
   30764          375 :                   if (i == 0)
   30765            0 :                     error_at (dloc, "expected directive name");
   30766              :                   else
   30767              :                     {
   30768          375 :                       const struct c_omp_directive *dir
   30769          375 :                         = c_omp_categorize_directive (directive[0],
   30770              :                                                       directive[1],
   30771              :                                                       directive[2]);
   30772          375 :                       if (dir
   30773          372 :                           && dir->id != PRAGMA_OMP_END
   30774          369 :                           && (dir->kind == C_OMP_DIR_DECLARATIVE
   30775          365 :                               || dir->kind == C_OMP_DIR_INFORMATIONAL
   30776          356 :                               || dir->kind == C_OMP_DIR_META))
   30777           13 :                         error_at (dloc, "invalid OpenMP directive name in "
   30778              :                                         "%qs clause argument: declarative, "
   30779              :                                         "informational, and meta directives "
   30780              :                                         "not permitted", p);
   30781              :                       else if (dir == NULL
   30782          359 :                                || dir->id == PRAGMA_OMP_END
   30783          356 :                                || (!dir->second && directive[1])
   30784          347 :                                || (!dir->third && directive[2]))
   30785           15 :                         error_at (dloc, "unknown OpenMP directive name in "
   30786              :                                         "%qs clause argument", p);
   30787              :                       else
   30788              :                         {
   30789          347 :                           int id = dir - c_omp_directives;
   30790          392 :                           if (bitmap_bit_p (p[0] == 'a' ? &contains_head
   30791              :                                                         : &absent_head, id))
   30792           18 :                             error_at (dloc, "%<%s%s%s%s%s%> directive "
   30793              :                                             "mentioned in both %<absent%> and "
   30794              :                                             "%<contains%> clauses",
   30795              :                                       directive[0],
   30796              :                                       directive[1] ? " " : "",
   30797              :                                       directive[1] ? directive[1] : "",
   30798              :                                       directive[2] ? " " : "",
   30799              :                                       directive[2] ? directive[2] : "");
   30800          383 :                           else if (!bitmap_set_bit (p[0] == 'a'
   30801              :                                                     ? &absent_head
   30802              :                                                     : &contains_head, id))
   30803           36 :                             error_at (dloc, "%<%s%s%s%s%s%> directive "
   30804              :                                             "mentioned multiple times in %qs "
   30805              :                                             "clauses",
   30806              :                                       directive[0],
   30807              :                                       directive[1] ? " " : "",
   30808              :                                       directive[1] ? directive[1] : "",
   30809              :                                       directive[2] ? " " : "",
   30810              :                                       directive[2] ? directive[2] : "", p);
   30811              :                         }
   30812          844 :                       for (; i; --i)
   30813          469 :                         c_parser_consume_token (parser);
   30814              :                     }
   30815          375 :                   if (c_parser_next_token_is (parser, CPP_COMMA))
   30816          229 :                     c_parser_consume_token (parser);
   30817              :                   else
   30818              :                     break;
   30819          229 :                 }
   30820              :               while (1);
   30821          146 :               parens.skip_until_found_close (parser);
   30822              :             }
   30823          146 :         }
   30824           10 :       else if (startswith (p, "ext_"))
   30825              :         {
   30826            6 :           warning_at (cloc, OPT_Wopenmp, "unknown assumption clause %qs", p);
   30827            6 :           c_parser_consume_token (parser);
   30828            6 :           if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
   30829              :             {
   30830            3 :               matching_parens parens;
   30831            3 :               parens.consume_open (parser);
   30832            3 :               c_parser_balanced_token_sequence (parser);
   30833            3 :               parens.require_close (parser);
   30834              :             }
   30835              :         }
   30836              :       else
   30837              :         {
   30838            4 :           c_parser_consume_token (parser);
   30839            4 :           error_at (cloc, "expected assumption clause");
   30840            4 :           break;
   30841              :         }
   30842              :     }
   30843          130 :   c_parser_skip_to_pragma_eol (parser);
   30844          130 : }
   30845              : 
   30846              : /* OpenMP 5.1
   30847              :    #pragma omp assume clauses[optseq] new-line  */
   30848              : 
   30849              : static void
   30850           46 : c_parser_omp_assume (c_parser *parser, bool *if_p)
   30851              : {
   30852           46 :   c_parser_omp_assumption_clauses (parser, true);
   30853           46 :   add_stmt (c_parser_omp_structured_block (parser, if_p));
   30854           46 : }
   30855              : 
   30856              : /* OpenMP 5.1
   30857              :    #pragma omp assumes clauses[optseq] new-line  */
   30858              : 
   30859              : static void
   30860           38 : c_parser_omp_assumes (c_parser *parser)
   30861              : {
   30862           38 :   c_parser_consume_pragma (parser);
   30863           38 :   c_parser_omp_assumption_clauses (parser, false);
   30864           38 : }
   30865              : 
   30866              : /* Helper function for c_parser_omp_metadirective.  */
   30867              : 
   30868              : static void
   30869           58 : analyze_metadirective_body (c_parser *parser,
   30870              :                             vec<c_token> &tokens,
   30871              :                             vec<tree> &labels)
   30872              : {
   30873           58 :   int nesting_depth = 0;
   30874           58 :   int bracket_depth = 0;
   30875           58 :   bool ignore_label = false;
   30876              : 
   30877              :   /* Read in the body tokens to the tokens for each candidate directive.  */
   30878         3242 :   while (1)
   30879              :     {
   30880         1650 :       c_token *token = c_parser_peek_token (parser);
   30881         1650 :       bool stop = false;
   30882              : 
   30883         1650 :       if (c_parser_next_token_is_keyword (parser, RID_CASE))
   30884            0 :         ignore_label = true;
   30885              : 
   30886         1650 :       switch (token->type)
   30887              :         {
   30888              :         case CPP_EOF:
   30889              :           break;
   30890          531 :         case CPP_NAME:
   30891          531 :           if (!ignore_label
   30892          531 :               && c_parser_peek_2nd_token (parser)->type == CPP_COLON)
   30893            0 :             labels.safe_push (token->value);
   30894          531 :           goto add;
   30895           21 :         case CPP_OPEN_BRACE:
   30896           21 :           ++nesting_depth;
   30897           21 :           goto add;
   30898           21 :         case CPP_CLOSE_BRACE:
   30899           21 :           if (--nesting_depth == 0 && bracket_depth == 0)
   30900           21 :             stop = true;
   30901           21 :           goto add;
   30902           85 :         case CPP_OPEN_PAREN:
   30903           85 :           ++bracket_depth;
   30904           85 :           goto add;
   30905           85 :         case CPP_CLOSE_PAREN:
   30906           85 :           --bracket_depth;
   30907           85 :           goto add;
   30908            9 :         case CPP_COLON:
   30909            9 :           ignore_label = false;
   30910            9 :           goto add;
   30911          185 :         case CPP_SEMICOLON:
   30912          185 :           if (nesting_depth == 0 && bracket_depth == 0)
   30913           50 :             stop = true;
   30914          185 :           goto add;
   30915         1650 :         default:
   30916         1650 :         add:
   30917         1650 :           tokens.safe_push (*token);
   30918         1650 :           if (token->type == CPP_PRAGMA)
   30919            5 :             c_parser_consume_pragma (parser);
   30920         1645 :           else if (token->type == CPP_PRAGMA_EOL)
   30921            5 :             c_parser_skip_to_pragma_eol (parser);
   30922              :           else
   30923         1640 :             c_parser_consume_token (parser);
   30924         1650 :           if (stop)
   30925              :             break;
   30926         1592 :           continue;
   30927              :         }
   30928           58 :       break;
   30929         1592 :     }
   30930           58 : }
   30931              : 
   30932              : /* OpenMP 5.0:
   30933              : 
   30934              :   # pragma omp metadirective [clause[, clause]]
   30935              : */
   30936              : 
   30937              : static void
   30938          110 : c_parser_omp_metadirective (c_parser *parser, bool *if_p)
   30939              : {
   30940          110 :   static unsigned int metadirective_region_count = 0;
   30941              : 
   30942          110 :   tree ret;
   30943          110 :   auto_vec<c_token> directive_tokens;
   30944          110 :   auto_vec<c_token> body_tokens;
   30945          110 :   auto_vec<tree> body_labels;
   30946          110 :   auto_vec<const struct c_omp_directive *> directives;
   30947          110 :   auto_vec<tree> ctxs;
   30948          110 :   vec<struct omp_variant> candidates;
   30949          110 :   bool default_seen = false;
   30950          110 :   int directive_token_idx = 0;
   30951          110 :   tree standalone_body = NULL_TREE;
   30952          110 :   location_t pragma_loc = c_parser_peek_token (parser)->location;
   30953          110 :   bool requires_body = false;
   30954              : 
   30955          110 :   ret = make_node (OMP_METADIRECTIVE);
   30956          110 :   SET_EXPR_LOCATION (ret, pragma_loc);
   30957          110 :   TREE_TYPE (ret) = void_type_node;
   30958          110 :   OMP_METADIRECTIVE_VARIANTS (ret) = NULL_TREE;
   30959              : 
   30960          110 :   c_parser_consume_pragma (parser);
   30961          418 :   while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
   30962              :     {
   30963          214 :       if (c_parser_next_token_is (parser, CPP_COMMA))
   30964           15 :         c_parser_consume_token (parser);
   30965          214 :       if (c_parser_next_token_is_not (parser, CPP_NAME)
   30966          278 :           && c_parser_next_token_is_not (parser, CPP_KEYWORD))
   30967              :         {
   30968            0 :           c_parser_error (parser, "expected %<when%>, "
   30969              :                           "%<otherwise%>, or %<default%> clause");
   30970            0 :           goto error;
   30971              :         }
   30972              : 
   30973          214 :       location_t match_loc = c_parser_peek_token (parser)->location;
   30974          214 :       const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
   30975          214 :       if (strcmp (p, "default") == 0)
   30976              :         {
   30977           64 :           gcc_rich_location richloc (pragma_loc);
   30978           64 :           richloc.add_fixit_replace (match_loc, "otherwise");
   30979           64 :           warning_at (&richloc, OPT_Wdeprecated_openmp,
   30980              :                       "%<default%> clause on metadirectives deprecated since "
   30981              :                       "OpenMP 5.2, use %<otherwise%>");
   30982           64 :         }
   30983          214 :       c_parser_consume_token (parser);
   30984          428 :       bool default_p
   30985          214 :         = strcmp (p, "default") == 0 || strcmp (p, "otherwise") == 0;
   30986          133 :       if (default_p)
   30987              :         {
   30988           81 :           if (default_seen)
   30989              :             {
   30990            4 :               error_at (match_loc, "too many %<otherwise%> or %<default%> "
   30991              :                         "clauses in %<metadirective%>");
   30992            4 :               goto error;
   30993              :             }
   30994              :           default_seen = true;
   30995              :         }
   30996          133 :       else if (default_seen)
   30997              :         {
   30998            2 :           error_at (match_loc, "%<otherwise%> or %<default%> clause "
   30999              :                     "must appear last in %<metadirective%>");
   31000            2 :           goto error;
   31001              :         }
   31002          208 :       if (!default_p && strcmp (p, "when") != 0)
   31003              :         {
   31004            2 :           error_at (match_loc, "%qs is not valid for %qs",
   31005              :                     p, "metadirective");
   31006            2 :           goto error;
   31007              :         }
   31008              : 
   31009          206 :       matching_parens parens;
   31010          206 :       tree ctx = NULL_TREE;
   31011          206 :       bool skip = false;
   31012              : 
   31013          206 :       if (!parens.require_open (parser))
   31014            0 :         goto error;
   31015              : 
   31016          206 :       if (!default_p)
   31017              :         {
   31018          129 :           ctx = c_parser_omp_context_selector_specification (parser,
   31019              :                                                              NULL_TREE);
   31020          129 :           if (ctx == error_mark_node)
   31021            2 :             goto error;
   31022          127 :           ctx = omp_check_context_selector (match_loc, ctx,
   31023              :                                             OMP_CTX_METADIRECTIVE);
   31024          127 :           if (ctx == error_mark_node)
   31025            0 :             goto error;
   31026              : 
   31027              :           /* Remove the selector from further consideration if it can be
   31028              :              evaluated as a non-match at this point.  */
   31029          127 :           skip = (omp_context_selector_matches (ctx, NULL_TREE, false) == 0);
   31030              : 
   31031          127 :           if (c_parser_next_token_is_not (parser, CPP_COLON))
   31032              :             {
   31033            2 :               c_parser_require (parser, CPP_COLON, "expected %<:%>");
   31034            2 :               goto error;
   31035              :             }
   31036          125 :           c_parser_consume_token (parser);
   31037              :         }
   31038              : 
   31039              :       /* Read in the directive type and create a dummy pragma token for
   31040              :          it.  */
   31041          202 :       location_t loc = c_parser_peek_token (parser)->location;
   31042              : 
   31043          202 :       const char *directive[3] = {};
   31044          202 :       int i;
   31045          561 :       for (i = 0; i < 3; i++)
   31046              :         {
   31047          541 :           tree id;
   31048          541 :           if (c_parser_peek_nth_token (parser, i + 1)->type
   31049              :               == CPP_CLOSE_PAREN)
   31050              :             {
   31051          118 :               if (i == 0)
   31052            2 :                 directive[i++] = "nothing";
   31053              :               break;
   31054              :             }
   31055          423 :           else if (c_parser_peek_nth_token (parser, i + 1)->type
   31056              :                    == CPP_NAME)
   31057          282 :             id = c_parser_peek_nth_token (parser, i + 1)->value;
   31058          141 :           else if (c_parser_peek_nth_token (parser, i + 1)->keyword
   31059              :                    != RID_MAX)
   31060              :             {
   31061           77 :               enum rid rid
   31062           77 :                 = c_parser_peek_nth_token (parser, i + 1)->keyword;
   31063           77 :               id = ridpointers[rid];
   31064              :             }
   31065              :           else
   31066              :             break;
   31067              : 
   31068          359 :           directive[i] = IDENTIFIER_POINTER (id);
   31069              :         }
   31070           86 :       if (i == 0)
   31071              :         {
   31072            0 :           error_at (loc, "expected directive name");
   31073            0 :           goto error;
   31074              :         }
   31075              : 
   31076          202 :       const struct c_omp_directive *omp_directive
   31077          202 :         = c_omp_categorize_directive (directive[0],
   31078              :                                       directive[1],
   31079          202 :                                       directive[2]);
   31080              : 
   31081          202 :       if (omp_directive == NULL)
   31082              :         {
   31083            4 :           for (int j = 0; j < i; j++)
   31084            2 :             c_parser_consume_token (parser);
   31085            2 :           c_parser_error (parser, "unknown directive name");
   31086            2 :           goto error;
   31087              :         }
   31088              :       else
   31089              :         {
   31090          200 :           int token_count = 0;
   31091          200 :           if (omp_directive->first) token_count++;
   31092          200 :           if (omp_directive->second) token_count++;
   31093          200 :           if (omp_directive->third) token_count++;
   31094          400 :           for (int j = 0; j < token_count; j++)
   31095          200 :             c_parser_consume_token (parser);
   31096              :         }
   31097          200 :       if (omp_directive->id == PRAGMA_OMP_METADIRECTIVE)
   31098              :         {
   31099            2 :           c_parser_error (parser,
   31100              :                           "metadirectives cannot be used as variants of a "
   31101              :                           "%<metadirective%>");
   31102            2 :           goto error;
   31103              :         }
   31104          198 :       if (omp_directive->kind == C_OMP_DIR_DECLARATIVE)
   31105              :         {
   31106            0 :           sorry_at (loc, "declarative directive variants of a "
   31107              :                          "%<metadirective%> are not supported");
   31108            0 :           goto error;
   31109              :         }
   31110          198 :       if (omp_directive->kind == C_OMP_DIR_CONSTRUCT)
   31111          117 :         requires_body = true;
   31112              : 
   31113          198 :       if (!skip)
   31114              :         {
   31115          163 :           c_token pragma_token;
   31116          163 :           pragma_token.type = CPP_PRAGMA;
   31117          163 :           pragma_token.location = loc;
   31118          163 :           pragma_token.pragma_kind = (enum pragma_kind) omp_directive->id;
   31119              : 
   31120          163 :           directives.safe_push (omp_directive);
   31121          163 :           directive_tokens.safe_push (pragma_token);
   31122          163 :           ctxs.safe_push (ctx);
   31123              :         }
   31124              : 
   31125              :       /* Read in tokens for the directive clauses.  */
   31126          198 :       int nesting_depth = 0;
   31127         1484 :       while (1)
   31128              :         {
   31129          841 :           c_token *token = c_parser_peek_token (parser);
   31130          841 :           switch (token->type)
   31131              :             {
   31132              :             case CPP_EOF:
   31133              :             case CPP_PRAGMA_EOL:
   31134              :               break;
   31135          117 :             case CPP_OPEN_PAREN:
   31136          117 :               ++nesting_depth;
   31137          117 :               goto add;
   31138          313 :             case CPP_CLOSE_PAREN:
   31139          313 :               if (nesting_depth-- == 0)
   31140              :                 {
   31141          196 :                   c_parser_consume_token (parser);
   31142          196 :                   break;
   31143              :                 }
   31144          117 :               goto add;
   31145          643 :             default:
   31146          643 :             add:
   31147          643 :               if (!skip)
   31148          550 :                 directive_tokens.safe_push (*token);
   31149          643 :               c_parser_consume_token (parser);
   31150          643 :               continue;
   31151              :             }
   31152          198 :           break;
   31153          643 :         }
   31154              : 
   31155          198 :       if (!skip)
   31156              :         {
   31157          163 :           c_token eol_token;
   31158          163 :           memset (&eol_token, 0, sizeof (eol_token));
   31159          163 :           eol_token.type = CPP_PRAGMA_EOL;
   31160          163 :           directive_tokens.safe_push (eol_token);
   31161              :         }
   31162              :     }
   31163           94 :   c_parser_skip_to_pragma_eol (parser);
   31164              : 
   31165              :   /* If only one selector matches and it evaluates to 'omp nothing', no need to
   31166              :      proceed.  */
   31167           94 :   if (ctxs.length () == 1)
   31168              :     {
   31169           37 :       tree ctx = ctxs[0];
   31170           37 :       if (ctx == NULL_TREE
   31171           37 :           || (omp_context_selector_matches (ctx, NULL_TREE, false) == 1
   31172           13 :               && directive_tokens[0].pragma_kind == PRAGMA_OMP_NOTHING))
   31173              :         return;
   31174              :     }
   31175              : 
   31176           72 :   if (!default_seen)
   31177              :     {
   31178              :       /* Add a default clause that evaluates to 'omp nothing'.  */
   31179           27 :       const struct c_omp_directive *omp_directive
   31180           27 :         = c_omp_categorize_directive ("nothing", NULL, NULL);
   31181              : 
   31182           27 :       c_token pragma_token;
   31183           27 :       pragma_token.type = CPP_PRAGMA;
   31184           27 :       pragma_token.location = UNKNOWN_LOCATION;
   31185           27 :       pragma_token.pragma_kind = PRAGMA_OMP_NOTHING;
   31186              : 
   31187           27 :       directives.safe_push (omp_directive);
   31188           27 :       directive_tokens.safe_push (pragma_token);
   31189           27 :       ctxs.safe_push (NULL_TREE);
   31190              : 
   31191           27 :       c_token eol_token;
   31192           27 :       memset (&eol_token, 0, sizeof (eol_token));
   31193           27 :       eol_token.type = CPP_PRAGMA_EOL;
   31194           27 :       directive_tokens.safe_push (eol_token);
   31195              :     }
   31196              : 
   31197           72 :   if (requires_body)
   31198           58 :     analyze_metadirective_body (parser, body_tokens, body_labels);
   31199              : 
   31200              :   /* Process each candidate directive.  */
   31201           72 :   unsigned i;
   31202           72 :   tree ctx;
   31203              : 
   31204          234 :   FOR_EACH_VEC_ELT (ctxs, i, ctx)
   31205              :     {
   31206          162 :       auto_vec<c_token> tokens;
   31207              : 
   31208              :       /* Add the directive tokens.  */
   31209          842 :       do
   31210          842 :         tokens.safe_push (directive_tokens [directive_token_idx++]);
   31211          842 :       while (tokens.last ().type != CPP_PRAGMA_EOL);
   31212              : 
   31213              :       /* Add the body tokens.  */
   31214          162 :       gcc_assert (requires_body || body_tokens.is_empty ());
   31215         3670 :       for (unsigned j = 0; j < body_tokens.length (); j++)
   31216         3508 :         tokens.safe_push (body_tokens[j]);
   31217              : 
   31218              :       /* Make sure nothing tries to read past the end of the tokens.  */
   31219          162 :       c_token eof_token;
   31220          162 :       memset (&eof_token, 0, sizeof (eof_token));
   31221          162 :       eof_token.type = CPP_EOF;
   31222          162 :       tokens.safe_push (eof_token);
   31223          162 :       tokens.safe_push (eof_token);
   31224              : 
   31225          162 :       unsigned int old_tokens_avail = parser->tokens_avail;
   31226          162 :       c_token *old_tokens = parser->tokens;
   31227          162 :       struct omp_attribute_pragma_state *old_in_omp_attribute_pragma
   31228              :         = parser->in_omp_attribute_pragma;
   31229          162 :       struct omp_metadirective_parse_data *old_state
   31230              :         = parser->omp_metadirective_state;
   31231              : 
   31232          162 :       struct omp_metadirective_parse_data new_state;
   31233          162 :       new_state.body_labels = &body_labels;
   31234          162 :       new_state.region_num = ++metadirective_region_count;
   31235              : 
   31236          162 :       parser->tokens = tokens.address ();
   31237          162 :       parser->tokens_avail = tokens.length ();
   31238          162 :       parser->in_omp_attribute_pragma = NULL;
   31239          162 :       parser->omp_metadirective_state = &new_state;
   31240              : 
   31241          162 :       int prev_errorcount = errorcount;
   31242          162 :       tree directive = c_begin_compound_stmt (true);
   31243              : 
   31244          162 :       c_parser_pragma (parser, pragma_compound, if_p, NULL_TREE);
   31245          162 :       directive = c_end_compound_stmt (pragma_loc, directive, true);
   31246          162 :       bool standalone_p
   31247          162 :         = directives[i]->kind == C_OMP_DIR_STANDALONE
   31248          162 :           || directives[i]->kind == C_OMP_DIR_UTILITY;
   31249           89 :       if (standalone_p && requires_body)
   31250              :         {
   31251              :           /* Parsing standalone directives will not consume the body
   31252              :              tokens, so do that here.  */
   31253           53 :           if (standalone_body == NULL_TREE)
   31254              :             {
   31255           51 :               standalone_body = push_stmt_list ();
   31256           51 :               c_parser_statement (parser, if_p); // TODO skip this
   31257           51 :               standalone_body = pop_stmt_list (standalone_body);
   31258              :             }
   31259              :           else
   31260            2 :             c_parser_skip_to_end_of_block_or_statement (parser, true);
   31261              :         }
   31262              : 
   31263          162 :       tree body = standalone_p ? standalone_body : NULL_TREE;
   31264          162 :       tree variant = make_omp_metadirective_variant (ctx, directive, body);
   31265          324 :       OMP_METADIRECTIVE_VARIANTS (ret)
   31266          162 :         = chainon (OMP_METADIRECTIVE_VARIANTS (ret), variant);
   31267              : 
   31268              :       /* Check that all valid tokens have been consumed if no parse errors
   31269              :          encountered.  */
   31270          162 :       if (errorcount == prev_errorcount)
   31271              :         {
   31272          160 :           gcc_assert (parser->tokens_avail == 2);
   31273          160 :           gcc_assert (c_parser_next_token_is (parser, CPP_EOF));
   31274          160 :           gcc_assert (c_parser_peek_2nd_token (parser)->type == CPP_EOF);
   31275              :         }
   31276              : 
   31277          162 :       parser->tokens = old_tokens;
   31278          162 :       parser->tokens_avail = old_tokens_avail;
   31279          162 :       parser->in_omp_attribute_pragma = old_in_omp_attribute_pragma;
   31280          162 :       parser->omp_metadirective_state = old_state;
   31281          162 :     }
   31282              : 
   31283              :   /* Try to resolve the metadirective early.  */
   31284           72 :   candidates = omp_early_resolve_metadirective (ret);
   31285           72 :   if (!candidates.is_empty ())
   31286           48 :     ret = c_omp_expand_variant_construct (candidates);
   31287              : 
   31288           72 :   add_stmt (ret);
   31289           72 :   return;
   31290              : 
   31291           16 : error:
   31292              :   /* Skip the metadirective pragma.  Do not skip the metadirective body.  */
   31293           16 :   if (parser->in_pragma)
   31294           16 :     c_parser_skip_to_pragma_eol (parser, false);
   31295          110 : }
   31296              : 
   31297              : /* Main entry point to parsing most OpenMP pragmas.  */
   31298              : 
   31299              : static void
   31300        17652 : c_parser_omp_construct (c_parser *parser, bool *if_p)
   31301              : {
   31302        17652 :   enum pragma_kind p_kind;
   31303        17652 :   location_t loc;
   31304        17652 :   tree stmt;
   31305        17652 :   char p_name[sizeof "#pragma omp teams distribute parallel for simd"];
   31306        17652 :   omp_clause_mask mask (0);
   31307              : 
   31308        17652 :   loc = c_parser_peek_token (parser)->location;
   31309        17652 :   p_kind = c_parser_peek_token (parser)->pragma_kind;
   31310        17652 :   c_parser_consume_pragma (parser);
   31311              : 
   31312        17652 :   switch (p_kind)
   31313              :     {
   31314          309 :     case PRAGMA_OACC_ATOMIC:
   31315          309 :       c_parser_omp_atomic (loc, parser, true);
   31316         2131 :       return;
   31317          137 :     case PRAGMA_OACC_CACHE:
   31318          137 :       strcpy (p_name, "#pragma acc");
   31319          137 :       stmt = c_parser_oacc_cache (loc, parser);
   31320          137 :       break;
   31321          497 :     case PRAGMA_OACC_DATA:
   31322          497 :       stmt = c_parser_oacc_data (loc, parser, if_p);
   31323          497 :       break;
   31324           23 :     case PRAGMA_OACC_HOST_DATA:
   31325           23 :       stmt = c_parser_oacc_host_data (loc, parser, if_p);
   31326           23 :       break;
   31327         2154 :     case PRAGMA_OACC_KERNELS:
   31328         2154 :     case PRAGMA_OACC_PARALLEL:
   31329         2154 :     case PRAGMA_OACC_SERIAL:
   31330         2154 :       strcpy (p_name, "#pragma acc");
   31331         2154 :       stmt = c_parser_oacc_compute (loc, parser, p_kind, p_name, if_p);
   31332         2154 :       break;
   31333         1771 :     case PRAGMA_OACC_LOOP:
   31334         1771 :       strcpy (p_name, "#pragma acc");
   31335         1771 :       stmt = c_parser_oacc_loop (loc, parser, p_name, mask, NULL, if_p);
   31336         1771 :       break;
   31337           86 :     case PRAGMA_OACC_WAIT:
   31338           86 :       strcpy (p_name, "#pragma wait");
   31339           86 :       stmt = c_parser_oacc_wait (loc, parser, p_name);
   31340           86 :       break;
   31341         1467 :     case PRAGMA_OMP_ATOMIC:
   31342         1467 :       c_parser_omp_atomic (loc, parser, false);
   31343         1467 :       return;
   31344          144 :     case PRAGMA_OMP_CRITICAL:
   31345          144 :       stmt = c_parser_omp_critical (loc, parser, if_p);
   31346          144 :       break;
   31347         1322 :     case PRAGMA_OMP_DISTRIBUTE:
   31348         1322 :       strcpy (p_name, "#pragma omp");
   31349         1322 :       stmt = c_parser_omp_distribute (loc, parser, p_name, mask, NULL, if_p);
   31350         1322 :       break;
   31351         1834 :     case PRAGMA_OMP_FOR:
   31352         1834 :       strcpy (p_name, "#pragma omp");
   31353         1834 :       stmt = c_parser_omp_for (loc, parser, p_name, mask, NULL, if_p);
   31354         1834 :       break;
   31355          164 :     case PRAGMA_OMP_LOOP:
   31356          164 :       strcpy (p_name, "#pragma omp");
   31357          164 :       stmt = c_parser_omp_loop (loc, parser, p_name, mask, NULL, if_p);
   31358          164 :       break;
   31359           74 :     case PRAGMA_OMP_MASKED:
   31360           74 :       strcpy (p_name, "#pragma omp");
   31361           74 :       stmt = c_parser_omp_masked (loc, parser, p_name, mask, NULL, if_p);
   31362           74 :       break;
   31363          137 :     case PRAGMA_OMP_MASTER:
   31364          137 :       strcpy (p_name, "#pragma omp");
   31365          137 :       stmt = c_parser_omp_master (loc, parser, p_name, mask, NULL, if_p,
   31366              :                                   UNKNOWN_LOCATION);
   31367          137 :       break;
   31368         2536 :     case PRAGMA_OMP_PARALLEL:
   31369         2536 :       strcpy (p_name, "#pragma omp");
   31370         2536 :       stmt = c_parser_omp_parallel (loc, parser, p_name, mask, NULL, if_p);
   31371         2536 :       break;
   31372           68 :     case PRAGMA_OMP_SCOPE:
   31373           68 :       stmt = c_parser_omp_scope (loc, parser, if_p);
   31374           68 :       break;
   31375          108 :     case PRAGMA_OMP_SECTIONS:
   31376          108 :       strcpy (p_name, "#pragma omp");
   31377          108 :       stmt = c_parser_omp_sections (loc, parser, p_name, mask, NULL);
   31378          108 :       break;
   31379          872 :     case PRAGMA_OMP_SIMD:
   31380          872 :       strcpy (p_name, "#pragma omp");
   31381          872 :       stmt = c_parser_omp_simd (loc, parser, p_name, mask, NULL, if_p);
   31382          872 :       break;
   31383          230 :     case PRAGMA_OMP_SINGLE:
   31384          230 :       stmt = c_parser_omp_single (loc, parser, if_p);
   31385          230 :       break;
   31386          918 :     case PRAGMA_OMP_TASK:
   31387          918 :       stmt = c_parser_omp_task (loc, parser, if_p);
   31388          918 :       break;
   31389          138 :     case PRAGMA_OMP_TASKGROUP:
   31390          138 :       stmt = c_parser_omp_taskgroup (loc, parser, if_p);
   31391          138 :       break;
   31392          256 :     case PRAGMA_OMP_TASKLOOP:
   31393          256 :       strcpy (p_name, "#pragma omp");
   31394          256 :       stmt = c_parser_omp_taskloop (loc, parser, p_name, mask, NULL, if_p);
   31395          256 :       break;
   31396         1991 :     case PRAGMA_OMP_TEAMS:
   31397         1991 :       strcpy (p_name, "#pragma omp");
   31398         1991 :       stmt = c_parser_omp_teams (loc, parser, p_name, mask, NULL, if_p);
   31399         1991 :       break;
   31400           46 :     case PRAGMA_OMP_ASSUME:
   31401           46 :       c_parser_omp_assume (parser, if_p);
   31402           46 :       return;
   31403          110 :     case PRAGMA_OMP_TILE:
   31404          110 :       stmt = c_parser_omp_tile (loc, parser, if_p);
   31405          110 :       break;
   31406          105 :     case PRAGMA_OMP_UNROLL:
   31407          105 :       stmt = c_parser_omp_unroll (loc, parser, if_p);
   31408          105 :       break;
   31409          155 :     case PRAGMA_OMP_DISPATCH:
   31410          155 :       stmt = c_parser_omp_dispatch (loc, parser);
   31411          155 :       break;
   31412            0 :     default:
   31413            0 :       gcc_unreachable ();
   31414              :     }
   31415              : 
   31416        15830 :   if (stmt && stmt != error_mark_node)
   31417        15521 :     gcc_assert (EXPR_LOCATION (stmt) != UNKNOWN_LOCATION);
   31418              : }
   31419              : 
   31420              : /* OpenMP 6.0:
   31421              :    # pragma omp groupprivate (variable-list) [device_type(...)]  */
   31422              : 
   31423              : #define OMP_GROUPPRIVATE_CLAUSE_MASK                                    \
   31424              :         ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE_TYPE) )
   31425              : 
   31426              : static void
   31427            9 : c_parser_omp_groupprivate (c_parser *parser)
   31428              : {
   31429            9 :   location_t loc = c_parser_peek_token (parser)->location;
   31430            9 :   c_parser_consume_pragma (parser);
   31431            9 :   tree vars = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ERROR, NULL);
   31432            9 :   tree clauses = c_parser_omp_all_clauses (parser, OMP_GROUPPRIVATE_CLAUSE_MASK,
   31433              :                                            "#pragma omp groupprivate");
   31434              :   /* TODO: Implies 'declare target local' with specified device_type, check for
   31435              :      conflicts.  Check for other restrictions.  */
   31436            9 :   (void) vars;
   31437            9 :   (void) clauses;
   31438            9 :   sorry_at (loc, "%<omp groupprivate%>");
   31439            9 : }
   31440              : 
   31441              : /* OpenMP 2.5:
   31442              :    # pragma omp threadprivate (variable-list) */
   31443              : 
   31444              : static void
   31445           79 : c_parser_omp_threadprivate (c_parser *parser)
   31446              : {
   31447           79 :   tree vars, t;
   31448           79 :   location_t loc;
   31449              : 
   31450           79 :   c_parser_consume_pragma (parser);
   31451           79 :   vars = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ERROR, NULL);
   31452              : 
   31453              :   /* Mark every variable in VARS to be assigned thread local storage.  */
   31454          248 :   for (t = vars; t; t = TREE_CHAIN (t))
   31455              :     {
   31456           90 :       tree v = TREE_PURPOSE (t);
   31457           90 :       loc = EXPR_LOCATION (TREE_VALUE (t));
   31458              : 
   31459              :       /* If V had already been marked threadprivate, it doesn't matter
   31460              :          whether it had been used prior to this point.  */
   31461           90 :       if (!VAR_P (v))
   31462            1 :         error_at (loc, "%qD is not a variable", v);
   31463           89 :       else if (TREE_USED (v) && !C_DECL_THREADPRIVATE_P (v))
   31464            2 :         error_at (loc, "%qE declared %<threadprivate%> after first use", v);
   31465           87 :       else if (! is_global_var (v))
   31466            2 :         error_at (loc, "automatic variable %qE cannot be %<threadprivate%>", v);
   31467           85 :       else if (TREE_TYPE (v) == error_mark_node)
   31468              :         ;
   31469           84 :       else if (! COMPLETE_TYPE_P (TREE_TYPE (v)))
   31470            1 :         error_at (loc, "%<threadprivate%> %qE has incomplete type", v);
   31471              :       else
   31472              :         {
   31473           83 :           if (! DECL_THREAD_LOCAL_P (v))
   31474              :             {
   31475           83 :               set_decl_tls_model (v, decl_default_tls_model (v));
   31476              :               /* If rtl has been already set for this var, call
   31477              :                  make_decl_rtl once again, so that encode_section_info
   31478              :                  has a chance to look at the new decl flags.  */
   31479           83 :               if (DECL_RTL_SET_P (v))
   31480            0 :                 make_decl_rtl (v);
   31481              :             }
   31482           83 :           C_DECL_THREADPRIVATE_P (v) = 1;
   31483              :         }
   31484              :     }
   31485              : 
   31486           79 :   c_parser_skip_to_pragma_eol (parser);
   31487           79 : }
   31488              : 
   31489              : /* Parse a transaction attribute (GCC Extension).
   31490              : 
   31491              :    transaction-attribute:
   31492              :      gnu-attributes
   31493              :      attribute-specifier
   31494              : */
   31495              : 
   31496              : static tree
   31497          139 : c_parser_transaction_attributes (c_parser *parser)
   31498              : {
   31499          139 :   if (c_parser_next_token_is_keyword (parser, RID_ATTRIBUTE))
   31500            0 :     return c_parser_gnu_attributes (parser);
   31501              : 
   31502          139 :   if (!c_parser_next_token_is (parser, CPP_OPEN_SQUARE))
   31503              :     return NULL_TREE;
   31504           20 :   return c_parser_std_attribute_specifier (parser, true);
   31505              : }
   31506              : 
   31507              : /* Parse a __transaction_atomic or __transaction_relaxed statement
   31508              :    (GCC Extension).
   31509              : 
   31510              :    transaction-statement:
   31511              :      __transaction_atomic transaction-attribute[opt] compound-statement
   31512              :      __transaction_relaxed compound-statement
   31513              : 
   31514              :    Note that the only valid attribute is: "outer".
   31515              : */
   31516              : 
   31517              : static tree
   31518          137 : c_parser_transaction (c_parser *parser, enum rid keyword)
   31519              : {
   31520          137 :   unsigned int old_in = parser->in_transaction;
   31521          137 :   unsigned int this_in = 1, new_in;
   31522          137 :   location_t loc = c_parser_peek_token (parser)->location;
   31523          137 :   tree stmt, attrs;
   31524              : 
   31525          274 :   gcc_assert ((keyword == RID_TRANSACTION_ATOMIC
   31526              :       || keyword == RID_TRANSACTION_RELAXED)
   31527              :       && c_parser_next_token_is_keyword (parser, keyword));
   31528          137 :   c_parser_consume_token (parser);
   31529              : 
   31530          137 :   if (keyword == RID_TRANSACTION_RELAXED)
   31531              :     this_in |= TM_STMT_ATTR_RELAXED;
   31532              :   else
   31533              :     {
   31534          106 :       attrs = c_parser_transaction_attributes (parser);
   31535          106 :       if (attrs)
   31536           14 :         this_in |= parse_tm_stmt_attr (attrs, TM_STMT_ATTR_OUTER);
   31537              :     }
   31538              : 
   31539              :   /* Keep track if we're in the lexical scope of an outer transaction.  */
   31540          137 :   new_in = this_in | (old_in & TM_STMT_ATTR_OUTER);
   31541              : 
   31542          137 :   parser->in_transaction = new_in;
   31543          137 :   stmt = c_parser_compound_statement (parser);
   31544          137 :   parser->in_transaction = old_in;
   31545              : 
   31546          137 :   if (flag_tm)
   31547          135 :     stmt = c_finish_transaction (loc, stmt, this_in);
   31548              :   else
   31549            2 :     error_at (loc,
   31550              :               keyword == RID_TRANSACTION_ATOMIC
   31551              :               ? G_("%<__transaction_atomic%> without transactional memory "
   31552              :                    "support enabled")
   31553              :               : G_("%<__transaction_relaxed%> without transactional memory "
   31554              :                    "support enabled"));
   31555              : 
   31556          137 :   return stmt;
   31557              : }
   31558              : 
   31559              : /* Parse a __transaction_atomic or __transaction_relaxed expression
   31560              :    (GCC Extension).
   31561              : 
   31562              :    transaction-expression:
   31563              :      __transaction_atomic ( expression )
   31564              :      __transaction_relaxed ( expression )
   31565              : */
   31566              : 
   31567              : static struct c_expr
   31568            7 : c_parser_transaction_expression (c_parser *parser, enum rid keyword)
   31569              : {
   31570            7 :   struct c_expr ret;
   31571            7 :   unsigned int old_in = parser->in_transaction;
   31572            7 :   unsigned int this_in = 1;
   31573            7 :   location_t loc = c_parser_peek_token (parser)->location;
   31574            7 :   tree attrs;
   31575              : 
   31576           14 :   gcc_assert ((keyword == RID_TRANSACTION_ATOMIC
   31577              :       || keyword == RID_TRANSACTION_RELAXED)
   31578              :       && c_parser_next_token_is_keyword (parser, keyword));
   31579            7 :   c_parser_consume_token (parser);
   31580              : 
   31581            7 :   if (keyword == RID_TRANSACTION_RELAXED)
   31582              :     this_in |= TM_STMT_ATTR_RELAXED;
   31583              :   else
   31584              :     {
   31585            5 :       attrs = c_parser_transaction_attributes (parser);
   31586            5 :       if (attrs)
   31587            0 :         this_in |= parse_tm_stmt_attr (attrs, 0);
   31588              :     }
   31589              : 
   31590            7 :   parser->in_transaction = this_in;
   31591            7 :   matching_parens parens;
   31592            7 :   if (parens.require_open (parser))
   31593              :     {
   31594            7 :       tree expr = c_parser_expression (parser).value;
   31595            7 :       ret.original_type = TREE_TYPE (expr);
   31596            7 :       ret.value = build1 (TRANSACTION_EXPR, ret.original_type, expr);
   31597            7 :       if (this_in & TM_STMT_ATTR_RELAXED)
   31598            2 :         TRANSACTION_EXPR_RELAXED (ret.value) = 1;
   31599            7 :       SET_EXPR_LOCATION (ret.value, loc);
   31600            7 :       ret.original_code = TRANSACTION_EXPR;
   31601            7 :       ret.m_decimal = 0;
   31602            7 :       if (!parens.require_close (parser))
   31603              :         {
   31604            0 :           c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
   31605            0 :           goto error;
   31606              :         }
   31607              :     }
   31608              :   else
   31609              :     {
   31610            0 :      error:
   31611            0 :       ret.set_error ();
   31612            0 :       ret.original_code = ERROR_MARK;
   31613            0 :       ret.original_type = NULL;
   31614              :     }
   31615            7 :   parser->in_transaction = old_in;
   31616              : 
   31617            7 :   if (!flag_tm)
   31618            6 :     error_at (loc,
   31619              :               keyword == RID_TRANSACTION_ATOMIC
   31620              :               ? G_("%<__transaction_atomic%> without transactional memory "
   31621              :                    "support enabled")
   31622              :               : G_("%<__transaction_relaxed%> without transactional memory "
   31623              :                    "support enabled"));
   31624              : 
   31625            7 :   set_c_expr_source_range (&ret, loc, loc);
   31626              : 
   31627            7 :   return ret;
   31628              : }
   31629              : 
   31630              : /* Parse a __transaction_cancel statement (GCC Extension).
   31631              : 
   31632              :    transaction-cancel-statement:
   31633              :      __transaction_cancel transaction-attribute[opt] ;
   31634              : 
   31635              :    Note that the only valid attribute is "outer".
   31636              : */
   31637              : 
   31638              : static tree
   31639           28 : c_parser_transaction_cancel (c_parser *parser)
   31640              : {
   31641           28 :   location_t loc = c_parser_peek_token (parser)->location;
   31642           28 :   tree attrs;
   31643           28 :   bool is_outer = false;
   31644              : 
   31645           28 :   gcc_assert (c_parser_next_token_is_keyword (parser, RID_TRANSACTION_CANCEL));
   31646           28 :   c_parser_consume_token (parser);
   31647              : 
   31648           28 :   attrs = c_parser_transaction_attributes (parser);
   31649           28 :   if (attrs)
   31650            5 :     is_outer = (parse_tm_stmt_attr (attrs, TM_STMT_ATTR_OUTER) != 0);
   31651              : 
   31652           28 :   if (!flag_tm)
   31653              :     {
   31654            2 :       error_at (loc, "%<__transaction_cancel%> without "
   31655              :                 "transactional memory support enabled");
   31656            2 :       goto ret_error;
   31657              :     }
   31658           26 :   else if (parser->in_transaction & TM_STMT_ATTR_RELAXED)
   31659              :     {
   31660            0 :       error_at (loc, "%<__transaction_cancel%> within a "
   31661              :                 "%<__transaction_relaxed%>");
   31662            0 :       goto ret_error;
   31663              :     }
   31664           26 :   else if (is_outer)
   31665              :     {
   31666            5 :       if ((parser->in_transaction & TM_STMT_ATTR_OUTER) == 0
   31667            5 :           && !is_tm_may_cancel_outer (current_function_decl))
   31668              :         {
   31669            0 :           error_at (loc, "outer %<__transaction_cancel%> not "
   31670              :                     "within outer %<__transaction_atomic%> or "
   31671              :                     "a %<transaction_may_cancel_outer%> function");
   31672            0 :           goto ret_error;
   31673              :         }
   31674              :     }
   31675           21 :   else if (parser->in_transaction == 0)
   31676              :     {
   31677            0 :       error_at (loc, "%<__transaction_cancel%> not within "
   31678              :                 "%<__transaction_atomic%>");
   31679            0 :       goto ret_error;
   31680              :     }
   31681              : 
   31682           26 :   return add_stmt (build_tm_abort_call (loc, is_outer));
   31683              : 
   31684            2 :  ret_error:
   31685            2 :   return build1 (NOP_EXPR, void_type_node, error_mark_node);
   31686              : }
   31687              : 
   31688              : /* Parse a single source file.  */
   31689              : 
   31690              : void
   31691       110226 : c_parse_file (void)
   31692              : {
   31693              :   /* Use local storage to begin.  If the first token is a pragma, parse it.
   31694              :      If it is #pragma GCC pch_preprocess, then this will load a PCH file
   31695              :      which will cause garbage collection.  */
   31696       110226 :   c_parser tparser;
   31697              : 
   31698       110226 :   memset (&tparser, 0, sizeof tparser);
   31699       110226 :   tparser.translate_strings_p = true;
   31700       110226 :   tparser.tokens = &tparser.tokens_buf[0];
   31701       110226 :   the_parser = &tparser;
   31702              : 
   31703       110226 :   if (c_parser_peek_token (&tparser)->pragma_kind == PRAGMA_GCC_PCH_PREPROCESS)
   31704           12 :     c_parser_pragma_pch_preprocess (&tparser);
   31705              :   else
   31706       110146 :     c_common_no_more_pch ();
   31707              : 
   31708       110158 :   the_parser = ggc_alloc<c_parser> ();
   31709       110158 :   *the_parser = tparser;
   31710       110158 :   if (tparser.tokens == &tparser.tokens_buf[0])
   31711       110158 :     the_parser->tokens = &the_parser->tokens_buf[0];
   31712              : 
   31713              :   /* Initialize EH, if we've been told to do so.  */
   31714       110158 :   if (flag_exceptions)
   31715          526 :     using_eh_for_cleanups ();
   31716              : 
   31717       110158 :   c_parser_translation_unit (the_parser);
   31718       110068 :   the_parser = NULL;
   31719       110068 : }
   31720              : 
   31721              : void
   31722         5827 : c_init_preprocess (void)
   31723              : {
   31724              :   /* Create a parser for use by pragma_lex during preprocessing.  */
   31725         5827 :   the_parser = ggc_alloc<c_parser> ();
   31726         5827 :   memset (the_parser, 0, sizeof (c_parser));
   31727         5827 :   the_parser->tokens = &the_parser->tokens_buf[0];
   31728         5827 : }
   31729              : 
   31730              : /* Parse the body of a function declaration marked with "__RTL".
   31731              : 
   31732              :    The RTL parser works on the level of characters read from a
   31733              :    FILE *, whereas c_parser works at the level of tokens.
   31734              :    Square this circle by consuming all of the tokens up to and
   31735              :    including the closing brace, recording the start/end of the RTL
   31736              :    fragment, and reopening the file and re-reading the relevant
   31737              :    lines within the RTL parser.
   31738              : 
   31739              :    This requires the opening and closing braces of the C function
   31740              :    to be on separate lines from the RTL they wrap.
   31741              : 
   31742              :    Take ownership of START_WITH_PASS, if non-NULL.  */
   31743              : 
   31744              : location_t
   31745           39 : c_parser_parse_rtl_body (c_parser *parser, char *start_with_pass)
   31746              : {
   31747           39 :   if (!c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>"))
   31748              :     {
   31749            0 :       free (start_with_pass);
   31750            0 :       return c_parser_peek_token (parser)->location;
   31751              :     }
   31752              : 
   31753           39 :   location_t start_loc = c_parser_peek_token (parser)->location;
   31754              : 
   31755              :   /* Consume all tokens, up to the closing brace, handling
   31756              :      matching pairs of braces in the rtl dump.  */
   31757           39 :   int num_open_braces = 1;
   31758        37693 :   while (1)
   31759              :     {
   31760        18866 :       switch (c_parser_peek_token (parser)->type)
   31761              :         {
   31762            1 :         case CPP_OPEN_BRACE:
   31763            1 :           num_open_braces++;
   31764            1 :           break;
   31765           39 :         case CPP_CLOSE_BRACE:
   31766           39 :           if (--num_open_braces == 0)
   31767           38 :             goto found_closing_brace;
   31768              :           break;
   31769            1 :         case CPP_EOF:
   31770            1 :           error_at (start_loc, "no closing brace");
   31771            1 :           free (start_with_pass);
   31772            1 :           return c_parser_peek_token (parser)->location;
   31773              :         default:
   31774              :           break;
   31775              :         }
   31776        18827 :       c_parser_consume_token (parser);
   31777              :     }
   31778              : 
   31779           38 :  found_closing_brace:
   31780              :   /* At the closing brace; record its location.  */
   31781           38 :   location_t end_loc = c_parser_peek_token (parser)->location;
   31782              : 
   31783              :   /* Consume the closing brace.  */
   31784           38 :   c_parser_consume_token (parser);
   31785              : 
   31786              :   /* Invoke the RTL parser.  */
   31787           38 :   if (!read_rtl_function_body_from_file_range (start_loc, end_loc))
   31788              :     {
   31789            0 :       free (start_with_pass);
   31790            0 :       return end_loc;
   31791              :     }
   31792              : 
   31793              :  /*  Run the backend on the cfun created above, transferring ownership of
   31794              :      START_WITH_PASS.  */
   31795           37 :   run_rtl_passes (start_with_pass);
   31796           37 :   return end_loc;
   31797              : }
   31798              : 
   31799              : #include "gt-c-c-parser.h"
        

Generated by: LCOV version 2.6-beta

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