1627f7eb2Smrg /* All matcher functions. 2*4c3eb207Smrg Copyright (C) 2003-2020 Free Software Foundation, Inc. 3627f7eb2Smrg Contributed by Steven Bosscher 4627f7eb2Smrg 5627f7eb2Smrg This file is part of GCC. 6627f7eb2Smrg 7627f7eb2Smrg GCC is free software; you can redistribute it and/or modify it under 8627f7eb2Smrg the terms of the GNU General Public License as published by the Free 9627f7eb2Smrg Software Foundation; either version 3, or (at your option) any later 10627f7eb2Smrg version. 11627f7eb2Smrg 12627f7eb2Smrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13627f7eb2Smrg WARRANTY; without even the implied warranty of MERCHANTABILITY or 14627f7eb2Smrg FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15627f7eb2Smrg for more details. 16627f7eb2Smrg 17627f7eb2Smrg You should have received a copy of the GNU General Public License 18627f7eb2Smrg along with GCC; see the file COPYING3. If not see 19627f7eb2Smrg <http://www.gnu.org/licenses/>. */ 20627f7eb2Smrg 21627f7eb2Smrg 22627f7eb2Smrg #ifndef GFC_MATCH_H 23627f7eb2Smrg #define GFC_MATCH_H 24627f7eb2Smrg 25627f7eb2Smrg /* gfc_new_block points to the symbol of a newly matched block. */ 26627f7eb2Smrg extern gfc_symbol *gfc_new_block; 27627f7eb2Smrg 28627f7eb2Smrg /* Current statement label. Zero means no statement label. Because 29627f7eb2Smrg new_st can get wiped during statement matching, we have to keep it 30627f7eb2Smrg separate. */ 31627f7eb2Smrg extern gfc_st_label *gfc_statement_label; 32627f7eb2Smrg 33627f7eb2Smrg extern int gfc_matching_ptr_assignment; 34627f7eb2Smrg extern int gfc_matching_procptr_assignment; 35627f7eb2Smrg extern bool gfc_matching_prefix; 36627f7eb2Smrg 37627f7eb2Smrg /* Default access specifier while matching procedure bindings. */ 38627f7eb2Smrg extern gfc_access gfc_typebound_default_access; 39627f7eb2Smrg 40627f7eb2Smrg /****************** All gfc_match* routines *****************/ 41627f7eb2Smrg 42627f7eb2Smrg /* match.c. */ 43627f7eb2Smrg 44627f7eb2Smrg /* Generic match subroutines. */ 45627f7eb2Smrg match gfc_match_special_char (gfc_char_t *); 46627f7eb2Smrg match gfc_match_space (void); 47627f7eb2Smrg match gfc_match_eos (void); 48627f7eb2Smrg match gfc_match_small_literal_int (int *, int *); 49627f7eb2Smrg match gfc_match_st_label (gfc_st_label **); 50627f7eb2Smrg match gfc_match_label (void); 51627f7eb2Smrg match gfc_match_small_int (int *); 52627f7eb2Smrg match gfc_match_small_int_expr (int *, gfc_expr **); 53627f7eb2Smrg match gfc_match_name (char *); 54627f7eb2Smrg match gfc_match_name_C (const char **buffer); 55627f7eb2Smrg match gfc_match_symbol (gfc_symbol **, int); 56627f7eb2Smrg match gfc_match_sym_tree (gfc_symtree **, int); 57627f7eb2Smrg match gfc_match_intrinsic_op (gfc_intrinsic_op *); 58627f7eb2Smrg match gfc_match_char (char); 59627f7eb2Smrg match gfc_match (const char *, ...); 60627f7eb2Smrg match gfc_match_iterator (gfc_iterator *, int); 61627f7eb2Smrg match gfc_match_parens (void); 62627f7eb2Smrg match gfc_match_type_spec (gfc_typespec *); 63627f7eb2Smrg match gfc_match_member_sep(gfc_symbol *); 64627f7eb2Smrg 65627f7eb2Smrg 66627f7eb2Smrg /* Statement matchers. */ 67627f7eb2Smrg match gfc_match_program (void); 68627f7eb2Smrg match gfc_match_pointer_assignment (void); 69627f7eb2Smrg match gfc_match_assignment (void); 70627f7eb2Smrg match gfc_match_if (gfc_statement *); 71627f7eb2Smrg match gfc_match_else (void); 72627f7eb2Smrg match gfc_match_elseif (void); 73627f7eb2Smrg match gfc_match_event_post (void); 74627f7eb2Smrg match gfc_match_event_wait (void); 75627f7eb2Smrg match gfc_match_critical (void); 76627f7eb2Smrg match gfc_match_fail_image (void); 77627f7eb2Smrg match gfc_match_change_team (void); 78627f7eb2Smrg match gfc_match_end_team (void); 79627f7eb2Smrg match gfc_match_form_team (void); 80627f7eb2Smrg match gfc_match_sync_team (void); 81627f7eb2Smrg match gfc_match_block (void); 82627f7eb2Smrg match gfc_match_associate (void); 83627f7eb2Smrg match gfc_match_do (void); 84627f7eb2Smrg match gfc_match_cycle (void); 85627f7eb2Smrg match gfc_match_exit (void); 86627f7eb2Smrg match gfc_match_lock (void); 87627f7eb2Smrg match gfc_match_pause (void); 88627f7eb2Smrg match gfc_match_stop (void); 89627f7eb2Smrg match gfc_match_error_stop (void); 90627f7eb2Smrg match gfc_match_continue (void); 91627f7eb2Smrg match gfc_match_assign (void); 92627f7eb2Smrg match gfc_match_goto (void); 93627f7eb2Smrg match gfc_match_sync_all (void); 94627f7eb2Smrg match gfc_match_sync_images (void); 95627f7eb2Smrg match gfc_match_sync_memory (void); 96627f7eb2Smrg match gfc_match_unlock (void); 97627f7eb2Smrg 98627f7eb2Smrg match gfc_match_allocate (void); 99627f7eb2Smrg match gfc_match_nullify (void); 100627f7eb2Smrg match gfc_match_deallocate (void); 101627f7eb2Smrg match gfc_match_return (void); 102627f7eb2Smrg match gfc_match_call (void); 103627f7eb2Smrg 104627f7eb2Smrg /* We want to use this function to check for a common-block-name 105627f7eb2Smrg that can exist in a bind statement, so removed the "static" 106627f7eb2Smrg declaration of the function in match.c. 107627f7eb2Smrg 108627f7eb2Smrg TODO: should probably rename this now that it'll be globally seen to 109627f7eb2Smrg gfc_match_common_name. */ 110627f7eb2Smrg match match_common_name (char *name); 111627f7eb2Smrg 112627f7eb2Smrg match gfc_match_common (void); 113627f7eb2Smrg match gfc_match_block_data (void); 114627f7eb2Smrg match gfc_match_namelist (void); 115627f7eb2Smrg match gfc_match_module (void); 116627f7eb2Smrg match gfc_match_equivalence (void); 117627f7eb2Smrg match gfc_match_st_function (void); 118627f7eb2Smrg match gfc_match_ptr_fcn_assign (void); 119627f7eb2Smrg match gfc_match_case (void); 120627f7eb2Smrg match gfc_match_select (void); 121627f7eb2Smrg match gfc_match_select_type (void); 122627f7eb2Smrg match gfc_match_type_is (void); 123627f7eb2Smrg match gfc_match_class_is (void); 124*4c3eb207Smrg match gfc_match_select_rank (void); 125*4c3eb207Smrg match gfc_match_rank_is (void); 126627f7eb2Smrg match gfc_match_where (gfc_statement *); 127627f7eb2Smrg match gfc_match_elsewhere (void); 128627f7eb2Smrg match gfc_match_forall (gfc_statement *); 129627f7eb2Smrg 130627f7eb2Smrg /* Other functions. */ 131627f7eb2Smrg 132627f7eb2Smrg gfc_common_head *gfc_get_common (const char *, int); 133627f7eb2Smrg 134627f7eb2Smrg /* openmp.c. */ 135627f7eb2Smrg 136627f7eb2Smrg /* OpenACC directive matchers. */ 137627f7eb2Smrg match gfc_match_oacc_atomic (void); 138627f7eb2Smrg match gfc_match_oacc_cache (void); 139627f7eb2Smrg match gfc_match_oacc_wait (void); 140627f7eb2Smrg match gfc_match_oacc_update (void); 141627f7eb2Smrg match gfc_match_oacc_declare (void); 142627f7eb2Smrg match gfc_match_oacc_loop (void); 143627f7eb2Smrg match gfc_match_oacc_host_data (void); 144627f7eb2Smrg match gfc_match_oacc_data (void); 145627f7eb2Smrg match gfc_match_oacc_kernels (void); 146627f7eb2Smrg match gfc_match_oacc_kernels_loop (void); 147627f7eb2Smrg match gfc_match_oacc_parallel (void); 148627f7eb2Smrg match gfc_match_oacc_parallel_loop (void); 149*4c3eb207Smrg match gfc_match_oacc_serial (void); 150*4c3eb207Smrg match gfc_match_oacc_serial_loop (void); 151627f7eb2Smrg match gfc_match_oacc_enter_data (void); 152627f7eb2Smrg match gfc_match_oacc_exit_data (void); 153627f7eb2Smrg match gfc_match_oacc_routine (void); 154627f7eb2Smrg 155627f7eb2Smrg /* OpenMP directive matchers. */ 156*4c3eb207Smrg match gfc_match_omp_eos_error (void); 157627f7eb2Smrg match gfc_match_omp_atomic (void); 158627f7eb2Smrg match gfc_match_omp_barrier (void); 159627f7eb2Smrg match gfc_match_omp_cancel (void); 160627f7eb2Smrg match gfc_match_omp_cancellation_point (void); 161627f7eb2Smrg match gfc_match_omp_critical (void); 162627f7eb2Smrg match gfc_match_omp_declare_reduction (void); 163627f7eb2Smrg match gfc_match_omp_declare_simd (void); 164627f7eb2Smrg match gfc_match_omp_declare_target (void); 165627f7eb2Smrg match gfc_match_omp_distribute (void); 166627f7eb2Smrg match gfc_match_omp_distribute_parallel_do (void); 167627f7eb2Smrg match gfc_match_omp_distribute_parallel_do_simd (void); 168627f7eb2Smrg match gfc_match_omp_distribute_simd (void); 169627f7eb2Smrg match gfc_match_omp_do (void); 170627f7eb2Smrg match gfc_match_omp_do_simd (void); 171627f7eb2Smrg match gfc_match_omp_flush (void); 172627f7eb2Smrg match gfc_match_omp_master (void); 173627f7eb2Smrg match gfc_match_omp_ordered (void); 174627f7eb2Smrg match gfc_match_omp_ordered_depend (void); 175627f7eb2Smrg match gfc_match_omp_parallel (void); 176627f7eb2Smrg match gfc_match_omp_parallel_do (void); 177627f7eb2Smrg match gfc_match_omp_parallel_do_simd (void); 178627f7eb2Smrg match gfc_match_omp_parallel_sections (void); 179627f7eb2Smrg match gfc_match_omp_parallel_workshare (void); 180627f7eb2Smrg match gfc_match_omp_sections (void); 181627f7eb2Smrg match gfc_match_omp_simd (void); 182627f7eb2Smrg match gfc_match_omp_single (void); 183627f7eb2Smrg match gfc_match_omp_target (void); 184627f7eb2Smrg match gfc_match_omp_target_data (void); 185627f7eb2Smrg match gfc_match_omp_target_enter_data (void); 186627f7eb2Smrg match gfc_match_omp_target_exit_data (void); 187627f7eb2Smrg match gfc_match_omp_target_parallel (void); 188627f7eb2Smrg match gfc_match_omp_target_parallel_do (void); 189627f7eb2Smrg match gfc_match_omp_target_parallel_do_simd (void); 190627f7eb2Smrg match gfc_match_omp_target_simd (void); 191627f7eb2Smrg match gfc_match_omp_target_teams (void); 192627f7eb2Smrg match gfc_match_omp_target_teams_distribute (void); 193627f7eb2Smrg match gfc_match_omp_target_teams_distribute_parallel_do (void); 194627f7eb2Smrg match gfc_match_omp_target_teams_distribute_parallel_do_simd (void); 195627f7eb2Smrg match gfc_match_omp_target_teams_distribute_simd (void); 196627f7eb2Smrg match gfc_match_omp_target_update (void); 197627f7eb2Smrg match gfc_match_omp_task (void); 198627f7eb2Smrg match gfc_match_omp_taskgroup (void); 199627f7eb2Smrg match gfc_match_omp_taskloop (void); 200627f7eb2Smrg match gfc_match_omp_taskloop_simd (void); 201627f7eb2Smrg match gfc_match_omp_taskwait (void); 202627f7eb2Smrg match gfc_match_omp_taskyield (void); 203627f7eb2Smrg match gfc_match_omp_teams (void); 204627f7eb2Smrg match gfc_match_omp_teams_distribute (void); 205627f7eb2Smrg match gfc_match_omp_teams_distribute_parallel_do (void); 206627f7eb2Smrg match gfc_match_omp_teams_distribute_parallel_do_simd (void); 207627f7eb2Smrg match gfc_match_omp_teams_distribute_simd (void); 208627f7eb2Smrg match gfc_match_omp_threadprivate (void); 209627f7eb2Smrg match gfc_match_omp_workshare (void); 210627f7eb2Smrg match gfc_match_omp_end_critical (void); 211627f7eb2Smrg match gfc_match_omp_end_nowait (void); 212627f7eb2Smrg match gfc_match_omp_end_single (void); 213627f7eb2Smrg 214627f7eb2Smrg /* decl.c. */ 215627f7eb2Smrg 216627f7eb2Smrg match gfc_match_data (void); 217627f7eb2Smrg match gfc_match_null (gfc_expr **); 218627f7eb2Smrg match gfc_match_kind_spec (gfc_typespec *, bool); 219627f7eb2Smrg match gfc_match_old_kind_spec (gfc_typespec *); 220627f7eb2Smrg match gfc_match_decl_type_spec (gfc_typespec *, int); 221627f7eb2Smrg 222627f7eb2Smrg match gfc_match_end (gfc_statement *); 223627f7eb2Smrg match gfc_match_data_decl (void); 224627f7eb2Smrg match gfc_match_formal_arglist (gfc_symbol *, int, int, bool = false); 225627f7eb2Smrg match gfc_match_procedure (void); 226627f7eb2Smrg match gfc_match_generic (void); 227627f7eb2Smrg match gfc_match_function_decl (void); 228627f7eb2Smrg match gfc_match_entry (void); 229627f7eb2Smrg match gfc_match_subroutine (void); 230627f7eb2Smrg match gfc_match_submod_proc (void); 231627f7eb2Smrg match gfc_match_map (void); 232627f7eb2Smrg match gfc_match_union (void); 233627f7eb2Smrg match gfc_match_structure_decl (void); 234627f7eb2Smrg match gfc_match_derived_decl (void); 235627f7eb2Smrg match gfc_match_final_decl (void); 236627f7eb2Smrg match gfc_match_type (gfc_statement *); 237627f7eb2Smrg 238627f7eb2Smrg match gfc_match_implicit_none (void); 239627f7eb2Smrg match gfc_match_implicit (void); 240627f7eb2Smrg 241627f7eb2Smrg void gfc_set_constant_character_len (gfc_charlen_t, gfc_expr *, 242627f7eb2Smrg gfc_charlen_t); 243627f7eb2Smrg 244627f7eb2Smrg /* Matchers for attribute declarations. */ 245627f7eb2Smrg match gfc_match_allocatable (void); 246627f7eb2Smrg match gfc_match_asynchronous (void); 247627f7eb2Smrg match gfc_match_automatic (void); 248627f7eb2Smrg match gfc_match_codimension (void); 249627f7eb2Smrg match gfc_match_contiguous (void); 250627f7eb2Smrg match gfc_match_dimension (void); 251627f7eb2Smrg match gfc_match_external (void); 252627f7eb2Smrg match gfc_match_gcc_attributes (void); 253627f7eb2Smrg match gfc_match_gcc_builtin (void); 254627f7eb2Smrg match gfc_match_gcc_ivdep (void); 255627f7eb2Smrg match gfc_match_gcc_novector (void); 256627f7eb2Smrg match gfc_match_gcc_unroll (void); 257627f7eb2Smrg match gfc_match_gcc_vector (void); 258627f7eb2Smrg match gfc_match_import (void); 259627f7eb2Smrg match gfc_match_intent (void); 260627f7eb2Smrg match gfc_match_intrinsic (void); 261627f7eb2Smrg match gfc_match_optional (void); 262627f7eb2Smrg match gfc_match_parameter (void); 263627f7eb2Smrg match gfc_match_pointer (void); 264627f7eb2Smrg match gfc_match_protected (void); 265627f7eb2Smrg match gfc_match_private (gfc_statement *); 266627f7eb2Smrg match gfc_match_public (gfc_statement *); 267627f7eb2Smrg match gfc_match_save (void); 268627f7eb2Smrg match gfc_match_static (void); 269627f7eb2Smrg match gfc_match_modproc (void); 270627f7eb2Smrg match gfc_match_target (void); 271627f7eb2Smrg match gfc_match_value (void); 272627f7eb2Smrg match gfc_match_volatile (void); 273627f7eb2Smrg 274627f7eb2Smrg /* decl.c. */ 275627f7eb2Smrg 276627f7eb2Smrg /* Fortran 2003 c interop. 277627f7eb2Smrg TODO: some of these should be moved to another file rather than decl.c */ 278627f7eb2Smrg void set_com_block_bind_c (gfc_common_head *, int); 279627f7eb2Smrg bool set_verify_bind_c_sym (gfc_symbol *, int); 280627f7eb2Smrg bool set_verify_bind_c_com_block (gfc_common_head *, int); 281627f7eb2Smrg bool get_bind_c_idents (void); 282627f7eb2Smrg match gfc_match_bind_c_stmt (void); 283627f7eb2Smrg match gfc_match_suffix (gfc_symbol *, gfc_symbol **); 284627f7eb2Smrg match gfc_match_bind_c (gfc_symbol *, bool); 285627f7eb2Smrg match gfc_get_type_attr_spec (symbol_attribute *, char*); 286627f7eb2Smrg 287627f7eb2Smrg /* primary.c. */ 288627f7eb2Smrg match gfc_match_structure_constructor (gfc_symbol *, gfc_expr **); 289627f7eb2Smrg match gfc_match_variable (gfc_expr **, int); 290627f7eb2Smrg match gfc_match_equiv_variable (gfc_expr **); 291627f7eb2Smrg match gfc_match_actual_arglist (int, gfc_actual_arglist **, bool = false); 292627f7eb2Smrg match gfc_match_literal_constant (gfc_expr **, int); 293627f7eb2Smrg 294627f7eb2Smrg /* expr.c -- FIXME: this one should be eliminated by moving the 295627f7eb2Smrg matcher to matchexp.c and a call to a new function in expr.c that 296627f7eb2Smrg only makes sure the init expr. is valid. */ 297627f7eb2Smrg bool gfc_reduce_init_expr (gfc_expr *expr); 298627f7eb2Smrg match gfc_match_init_expr (gfc_expr **); 299627f7eb2Smrg 300627f7eb2Smrg /* array.c. */ 301627f7eb2Smrg match gfc_match_array_spec (gfc_array_spec **, bool, bool); 302627f7eb2Smrg match gfc_match_array_ref (gfc_array_ref *, gfc_array_spec *, int, int); 303627f7eb2Smrg match gfc_match_array_constructor (gfc_expr **); 304627f7eb2Smrg 305627f7eb2Smrg /* interface.c. */ 306627f7eb2Smrg match gfc_match_abstract_interface (void); 307627f7eb2Smrg match gfc_match_generic_spec (interface_type *, char *, gfc_intrinsic_op *); 308627f7eb2Smrg match gfc_match_interface (void); 309627f7eb2Smrg match gfc_match_end_interface (void); 310627f7eb2Smrg 311627f7eb2Smrg /* io.c. */ 312627f7eb2Smrg match gfc_match_format (void); 313627f7eb2Smrg match gfc_match_open (void); 314627f7eb2Smrg match gfc_match_close (void); 315627f7eb2Smrg match gfc_match_endfile (void); 316627f7eb2Smrg match gfc_match_backspace (void); 317627f7eb2Smrg match gfc_match_rewind (void); 318627f7eb2Smrg match gfc_match_flush (void); 319627f7eb2Smrg match gfc_match_inquire (void); 320627f7eb2Smrg match gfc_match_read (void); 321627f7eb2Smrg match gfc_match_wait (void); 322627f7eb2Smrg match gfc_match_write (void); 323627f7eb2Smrg match gfc_match_print (void); 324627f7eb2Smrg 325627f7eb2Smrg /* matchexp.c. */ 326627f7eb2Smrg match gfc_match_defined_op_name (char *, int); 327627f7eb2Smrg match gfc_match_expr (gfc_expr **); 328627f7eb2Smrg 329627f7eb2Smrg /* module.c. */ 330627f7eb2Smrg match gfc_match_use (void); 331627f7eb2Smrg match gfc_match_submodule (void); 332627f7eb2Smrg void gfc_use_modules (void); 333627f7eb2Smrg 334627f7eb2Smrg #endif /* GFC_MATCH_H */ 335627f7eb2Smrg 336