Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11605,6 +11605,9 @@ class OpenMPAtomicUpdateChecker {
/// RHS binary operation does not have reference to the updated LHS
/// part.
NotAnUpdateExpression,
/// An expression contains semantical error not related to
/// 'omp atomic [update]'
NotAValidExpression,
/// No errors is found.
NoError
};
Expand Down Expand Up @@ -11782,6 +11785,10 @@ bool OpenMPAtomicUpdateChecker::checkStatement(Stmt *S, unsigned DiagId,
ErrorFound = NotABinaryOrUnaryExpression;
NoteLoc = ErrorLoc = AtomicBody->getExprLoc();
NoteRange = ErrorRange = AtomicBody->getSourceRange();
} else if (AtomicBody->containsErrors()) {
ErrorFound = NotAValidExpression;
NoteLoc = ErrorLoc = AtomicBody->getExprLoc();
NoteRange = ErrorRange = AtomicBody->getSourceRange();
}
} else {
ErrorFound = NotAScalarType;
Expand Down
12 changes: 12 additions & 0 deletions clang/test/SemaOpenMP/atomic-capture-const-no-crash.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: %clang_cc1 -fopenmp-simd -fsyntax-only -verify %s
// see https://github.com/llvm/llvm-project/issues/69069
// or https://github.com/llvm/llvm-project/pull/71480

void test() {
int v; const int x; // expected-note {{variable 'x' declared const here}}
#pragma omp atomic capture
{
v = x;
x = 1; // expected-error {{cannot assign to variable 'x' with const-qualified type 'const int'}}
}
}