[PATCH] D126324: [clang] Allow const variables with weak attribute to be overridden
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 25 04:31:06 PDT 2022
aaron.ballman added a comment.
The changes so far look sensible, but I think we should add some more tests for a few situations. 1) Using a const weak symbol as a valid initializer should be diagnosed (with a warning? with an error?) so users are alerted to the behavioral quirks. 2) Using a const weak symbol in a constant expression context should probably be an error, right? e.g.,
const int hmm __attribute__((weak)) = 12;
int erp = hmm; // Error in C, dynamic init in C++?
int main() {
int blerp = hmm; // OK in both languages
constexpr int derp = hmm; // Error in C++
int array[hmm]; // Error in both languages
}
Also, this definitely could use a release note so users know about the behavioral change.
Do you have any ideas on how much code this change is expected to break? (Is it sufficient enough that we want to have an explicit deprecation period of the existing behavior before we switch to the new behavior?)
================
Comment at: clang/include/clang/Basic/Attr.td:2962
let Subjects = SubjectList<[Var, Function, CXXRecord]>;
- let Documentation = [Undocumented];
+ let Documentation = [WeakDocs];
let SimpleHandler = 1;
----------------
THANK YOU!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126324/new/
https://reviews.llvm.org/D126324
More information about the cfe-commits
mailing list