[clang] [clang-tools-extra] [Clang][Sema]Report error for non-base types in constructor initializers before causing issue in initializer order (PR #201379)

Gábor Spaits via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 24 01:48:33 PDT 2026


spaits wrote:

Currently, this patch also reports and error for this code:
```cpp
class SomeBase {};

struct S0 : SomeBase {
    S0(int) {}
    template <class T>
    S0(T) : Member(42), T(42) {};
    int Member{21};
};
```
Also the clang-tidy test case:
```

namespace gh192510 {
  template<typename T>
  struct C {

  };

  struct Base {  
    int x;
  };

  template<typename T>
  class X: public Base/*, private C<T>*/ {
    using INT = C<T>;

    X(INT i) : INT(i) {} // no crash
    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: constructor does not initialize these bases: Base
  };
}
```
Also gives an error.
If I understand it correctly, I shouldn't report an error, when the class has any base classes. But in that case I think the template types may still get down to the member initialization warning generation phase and we may still crash. I will check it out.

https://github.com/llvm/llvm-project/pull/201379


More information about the cfe-commits mailing list