Hi Tobias,
One has the choice between (a) Using the location where the expression was defined (in the scoping unit) – currently done (i.e. replacing expr->where by expr->symtree->n.sym->where) (b) using the location where the parameter is used, i.e. keeping expr->where despite simplification.
Or you could use both. With the nice colorization of error messages that David introduced gcc10, this is quite readable. Hm... this would require an additional member in the gfc_expr structure. While this may be a nice addition, it is certainly not necessary to get this patch in. So, OK for trunk, and thanks for the patch! Regards Thomas