OSDN Git Service

PR c++/51461
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Dec 2011 22:34:49 +0000 (22:34 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Dec 2011 22:34:49 +0000 (22:34 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/static4.C [new file with mode: 0644]

index ea5ebaa..9773ae7 100644 (file)
@@ -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.
index 919e235..fedc52c 100644 (file)
@@ -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);
index 0cc6464..37023d1 100644 (file)
@@ -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 (file)
index 0000000..0cdc48b
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/51461
+
+struct A
+{
+  static const A a = 0;                // { dg-error "incomplete|non-integral" }
+};