comparison gcc/fortran/expr.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Routines for manipulation of expression nodes. 1 /* Routines for manipulation of expression nodes.
2 Copyright (C) 2000-2018 Free Software Foundation, Inc. 2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
3 Contributed by Andy Vaught 3 Contributed by Andy Vaught
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify it under 7 GCC is free software; you can redistribute it and/or modify it under
340 case_bt_struct: 340 case_bt_struct:
341 case BT_CLASS: 341 case BT_CLASS:
342 case BT_ASSUMED: 342 case BT_ASSUMED:
343 break; /* Already done. */ 343 break; /* Already done. */
344 344
345 case BT_BOZ:
346 q->boz.len = p->boz.len;
347 q->boz.rdx = p->boz.rdx;
348 q->boz.str = XCNEWVEC (char, q->boz.len + 1);
349 strncpy (q->boz.str, p->boz.str, p->boz.len);
350 break;
351
345 case BT_PROCEDURE: 352 case BT_PROCEDURE:
346 case BT_VOID: 353 case BT_VOID:
347 /* Should never be reached. */ 354 /* Should never be reached. */
348 case BT_UNKNOWN: 355 case BT_UNKNOWN:
349 gfc_internal_error ("gfc_copy_expr(): Bad expr node"); 356 gfc_internal_error ("gfc_copy_expr(): Bad expr node");
388 break; 395 break;
389 396
390 case EXPR_VARIABLE: 397 case EXPR_VARIABLE:
391 case EXPR_NULL: 398 case EXPR_NULL:
392 break; 399 break;
400
401 case EXPR_UNKNOWN:
402 gcc_unreachable ();
393 } 403 }
394 404
395 q->shape = gfc_copy_shape (p->shape, p->rank); 405 q->shape = gfc_copy_shape (p->shape, p->rank);
396 406
397 q->ref = gfc_copy_ref (p->ref); 407 q->ref = gfc_copy_ref (p->ref);
597 gfc_free_expr (p->u.ss.start); 607 gfc_free_expr (p->u.ss.start);
598 gfc_free_expr (p->u.ss.end); 608 gfc_free_expr (p->u.ss.end);
599 break; 609 break;
600 610
601 case REF_COMPONENT: 611 case REF_COMPONENT:
612 case REF_INQUIRY:
602 break; 613 break;
603 } 614 }
604 615
605 free (p); 616 free (p);
606 } 617 }
752 free (ar); 763 free (ar);
753 break; 764 break;
754 765
755 case REF_COMPONENT: 766 case REF_COMPONENT:
756 dest->u.c = src->u.c; 767 dest->u.c = src->u.c;
768 break;
769
770 case REF_INQUIRY:
771 dest->u.i = src->u.i;
757 break; 772 break;
758 773
759 case REF_SUBSTRING: 774 case REF_SUBSTRING:
760 dest->u.ss = src->u.ss; 775 dest->u.ss = src->u.ss;
761 dest->u.ss.start = gfc_copy_expr (src->u.ss.start); 776 dest->u.ss.start = gfc_copy_expr (src->u.ss.start);
1051 return false; 1066 return false;
1052 } 1067 }
1053 } 1068 }
1054 1069
1055 1070
1071 /* Is true if the expression or symbol is a passed CFI descriptor. */
1072 bool
1073 is_CFI_desc (gfc_symbol *sym, gfc_expr *e)
1074 {
1075 if (sym == NULL
1076 && e && e->expr_type == EXPR_VARIABLE)
1077 sym = e->symtree->n.sym;
1078
1079 if (sym && sym->attr.dummy
1080 && sym->ns->proc_name->attr.is_bind_c
1081 && sym->attr.dimension
1082 && (sym->attr.pointer
1083 || sym->attr.allocatable
1084 || sym->as->type == AS_ASSUMED_SHAPE
1085 || sym->as->type == AS_ASSUMED_RANK))
1086 return true;
1087
1088 return false;
1089 }
1090
1091
1056 /* Is true if an array reference is followed by a component or substring 1092 /* Is true if an array reference is followed by a component or substring
1057 reference. */ 1093 reference. */
1058 bool 1094 bool
1059 is_subref_array (gfc_expr * e) 1095 is_subref_array (gfc_expr * e)
1060 { 1096 {
1061 gfc_ref * ref; 1097 gfc_ref * ref;
1062 bool seen_array; 1098 bool seen_array;
1099 gfc_symbol *sym;
1063 1100
1064 if (e->expr_type != EXPR_VARIABLE) 1101 if (e->expr_type != EXPR_VARIABLE)
1065 return false; 1102 return false;
1066 1103
1067 if (e->symtree->n.sym->attr.subref_array_pointer) 1104 sym = e->symtree->n.sym;
1105
1106 if (sym->attr.subref_array_pointer)
1068 return true; 1107 return true;
1069 1108
1070 if (e->symtree->n.sym->ts.type == BT_CLASS
1071 && e->symtree->n.sym->attr.dummy
1072 && CLASS_DATA (e->symtree->n.sym)->attr.dimension
1073 && CLASS_DATA (e->symtree->n.sym)->attr.class_pointer)
1074 return true;
1075
1076 seen_array = false; 1109 seen_array = false;
1110
1077 for (ref = e->ref; ref; ref = ref->next) 1111 for (ref = e->ref; ref; ref = ref->next)
1078 { 1112 {
1113 /* If we haven't seen the array reference and this is an intrinsic,
1114 what follows cannot be a subreference array, unless there is a
1115 substring reference. */
1116 if (!seen_array && ref->type == REF_COMPONENT
1117 && ref->u.c.component->ts.type != BT_CHARACTER
1118 && ref->u.c.component->ts.type != BT_CLASS
1119 && !gfc_bt_struct (ref->u.c.component->ts.type))
1120 return false;
1121
1079 if (ref->type == REF_ARRAY 1122 if (ref->type == REF_ARRAY
1080 && ref->u.ar.type != AR_ELEMENT) 1123 && ref->u.ar.type != AR_ELEMENT)
1081 seen_array = true; 1124 seen_array = true;
1082 1125
1083 if (seen_array 1126 if (seen_array
1084 && ref->type != REF_ARRAY) 1127 && ref->type != REF_ARRAY)
1085 return seen_array; 1128 return seen_array;
1086 } 1129 }
1130
1131 if (sym->ts.type == BT_CLASS
1132 && sym->attr.dummy
1133 && CLASS_DATA (sym)->attr.dimension
1134 && CLASS_DATA (sym)->attr.class_pointer)
1135 return true;
1136
1087 return false; 1137 return false;
1088 } 1138 }
1089 1139
1090 1140
1091 /* Try to collapse intrinsic expressions. */ 1141 /* Try to collapse intrinsic expressions. */
1626 limit = mpz_get_ui (ptr); 1676 limit = mpz_get_ui (ptr);
1627 if (limit >= flag_max_array_constructor) 1677 if (limit >= flag_max_array_constructor)
1628 { 1678 {
1629 gfc_error ("The number of elements in the array constructor " 1679 gfc_error ("The number of elements in the array constructor "
1630 "at %L requires an increase of the allowed %d " 1680 "at %L requires an increase of the allowed %d "
1631 "upper limit. See -fmax-array-constructor " 1681 "upper limit. See %<-fmax-array-constructor%> "
1632 "option", &expr->where, flag_max_array_constructor); 1682 "option", &expr->where, flag_max_array_constructor);
1633 return false; 1683 return false;
1634 } 1684 }
1635 1685
1636 cons = gfc_constructor_lookup (base, limit); 1686 cons = gfc_constructor_lookup (base, limit);
1689 chr[length] = '\0'; 1739 chr[length] = '\0';
1690 return true; 1740 return true;
1691 } 1741 }
1692 1742
1693 1743
1744 /* Pull an inquiry result out of an expression. */
1745
1746 static bool
1747 find_inquiry_ref (gfc_expr *p, gfc_expr **newp)
1748 {
1749 gfc_ref *ref;
1750 gfc_ref *inquiry = NULL;
1751 gfc_expr *tmp;
1752
1753 tmp = gfc_copy_expr (p);
1754
1755 if (tmp->ref && tmp->ref->type == REF_INQUIRY)
1756 {
1757 inquiry = tmp->ref;
1758 tmp->ref = NULL;
1759 }
1760 else
1761 {
1762 for (ref = tmp->ref; ref; ref = ref->next)
1763 if (ref->next && ref->next->type == REF_INQUIRY)
1764 {
1765 inquiry = ref->next;
1766 ref->next = NULL;
1767 }
1768 }
1769
1770 if (!inquiry)
1771 {
1772 gfc_free_expr (tmp);
1773 return false;
1774 }
1775
1776 gfc_resolve_expr (tmp);
1777
1778 /* In principle there can be more than one inquiry reference. */
1779 for (; inquiry; inquiry = inquiry->next)
1780 {
1781 switch (inquiry->u.i)
1782 {
1783 case INQUIRY_LEN:
1784 if (tmp->ts.type != BT_CHARACTER)
1785 goto cleanup;
1786
1787 if (!gfc_notify_std (GFC_STD_F2003, "LEN part_ref at %C"))
1788 goto cleanup;
1789
1790 if (tmp->ts.u.cl->length
1791 && tmp->ts.u.cl->length->expr_type == EXPR_CONSTANT)
1792 *newp = gfc_copy_expr (tmp->ts.u.cl->length);
1793 else if (tmp->expr_type == EXPR_CONSTANT)
1794 *newp = gfc_get_int_expr (gfc_default_integer_kind,
1795 NULL, tmp->value.character.length);
1796 else
1797 goto cleanup;
1798
1799 break;
1800
1801 case INQUIRY_KIND:
1802 if (tmp->ts.type == BT_DERIVED || tmp->ts.type == BT_CLASS)
1803 goto cleanup;
1804
1805 if (!gfc_notify_std (GFC_STD_F2003, "KIND part_ref at %C"))
1806 goto cleanup;
1807
1808 *newp = gfc_get_int_expr (gfc_default_integer_kind,
1809 NULL, tmp->ts.kind);
1810 break;
1811
1812 case INQUIRY_RE:
1813 if (tmp->ts.type != BT_COMPLEX || tmp->expr_type != EXPR_CONSTANT)
1814 goto cleanup;
1815
1816 if (!gfc_notify_std (GFC_STD_F2008, "RE part_ref at %C"))
1817 goto cleanup;
1818
1819 *newp = gfc_get_constant_expr (BT_REAL, tmp->ts.kind, &tmp->where);
1820 mpfr_set ((*newp)->value.real,
1821 mpc_realref (tmp->value.complex), GFC_RND_MODE);
1822 break;
1823
1824 case INQUIRY_IM:
1825 if (tmp->ts.type != BT_COMPLEX || tmp->expr_type != EXPR_CONSTANT)
1826 goto cleanup;
1827
1828 if (!gfc_notify_std (GFC_STD_F2008, "IM part_ref at %C"))
1829 goto cleanup;
1830
1831 *newp = gfc_get_constant_expr (BT_REAL, tmp->ts.kind, &tmp->where);
1832 mpfr_set ((*newp)->value.real,
1833 mpc_imagref (tmp->value.complex), GFC_RND_MODE);
1834 break;
1835 }
1836 tmp = gfc_copy_expr (*newp);
1837 }
1838
1839 if (!(*newp))
1840 goto cleanup;
1841 else if ((*newp)->expr_type != EXPR_CONSTANT)
1842 {
1843 gfc_free_expr (*newp);
1844 goto cleanup;
1845 }
1846
1847 gfc_free_expr (tmp);
1848 return true;
1849
1850 cleanup:
1851 gfc_free_expr (tmp);
1852 return false;
1853 }
1854
1855
1694 1856
1695 /* Simplify a subobject reference of a constructor. This occurs when 1857 /* Simplify a subobject reference of a constructor. This occurs when
1696 parameter variable values are substituted. */ 1858 parameter variable values are substituted. */
1697 1859
1698 static bool 1860 static bool
1699 simplify_const_ref (gfc_expr *p) 1861 simplify_const_ref (gfc_expr *p)
1700 { 1862 {
1701 gfc_constructor *cons, *c; 1863 gfc_constructor *cons, *c;
1702 gfc_expr *newp; 1864 gfc_expr *newp = NULL;
1703 gfc_ref *last_ref; 1865 gfc_ref *last_ref;
1704 1866
1705 while (p->ref) 1867 while (p->ref)
1706 { 1868 {
1707 switch (p->ref->type) 1869 switch (p->ref->type)
1773 } 1935 }
1774 else 1936 else
1775 string_len = 0; 1937 string_len = 0;
1776 1938
1777 if (!p->ts.u.cl) 1939 if (!p->ts.u.cl)
1778 p->ts.u.cl = gfc_new_charlen (p->symtree->n.sym->ns, 1940 {
1779 NULL); 1941 if (p->symtree)
1942 p->ts.u.cl = gfc_new_charlen (p->symtree->n.sym->ns,
1943 NULL);
1944 else
1945 p->ts.u.cl = gfc_new_charlen (gfc_current_ns,
1946 NULL);
1947 }
1780 else 1948 else
1781 gfc_free_expr (p->ts.u.cl->length); 1949 gfc_free_expr (p->ts.u.cl->length);
1782 1950
1783 p->ts.u.cl->length 1951 p->ts.u.cl->length
1784 = gfc_get_int_expr (gfc_charlen_int_kind, 1952 = gfc_get_int_expr (gfc_charlen_int_kind,
1798 case REF_COMPONENT: 1966 case REF_COMPONENT:
1799 cons = find_component_ref (p->value.constructor, p->ref); 1967 cons = find_component_ref (p->value.constructor, p->ref);
1800 remove_subobject_ref (p, cons); 1968 remove_subobject_ref (p, cons);
1801 break; 1969 break;
1802 1970
1803 case REF_SUBSTRING: 1971 case REF_INQUIRY:
1804 if (!find_substring_ref (p, &newp)) 1972 if (!find_inquiry_ref (p, &newp))
1805 return false; 1973 return false;
1806 1974
1807 gfc_replace_expr (p, newp); 1975 gfc_replace_expr (p, newp);
1808 gfc_free_ref_list (p->ref); 1976 gfc_free_ref_list (p->ref);
1809 p->ref = NULL; 1977 p->ref = NULL;
1810 break; 1978 break;
1979
1980 case REF_SUBSTRING:
1981 if (!find_substring_ref (p, &newp))
1982 return false;
1983
1984 gfc_replace_expr (p, newp);
1985 gfc_free_ref_list (p->ref);
1986 p->ref = NULL;
1987 break;
1811 } 1988 }
1812 } 1989 }
1813 1990
1814 return true; 1991 return true;
1815 } 1992 }
1816 1993
1817 1994
1818 /* Simplify a chain of references. */ 1995 /* Simplify a chain of references. */
1819 1996
1820 static bool 1997 static bool
1821 simplify_ref_chain (gfc_ref *ref, int type) 1998 simplify_ref_chain (gfc_ref *ref, int type, gfc_expr **p)
1822 { 1999 {
1823 int n; 2000 int n;
2001 gfc_expr *newp;
1824 2002
1825 for (; ref; ref = ref->next) 2003 for (; ref; ref = ref->next)
1826 { 2004 {
1827 switch (ref->type) 2005 switch (ref->type)
1828 { 2006 {
1843 return false; 2021 return false;
1844 if (!gfc_simplify_expr (ref->u.ss.end, type)) 2022 if (!gfc_simplify_expr (ref->u.ss.end, type))
1845 return false; 2023 return false;
1846 break; 2024 break;
1847 2025
2026 case REF_INQUIRY:
2027 if (!find_inquiry_ref (*p, &newp))
2028 return false;
2029
2030 gfc_replace_expr (*p, newp);
2031 gfc_free_ref_list ((*p)->ref);
2032 (*p)->ref = NULL;
2033 return true;
2034
1848 default: 2035 default:
1849 break; 2036 break;
1850 } 2037 }
1851 } 2038 }
1852 return true; 2039 return true;
1858 static bool 2045 static bool
1859 simplify_parameter_variable (gfc_expr *p, int type) 2046 simplify_parameter_variable (gfc_expr *p, int type)
1860 { 2047 {
1861 gfc_expr *e; 2048 gfc_expr *e;
1862 bool t; 2049 bool t;
2050
2051 /* Set rank and check array ref; as resolve_variable calls
2052 gfc_simplify_expr, call gfc_resolve_ref + gfc_expression_rank instead. */
2053 if (!gfc_resolve_ref (p))
2054 {
2055 gfc_error_check ();
2056 return false;
2057 }
2058 gfc_expression_rank (p);
1863 2059
1864 if (gfc_is_size_zero_array (p)) 2060 if (gfc_is_size_zero_array (p))
1865 { 2061 {
1866 if (p->expr_type == EXPR_ARRAY) 2062 if (p->expr_type == EXPR_ARRAY)
1867 return true; 2063 return true;
1881 if (e == NULL) 2077 if (e == NULL)
1882 return false; 2078 return false;
1883 2079
1884 e->rank = p->rank; 2080 e->rank = p->rank;
1885 2081
2082 if (e->ts.type == BT_CHARACTER && e->ts.u.cl == NULL)
2083 e->ts.u.cl = gfc_new_charlen (gfc_current_ns, p->ts.u.cl);
2084
1886 /* Do not copy subobject refs for constant. */ 2085 /* Do not copy subobject refs for constant. */
1887 if (e->expr_type != EXPR_CONSTANT && p->ref != NULL) 2086 if (e->expr_type != EXPR_CONSTANT && p->ref != NULL)
1888 e->ref = gfc_copy_ref (p->ref); 2087 e->ref = gfc_copy_ref (p->ref);
1889 t = gfc_simplify_expr (e, type); 2088 t = gfc_simplify_expr (e, type);
2089 e->where = p->where;
1890 2090
1891 /* Only use the simplification if it eliminated all subobject references. */ 2091 /* Only use the simplification if it eliminated all subobject references. */
1892 if (t && !e->ref) 2092 if (t && !e->ref)
1893 gfc_replace_expr (p, e); 2093 gfc_replace_expr (p, e);
1894 else 2094 else
1916 The expression type is defined for: 2116 The expression type is defined for:
1917 0 Basic expression parsing 2117 0 Basic expression parsing
1918 1 Simplifying array constructors -- will substitute 2118 1 Simplifying array constructors -- will substitute
1919 iterator values. 2119 iterator values.
1920 Returns false on error, true otherwise. 2120 Returns false on error, true otherwise.
1921 NOTE: Will return true even if the expression can not be simplified. */ 2121 NOTE: Will return true even if the expression cannot be simplified. */
1922 2122
1923 bool 2123 bool
1924 gfc_simplify_expr (gfc_expr *p, int type) 2124 gfc_simplify_expr (gfc_expr *p, int type)
1925 { 2125 {
1926 gfc_actual_arglist *ap; 2126 gfc_actual_arglist *ap;
1931 return true; 2131 return true;
1932 2132
1933 switch (p->expr_type) 2133 switch (p->expr_type)
1934 { 2134 {
1935 case EXPR_CONSTANT: 2135 case EXPR_CONSTANT:
2136 if (p->ref && p->ref->type == REF_INQUIRY)
2137 simplify_ref_chain (p->ref, type, &p);
2138 break;
1936 case EXPR_NULL: 2139 case EXPR_NULL:
1937 break; 2140 break;
1938 2141
1939 case EXPR_FUNCTION: 2142 case EXPR_FUNCTION:
1940 // For array-bound functions, we don't need to optimize 2143 // For array-bound functions, we don't need to optimize
1967 } 2170 }
1968 2171
1969 break; 2172 break;
1970 2173
1971 case EXPR_SUBSTRING: 2174 case EXPR_SUBSTRING:
1972 if (!simplify_ref_chain (p->ref, type)) 2175 if (!simplify_ref_chain (p->ref, type, &p))
1973 return false; 2176 return false;
1974 2177
1975 if (gfc_is_constant_expr (p)) 2178 if (gfc_is_constant_expr (p))
1976 { 2179 {
1977 gfc_char_t *s; 2180 gfc_char_t *s;
2029 { 2232 {
2030 gfc_simplify_iterator_var (p); 2233 gfc_simplify_iterator_var (p);
2031 } 2234 }
2032 2235
2033 /* Simplify subcomponent references. */ 2236 /* Simplify subcomponent references. */
2034 if (!simplify_ref_chain (p->ref, type)) 2237 if (!simplify_ref_chain (p->ref, type, &p))
2035 return false; 2238 return false;
2036 2239
2037 break; 2240 break;
2038 2241
2039 case EXPR_STRUCTURE: 2242 case EXPR_STRUCTURE:
2040 case EXPR_ARRAY: 2243 case EXPR_ARRAY:
2041 if (!simplify_ref_chain (p->ref, type)) 2244 if (!simplify_ref_chain (p->ref, type, &p))
2042 return false; 2245 return false;
2246
2247 /* If the following conditions hold, we found something like kind type
2248 inquiry of the form a(2)%kind while simplify the ref chain. */
2249 if (p->expr_type == EXPR_CONSTANT && !p->ref && !p->rank && !p->shape)
2250 return true;
2043 2251
2044 if (!simplify_constructor (p->value.constructor, type)) 2252 if (!simplify_constructor (p->value.constructor, type))
2045 return false; 2253 return false;
2046 2254
2047 if (p->expr_type == EXPR_ARRAY && p->ref && p->ref->type == REF_ARRAY 2255 if (p->expr_type == EXPR_ARRAY && p->ref && p->ref->type == REF_ARRAY
2054 break; 2262 break;
2055 2263
2056 case EXPR_COMPCALL: 2264 case EXPR_COMPCALL:
2057 case EXPR_PPC: 2265 case EXPR_PPC:
2058 break; 2266 break;
2267
2268 case EXPR_UNKNOWN:
2269 gcc_unreachable ();
2059 } 2270 }
2060 2271
2061 return true; 2272 return true;
2062 } 2273 }
2063 2274
2378 } 2589 }
2379 2590
2380 static bool check_restricted (gfc_expr *); 2591 static bool check_restricted (gfc_expr *);
2381 2592
2382 /* F95, 7.1.6.1, Initialization expressions, (7) 2593 /* F95, 7.1.6.1, Initialization expressions, (7)
2383 F2003, 7.1.7 Initialization expression, (8) */ 2594 F2003, 7.1.7 Initialization expression, (8)
2595 F2008, 7.1.12 Constant expression, (4) */
2384 2596
2385 static match 2597 static match
2386 check_inquiry (gfc_expr *e, int not_restricted) 2598 check_inquiry (gfc_expr *e, int not_restricted)
2387 { 2599 {
2388 const char *name; 2600 const char *name;
2402 "digits", "epsilon", "huge", "maxexponent", "minexponent", 2614 "digits", "epsilon", "huge", "maxexponent", "minexponent",
2403 "precision", "radix", "range", "tiny", 2615 "precision", "radix", "range", "tiny",
2404 "new_line", NULL 2616 "new_line", NULL
2405 }; 2617 };
2406 2618
2619 /* std=f2008+ or -std=gnu */
2620 static const char *const inquiry_func_gnu[] = {
2621 "lbound", "shape", "size", "ubound",
2622 "bit_size", "len", "kind",
2623 "digits", "epsilon", "huge", "maxexponent", "minexponent",
2624 "precision", "radix", "range", "tiny",
2625 "new_line", "storage_size", NULL
2626 };
2627
2407 int i = 0; 2628 int i = 0;
2408 gfc_actual_arglist *ap; 2629 gfc_actual_arglist *ap;
2630 gfc_symbol *sym;
2631 gfc_symbol *asym;
2409 2632
2410 if (!e->value.function.isym 2633 if (!e->value.function.isym
2411 || !e->value.function.isym->inquiry) 2634 || !e->value.function.isym->inquiry)
2412 return MATCH_NO; 2635 return MATCH_NO;
2413 2636
2414 /* An undeclared parameter will get us here (PR25018). */ 2637 /* An undeclared parameter will get us here (PR25018). */
2415 if (e->symtree == NULL) 2638 if (e->symtree == NULL)
2416 return MATCH_NO; 2639 return MATCH_NO;
2417 2640
2418 if (e->symtree->n.sym->from_intmod) 2641 sym = e->symtree->n.sym;
2419 { 2642
2420 if (e->symtree->n.sym->from_intmod == INTMOD_ISO_FORTRAN_ENV 2643 if (sym->from_intmod)
2421 && e->symtree->n.sym->intmod_sym_id != ISOFORTRAN_COMPILER_OPTIONS 2644 {
2422 && e->symtree->n.sym->intmod_sym_id != ISOFORTRAN_COMPILER_VERSION) 2645 if (sym->from_intmod == INTMOD_ISO_FORTRAN_ENV
2646 && sym->intmod_sym_id != ISOFORTRAN_COMPILER_OPTIONS
2647 && sym->intmod_sym_id != ISOFORTRAN_COMPILER_VERSION)
2423 return MATCH_NO; 2648 return MATCH_NO;
2424 2649
2425 if (e->symtree->n.sym->from_intmod == INTMOD_ISO_C_BINDING 2650 if (sym->from_intmod == INTMOD_ISO_C_BINDING
2426 && e->symtree->n.sym->intmod_sym_id != ISOCBINDING_C_SIZEOF) 2651 && sym->intmod_sym_id != ISOCBINDING_C_SIZEOF)
2427 return MATCH_NO; 2652 return MATCH_NO;
2428 } 2653 }
2429 else 2654 else
2430 { 2655 {
2431 name = e->symtree->n.sym->name; 2656 name = sym->name;
2432 2657
2433 functions = (gfc_option.warn_std & GFC_STD_F2003) 2658 functions = inquiry_func_gnu;
2434 ? inquiry_func_f2003 : inquiry_func_f95; 2659 if (gfc_option.warn_std & GFC_STD_F2003)
2660 functions = inquiry_func_f2003;
2661 if (gfc_option.warn_std & GFC_STD_F95)
2662 functions = inquiry_func_f95;
2435 2663
2436 for (i = 0; functions[i]; i++) 2664 for (i = 0; functions[i]; i++)
2437 if (strcmp (functions[i], name) == 0) 2665 if (strcmp (functions[i], name) == 0)
2438 break; 2666 break;
2439 2667
2448 for (ap = e->value.function.actual; ap; ap = ap->next) 2676 for (ap = e->value.function.actual; ap; ap = ap->next)
2449 { 2677 {
2450 if (!ap->expr) 2678 if (!ap->expr)
2451 continue; 2679 continue;
2452 2680
2681 asym = ap->expr->symtree ? ap->expr->symtree->n.sym : NULL;
2682
2453 if (ap->expr->ts.type == BT_UNKNOWN) 2683 if (ap->expr->ts.type == BT_UNKNOWN)
2454 { 2684 {
2455 if (ap->expr->symtree->n.sym->ts.type == BT_UNKNOWN 2685 if (asym && asym->ts.type == BT_UNKNOWN
2456 && !gfc_set_default_type (ap->expr->symtree->n.sym, 0, gfc_current_ns)) 2686 && !gfc_set_default_type (asym, 0, gfc_current_ns))
2457 return MATCH_NO; 2687 return MATCH_NO;
2458 2688
2459 ap->expr->ts = ap->expr->symtree->n.sym->ts; 2689 ap->expr->ts = asym->ts;
2460 } 2690 }
2461 2691
2462 /* Assumed character length will not reduce to a constant expression 2692 if (asym && asym->assoc && asym->assoc->target
2463 with LEN, as required by the standard. */ 2693 && asym->assoc->target->expr_type == EXPR_CONSTANT)
2464 if (i == 5 && not_restricted && ap->expr->symtree 2694 {
2465 && ap->expr->symtree->n.sym->ts.type == BT_CHARACTER 2695 gfc_free_expr (ap->expr);
2466 && (ap->expr->symtree->n.sym->ts.u.cl->length == NULL 2696 ap->expr = gfc_copy_expr (asym->assoc->target);
2467 || ap->expr->symtree->n.sym->ts.deferred)) 2697 }
2468 { 2698
2469 gfc_error ("Assumed or deferred character length variable %qs " 2699 /* Assumed character length will not reduce to a constant expression
2470 "in constant expression at %L", 2700 with LEN, as required by the standard. */
2471 ap->expr->symtree->n.sym->name, 2701 if (i == 5 && not_restricted && asym
2472 &ap->expr->where); 2702 && asym->ts.type == BT_CHARACTER
2473 return MATCH_ERROR; 2703 && ((asym->ts.u.cl && asym->ts.u.cl->length == NULL)
2474 } 2704 || asym->ts.deferred))
2475 else if (not_restricted && !gfc_check_init_expr (ap->expr)) 2705 {
2706 gfc_error ("Assumed or deferred character length variable %qs "
2707 "in constant expression at %L",
2708 asym->name, &ap->expr->where);
2476 return MATCH_ERROR; 2709 return MATCH_ERROR;
2477 2710 }
2478 if (not_restricted == 0 2711 else if (not_restricted && !gfc_check_init_expr (ap->expr))
2479 && ap->expr->expr_type != EXPR_VARIABLE 2712 return MATCH_ERROR;
2480 && !check_restricted (ap->expr)) 2713
2481 return MATCH_ERROR; 2714 if (not_restricted == 0
2482 2715 && ap->expr->expr_type != EXPR_VARIABLE
2483 if (not_restricted == 0 2716 && !check_restricted (ap->expr))
2484 && ap->expr->expr_type == EXPR_VARIABLE 2717 return MATCH_ERROR;
2485 && ap->expr->symtree->n.sym->attr.dummy 2718
2486 && ap->expr->symtree->n.sym->attr.optional) 2719 if (not_restricted == 0
2487 return MATCH_NO; 2720 && ap->expr->expr_type == EXPR_VARIABLE
2721 && asym->attr.dummy && asym->attr.optional)
2722 return MATCH_NO;
2488 } 2723 }
2489 2724
2490 return MATCH_YES; 2725 return MATCH_YES;
2491 } 2726 }
2492 2727
2507 "product", "repeat", "reshape", "selected_char_kind", "selected_int_kind", 2742 "product", "repeat", "reshape", "selected_char_kind", "selected_int_kind",
2508 "selected_real_kind", "spread", "sum", "transfer", "transpose", 2743 "selected_real_kind", "spread", "sum", "transfer", "transpose",
2509 "trim", "unpack", NULL 2744 "trim", "unpack", NULL
2510 }; 2745 };
2511 2746
2747 static const char * const trans_func_f2008[] = {
2748 "all", "any", "count", "dot_product", "matmul", "null", "pack",
2749 "product", "repeat", "reshape", "selected_char_kind", "selected_int_kind",
2750 "selected_real_kind", "spread", "sum", "transfer", "transpose",
2751 "trim", "unpack", "findloc", NULL
2752 };
2753
2512 int i; 2754 int i;
2513 const char *name; 2755 const char *name;
2514 const char *const *functions; 2756 const char *const *functions;
2515 2757
2516 if (!e->value.function.isym 2758 if (!e->value.function.isym
2517 || !e->value.function.isym->transformational) 2759 || !e->value.function.isym->transformational)
2518 return MATCH_NO; 2760 return MATCH_NO;
2519 2761
2520 name = e->symtree->n.sym->name; 2762 name = e->symtree->n.sym->name;
2521 2763
2522 functions = (gfc_option.allow_std & GFC_STD_F2003) 2764 if (gfc_option.allow_std & GFC_STD_F2008)
2523 ? trans_func_f2003 : trans_func_f95; 2765 functions = trans_func_f2008;
2766 else if (gfc_option.allow_std & GFC_STD_F2003)
2767 functions = trans_func_f2003;
2768 else
2769 functions = trans_func_f95;
2524 2770
2525 /* NULL() is dealt with below. */ 2771 /* NULL() is dealt with below. */
2526 if (strcmp ("null", name) == 0) 2772 if (strcmp ("null", name) == 0)
2527 return MATCH_NO; 2773 return MATCH_NO;
2528 2774
2721 "in an initialization expression", 2967 "in an initialization expression",
2722 e->symtree->n.sym->name, &e->where); 2968 e->symtree->n.sym->name, &e->where);
2723 break; 2969 break;
2724 2970
2725 case AS_DEFERRED: 2971 case AS_DEFERRED:
2726 gfc_error ("Deferred array %qs at %L is not permitted " 2972 if (!e->symtree->n.sym->attr.allocatable
2727 "in an initialization expression", 2973 && !e->symtree->n.sym->attr.pointer
2728 e->symtree->n.sym->name, &e->where); 2974 && e->symtree->n.sym->attr.dummy)
2975 gfc_error ("Assumed-shape array %qs at %L is not permitted "
2976 "in an initialization expression",
2977 e->symtree->n.sym->name, &e->where);
2978 else
2979 gfc_error ("Deferred array %qs at %L is not permitted "
2980 "in an initialization expression",
2981 e->symtree->n.sym->name, &e->where);
2729 break; 2982 break;
2730 2983
2731 case AS_EXPLICIT: 2984 case AS_EXPLICIT:
2732 gfc_error ("Array %qs at %L is a variable, which does " 2985 gfc_error ("Array %qs at %L is a variable, which does "
2733 "not reduce to a constant expression", 2986 "not reduce to a constant expression",
2812 t = gfc_resolve_expr (expr); 3065 t = gfc_resolve_expr (expr);
2813 if (t) 3066 if (t)
2814 t = gfc_check_init_expr (expr); 3067 t = gfc_check_init_expr (expr);
2815 gfc_init_expr_flag = false; 3068 gfc_init_expr_flag = false;
2816 3069
2817 if (!t) 3070 if (!t || !expr)
2818 return false; 3071 return false;
2819 3072
2820 if (expr->expr_type == EXPR_ARRAY) 3073 if (expr->expr_type == EXPR_ARRAY)
2821 { 3074 {
2822 if (!gfc_check_constructor_type (expr)) 3075 if (!gfc_check_constructor_type (expr))
2913 || !strcmp (f->name, "ieee_support_rounding") 3166 || !strcmp (f->name, "ieee_support_rounding")
2914 || !strcmp (f->name, "ieee_support_flag") 3167 || !strcmp (f->name, "ieee_support_flag")
2915 || !strcmp (f->name, "ieee_support_halting") 3168 || !strcmp (f->name, "ieee_support_halting")
2916 || !strcmp (f->name, "ieee_support_datatype") 3169 || !strcmp (f->name, "ieee_support_datatype")
2917 || !strcmp (f->name, "ieee_support_denormal") 3170 || !strcmp (f->name, "ieee_support_denormal")
3171 || !strcmp (f->name, "ieee_support_subnormal")
2918 || !strcmp (f->name, "ieee_support_divide") 3172 || !strcmp (f->name, "ieee_support_divide")
2919 || !strcmp (f->name, "ieee_support_inf") 3173 || !strcmp (f->name, "ieee_support_inf")
2920 || !strcmp (f->name, "ieee_support_io") 3174 || !strcmp (f->name, "ieee_support_io")
2921 || !strcmp (f->name, "ieee_support_nan") 3175 || !strcmp (f->name, "ieee_support_nan")
2922 || !strcmp (f->name, "ieee_support_sqrt") 3176 || !strcmp (f->name, "ieee_support_sqrt")
3089 3343
3090 /* If a dummy argument appears in a context that is valid for a 3344 /* If a dummy argument appears in a context that is valid for a
3091 restricted expression in an elemental procedure, it will have 3345 restricted expression in an elemental procedure, it will have
3092 already been simplified away once we get here. Therefore we 3346 already been simplified away once we get here. Therefore we
3093 don't need to jump through hoops to distinguish valid from 3347 don't need to jump through hoops to distinguish valid from
3094 invalid cases. */ 3348 invalid cases. Allowed in F2008 and F2018. */
3095 if (sym->attr.dummy && sym->ns == gfc_current_ns 3349 if (gfc_notification_std (GFC_STD_F2008)
3350 && sym->attr.dummy && sym->ns == gfc_current_ns
3096 && sym->ns->proc_name && sym->ns->proc_name->attr.elemental) 3351 && sym->ns->proc_name && sym->ns->proc_name->attr.elemental)
3097 { 3352 {
3098 gfc_error ("Dummy argument %qs not allowed in expression at %L", 3353 gfc_error_now ("Dummy argument %qs not "
3099 sym->name, &e->where); 3354 "allowed in expression at %L",
3355 sym->name, &e->where);
3100 break; 3356 break;
3101 } 3357 }
3102 3358
3103 if (sym->attr.optional) 3359 if (sym->attr.optional)
3104 { 3360 {
3237 3493
3238 if (op1->rank == 0 || op2->rank == 0) 3494 if (op1->rank == 0 || op2->rank == 0)
3239 return true; 3495 return true;
3240 3496
3241 va_start (argp, optype_msgid); 3497 va_start (argp, optype_msgid);
3242 vsnprintf (buffer, 240, optype_msgid, argp); 3498 d = vsnprintf (buffer, sizeof (buffer), optype_msgid, argp);
3243 va_end (argp); 3499 va_end (argp);
3500 if (d < 1 || d >= (int) sizeof (buffer)) /* Reject truncation. */
3501 gfc_internal_error ("optype_msgid overflow: %d", d);
3244 3502
3245 if (op1->rank != op2->rank) 3503 if (op1->rank != op2->rank)
3246 { 3504 {
3247 gfc_error ("Incompatible ranks in %s (%d and %d) at %L", _(buffer), 3505 gfc_error ("Incompatible ranks in %s (%d and %d) at %L", _(buffer),
3248 op1->rank, op2->rank, &op1->where); 3506 op1->rank, op2->rank, &op1->where);
3293 gfc_ref *ref; 3551 gfc_ref *ref;
3294 int has_pointer; 3552 int has_pointer;
3295 3553
3296 sym = lvalue->symtree->n.sym; 3554 sym = lvalue->symtree->n.sym;
3297 3555
3298 /* See if this is the component or subcomponent of a pointer. */ 3556 /* See if this is the component or subcomponent of a pointer and guard
3557 against assignment to LEN or KIND part-refs. */
3299 has_pointer = sym->attr.pointer; 3558 has_pointer = sym->attr.pointer;
3300 for (ref = lvalue->ref; ref; ref = ref->next) 3559 for (ref = lvalue->ref; ref; ref = ref->next)
3301 if (ref->type == REF_COMPONENT && ref->u.c.component->attr.pointer) 3560 {
3302 { 3561 if (!has_pointer && ref->type == REF_COMPONENT
3303 has_pointer = 1; 3562 && ref->u.c.component->attr.pointer)
3304 break; 3563 has_pointer = 1;
3305 } 3564 else if (ref->type == REF_INQUIRY
3565 && (ref->u.i == INQUIRY_LEN || ref->u.i == INQUIRY_KIND))
3566 {
3567 gfc_error ("Assignment to a LEN or KIND part_ref at %L is not "
3568 "allowed", &lvalue->where);
3569 return false;
3570 }
3571 }
3306 3572
3307 /* 12.5.2.2, Note 12.26: The result variable is very similar to any other 3573 /* 12.5.2.2, Note 12.26: The result variable is very similar to any other
3308 variable local to a function subprogram. Its existence begins when 3574 variable local to a function subprogram. Its existence begins when
3309 execution of the function is initiated and ends when execution of the 3575 execution of the function is initiated and ends when execution of the
3310 function is terminated... 3576 function is terminated...
3356 { 3622 {
3357 gfc_error ("%qs at %L is not a VALUE", sym->name, &lvalue->where); 3623 gfc_error ("%qs at %L is not a VALUE", sym->name, &lvalue->where);
3358 return false; 3624 return false;
3359 } 3625 }
3360 } 3626 }
3627 else
3628 {
3629 /* Reject assigning to an external symbol. For initializers, this
3630 was already done before, in resolve_fl_procedure. */
3631 if (sym->attr.flavor == FL_PROCEDURE && sym->attr.external
3632 && sym->attr.proc != PROC_MODULE && !rvalue->error)
3633 {
3634 gfc_error ("Illegal assignment to external procedure at %L",
3635 &lvalue->where);
3636 return false;
3637 }
3638 }
3361 3639
3362 if (rvalue->rank != 0 && lvalue->rank != rvalue->rank) 3640 if (rvalue->rank != 0 && lvalue->rank != rvalue->rank)
3363 { 3641 {
3364 gfc_error ("Incompatible ranks %d and %d in assignment at %L", 3642 gfc_error ("Incompatible ranks %d and %d in assignment at %L",
3365 lvalue->rank, rvalue->rank, &lvalue->where); 3643 lvalue->rank, rvalue->rank, &lvalue->where);
3396 /* Check size of array assignments. */ 3674 /* Check size of array assignments. */
3397 if (lvalue->rank != 0 && rvalue->rank != 0 3675 if (lvalue->rank != 0 && rvalue->rank != 0
3398 && !gfc_check_conformance (lvalue, rvalue, "array assignment")) 3676 && !gfc_check_conformance (lvalue, rvalue, "array assignment"))
3399 return false; 3677 return false;
3400 3678
3401 if (rvalue->is_boz && lvalue->ts.type != BT_INTEGER
3402 && lvalue->symtree->n.sym->attr.data
3403 && !gfc_notify_std (GFC_STD_GNU, "BOZ literal at %L used to "
3404 "initialize non-integer variable %qs",
3405 &rvalue->where, lvalue->symtree->n.sym->name))
3406 return false;
3407 else if (rvalue->is_boz && !lvalue->symtree->n.sym->attr.data
3408 && !gfc_notify_std (GFC_STD_GNU, "BOZ literal at %L outside "
3409 "a DATA statement and outside INT/REAL/DBLE/CMPLX",
3410 &rvalue->where))
3411 return false;
3412
3413 /* Handle the case of a BOZ literal on the RHS. */ 3679 /* Handle the case of a BOZ literal on the RHS. */
3414 if (rvalue->is_boz && lvalue->ts.type != BT_INTEGER) 3680 if (rvalue->ts.type == BT_BOZ)
3415 { 3681 {
3416 int rc; 3682 if (lvalue->symtree->n.sym->attr.data)
3417 if (warn_surprising) 3683 {
3418 gfc_warning (OPT_Wsurprising, 3684 if (lvalue->ts.type == BT_INTEGER
3419 "BOZ literal at %L is bitwise transferred " 3685 && gfc_boz2int (rvalue, lvalue->ts.kind))
3420 "non-integer symbol %qs", &rvalue->where, 3686 return true;
3421 lvalue->symtree->n.sym->name); 3687
3422 if (!gfc_convert_boz (rvalue, &lvalue->ts)) 3688 if (lvalue->ts.type == BT_REAL
3689 && gfc_boz2real (rvalue, lvalue->ts.kind))
3690 {
3691 if (gfc_invalid_boz ("BOZ literal constant near %L cannot "
3692 "be assigned to a REAL variable",
3693 &rvalue->where))
3694 return false;
3695 return true;
3696 }
3697 }
3698
3699 if (!lvalue->symtree->n.sym->attr.data
3700 && gfc_invalid_boz ("BOZ literal constant at %L is neither a "
3701 "data-stmt-constant nor an actual argument to "
3702 "INT, REAL, DBLE, or CMPLX intrinsic function",
3703 &rvalue->where))
3423 return false; 3704 return false;
3424 if ((rc = gfc_range_check (rvalue)) != ARITH_OK) 3705
3425 { 3706 if (lvalue->ts.type == BT_INTEGER
3426 if (rc == ARITH_UNDERFLOW) 3707 && gfc_boz2int (rvalue, lvalue->ts.kind))
3427 gfc_error ("Arithmetic underflow of bit-wise transferred BOZ at %L" 3708 return true;
3428 ". This check can be disabled with the option " 3709
3429 "%<-fno-range-check%>", &rvalue->where); 3710 if (lvalue->ts.type == BT_REAL
3430 else if (rc == ARITH_OVERFLOW) 3711 && gfc_boz2real (rvalue, lvalue->ts.kind))
3431 gfc_error ("Arithmetic overflow of bit-wise transferred BOZ at %L" 3712 return true;
3432 ". This check can be disabled with the option " 3713
3433 "%<-fno-range-check%>", &rvalue->where); 3714 gfc_error ("BOZ literal constant near %L cannot be assigned to a "
3434 else if (rc == ARITH_NAN) 3715 "%qs variable", &rvalue->where, gfc_typename (lvalue));
3435 gfc_error ("Arithmetic NaN of bit-wise transferred BOZ at %L" 3716 return false;
3436 ". This check can be disabled with the option "
3437 "%<-fno-range-check%>", &rvalue->where);
3438 return false;
3439 }
3440 } 3717 }
3441 3718
3442 if (gfc_expr_attr (lvalue).pdt_kind || gfc_expr_attr (lvalue).pdt_len) 3719 if (gfc_expr_attr (lvalue).pdt_kind || gfc_expr_attr (lvalue).pdt_len)
3443 { 3720 {
3444 gfc_error ("The assignment to a KIND or LEN component of a " 3721 gfc_error ("The assignment to a KIND or LEN component of a "
3459 converted to any other type. */ 3736 converted to any other type. */
3460 if ((gfc_numeric_ts (&lvalue->ts) && gfc_numeric_ts (&rvalue->ts)) 3737 if ((gfc_numeric_ts (&lvalue->ts) && gfc_numeric_ts (&rvalue->ts))
3461 || rvalue->ts.type == BT_HOLLERITH) 3738 || rvalue->ts.type == BT_HOLLERITH)
3462 return true; 3739 return true;
3463 3740
3741 if (flag_dec_char_conversions && (gfc_numeric_ts (&lvalue->ts)
3742 || lvalue->ts.type == BT_LOGICAL)
3743 && rvalue->ts.type == BT_CHARACTER
3744 && rvalue->ts.kind == gfc_default_character_kind)
3745 return true;
3746
3464 if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL) 3747 if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL)
3465 return true; 3748 return true;
3466 3749
3467 where = lvalue->where.lb ? &lvalue->where : &rvalue->where; 3750 where = lvalue->where.lb ? &lvalue->where : &rvalue->where;
3468 gfc_error ("Incompatible types in DATA statement at %L; attempted " 3751 gfc_error ("Incompatible types in DATA statement at %L; attempted "
3469 "conversion of %s to %s", where, 3752 "conversion of %s to %s", where,
3470 gfc_typename (&rvalue->ts), gfc_typename (&lvalue->ts)); 3753 gfc_typename (rvalue), gfc_typename (lvalue));
3471 3754
3472 return false; 3755 return false;
3473 } 3756 }
3474 3757
3475 /* Assignment is the only case where character variables of different 3758 /* Assignment is the only case where character variables of different
3492 /* Check that a pointer assignment is OK. We first check lvalue, and 3775 /* Check that a pointer assignment is OK. We first check lvalue, and
3493 we only check rvalue if it's not an assignment to NULL() or a 3776 we only check rvalue if it's not an assignment to NULL() or a
3494 NULLIFY statement. */ 3777 NULLIFY statement. */
3495 3778
3496 bool 3779 bool
3497 gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue) 3780 gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue,
3781 bool suppress_type_test, bool is_init_expr)
3498 { 3782 {
3499 symbol_attribute attr, lhs_attr; 3783 symbol_attribute attr, lhs_attr;
3500 gfc_ref *ref; 3784 gfc_ref *ref;
3501 bool is_pure, is_implicit_pure, rank_remap; 3785 bool is_pure, is_implicit_pure, rank_remap;
3502 int proc_pointer; 3786 int proc_pointer;
3787 bool same_rank;
3503 3788
3504 lhs_attr = gfc_expr_attr (lvalue); 3789 lhs_attr = gfc_expr_attr (lvalue);
3505 if (lvalue->ts.type == BT_UNKNOWN && !lhs_attr.proc_pointer) 3790 if (lvalue->ts.type == BT_UNKNOWN && !lhs_attr.proc_pointer)
3506 { 3791 {
3507 gfc_error ("Pointer assignment target is not a POINTER at %L", 3792 gfc_error ("Pointer assignment target is not a POINTER at %L",
3519 } 3804 }
3520 3805
3521 proc_pointer = lvalue->symtree->n.sym->attr.proc_pointer; 3806 proc_pointer = lvalue->symtree->n.sym->attr.proc_pointer;
3522 3807
3523 rank_remap = false; 3808 rank_remap = false;
3809 same_rank = lvalue->rank == rvalue->rank;
3524 for (ref = lvalue->ref; ref; ref = ref->next) 3810 for (ref = lvalue->ref; ref; ref = ref->next)
3525 { 3811 {
3526 if (ref->type == REF_COMPONENT) 3812 if (ref->type == REF_COMPONENT)
3527 proc_pointer = ref->u.c.component->attr.proc_pointer; 3813 proc_pointer = ref->u.c.component->attr.proc_pointer;
3528 3814
3543 if (!gfc_notify_std (GFC_STD_F2003, "Bounds specification " 3829 if (!gfc_notify_std (GFC_STD_F2003, "Bounds specification "
3544 "for %qs in pointer assignment at %L", 3830 "for %qs in pointer assignment at %L",
3545 lvalue->symtree->n.sym->name, &lvalue->where)) 3831 lvalue->symtree->n.sym->name, &lvalue->where))
3546 return false; 3832 return false;
3547 3833
3548 /* When bounds are given, all lbounds are necessary and either all 3834 /* Fortran standard (e.g. F2018, 10.2.2 Pointer assignment):
3549 or none of the upper bounds; no strides are allowed. If the 3835 *
3550 upper bounds are present, we may do rank remapping. */ 3836 * (C1017) If bounds-spec-list is specified, the number of
3837 * bounds-specs shall equal the rank of data-pointer-object.
3838 *
3839 * If bounds-spec-list appears, it specifies the lower bounds.
3840 *
3841 * (C1018) If bounds-remapping-list is specified, the number of
3842 * bounds-remappings shall equal the rank of data-pointer-object.
3843 *
3844 * If bounds-remapping-list appears, it specifies the upper and
3845 * lower bounds of each dimension of the pointer; the pointer target
3846 * shall be simply contiguous or of rank one.
3847 *
3848 * (C1019) If bounds-remapping-list is not specified, the ranks of
3849 * data-pointer-object and data-target shall be the same.
3850 *
3851 * Thus when bounds are given, all lbounds are necessary and either
3852 * all or none of the upper bounds; no strides are allowed. If the
3853 * upper bounds are present, we may do rank remapping. */
3551 for (dim = 0; dim < ref->u.ar.dimen; ++dim) 3854 for (dim = 0; dim < ref->u.ar.dimen; ++dim)
3552 { 3855 {
3553 if (!ref->u.ar.start[dim]
3554 || ref->u.ar.dimen_type[dim] != DIMEN_RANGE)
3555 {
3556 gfc_error ("Lower bound has to be present at %L",
3557 &lvalue->where);
3558 return false;
3559 }
3560 if (ref->u.ar.stride[dim]) 3856 if (ref->u.ar.stride[dim])
3561 { 3857 {
3562 gfc_error ("Stride must not be present at %L", 3858 gfc_error ("Stride must not be present at %L",
3563 &lvalue->where); 3859 &lvalue->where);
3564 return false; 3860 return false;
3565 } 3861 }
3862 if (!same_rank && (!ref->u.ar.start[dim] ||!ref->u.ar.end[dim]))
3863 {
3864 gfc_error ("Rank remapping requires a "
3865 "list of %<lower-bound : upper-bound%> "
3866 "specifications at %L", &lvalue->where);
3867 return false;
3868 }
3869 if (!ref->u.ar.start[dim]
3870 || ref->u.ar.dimen_type[dim] != DIMEN_RANGE)
3871 {
3872 gfc_error ("Expected list of %<lower-bound :%> or "
3873 "list of %<lower-bound : upper-bound%> "
3874 "specifications at %L", &lvalue->where);
3875 return false;
3876 }
3566 3877
3567 if (dim == 0) 3878 if (dim == 0)
3568 rank_remap = (ref->u.ar.end[dim] != NULL); 3879 rank_remap = (ref->u.ar.end[dim] != NULL);
3569 else 3880 else
3570 { 3881 {
3571 if ((rank_remap && !ref->u.ar.end[dim]) 3882 if ((rank_remap && !ref->u.ar.end[dim]))
3572 || (!rank_remap && ref->u.ar.end[dim]))
3573 { 3883 {
3574 gfc_error ("Either all or none of the upper bounds" 3884 gfc_error ("Rank remapping requires a "
3575 " must be specified at %L", &lvalue->where); 3885 "list of %<lower-bound : upper-bound%> "
3886 "specifications at %L", &lvalue->where);
3887 return false;
3888 }
3889 if (!rank_remap && ref->u.ar.end[dim])
3890 {
3891 gfc_error ("Expected list of %<lower-bound :%> or "
3892 "list of %<lower-bound : upper-bound%> "
3893 "specifications at %L", &lvalue->where);
3576 return false; 3894 return false;
3577 } 3895 }
3578 } 3896 }
3579 } 3897 }
3580 } 3898 }
3620 { 3938 {
3621 gfc_error ("Invalid procedure pointer assignment at %L", 3939 gfc_error ("Invalid procedure pointer assignment at %L",
3622 &rvalue->where); 3940 &rvalue->where);
3623 return false; 3941 return false;
3624 } 3942 }
3943
3625 if (rvalue->expr_type == EXPR_VARIABLE && !attr.proc_pointer) 3944 if (rvalue->expr_type == EXPR_VARIABLE && !attr.proc_pointer)
3626 { 3945 {
3627 /* Check for intrinsics. */ 3946 /* Check for intrinsics. */
3628 gfc_symbol *sym = rvalue->symtree->n.sym; 3947 gfc_symbol *sym = rvalue->symtree->n.sym;
3629 if (!sym->attr.intrinsic 3948 if (!sym->attr.intrinsic
3816 return false; 4135 return false;
3817 } 4136 }
3818 4137
3819 return true; 4138 return true;
3820 } 4139 }
4140 else
4141 {
4142 /* A non-proc pointer cannot point to a constant. */
4143 if (rvalue->expr_type == EXPR_CONSTANT)
4144 {
4145 gfc_error_now ("Pointer assignment target cannot be a constant at %L",
4146 &rvalue->where);
4147 return false;
4148 }
4149 }
3821 4150
3822 if (!gfc_compare_types (&lvalue->ts, &rvalue->ts)) 4151 if (!gfc_compare_types (&lvalue->ts, &rvalue->ts))
3823 { 4152 {
3824 /* Check for F03:C717. */ 4153 /* Check for F03:C717. */
3825 if (UNLIMITED_POLY (rvalue) 4154 if (UNLIMITED_POLY (rvalue)
3829 || lvalue->ts.u.derived->attr.sequence)))) 4158 || lvalue->ts.u.derived->attr.sequence))))
3830 gfc_error ("Data-pointer-object at %L must be unlimited " 4159 gfc_error ("Data-pointer-object at %L must be unlimited "
3831 "polymorphic, or of a type with the BIND or SEQUENCE " 4160 "polymorphic, or of a type with the BIND or SEQUENCE "
3832 "attribute, to be compatible with an unlimited " 4161 "attribute, to be compatible with an unlimited "
3833 "polymorphic target", &lvalue->where); 4162 "polymorphic target", &lvalue->where);
3834 else 4163 else if (!suppress_type_test)
3835 gfc_error ("Different types in pointer assignment at %L; " 4164 gfc_error ("Different types in pointer assignment at %L; "
3836 "attempted assignment of %s to %s", &lvalue->where, 4165 "attempted assignment of %s to %s", &lvalue->where,
3837 gfc_typename (&rvalue->ts), 4166 gfc_typename (rvalue), gfc_typename (lvalue));
3838 gfc_typename (&lvalue->ts));
3839 return false; 4167 return false;
3840 } 4168 }
3841 4169
3842 if (lvalue->ts.type != BT_CLASS && lvalue->ts.kind != rvalue->ts.kind) 4170 if (lvalue->ts.type != BT_CLASS && lvalue->ts.kind != rvalue->ts.kind)
3843 { 4171 {
3923 "at %L must deliver a pointer result", 4251 "at %L must deliver a pointer result",
3924 &rvalue->where); 4252 &rvalue->where);
3925 return false; 4253 return false;
3926 } 4254 }
3927 4255
3928 if (!attr.target && !attr.pointer) 4256 if (is_init_expr)
3929 { 4257 {
3930 gfc_error ("Pointer assignment target is neither TARGET " 4258 gfc_symbol *sym;
3931 "nor POINTER at %L", &rvalue->where); 4259 bool target;
3932 return false; 4260
4261 gcc_assert (rvalue->symtree);
4262 sym = rvalue->symtree->n.sym;
4263
4264 if (sym->ts.type == BT_CLASS && sym->attr.class_ok)
4265 target = CLASS_DATA (sym)->attr.target;
4266 else
4267 target = sym->attr.target;
4268
4269 if (!target && !proc_pointer)
4270 {
4271 gfc_error ("Pointer assignment target in initialization expression "
4272 "does not have the TARGET attribute at %L",
4273 &rvalue->where);
4274 return false;
4275 }
4276 }
4277 else
4278 {
4279 if (!attr.target && !attr.pointer)
4280 {
4281 gfc_error ("Pointer assignment target is neither TARGET "
4282 "nor POINTER at %L", &rvalue->where);
4283 return false;
4284 }
3933 } 4285 }
3934 4286
3935 if (is_pure && gfc_impure_variable (rvalue->symtree->n.sym)) 4287 if (is_pure && gfc_impure_variable (rvalue->symtree->n.sym))
3936 { 4288 {
3937 gfc_error ("Bad target in pointer assignment in PURE " 4289 gfc_error ("Bad target in pointer assignment in PURE "
4061 ? CLASS_DATA (sym)->attr.class_pointer : sym->attr.pointer; 4413 ? CLASS_DATA (sym)->attr.class_pointer : sym->attr.pointer;
4062 proc_pointer = sym->attr.proc_pointer; 4414 proc_pointer = sym->attr.proc_pointer;
4063 } 4415 }
4064 4416
4065 if (pointer || proc_pointer) 4417 if (pointer || proc_pointer)
4066 r = gfc_check_pointer_assign (&lvalue, rvalue); 4418 r = gfc_check_pointer_assign (&lvalue, rvalue, false, true);
4067 else 4419 else
4068 { 4420 {
4069 /* If a conversion function, e.g., __convert_i8_i4, was inserted 4421 /* If a conversion function, e.g., __convert_i8_i4, was inserted
4070 into an array constructor, we should check if it can be reduced 4422 into an array constructor, we should check if it can be reduced
4071 as an initialization expression. */ 4423 as an initialization expression. */
4081 free (lvalue.ref); 4433 free (lvalue.ref);
4082 4434
4083 if (!r) 4435 if (!r)
4084 return r; 4436 return r;
4085 4437
4086 if (pointer && rvalue->expr_type != EXPR_NULL) 4438 if (pointer && rvalue->expr_type != EXPR_NULL && !proc_pointer)
4087 { 4439 {
4088 /* F08:C461. Additional checks for pointer initialization. */ 4440 /* F08:C461. Additional checks for pointer initialization. */
4089 symbol_attribute attr; 4441 symbol_attribute attr;
4090 attr = gfc_expr_attr (rvalue); 4442 attr = gfc_expr_attr (rvalue);
4091 if (attr.allocatable) 4443 if (attr.allocatable)
4123 symbol_attribute attr = gfc_expr_attr (rvalue); 4475 symbol_attribute attr = gfc_expr_attr (rvalue);
4124 if (attr.proc_pointer) 4476 if (attr.proc_pointer)
4125 { 4477 {
4126 gfc_error ("Procedure pointer initialization target at %L " 4478 gfc_error ("Procedure pointer initialization target at %L "
4127 "may not be a procedure pointer", &rvalue->where); 4479 "may not be a procedure pointer", &rvalue->where);
4480 return false;
4481 }
4482 if (attr.proc == PROC_INTERNAL)
4483 {
4484 gfc_error ("Internal procedure %qs is invalid in "
4485 "procedure pointer initialization at %L",
4486 rvalue->symtree->name, &rvalue->where);
4487 return false;
4488 }
4489 if (attr.dummy)
4490 {
4491 gfc_error ("Dummy procedure %qs is invalid in "
4492 "procedure pointer initialization at %L",
4493 rvalue->symtree->name, &rvalue->where);
4128 return false; 4494 return false;
4129 } 4495 }
4130 } 4496 }
4131 4497
4132 return true; 4498 return true;
4310 void 4676 void
4311 gfc_apply_init (gfc_typespec *ts, symbol_attribute *attr, gfc_expr *init) 4677 gfc_apply_init (gfc_typespec *ts, symbol_attribute *attr, gfc_expr *init)
4312 { 4678 {
4313 if (ts->type == BT_CHARACTER && !attr->pointer && init 4679 if (ts->type == BT_CHARACTER && !attr->pointer && init
4314 && ts->u.cl 4680 && ts->u.cl
4315 && ts->u.cl->length && ts->u.cl->length->expr_type == EXPR_CONSTANT) 4681 && ts->u.cl->length
4316 { 4682 && ts->u.cl->length->expr_type == EXPR_CONSTANT
4317 gcc_assert (ts->u.cl && ts->u.cl->length); 4683 && ts->u.cl->length->ts.type == BT_INTEGER)
4318 gcc_assert (ts->u.cl->length->expr_type == EXPR_CONSTANT); 4684 {
4319 gcc_assert (ts->u.cl->length->ts.type == BT_INTEGER);
4320
4321 HOST_WIDE_INT len = gfc_mpz_get_hwi (ts->u.cl->length->value.integer); 4685 HOST_WIDE_INT len = gfc_mpz_get_hwi (ts->u.cl->length->value.integer);
4322 4686
4323 if (init->expr_type == EXPR_CONSTANT) 4687 if (init->expr_type == EXPR_CONSTANT)
4324 gfc_set_constant_character_len (len, init, -1); 4688 gfc_set_constant_character_len (len, init, -1);
4325 else if (init 4689 else if (init
4488 4852
4489 static bool 4853 static bool
4490 comp_pointer (gfc_component *comp) 4854 comp_pointer (gfc_component *comp)
4491 { 4855 {
4492 return comp->attr.pointer 4856 return comp->attr.pointer
4493 || comp->attr.pointer
4494 || comp->attr.proc_pointer 4857 || comp->attr.proc_pointer
4495 || comp->attr.class_pointer 4858 || comp->attr.class_pointer
4496 || class_pointer (comp); 4859 || class_pointer (comp);
4497 } 4860 }
4498 4861
4778 case REF_COMPONENT: 5141 case REF_COMPONENT:
4779 as = ref->u.c.component->as; 5142 as = ref->u.c.component->as;
4780 continue; 5143 continue;
4781 5144
4782 case REF_SUBSTRING: 5145 case REF_SUBSTRING:
5146 case REF_INQUIRY:
4783 continue; 5147 continue;
4784 5148
4785 case REF_ARRAY: 5149 case REF_ARRAY:
4786 { 5150 {
4787 switch (ref->u.ar.type) 5151 switch (ref->u.ar.type)
4929 if (gfc_traverse_expr (ref->u.c.component->as->upper[i], 5293 if (gfc_traverse_expr (ref->u.c.component->as->upper[i],
4930 sym, func, f)) 5294 sym, func, f))
4931 return true; 5295 return true;
4932 } 5296 }
4933 break; 5297 break;
5298
5299 case REF_INQUIRY:
5300 return true;
4934 5301
4935 default: 5302 default:
4936 gcc_unreachable (); 5303 gcc_unreachable ();
4937 } 5304 }
4938 ref = ref->next; 5305 ref = ref->next;
5284 break; 5651 break;
5285 } 5652 }
5286 break; 5653 break;
5287 5654
5288 case REF_SUBSTRING: 5655 case REF_SUBSTRING:
5656 case REF_INQUIRY:
5289 break; 5657 break;
5290 } 5658 }
5291 5659
5292 return coarray && !coindexed; 5660 return coarray && !coindexed;
5293 } 5661 }
5390 bool colon; 5758 bool colon;
5391 int i; 5759 int i;
5392 gfc_array_ref *ar = NULL; 5760 gfc_array_ref *ar = NULL;
5393 gfc_ref *ref, *part_ref = NULL; 5761 gfc_ref *ref, *part_ref = NULL;
5394 gfc_symbol *sym; 5762 gfc_symbol *sym;
5763
5764 if (expr->expr_type == EXPR_ARRAY)
5765 return true;
5395 5766
5396 if (expr->expr_type == EXPR_FUNCTION) 5767 if (expr->expr_type == EXPR_FUNCTION)
5397 { 5768 {
5398 if (expr->value.function.esym) 5769 if (expr->value.function.esym)
5399 return expr->value.function.esym->result->attr.contiguous; 5770 return expr->value.function.esym->result->attr.contiguous;
5504 } 5875 }
5505 5876
5506 return true; 5877 return true;
5507 } 5878 }
5508 5879
5880 /* Return true if the expression is guaranteed to be non-contiguous,
5881 false if we cannot prove anything. It is probably best to call
5882 this after gfc_is_simply_contiguous. If neither of them returns
5883 true, we cannot say (at compile-time). */
5884
5885 bool
5886 gfc_is_not_contiguous (gfc_expr *array)
5887 {
5888 int i;
5889 gfc_array_ref *ar = NULL;
5890 gfc_ref *ref;
5891 bool previous_incomplete;
5892
5893 for (ref = array->ref; ref; ref = ref->next)
5894 {
5895 /* Array-ref shall be last ref. */
5896
5897 if (ar)
5898 return true;
5899
5900 if (ref->type == REF_ARRAY)
5901 ar = &ref->u.ar;
5902 }
5903
5904 if (ar == NULL || ar->type != AR_SECTION)
5905 return false;
5906
5907 previous_incomplete = false;
5908
5909 /* Check if we can prove that the array is not contiguous. */
5910
5911 for (i = 0; i < ar->dimen; i++)
5912 {
5913 mpz_t arr_size, ref_size;
5914
5915 if (gfc_ref_dimen_size (ar, i, &ref_size, NULL))
5916 {
5917 if (gfc_dep_difference (ar->as->lower[i], ar->as->upper[i], &arr_size))
5918 {
5919 /* a(2:4,2:) is known to be non-contiguous, but
5920 a(2:4,i:i) can be contiguous. */
5921 if (previous_incomplete && mpz_cmp_si (ref_size, 1) != 0)
5922 {
5923 mpz_clear (arr_size);
5924 mpz_clear (ref_size);
5925 return true;
5926 }
5927 else if (mpz_cmp (arr_size, ref_size) != 0)
5928 previous_incomplete = true;
5929
5930 mpz_clear (arr_size);
5931 }
5932
5933 /* Check for a(::2), i.e. where the stride is not unity.
5934 This is only done if there is more than one element in
5935 the reference along this dimension. */
5936
5937 if (mpz_cmp_ui (ref_size, 1) > 0 && ar->type == AR_SECTION
5938 && ar->dimen_type[i] == DIMEN_RANGE
5939 && ar->stride[i] && ar->stride[i]->expr_type == EXPR_CONSTANT
5940 && mpz_cmp_si (ar->stride[i]->value.integer, 1) != 0)
5941 return true;
5942
5943 mpz_clear (ref_size);
5944 }
5945 }
5946 /* We didn't find anything definitive. */
5947 return false;
5948 }
5509 5949
5510 /* Build call to an intrinsic procedure. The number of arguments has to be 5950 /* Build call to an intrinsic procedure. The number of arguments has to be
5511 passed (rather than ending the list with a NULL value) because we may 5951 passed (rather than ending the list with a NULL value) because we may
5512 want to add arguments but with a NULL-expression. */ 5952 want to add arguments but with a NULL-expression. */
5513 5953
5695 ptr_component = true; 6135 ptr_component = true;
5696 if (!pointer) 6136 if (!pointer)
5697 check_intentin = false; 6137 check_intentin = false;
5698 } 6138 }
5699 } 6139 }
5700 if (check_intentin && sym->attr.intent == INTENT_IN) 6140
6141 if (check_intentin
6142 && (sym->attr.intent == INTENT_IN
6143 || (sym->attr.select_type_temporary && sym->assoc
6144 && sym->assoc->target && sym->assoc->target->symtree
6145 && sym->assoc->target->symtree->n.sym->attr.intent == INTENT_IN)))
5701 { 6146 {
5702 if (pointer && is_pointer) 6147 if (pointer && is_pointer)
5703 { 6148 {
5704 if (context) 6149 if (context)
5705 gfc_error ("Dummy argument %qs with INTENT(IN) in pointer" 6150 gfc_error ("Dummy argument %qs with INTENT(IN) in pointer"
5707 sym->name, context, &e->where); 6152 sym->name, context, &e->where);
5708 return false; 6153 return false;
5709 } 6154 }
5710 if (!pointer && !is_pointer && !sym->attr.pointer) 6155 if (!pointer && !is_pointer && !sym->attr.pointer)
5711 { 6156 {
6157 const char *name = sym->attr.select_type_temporary
6158 ? sym->assoc->target->symtree->name : sym->name;
5712 if (context) 6159 if (context)
5713 gfc_error ("Dummy argument %qs with INTENT(IN) in variable" 6160 gfc_error ("Dummy argument %qs with INTENT(IN) in variable"
5714 " definition context (%s) at %L", 6161 " definition context (%s) at %L",
5715 sym->name, context, &e->where); 6162 name, context, &e->where);
5716 return false; 6163 return false;
5717 } 6164 }
5718 } 6165 }
5719 6166
5720 /* PROTECTED and use-associated. */ 6167 /* PROTECTED and use-associated. */
5721 if (sym->attr.is_protected && sym->attr.use_assoc && check_intentin) 6168 if (sym->attr.is_protected && sym->attr.use_assoc && check_intentin)
5722 { 6169 {
5723 if (pointer && is_pointer) 6170 if (pointer && is_pointer)
5724 { 6171 {
5725 if (context) 6172 if (context)
5726 gfc_error ("Variable %qs is PROTECTED and can not appear in a" 6173 gfc_error ("Variable %qs is PROTECTED and cannot appear in a"
5727 " pointer association context (%s) at %L", 6174 " pointer association context (%s) at %L",
5728 sym->name, context, &e->where); 6175 sym->name, context, &e->where);
5729 return false; 6176 return false;
5730 } 6177 }
5731 if (!pointer && !is_pointer) 6178 if (!pointer && !is_pointer)
5732 { 6179 {
5733 if (context) 6180 if (context)
5734 gfc_error ("Variable %qs is PROTECTED and can not appear in a" 6181 gfc_error ("Variable %qs is PROTECTED and cannot appear in a"
5735 " variable definition context (%s) at %L", 6182 " variable definition context (%s) at %L",
5736 sym->name, context, &e->where); 6183 sym->name, context, &e->where);
5737 return false; 6184 return false;
5738 } 6185 }
5739 } 6186 }
5741 /* Variable not assignable from a PURE procedure but appears in 6188 /* Variable not assignable from a PURE procedure but appears in
5742 variable definition context. */ 6189 variable definition context. */
5743 if (!pointer && !own_scope && gfc_pure (NULL) && gfc_impure_variable (sym)) 6190 if (!pointer && !own_scope && gfc_pure (NULL) && gfc_impure_variable (sym))
5744 { 6191 {
5745 if (context) 6192 if (context)
5746 gfc_error ("Variable %qs can not appear in a variable definition" 6193 gfc_error ("Variable %qs cannot appear in a variable definition"
5747 " context (%s) at %L in PURE procedure", 6194 " context (%s) at %L in PURE procedure",
5748 sym->name, context, &e->where); 6195 sym->name, context, &e->where);
5749 return false; 6196 return false;
5750 } 6197 }
5751 6198
5766 break; 6213 break;
5767 } 6214 }
5768 } 6215 }
5769 } 6216 }
5770 /* Check variable definition context for associate-names. */ 6217 /* Check variable definition context for associate-names. */
5771 if (!pointer && sym->assoc) 6218 if (!pointer && sym->assoc && !sym->attr.select_rank_temporary)
5772 { 6219 {
5773 const char* name; 6220 const char* name;
5774 gfc_association_list* assoc; 6221 gfc_association_list* assoc;
5775 6222
5776 gcc_assert (sym->assoc->target); 6223 gcc_assert (sym->assoc->target);
5800 if (!assoc->variable) 6247 if (!assoc->variable)
5801 { 6248 {
5802 if (context) 6249 if (context)
5803 { 6250 {
5804 if (assoc->target->expr_type == EXPR_VARIABLE) 6251 if (assoc->target->expr_type == EXPR_VARIABLE)
5805 gfc_error ("%qs at %L associated to vector-indexed target can" 6252 gfc_error ("%qs at %L associated to vector-indexed target"
5806 " not be used in a variable definition context (%s)", 6253 " cannot be used in a variable definition"
6254 " context (%s)",
5807 name, &e->where, context); 6255 name, &e->where, context);
5808 else 6256 else
5809 gfc_error ("%qs at %L associated to expression can" 6257 gfc_error ("%qs at %L associated to expression"
5810 " not be used in a variable definition context (%s)", 6258 " cannot be used in a variable definition"
6259 " context (%s)",
5811 name, &e->where, context); 6260 name, &e->where, context);
5812 } 6261 }
5813 return false; 6262 return false;
5814 } 6263 }
5815 6264
5816 /* Target must be allowed to appear in a variable definition context. */ 6265 /* Target must be allowed to appear in a variable definition context. */
5817 if (!gfc_check_vardef_context (assoc->target, pointer, false, false, NULL)) 6266 if (!gfc_check_vardef_context (assoc->target, pointer, false, false, NULL))
5818 { 6267 {
5819 if (context) 6268 if (context)
5820 gfc_error ("Associate-name %qs can not appear in a variable" 6269 gfc_error ("Associate-name %qs cannot appear in a variable"
5821 " definition context (%s) at %L because its target" 6270 " definition context (%s) at %L because its target"
5822 " at %L can not, either", 6271 " at %L cannot, either",
5823 name, context, &e->where, 6272 name, context, &e->where,
5824 &assoc->target->where); 6273 &assoc->target->where);
5825 return false; 6274 return false;
5826 } 6275 }
5827 } 6276 }