[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/for_linear_messages.cpp b/clang/test/OpenMP/for_linear_messages.cpp
index 622cd4a..f35e534 100644
--- a/clang/test/OpenMP/for_linear_messages.cpp
+++ b/clang/test/OpenMP/for_linear_messages.cpp
@@ -122,7 +122,7 @@
   #pragma omp for linear (S1) // expected-error {{'S1' does not refer to a value}}
   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 for linear (a, b:B::ib)
   for (int k = 0; k < argc; ++k) ++k;
   #pragma omp for linear (argv[1]) // expected-error {{expected variable name}}
@@ -188,7 +188,7 @@
   #pragma omp for linear (S1) // expected-error {{'S1' does not refer to a value}}
   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 for linear(a, b)
   for (int k = 0; k < argc; ++k) ++k;
   #pragma omp for linear (argv[1]) // expected-error {{expected variable name}}