Closed Bug 1771075 (Wdeprecated-volatile) Opened 2 years ago Closed 1 year ago

[meta] Fix and re-enable C++20 -Wvolatile and -Wdeprecated-volatile warnings

Categories

(Firefox Build System :: General, task, P3)

task

Tracking

(firefox110 fixed)

RESOLVED FIXED
110 Branch
Tracking Status
firefox110 --- fixed

People

(Reporter: cpeterson, Assigned: cpeterson)

References

Details

(Keywords: meta)

Attachments

(1 file)

C++20 deprecated some uses of volatile:

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1152r3.html

clang -std=c++20 warns about the following issues:

  • compound assignment to object of volatile-qualified type A is deprecated, e.g. v += 1.
  • decrement/increment of object of volatile-qualified type B is deprecated, e.g. v++.
  • use of result of assignment to object of volatile-qualified type A is deprecated
  • volatile-qualified parameter type A is deprecated
  • volatile-qualified return type A is deprecated
  • volatile qualifier in structured binding declaration is deprecated

https://clang.llvm.org/docs/DiagnosticsReference.html#wdeprecated-volatile

Unfortunately, clang's -Wdeprecated-volatile doesn't work in -std=c++17 mode. (See https://github.com/llvm/llvm-project/issues/55338.) It can only suppress warnings reported in -std=c++20 mode. gcc's equivalent warning, -Wvolatile, can be enabled in -std=c++17 mode. So if we fix the warnings below, we can enable gcc's -Wvolatile before enabling -std=c++20 mode to prevent regressions.

-Wdeprecated-volatile warnings in mozilla-central:

dom/media/gtest/TestMediaEventSource.cpp:234:43 [-Wdeprecated-volatile] compound assignment to object of volatile-qualified type 'volatile int' is deprecated
dom/media/systemservices/CamerasParent.cpp:1059:18 [-Wdeprecated-volatile] increment of object of volatile-qualified type 'volatile uint64_t' (aka 'volatile unsigned long long') is deprecated
gfx/vr/VRShMem.cpp:420:37 [-Wdeprecated-volatile] increment of object of volatile-qualified type 'volatile int64_t' (aka 'volatile long long') is deprecated
gfx/vr/VRShMem.cpp:423:37 [-Wdeprecated-volatile] increment of object of volatile-qualified type 'volatile int64_t' (aka 'volatile long long') is deprecated
gfx/vr/VRShMem.cpp:515:32 [-Wdeprecated-volatile] increment of object of volatile-qualified type 'volatile int64_t' (aka 'volatile long long') is deprecated
gfx/vr/VRShMem.cpp:517:32 [-Wdeprecated-volatile] increment of object of volatile-qualified type 'volatile int64_t' (aka 'volatile long long') is deprecated
js/src/gdb/gdb-tests.cpp:23:36: '++' expression of 'volatile'-qualified type is deprecated [-Wvolatile]
js/src/jsapi-tests/testGCStoreBufferRemoval.cpp:17:32: '++' expression of 'volatile'-qualified type is deprecated [-Wvolatile]
js/src/jsapi-tests/testGCStoreBufferRemoval.cpp:18:33: '--' expression of 'volatile'-qualified type is deprecated [-Wvolatile]
mfbt/SHA1.cpp:400:9 [-Wdeprecated-volatile] compound assignment to object of volatile-qualified type 'volatile unsigned int' is deprecated
mfbt/SHA1.cpp:401:9 [-Wdeprecated-volatile] compound assignment to object of volatile-qualified type 'volatile unsigned int' is deprecated
mfbt/SHA1.cpp:402:9 [-Wdeprecated-volatile] compound assignment to object of volatile-qualified type 'volatile unsigned int' is deprecated
mfbt/SHA1.cpp:403:9 [-Wdeprecated-volatile] compound assignment to object of volatile-qualified type 'volatile unsigned int' is deprecated
mfbt/SHA1.cpp:404:9 [-Wdeprecated-volatile] compound assignment to object of volatile-qualified type 'volatile unsigned int' is deprecated
third_party/libwebrtc/rtc_base/race_checker.cc:28:20 [-Wdeprecated-volatile] increment of object of volatile-qualified type 'volatile int' is deprecated
third_party/libwebrtc/rtc_base/race_checker.cc:38:3 [-Wdeprecated-volatile] decrement of object of volatile-qualified type 'volatile int' is deprecated
Alias: Wdeprecated-volatile

Fixing these C++20 warnings doesn't block updating from C++17 to C++20 because they were downgraded from errors to warnings in bug 1781001.

No longer blocks: C++20
See Also: → C++20, 1781001
Summary: Fix or suppress C++20 -Wdeprecated-volatile warnings → Fix and re-enable C++20 -Wvolatile and -Wdeprecated-volatile warnings
Keywords: meta
Summary: Fix and re-enable C++20 -Wvolatile and -Wdeprecated-volatile warnings → [meta] Fix and re-enable C++20 -Wvolatile and -Wdeprecated-volatile warnings
Depends on: 1802649
Depends on: 1803504
Depends on: 1805337
Depends on: 1806779
Assignee: nobody → cpeterson

We can enable C++20 -Wvolatile warnings in gcc before we compile as -std=c++20, but not in clang. These warnings will be enabled by default with gcc and clang -std=c++20, so we won't need to explicitly enable -Wvolatile after we're compiling as -std=c++20.

Pushed by cpeterson@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c0d8167d9801
Enable C++20 -Wvolatile warnings. r=firefox-build-system-reviewers,glandium
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 110 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: