[clang] [clang] Mark constructors with invalid initializers as invalid (PR #137773)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 30 04:03:08 PDT 2025
================
@@ -2,16 +2,20 @@
// RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++11 %s
-class A {
+class A {
+ // expected-note at -1 {{candidate constructor}}
+#if __cplusplus >= 201103L // C++11 or later
+ // expected-note at -3 {{candidate constructor}}
+#endif
int m;
public:
A() : A::m(17) { } // expected-error {{member initializer 'm' does not name a non-static data member or base class}}
- A(int);
+ A(int); // expected-note {{candidate constructor}}
};
class B : public A {
public:
- B() : A(), m(1), n(3.14) { }
+ B() : A(), m(1), n(3.14) { } // expected-error {{no matching constructor for initialization of 'A'}}
----------------
AaronBallman wrote:
Oof, yeah, this diagnostic is confusing because it sure looks like there's a matching constructor for `A`.
https://github.com/llvm/llvm-project/pull/137773
More information about the cfe-commits
mailing list