diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-16 22:34:49 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-16 22:34:49 +0000 |
commit | eb19e4aeb1c859c5fea7b36de55033a905152804 (patch) | |
tree | 66a509d6818a7c54ae0955a7fe30fc1abbf1c495 | |
parent | a047d54677aafee38b4267a352b1d5d6cbc0b6ca (diff) | |
download | gcc-eb19e4aeb1c859c5fea7b36de55033a905152804.tar.gz |
PR c++/51461
* decl.c (check_static_variable_definition): Check COMPLETE_TYPE_P
before literal_type_p.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182415 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/static4.C | 6 |
4 files changed, 20 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ea5ebaa8a8a..9773ae7e2ac 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-12-16 Jason Merrill <jason@redhat.com> + PR c++/51461 + * decl.c (check_static_variable_definition): Check COMPLETE_TYPE_P + before literal_type_p. + PR c++/51331 * class.c (convert_to_base_statically): Just call build_simple_base_path. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 919e2355d88..fedc52cd833 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5449,7 +5449,7 @@ check_initializer (tree decl, tree init, int flags, VEC(tree,gc) **cleanups) } else if (!COMPLETE_TYPE_P (type)) { - error ("%qD has incomplete type", decl); + error ("%q#D has incomplete type", decl); TREE_TYPE (decl) = error_mark_node; return NULL_TREE; } @@ -7807,7 +7807,10 @@ check_static_variable_definition (tree decl, tree type) return 0; else if (cxx_dialect >= cxx0x && !INTEGRAL_OR_ENUMERATION_TYPE_P (type)) { - if (literal_type_p (type)) + if (!COMPLETE_TYPE_P (type)) + error ("in-class initialization of static data member %q#D of " + "incomplete type", decl); + else if (literal_type_p (type)) permerror (input_location, "%<constexpr%> needed for in-class initialization of " "static data member %q#D of non-integral type", decl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0cc64645881..37023d12bd5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2011-12-16 Jason Merrill <jason@redhat.com> + PR c++/51461 + * g++.dg/init/static4.C: New. + +2011-12-16 Jason Merrill <jason@redhat.com> + PR c++/51331 * g++.dg/init/value10.C: New. diff --git a/gcc/testsuite/g++.dg/init/static4.C b/gcc/testsuite/g++.dg/init/static4.C new file mode 100644 index 00000000000..0cdc48b0e45 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/static4.C @@ -0,0 +1,6 @@ +// PR c++/51461 + +struct A +{ + static const A a = 0; // { dg-error "incomplete|non-integral" } +}; |