[OpenMP] Refactor const restriction for linear

As discussed in D56113, this patch refactors the implementation of the
const restriction for linear to reuse a function introduced by D56113.
A side effect is that, if a variable has mutable members, this
diagnostic is now skipped, and the diagnostic for the variable not
being an integer or pointer is reported instead.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D56299

llvm-svn: 350441
diff --git a/clang/test/OpenMP/target_simd_linear_messages.cpp b/clang/test/OpenMP/target_simd_linear_messages.cpp
index 6a094b8..d19409f 100644
--- a/clang/test/OpenMP/target_simd_linear_messages.cpp
+++ b/clang/test/OpenMP/target_simd_linear_messages.cpp
@@ -146,7 +146,7 @@
   for (int k = 0; k < argc; ++k)
     ++k;
 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
-// expected-error@+1 {{const-qualified variable cannot be linear}}
+// expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
 #pragma omp target simd linear(a, b : B::ib)
   for (int k = 0; k < argc; ++k)
     ++k;
@@ -231,7 +231,7 @@
   for (int k = 0; k < argc; ++k)
     ++k;
 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
-// expected-error@+1 {{const-qualified variable cannot be linear}}
+// expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
 #pragma omp target simd linear(a, b)
   for (int k = 0; k < argc; ++k)
     ++k;