{
char name[GFC_MAX_SYMBOL_LEN + 1];
gfc_ref *substring, *tail, *tmp;
- gfc_component *component;
+ gfc_component *component = NULL;
+ gfc_component *previous = NULL;
gfc_symbol *sym = primary->symtree->n.sym;
gfc_expr *tgt_expr = NULL;
match m;
break;
}
+ previous = component;
+
if (!inquiry && !intrinsic)
component = gfc_find_component (sym, name, false, false, &tmp);
else
component = NULL;
- /* In some cases, returning MATCH_NO gives a better error message. Most
- cases return "Unclassifiable statement at..." */
if (intrinsic && !inquiry)
- return MATCH_NO;
+ {
+ gfc_error ("%qs at %C is not an inquiry reference to an intrinsic "
+ "type component %qs", name, previous->name);
+ return MATCH_ERROR;
+ }
else if (component == NULL && !inquiry)
return MATCH_ERROR;
--- /dev/null
+! { dg-do run }
+!
+! Test the fix for PR96325 in which the typebound procedure reference
+! 'foo' was applied to an intrinsic type component without generating
+! an error. The result of the expression was the value of the arg..
+!
+! Contributed by Gerhardt Steinmetz <gscfq@t-online.de>
+!
+ implicit none
+
+ type t2
+ integer r1
+ end type
+
+ type(t2) :: t
+ integer :: a
+
+ a = t%r1%foo(1) { dg-error "is not an inquiry reference" }
+ if (a == 42) stop
+
+ end