[clang] [clang] Mark constructors with invalid initializers as invalid (PR #137773)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 30 07:03:21 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'}}
----------------
tbaederr wrote:
I guess not, unless invalid constructors were to take part in lookup later when calling `A()`.
https://github.com/llvm/llvm-project/pull/137773
More information about the cfe-commits
mailing list