[PATCH] D63134: [clang] improving diagnotics for invalid constexpr defaulted special membres
Tyker via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 11 05:30:30 PDT 2019
Tyker created this revision.
Tyker added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
this patch improves diagnostic for invalid constexpr defaulted special members by adding notes explaining why the special member cannot be constexpr.
example
input:
01 struct B {};
02
03 struct C : virtual B {
04 };
05
06 struct D {
07 C c;
08 };
09
10 struct A : D {
11 constexpr A() = default;
12 };
13
14 union U {
15 A a;
16 int b;
17 constexpr U() = default;
18 };
19
20 struct E {
21 ~E() {}
22 };
23
24 struct F {
25 E e;
26 constexpr F& operator=(const F&) =default;
27 };
output with patch:
test.cpp:11:3: error: defaulted definition of default constructor is not constexpr because:
constexpr A() = default;
^
test.cpp:10:12: note: base class 'D' of 'A' has a non-constexpr implicit default constructor
struct A : D {
^
test.cpp:7:5: note: non-static data member 'c' of 'D' has a non-constexpr implicit default constructor
C c;
^
test.cpp:3:12: note: 'C' inherits virtually from 'B'
struct C : virtual B {
^
test.cpp:17:3: error: defaulted definition of default constructor is not constexpr because:
constexpr U() = default;
^
note: unions require exactly one non-static data member initializer to have a constexpr default constructor
test.cpp:26:3: error: defaulted definition of copy assignment operator is not constexpr because:
constexpr F& operator=(const F&) =default;
^
note: 'F' is not a literal type
3 errors generated.
I didn't adapt exitsing tests yet because the diagnostics emitted are likely be adapted during review.
Repository:
rC Clang
https://reviews.llvm.org/D63134
Files:
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63134.204019.patch
Type: text/x-patch
Size: 11382 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190611/0565b147/attachment-0001.bin>
More information about the cfe-commits
mailing list