steakhal added a comment.

Okay, thanks for clarifying.

So, it seems like it depends on the language flavor, but why does CSA behave 
differently in C and C++?
This is necessary to understand if we need to fix that instead of patching this 
particular checker.

I'd still add a test to the `clang/test/Analysis/unnamedBitfields.c`, something 
like this:

  // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s -x c
  // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s -x c++
  
  typedef struct {
    unsigned x : 3;
    unsigned : 29; 
    unsigned y;
  } A;
  void take_by_value(A a);
  
  void initlistExpr(void) {
    A a = {0}; // zero-initializes all fields
    take_by_value(a); // no-warning
  }
  
  void defaultConstruct(void) {
    A a; // uninitialized
    a.x = 0;
    take_by_value(a); // expected-warning{{Passed-by-value struct argument 
contains uninitialized data (e.g., field: 'y')}}
  }



---

FYI you can add syntax highlighting for your snippets here by:

  ```lang=C++


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146194/new/

https://reviews.llvm.org/D146194

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to