diff --git a/clang/include/clang/Basic/DiagnosticASTKinds.td b/clang/include/clang/Basic/DiagnosticASTKinds.td --- a/clang/include/clang/Basic/DiagnosticASTKinds.td +++ b/clang/include/clang/Basic/DiagnosticASTKinds.td @@ -6,6 +6,12 @@ // //===----------------------------------------------------------------------===// +//----------------understanding syntax of diagnostics messages--------===// +//keyword after def represents symbolic constant for that diagnostics +//for %select{}num The select operator uses num to select one of the alternatives inside the braces, which are separated by |. +//If you pass 0 as parameter , it will substitute the 0th alternative, which is the empty string; if you pass I, it will substitute the Ith alternative +//%num is a placeholder for a parameter passed to the diagnostic engine where num can be 0 for first argument 1 for second argument and so on +//===--------------------------------------------------------------------===// let Component = "AST" in { // Constant expression diagnostics. These (and their users) belong in Sema. diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp --- a/clang/lib/AST/Interp/Interp.cpp +++ b/clang/lib/AST/Interp/Interp.cpp @@ -387,7 +387,7 @@ QualType ElemType = CAT->getElementType(); if (isa(ElemType.getTypePtr())) { - const Record *R = BasePtr.getElemRecord(); + const Record *R = BasePtr.getElemRecord(); for (size_t I = 0; I != NumElems; ++I) { Pointer ElemPtr = BasePtr.atIndex(I).narrow(); Result &= CheckFieldsInitialized(S, OpPC, ElemPtr, R); diff --git a/clang/test/AST/Interp/cxx20.cpp b/clang/test/AST/Interp/cxx20.cpp --- a/clang/test/AST/Interp/cxx20.cpp +++ b/clang/test/AST/Interp/cxx20.cpp @@ -143,9 +143,9 @@ constexpr A() {} }; constexpr A a; // expected-error {{must be initialized by a constant expression}} \ - // expected-note {{subobject of type 'int' is not initialized}} \ + // expected-note {{subobject a is not initialized}} \ // ref-error {{must be initialized by a constant expression}} \ - // ref-note {{subobject of type 'int' is not initialized}} + // ref-note {{subobject a is not initialized}} class Base { @@ -161,18 +161,18 @@ constexpr Derived() : Base() {} }; constexpr Derived D; // expected-error {{must be initialized by a constant expression}} \ - // expected-note {{subobject of type 'int' is not initialized}} \ + // expected-note {{subobject a is not initialized}} \ // ref-error {{must be initialized by a constant expression}} \ - // ref-note {{subobject of type 'int' is not initialized}} + // ref-note {{subobject a is not initialized}} class C2 { public: A a; constexpr C2() {} }; constexpr C2 c2; // expected-error {{must be initialized by a constant expression}} \ - // expected-note {{subobject of type 'int' is not initialized}} \ + // expected-note {{subobject a is not initialized}} \ // ref-error {{must be initialized by a constant expression}} \ - // ref-note {{subobject of type 'int' is not initialized}} + // ref-note {{subobject a is not initialized}} // FIXME: These two are currently disabled because the array fields @@ -184,9 +184,9 @@ constexpr C3() {} }; constexpr C3 c3; // expected-error {{must be initialized by a constant expression}} \ - // expected-note {{subobject of type 'int' is not initialized}} \ + // expected-note {{subobject a is not initialized}} \ // ref-error {{must be initialized by a constant expression}} \ - // ref-note {{subobject of type 'int' is not initialized}} + // ref-note {{subobject a is not initialized}} class C4 { public: @@ -195,9 +195,9 @@ constexpr C4(){} }; constexpr C4 c4; // expected-error {{must be initialized by a constant expression}} \ - // expected-note {{subobject of type 'bool' is not initialized}} \ + // expected-note {{subobject B is not initialized}} \ // ref-error {{must be initialized by a constant expression}} \ - // ref-note {{subobject of type 'bool' is not initialized}} + // ref-note {{subobject B is not initialized}} #endif }; diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp @@ -359,7 +359,7 @@ // The constructor is still 'constexpr' here, but the result is not intended // to be a constant expression. The standard is not clear on how this should // work. - constexpr V v; // expected-error {{constant expression}} expected-note {{subobject of type 'int' is not initialized}} + constexpr V v; // expected-error {{constant expression}} expected-note {{subobject y is not initialized}} constexpr int k = V().x; // FIXME: ok? } diff --git a/clang/test/SemaCXX/attr-require-constant-initialization.cpp b/clang/test/SemaCXX/attr-require-constant-initialization.cpp --- a/clang/test/SemaCXX/attr-require-constant-initialization.cpp +++ b/clang/test/SemaCXX/attr-require-constant-initialization.cpp @@ -152,7 +152,7 @@ #else ATTR static PODType pod; // expected-error {{variable does not have a constant initializer}} // expected-note@-1 {{required by 'require_constant_initialization' attribute here}} -// expected-note-re@-2 {{{{non-constexpr constructor|subobject of type 'int' is not initialized}}}} +// expected-note-re@-2 {{{{non-constexpr constructor|subobject value and value2 is not initialized}}}} #endif ATTR static PODType pot2 = {ReturnInt()}; // expected-error {{variable does not have a constant initializer}} // expected-note@-1 {{required by 'require_constant_initialization' attribute here}} @@ -191,7 +191,7 @@ PODType TT2::pod_noinit; // expected-note 0+ {{declared here}} #if __cplusplus >= 201103L // expected-error@-2 {{variable does not have a constant initializer}} -// expected-note-re@-3 {{{{non-constexpr constructor|subobject of type 'int' is not initialized}}}} +// expected-note-re@-3 {{{{non-constexpr constructor|subobject value and value2 is not initialized}}}} #endif PODType TT2::pod_copy_init(TT2::pod_noinit); // expected-error {{variable does not have a constant initializer}} #if __cplusplus >= 201103L diff --git a/clang/test/SemaCXX/constant-expression-cxx2a.cpp b/clang/test/SemaCXX/constant-expression-cxx2a.cpp --- a/clang/test/SemaCXX/constant-expression-cxx2a.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx2a.cpp @@ -409,12 +409,12 @@ b.a.x = 2; return b; } - constexpr B uninit = return_uninit(); // expected-error {{constant expression}} expected-note {{subobject of type 'int' is not initialized}} + constexpr B uninit = return_uninit(); // expected-error {{constant expression}} expected-note {{subobject arr and p or q is not initialized}} static_assert(return_uninit().a.x == 2); constexpr A return_uninit_struct() { B b = {.b = 1}; b.a.x = 2; - return b.a; // expected-note {{in call to 'A(b.a)'}} expected-note {{subobject of type 'int' is not initialized}} + return b.a; // expected-note {{in call to 'A(b.a)'}} expected-note {{subobject arr and p or q is not initialized}} } // Note that this is rejected even though return_uninit() is accepted, and // return_uninit() copies the same stuff wrapped in a union. @@ -558,7 +558,7 @@ } }; constinit X x1(true); - constinit X x2(false); // expected-error {{constant initializer}} expected-note {{constinit}} expected-note {{subobject of type 'int' is not initialized}} + constinit X x2(false); // expected-error {{constant initializer}} expected-note {{constinit}} expected-note {{subobject n is not initialized}} struct Y { struct Z { int n; }; // expected-note {{here}} @@ -577,7 +577,7 @@ }; // FIXME: This is working around clang not implementing DR2026. With that // fixed, we should be able to test this without the injected copy. - constexpr Y copy(Y y) { return y; } // expected-note {{in call to 'Y(y)'}} expected-note {{subobject of type 'int' is not initialized}} + constexpr Y copy(Y y) { return y; } // expected-note {{in call to 'Y(y)'}} expected-note {{subobject z1.n is not initialized}} constexpr Y y1 = copy(Y()); static_assert(y1.z1.n == 1 && y1.z2.n == 2 && y1.z3.n == 3); diff --git a/clang/test/SemaCXX/cxx2a-consteval.cpp b/clang/test/SemaCXX/cxx2a-consteval.cpp --- a/clang/test/SemaCXX/cxx2a-consteval.cpp +++ b/clang/test/SemaCXX/cxx2a-consteval.cpp @@ -761,7 +761,7 @@ }; S s1; // expected-error {{call to consteval function 'NamespaceScopeConsteval::S::S' is not a constant expression}} \ - expected-note {{subobject of type 'int' is not initialized}} + expected-note {{subobject Val is not initialized}} template struct T { @@ -770,7 +770,7 @@ }; T t; // expected-error {{call to consteval function 'NamespaceScopeConsteval::T::T' is not a constant expression}} \ - expected-note {{subobject of type 'int' is not initialized}} + expected-note {{subobject Val is not initialized}} } // namespace NamespaceScopeConsteval