================
@@ -0,0 +1,47 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify
%s
+
+// This test verifies that the analyzer can 'see' the initializer of an
+// array of structs, covering const, non-const, and main() vs non-main cases.
+
+void clang_analyzer_warnIfReached(void);
+
+struct S {
+ int a;
+};
+
+// Non-const struct array: initializer should be visible in main().
+struct S struct_array[1] = {
+ {11},
+};
+
+int main(int argc, char **argv) {
+ if (struct_array->a == 11) {
+ clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+ } else {
+ clang_analyzer_warnIfReached(); // unreachable
+ }
----------------
steakhal wrote:
Have you considered using the `clang_analyzer_value`?
If yes, why did you opt for `clang_analyzer_warnIfReached` instead?
https://github.com/llvm/llvm-project/pull/189361
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits