llvm-project
e8ae7794 - [C] Add diagnostic + attr for unterminated strings (#137829)

Commit
225 days ago
[C] Add diagnostic + attr for unterminated strings (#137829) This introduces three things related to intialization like: char buf[3] = "foo"; where the array does not declare enough space for the null terminator but otherwise can represent the array contents exactly. 1) An attribute named 'nonstring' which can be used to mark that a field or variable is not intended to hold string data. 2) -Wunterminated-string-initialization, which is grouped under -Wextra, and diagnoses the above construct unless the declaration uses the 'nonstring' attribute. 3) -Wc++-unterminated-string-initialization, which is grouped under -Wc++-compat, and diagnoses the above construct even if the declaration uses the 'nonstring' attribute. Fixes #137705
Author
Parents
Loading