This is an archive of the discontinued LLVM Phabricator instance.

[clang][ExprConstant] Improve error message of compound assignment against uninitialized object
ClosedPublic

Authored by hazohelet on Aug 14 2023, 3:20 AM.

Details

Summary

BEFORE this patch, compound assignment operator against uninitialized object such as uninit += 1 was diagnosed as subexpression not valid
This patch clarifies the reason for the error by saying that uninit is an uninitialized object.

Fixes https://github.com/llvm/llvm-project/issues/51536

Diff Detail

Event Timeline

hazohelet created this revision.Aug 14 2023, 3:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 3:20 AM
hazohelet requested review of this revision.Aug 14 2023, 3:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 3:20 AM

Generally LGTM, but I feel like the changes aren't c++2a specific (except for uninitialized variables in constexpr functions).

clang/lib/AST/ExprConstant.cpp
4447
hazohelet updated this revision to Diff 550216.Aug 15 2023, 2:22 AM
hazohelet marked an inline comment as done.

Address comments from Timm

  • Moved test to C++14,20,23 test file from C++20-only one
  • NFC stylistic changes
tbaeder accepted this revision.Aug 18 2023, 2:11 AM
This revision is now accepted and ready to land.Aug 18 2023, 2:11 AM
shafik accepted this revision.Aug 23 2023, 6:03 PM
shafik added a subscriber: shafik.

LGTM

This revision was landed with ongoing or failed builds.Aug 25 2023, 12:08 AM
This revision was automatically updated to reflect the committed changes.