public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 58102 aka DR 1405
@ 2014-09-01 13:48 Paolo Carlini
  2014-09-02 14:11 ` Jason Merrill
  0 siblings, 1 reply; 9+ messages in thread
From: Paolo Carlini @ 2014-09-01 13:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 153 bytes --]

Hi,

I think that in order to implement the resolution we simply have to 
remove the check. Tested x86_64-linux.

Thanks,
Paolo.

//////////////////////

[-- Attachment #2: CL_58102 --]
[-- Type: text/plain, Size: 351 bytes --]

/cp
2014-09-01  Paolo Carlini  <paolo.carlini@oracle.com>

	DR 1405
	PR c++/58102
	* semantics.c (cxx_eval_outermost_constant_expr): Do not check
	for mutable sub-objects.

/testsuite
2014-09-01  Paolo Carlini  <paolo.carlini@oracle.com>

	DR 1405
	PR c++/58102
	* g++.dg/cpp0x/constexpr-mutable2.C: New.
	* g++.dg/cpp0x/constexpr-mutable1.C: Adjust.

[-- Attachment #3: patch_58102 --]
[-- Type: text/plain, Size: 1839 bytes --]

Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 214779)
+++ cp/semantics.c	(working copy)
@@ -9858,18 +9858,6 @@ cxx_eval_outermost_constant_expr (tree t, bool all
 
   verify_constant (r, allow_non_constant, &non_constant_p, &overflow_p);
 
-  if (TREE_CODE (t) != CONSTRUCTOR
-      && cp_has_mutable_p (TREE_TYPE (t)))
-    {
-      /* We allow a mutable type if the original expression was a
-	 CONSTRUCTOR so that we can do aggregate initialization of
-	 constexpr variables.  */
-      if (!allow_non_constant)
-	error ("%qT cannot be the type of a complete constant expression "
-	       "because it has mutable sub-objects", TREE_TYPE (t));
-      non_constant_p = true;
-    }
-
   /* Technically we should check this for all subexpressions, but that
      runs into problems with our internal representation of pointer
      subtraction and the 5.19 rules are still in flux.  */
Index: testsuite/g++.dg/cpp0x/constexpr-mutable1.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-mutable1.C	(revision 214785)
+++ testsuite/g++.dg/cpp0x/constexpr-mutable1.C	(working copy)
@@ -7,6 +7,6 @@ struct A
 };
 
 constexpr A a = { 0, 1 };
-constexpr A b = a;		// { dg-error "mutable" }
+constexpr A b = a;
 constexpr int i = a.i;
 constexpr int j = a.j;		// { dg-error "mutable" }
Index: testsuite/g++.dg/cpp0x/constexpr-mutable2.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-mutable2.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/constexpr-mutable2.C	(working copy)
@@ -0,0 +1,10 @@
+// DR 1405, PR c++/58102
+// { dg-do compile { target c++11 } }
+
+struct S {
+  mutable int n;
+  constexpr S() : n() {}
+};
+
+constexpr S s1 {};
+constexpr S s2 = {};

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-09-03 20:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-01 13:48 [C++ Patch] PR 58102 aka DR 1405 Paolo Carlini
2014-09-02 14:11 ` Jason Merrill
2014-09-02 14:17   ` Paolo Carlini
2014-09-02 14:28     ` Jason Merrill
2014-09-02 14:31       ` Paolo Carlini
2014-09-02 15:07       ` Paolo Carlini
2014-09-02 15:45         ` Jason Merrill
2014-09-03 10:53           ` Paolo Carlini
2014-09-03 20:33             ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).