Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang/test/AST/Interp/records.cpp
Show First 20 Lines • Show All 362 Lines • ▼ Show 20 Lines | constexpr YetAnotherDerived Oops(0); // ref-error {{must be initialized by a constant expression}} \ | ||||
// expected-note {{constructor inherited from base class 'YetAnotherBase' cannot be used in a constant expression}} | // expected-note {{constructor inherited from base class 'YetAnotherBase' cannot be used in a constant expression}} | ||||
}; | }; | ||||
namespace EmptyCtor { | namespace EmptyCtor { | ||||
struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; | struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; | ||||
constexpr piecewise_construct_t piecewise_construct = | constexpr piecewise_construct_t piecewise_construct = | ||||
piecewise_construct_t(); | piecewise_construct_t(); | ||||
}; | }; | ||||
namespace ConditionalInit { | |||||
erichkeane: Did this not work before? I don't see what part of teh code changes makes this work? | |||||
We call visitInitializer also when the return value is constructed in the calling function, so the return statement in getS() exercises the code added. tbaeder: We call `visitInitializer` also when the return value is constructed in the calling function… | |||||
struct S { int a; }; | |||||
constexpr S getS(bool b) { | |||||
return b ? S{12} : S{13}; | |||||
} | |||||
static_assert(getS(true).a == 12, ""); | |||||
static_assert(getS(false).a == 13, ""); | |||||
}; |
Did this not work before? I don't see what part of teh code changes makes this work?