[clang] Add check in SemaChecking for multiple unsequenced volatile accesses (PR #180955)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 13 02:45:39 PST 2026
================
@@ -815,3 +815,29 @@ void test_var() {
}
} // namespace templates
+
+namespace muliple_read_volatile {
+ volatile int v1;
+
+ void PositiveTest(){
+ int x = 0;
+ int y = 0;
+ x = v1 + v1; // cxx11-warning {{unsequenced accesses to volatile qualified 'v1'}}
+ // cxx17-warning at -1 {{unsequenced accesses to volatile qualified 'v1'}}
+ v1 = v1 * v1; // cxx11-warning {{unsequenced accesses to volatile qualified 'v1'}}
+ // cxx17-warning at -1 {{unsequenced accesses to volatile qualified 'v1'}}
+ x = v1 + (y++, v1); // cxx11-warning {{unsequenced accesses to volatile qualified 'v1'}}
+ // cxx17-warning at -1 {{unsequenced accesses to volatile qualified 'v1'}}
+ x = v1 + v1 || y; // cxx11-warning {{unsequenced accesses to volatile qualified 'v1'}}
+ // cxx17-warning at -1 {{unsequenced accesses to volatile qualified 'v1'}}
+ }
+
+ void NegativeTest(){
+ int x = 0;
+ int y = 0;
+ x = v1 + y; // no-warning
+ v1 = v1 * y; // no-warning
+ x = (v1, v1); // no-warning
+ x = v1 || v1; // no-warning
+ }
+} // namespace muliple_read_volatile
----------------
Fznamznon wrote:
Hmm, are you using check-clang build target to verify that tests are ok?
In `SemaCXX/warn-unsequenced.cpp` seems a wrong diagnostic message is caught by expected-warning directives.
I think in most of CodeGen tests the new warning fires and they use Werror as I can see in the summary https://github.com/llvm/llvm-project/actions/runs/21958635491?pr=180955 . CodeGen tests usually don't mark diagnostic messages and check emitted code instead so an error will prevent such tests from passing. The tests need to be examined whether they are intentionally trigger the new warning and if they do and the warning is correct for these, we probably need to disable the warning for these via command line. Otherwise bugs in the warning or the tests need to be fixed.
https://github.com/llvm/llvm-project/pull/180955
More information about the cfe-commits
mailing list