Clang error: const-qualified variable cannot be A (err_omp_const_variable)
Jump to navigation
Jump to search
| Text | error: const-qualified variable cannot be A |
|---|---|
| Type | Error |
| Category | OpenMP Issue |
| Internal Id | err_omp_const_variable |
| Internal Message | const-qualified variable cannot be %0
|
| Regular Expression | (?:error|fatal error)\: const\-qualified variable cannot be (.*?)
|
| First Commit | 2014-04-22 8dba66412b0a [OPENMP] parsing 'linear' clause (for directive 'omp simd') |
Description
Example
| Flags | -fopenmp -xc
|
|
|---|---|---|
| Source |
#include <omp.h>
int main() {
const int x = 10; // x is const
#pragma omp parallel for private(x) // error: x cannot be private in OpenMP
for(int i = 0; i < 10; i++) {}
return 0;
}
| |
| Compiler Output |
<source>:5:36: error: const-qualified variable cannot be private <source>:4:13: note: 'x' defined here |
Clang Internals (17.0.6)
Git Commit Message
[OPENMP] parsing 'linear' clause (for directive 'omp simd') Differential Revision: http://reviews.llvm.org/D3272 llvm-svn: 206891
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaOpenMP.cpp (line 1712)
static bool rejectConstNotMutableType(Sema &SemaRef, const ValueDecl *D, QualType Type, OpenMPClauseKind CKind, SourceLocation ELoc, bool AcceptIfMutable = true, bool ListItemNotVar = false) {
// ...
if (isConstNotMutableType(SemaRef, Type, AcceptIfMutable, &IsClassType)) {
unsigned Diag = ListItemNotVar ? diag::err_omp_const_list_item : IsClassType ? diag::err_omp_const_not_mutable_variable : diag::err_omp_const_variable;
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/OpenMP/target_teams_private_messages.cpp
- clang/test/OpenMP/target_teams_private_messages.cpp:88:44: error: const-qualified variable cannot be private
- clang/test/OpenMP/target_teams_private_messages.cpp:88:47: error: const-qualified variable cannot be private
- clang/test/OpenMP/target_teams_private_messages.cpp:96:34: error: const-qualified variable cannot be private