================
@@ -0,0 +1,38 @@
+// RUN: %clang_analyze_cc1 -xc %s \
+// RUN: -analyzer-checker=core,debug.ExprInspection,deadcode.DeadStores \
+// RUN: -verify
+// RUN: %clang_analyze_cc1 -xc++ %s \
+// RUN: -analyzer-checker=core,debug.ExprInspection,deadcode.DeadStores \
+// RUN: -verify -w
+
+// Self assignment initialization in C code will be treated as nop.
+// We will not report the VarDecl, but the following DeclRefExpr if it has not
+// yet been initialized then.
+
+void clang_analyzer_warnIfReached();
+
+struct S { int x; };
+union U { int x; };
+
+void nowarn() {
+ int x = x; // no-warnings for C/C++
+ int *p = p; // no-warnings for C/C++
+ struct S s = s; // no-warning for C, but C++ will not report
+ union U u = u; // no-warning for C, but C++ will not report
----------------
NagyDonat wrote:
Thanks for the clarification!
> Do you think it looks better with "no-warning for C, and C++ will not report
> either due to different AST structure"?
Yes, that would be better. To me the use of the word "but" strongly implied
that the behavior is different between C and C++.
https://github.com/llvm/llvm-project/pull/187530
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits