[cfe-commits] r141547 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Mon Oct 10 09:38:04 PDT 2011
Author: rsmith
Date: Mon Oct 10 11:38:04 2011
New Revision: 141547
URL: http://llvm.org/viewvc/llvm-project?rev=141547&view=rev
Log:
constexpr: Disable checking of constructor member initializer lists for
constexpr constructor templates. Such checking is optional, and currently hard
to get right since clang doesn't generate implicit member initializers until
instantiation (even for non-dependent members).
This is needed for clang to accept libstdc++ from g++4.6 in c++0x mode.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=141547&r1=141546&r2=141547&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Oct 10 11:38:04 2011
@@ -902,7 +902,8 @@
Diag(Dcl->getLocation(), diag::err_constexpr_union_ctor_no_init);
return false;
}
- } else if (!Constructor->isDelegatingConstructor()) {
+ } else if (!Constructor->isDependentContext() &&
+ !Constructor->isDelegatingConstructor()) {
assert(RD->getNumVBases() == 0 && "constexpr ctor with virtual bases");
// Skip detailed checking if we have enough initializers, and we would
Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp?rev=141547&r1=141546&r2=141547&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp Mon Oct 10 11:38:04 2011
@@ -150,6 +150,44 @@
constexpr AnonMembers(int(&)[6]) {} // expected-error {{constexpr constructor must initialize all members}}
};
+template<typename T> using Int = int;
+template<typename T>
+struct TemplateInit {
+ T a;
+ int b; // desired-note {{not initialized}}
+ Int<T> c; // desired-note {{not initialized}}
+ struct {
+ T d;
+ int e; // desired-note {{not initialized}}
+ Int<T> f; // desired-note {{not initialized}}
+ };
+ struct {
+ Literal l;
+ Literal m;
+ Literal n[3];
+ };
+ union { // desired-note {{not initialized}}
+ T g;
+ T h;
+ };
+ // FIXME: This is ill-formed (no diagnostic required). We should diagnose it.
+ constexpr TemplateInit() {} // desired-error {{must initialize all members}}
+};
+template<typename T> struct TemplateInit2 {
+ Literal l;
+ constexpr TemplateInit2() {} // ok
+};
+
+template<typename T> struct weak_ptr {
+ constexpr weak_ptr() : p(0) {}
+ T *p;
+};
+template<typename T> struct enable_shared_from_this {
+ weak_ptr<T> weak_this;
+ constexpr enable_shared_from_this() {} // ok
+};
+constexpr int f(enable_shared_from_this<int>);
+
// - every constructor involved in initializing non-static data members and base
// class sub-objects shall be a constexpr constructor.
//
More information about the cfe-commits
mailing list