[clang] [OpenMP] Fix atomic compare handling with overloaded operators (PR #141142)
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Wed May 28 11:38:09 PDT 2025
================
@@ -991,3 +991,34 @@ int mixed() {
// expected-note at +1 {{in instantiation of function template specialization 'mixed<int>' requested here}}
return mixed<int>();
}
+
+#ifdef OMP51
+struct U {};
+struct U operator<(U, U);
+struct U operator>(U, U);
+struct U operator==(U, U);
+
+template <typename T> void templated() {
+ T cx, cv, ce, cd;
+#pragma omp atomic compare capture
+ if (cx == ce) {
+ cx = cd;
+ } else {
+ cv = cx;
+ }
+#pragma omp atomic compare capture
+ {
+ cv = cx;
+ if (ce > cx) {
+ cx = ce;
+ }
+ }
+#pragma omp atomic compare capture
+ {
+ cv = cx;
+ if (cx < ce) {
+ cx = ce;
+ }
+ }
+}
+#endif
----------------
jhuber6 wrote:
Codegen wasn't the issue here, if you manually instantiated it the code would work fine, the issue was just Sema incorrectly rejecting this when there was no type given.
https://github.com/llvm/llvm-project/pull/141142
More information about the cfe-commits
mailing list