Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -11531,20 +11531,12 @@ } Type = Type.getNonReferenceType(); - // A list item must not be const-qualified. - if (Type.isConstant(Context)) { - Diag(ELoc, diag::err_omp_const_variable) - << getOpenMPClauseName(OMPC_linear); - if (D) { - bool IsDecl = - !VD || - VD->isThisDeclarationADefinition(Context) == VarDecl::DeclarationOnly; - Diag(D->getLocation(), - IsDecl ? diag::note_previous_decl : diag::note_defined_here) - << D; - } + // OpenMP 5.0 [2.19.3, List Item Privatization, Restrictions] + // A variable that is privatized must not have a const-qualified type + // unless it is of class type with a mutable member. This restriction does + // not apply to the firstprivate clause. + if (rejectConstNotMutableType(*this, D, Type, OMPC_linear, ELoc)) return true; - } // A list item must be of integral or pointer type. Type = Type.getUnqualifiedType().getCanonicalType(); Index: test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp =================================================================== --- test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp +++ test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp @@ -189,7 +189,7 @@ #pragma omp target #pragma omp teams -#pragma omp distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} +#pragma omp distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target @@ -294,7 +294,7 @@ #pragma omp target #pragma omp teams -#pragma omp distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} expected-error {{incomplete type 'S1' where a complete type is required}} +#pragma omp distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} expected-error {{incomplete type 'S1' where a complete type is required}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target Index: test/OpenMP/distribute_simd_linear_messages.cpp =================================================================== --- test/OpenMP/distribute_simd_linear_messages.cpp +++ test/OpenMP/distribute_simd_linear_messages.cpp @@ -189,7 +189,7 @@ #pragma omp target #pragma omp teams -#pragma omp distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} +#pragma omp distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target @@ -283,7 +283,7 @@ #pragma omp target #pragma omp teams -#pragma omp distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} expected-warning {{Non-trivial type 'const S2' is mapped, only trivial types are guaranteed to be mapped correctly}} expected-error {{incomplete type 'S1' where a complete type is required}} +#pragma omp distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} expected-warning {{Non-trivial type 'const S2' is mapped, only trivial types are guaranteed to be mapped correctly}} expected-error {{incomplete type 'S1' where a complete type is required}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target Index: test/OpenMP/for_linear_messages.cpp =================================================================== --- test/OpenMP/for_linear_messages.cpp +++ 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}} Index: test/OpenMP/for_simd_linear_messages.cpp =================================================================== --- test/OpenMP/for_simd_linear_messages.cpp +++ test/OpenMP/for_simd_linear_messages.cpp @@ -122,7 +122,7 @@ #pragma omp for simd 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 simd linear (a, b:B::ib) for (int k = 0; k < argc; ++k) ++k; #pragma omp for simd linear (argv[1]) // expected-error {{expected variable name}} @@ -186,7 +186,7 @@ #pragma omp for simd 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 simd linear (a, b) for (int k = 0; k < argc; ++k) ++k; #pragma omp for simd linear (argv[1]) // expected-error {{expected variable name}} Index: test/OpenMP/parallel_for_linear_messages.cpp =================================================================== --- test/OpenMP/parallel_for_linear_messages.cpp +++ test/OpenMP/parallel_for_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 parallel for 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 parallel for linear(a, b) for (int k = 0; k < argc; ++k) ++k; Index: test/OpenMP/parallel_for_simd_linear_messages.cpp =================================================================== --- test/OpenMP/parallel_for_simd_linear_messages.cpp +++ test/OpenMP/parallel_for_simd_linear_messages.cpp @@ -122,7 +122,7 @@ #pragma omp parallel for simd 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 parallel for simd linear (a, b:B::ib) for (int k = 0; k < argc; ++k) ++k; #pragma omp parallel for simd linear (argv[1]) // expected-error {{expected variable name}} @@ -186,7 +186,7 @@ #pragma omp parallel for simd 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 parallel for simd linear (a, b) for (int k = 0; k < argc; ++k) ++k; #pragma omp parallel for simd linear (argv[1]) // expected-error {{expected variable name}} Index: test/OpenMP/simd_linear_messages.cpp =================================================================== --- test/OpenMP/simd_linear_messages.cpp +++ test/OpenMP/simd_linear_messages.cpp @@ -132,7 +132,7 @@ #pragma omp simd 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 simd linear (val(a, b):B::ib) for (int k = 0; k < argc; ++k) ++k; #pragma omp simd linear (argv[1]) // expected-error {{expected variable name}} @@ -221,7 +221,7 @@ #pragma omp simd 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 simd linear(a, b) for (int k = 0; k < argc; ++k) ++k; #pragma omp simd linear (argv[1]) // expected-error {{expected variable name}} Index: test/OpenMP/target_parallel_for_linear_messages.cpp =================================================================== --- test/OpenMP/target_parallel_for_linear_messages.cpp +++ test/OpenMP/target_parallel_for_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 parallel for 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 parallel for linear(a, b) for (int k = 0; k < argc; ++k) ++k; Index: test/OpenMP/target_parallel_for_simd_linear_messages.cpp =================================================================== --- test/OpenMP/target_parallel_for_simd_linear_messages.cpp +++ test/OpenMP/target_parallel_for_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 parallel for 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 parallel for simd linear(a, b) for (int k = 0; k < argc; ++k) ++k; Index: test/OpenMP/target_simd_linear_messages.cpp =================================================================== --- test/OpenMP/target_simd_linear_messages.cpp +++ 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; Index: test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp =================================================================== --- test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp +++ test/OpenMP/target_teams_distribute_parallel_for_simd_linear_messages.cpp @@ -148,7 +148,7 @@ #pragma omp target teams distribute parallel for simd linear (S1) // expected-error {{'S1' does not refer to a value}} for (int k = 0; k < argc; ++k) ++k; -#pragma omp target teams distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} +#pragma omp target teams distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target teams distribute parallel for simd linear (argv[1]) // expected-error {{expected variable name}} @@ -216,7 +216,7 @@ for (int k = 0; k < argc; ++k) ++k; -#pragma omp target teams distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} +#pragma omp target teams distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target teams distribute parallel for simd linear (argv[1]) // expected-error {{expected variable name}} Index: test/OpenMP/target_teams_distribute_simd_linear_messages.cpp =================================================================== --- test/OpenMP/target_teams_distribute_simd_linear_messages.cpp +++ test/OpenMP/target_teams_distribute_simd_linear_messages.cpp @@ -148,7 +148,7 @@ #pragma omp target teams distribute simd linear (S1) // expected-error {{'S1' does not refer to a value}} for (int k = 0; k < argc; ++k) ++k; -#pragma omp target teams distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} +#pragma omp target teams distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target teams distribute simd linear (argv[1]) // expected-error {{expected variable name}} @@ -216,7 +216,7 @@ for (int k = 0; k < argc; ++k) ++k; -#pragma omp target teams distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} +#pragma omp target teams distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target teams distribute simd linear (argv[1]) // expected-error {{expected variable name}} Index: test/OpenMP/taskloop_simd_linear_messages.cpp =================================================================== --- test/OpenMP/taskloop_simd_linear_messages.cpp +++ test/OpenMP/taskloop_simd_linear_messages.cpp @@ -132,7 +132,7 @@ #pragma omp taskloop simd 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 taskloop simd linear (val(a, b):B::ib) for (int k = 0; k < argc; ++k) ++k; #pragma omp taskloop simd linear (argv[1]) // expected-error {{expected variable name}} @@ -221,7 +221,7 @@ #pragma omp taskloop simd 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 taskloop simd linear(a, b) for (int k = 0; k < argc; ++k) ++k; #pragma omp taskloop simd linear (argv[1]) // expected-error {{expected variable name}} Index: test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp =================================================================== --- test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp +++ test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp @@ -169,7 +169,7 @@ for (int k = 0; k < argc; ++k) ++k; #pragma omp target -#pragma omp teams distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} +#pragma omp teams distribute parallel for simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target @@ -250,7 +250,7 @@ #pragma omp target -#pragma omp teams distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} +#pragma omp teams distribute parallel for simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target Index: test/OpenMP/teams_distribute_simd_linear_messages.cpp =================================================================== --- test/OpenMP/teams_distribute_simd_linear_messages.cpp +++ test/OpenMP/teams_distribute_simd_linear_messages.cpp @@ -169,7 +169,7 @@ for (int k = 0; k < argc; ++k) ++k; #pragma omp target -#pragma omp teams distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} +#pragma omp teams distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target @@ -250,7 +250,7 @@ #pragma omp target -#pragma omp teams distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}} +#pragma omp teams distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} for (int k = 0; k < argc; ++k) ++k; #pragma omp target