PR c++/67364
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Feb 2016 14:09:24 +0000 (14:09 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Feb 2016 14:09:24 +0000 (14:09 +0000)
* constexpr.c (cxx_eval_component_reference): Don't complain about
unevaluated empty classes.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233716 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/cpp0x/constexpr-empty10.C [new file with mode: 0644]

index eb5cfe6..97296e4 100644 (file)
@@ -1,5 +1,9 @@
 2016-02-25  Jason Merrill  <jason@redhat.com>
 
+       PR c++/67364
+       * constexpr.c (cxx_eval_component_reference): Don't complain about
+       unevaluated empty classes.
+
        PR c++/68049
        * tree.c (strip_typedefs): Use DECL_ORIGINAL_TYPE.
 
index d3b04b1..8d9168c 100644 (file)
@@ -1983,7 +1983,8 @@ cxx_eval_component_reference (const constexpr_ctx *ctx, tree t,
       return t;
     }
 
-  if (CONSTRUCTOR_NO_IMPLICIT_ZERO (whole))
+  if (CONSTRUCTOR_NO_IMPLICIT_ZERO (whole)
+      && !is_empty_class (TREE_TYPE (part)))
     {
       /* 'whole' is part of the aggregate initializer we're currently
         building; if there's no initializer for this member yet, that's an
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-empty10.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty10.C
new file mode 100644 (file)
index 0000000..694ed3d
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/67364
+// { dg-do compile { target c++11 } }
+
+template <typename Xn>
+struct element : Xn {
+  constexpr element() : Xn() { }
+};
+
+template <typename Xn>
+struct closure {
+  element<Xn> member;
+  constexpr closure() { }
+};
+
+struct empty { };
+constexpr closure<empty> tup{};
+constexpr empty first = tup.member;