mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 03:47:02 -05:00
openmp: Improve Fortran Diagnostics for Linear Clause
This patch improves diagnostics for the linear clause, providing a more accurate and intuitive recommendation for remediation if the deprecated syntax is used. Additionally updates the relevant test to reflect the changed verbiage of the warning. gcc/fortran/ChangeLog: * openmp.cc (gfc_match_omp_clauses): New diagnostic logic. libgomp/ChangeLog: * testsuite/libgomp.fortran/pr84418-1.f90: Fix verbiage of dg-warning to reflect updated warning.
This commit is contained in:
@@ -3481,11 +3481,6 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
|
||||
gfc_current_locus = old_loc;
|
||||
break;
|
||||
}
|
||||
if (old_linear_modifier)
|
||||
gfc_warning (OPT_Wdeprecated_openmp,
|
||||
"Specification of the list items as arguments to "
|
||||
"the modifiers at %L is deprecated since "
|
||||
"OpenMP 5.2", &saved_loc);
|
||||
if (linear_op != OMP_LINEAR_DEFAULT)
|
||||
{
|
||||
if (gfc_match (" :") == MATCH_YES)
|
||||
@@ -3509,6 +3504,52 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (old_linear_modifier)
|
||||
{
|
||||
char var_names[512]{};
|
||||
int count, offset = 0;
|
||||
for (gfc_omp_namelist *n = *head; n; n = n->next)
|
||||
{
|
||||
if (!n->next)
|
||||
count = snprintf (var_names + offset,
|
||||
sizeof (var_names) - offset,
|
||||
"%s", n->sym->name);
|
||||
else
|
||||
count = snprintf (var_names + offset,
|
||||
sizeof (var_names) - offset,
|
||||
"%s, ", n->sym->name);
|
||||
if (count < 0 || count >= ((int)sizeof (var_names))
|
||||
- offset)
|
||||
{
|
||||
snprintf (var_names, 512, "%s, ..., ",
|
||||
(*head)->sym->name);
|
||||
while (n->next)
|
||||
n = n->next;
|
||||
offset = strlen (var_names);
|
||||
snprintf (var_names + offset,
|
||||
sizeof (var_names) - offset,
|
||||
"%s", n->sym->name);
|
||||
break;
|
||||
}
|
||||
offset += count;
|
||||
}
|
||||
char *var_names_for_warn = var_names;
|
||||
const char *op_name;
|
||||
switch (linear_op)
|
||||
{
|
||||
case OMP_LINEAR_REF: op_name = "ref"; break;
|
||||
case OMP_LINEAR_VAL: op_name = "val"; break;
|
||||
case OMP_LINEAR_UVAL: op_name = "uval"; break;
|
||||
default: gcc_unreachable ();
|
||||
}
|
||||
gfc_warning (OPT_Wdeprecated_openmp,
|
||||
"Specification of the list items as "
|
||||
"arguments to the modifiers at %L is "
|
||||
"deprecated; since OpenMP 5.2, use "
|
||||
"%<linear(%s : %s%s)%>", &saved_loc,
|
||||
var_names_for_warn, op_name,
|
||||
step == nullptr ? "" : ", step(...)");
|
||||
}
|
||||
else if (end_colon)
|
||||
{
|
||||
bool has_error = false;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
! { dg-options "-fno-inline" }
|
||||
! { dg-additional-options "-msse2" { target sse2_runtime } }
|
||||
! { dg-additional-options "-mavx" { target avx_runtime } }
|
||||
! { dg-warning "Specification of the list items as arguments to the modifiers at \\(1\\) is deprecated; since OpenMP 5.2, use 'linear\\(x, y : ref\\)' \\\[-Wdeprecated-openmp\\\]" "" { target *-*-* } 24 }
|
||||
|
||||
real :: a(1024), b(1024), c(1024)
|
||||
integer :: i
|
||||
@@ -20,7 +21,7 @@
|
||||
contains
|
||||
real function foo (x, y)
|
||||
real :: x, y
|
||||
!$omp declare simd linear (ref (x, y)) ! { dg-warning "Specification of the list items as arguments to the modifiers at \\(1\\) is deprecated since OpenMP 5.2 \\\[-Wdeprecated-openmp\\\]" }
|
||||
!$omp declare simd linear (ref (x, y))
|
||||
foo = x + y
|
||||
end function
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user