Commit 6da95378 by Jason Merrill Committed by Jason Merrill

re PR c++/46930 ([C++0x] ICE with static constexpr data member)

	PR c++/46930
	* decl.c (grokdeclarator): Reject uninitialized constexpr
	static data member.

From-SVN: r167834
parent ece17375
2010-12-14 Jason Merrill <jason@redhat.com>
PR c++/46930
* decl.c (grokdeclarator): Reject uninitialized constexpr
static data member.
2010-12-14 Nathan Froyd <froydnj@codesourcery.com>
PR c++/45330
......
......@@ -9763,6 +9763,13 @@ grokdeclarator (const cp_declarator *declarator,
if (thread_p)
DECL_TLS_MODEL (decl) = decl_default_tls_model (decl);
if (constexpr_p && !initialized)
{
error ("constexpr static data member %qD must have an "
"initializer", decl);
constexpr_p = false;
}
}
else
{
......
2010-12-14 Jason Merrill <jason@redhat.com>
PR c++/46930
* g++.dg/cpp0x/constexpr-decl.C: New.
* g++.dg/cpp0x/constexpr-ex1.C: Fix.
* g++.dg/cpp0x/constexpr-static5.C: Fix.
2010-12-14 Jan Hubicka <jh@suse.cz>
PR lto/46940
......
// PR c++/46930
// { dg-options -std=c++0x }
struct S {
static constexpr int size; // { dg-error "must have an initializer" }
// { dg-error "previous declaration" "" { target *-*-* } 5 }
};
const int limit = 2 * S::size;
constexpr int S::size = 256; // { dg-error "" }
......@@ -16,9 +16,9 @@ struct S {
constexpr int twice();
constexpr int t(); // { dg-message "used but never defined" }
private:
static constexpr int val; // constexpr variable
static constexpr int val = 7; // constexpr variable
};
constexpr int S::val = 7;
constexpr int S::twice() { return val + val; }
constexpr S s = { };
int x1 = s.twice(); // ok
......
......@@ -3,10 +3,10 @@
template <class T>
struct A
{
constexpr static T t;
constexpr static T t = T(); // { dg-error "literal" }
};
template <class T>
constexpr T A<T>::t = T(); // { dg-error "not literal" }
constexpr T A<T>::t;
struct B
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment