public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 48771
@ 2011-04-27  9:37 Paolo Carlini
  2011-04-28  7:41 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2011-04-27  9:37 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

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

Hi,

today I (re-)tested the below. As you can see, wrt the audit trail 
discussion, I also removed altogether valid_type_in_constexpr_fundecl_p, 
I can restore it if you want, just let me know.

Tested x86_64-linux. Ok for mainline? (not sure if it qualifies for the 
branch or we want to reconsider it in a couple of weeks?!?)

Thanks,
Paolo.

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

[-- Attachment #2: CL_48771_2 --]
[-- Type: text/plain, Size: 356 bytes --]

/cp
2011-04-27  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48771
	* semantics.c (literal_type_p): Reference types are literal types,
	per the FDIS.
	(valid_type_in_constexpr_fundecl_p): Remove.
	(is_valid_constexpr_fn): Adjust.

/testsuite
2011-04-27  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48771
	* g++.dg/ext/is_literal_type1.C: New.

[-- Attachment #3: patch_48771_2 --]
[-- Type: text/plain, Size: 2187 bytes --]

Index: testsuite/g++.dg/ext/is_literal_type1.C
===================================================================
--- testsuite/g++.dg/ext/is_literal_type1.C	(revision 0)
+++ testsuite/g++.dg/ext/is_literal_type1.C	(revision 0)
@@ -0,0 +1,11 @@
+// PR c++/48771
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+struct NonLiteral {
+  NonLiteral();
+  ~NonLiteral();
+};
+
+static_assert(__is_literal_type(NonLiteral&), "Error");
+static_assert(__is_literal_type(NonLiteral&&), "Error");
Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 173012)
+++ cp/semantics.c	(working copy)
@@ -5331,7 +5331,8 @@ float_const_decimal64_p (void)
 bool
 literal_type_p (tree t)
 {
-  if (SCALAR_TYPE_P (t))
+  if (SCALAR_TYPE_P (t)
+      || TREE_CODE (t) == REFERENCE_TYPE)
     return true;
   if (CLASS_TYPE_P (t))
     return CLASSTYPE_LITERAL_P (t);
@@ -5406,18 +5407,6 @@ retrieve_constexpr_fundef (tree fun)
   return (constexpr_fundef *) htab_find (constexpr_fundef_table, &fundef);
 }
 
-/* Return true if type expression T is a valid parameter type, or
-   a valid return type, of a constexpr function.  */
-
-static bool
-valid_type_in_constexpr_fundecl_p (tree t)
-{
-  return (literal_type_p (t)
-	  /* FIXME we allow ref to non-literal; should change standard to
-	     match, or change back if not.  */
-	  || TREE_CODE (t) == REFERENCE_TYPE);
-}
-
 /* Check whether the parameter and return types of FUN are valid for a
    constexpr function, and complain if COMPLAIN.  */
 
@@ -5427,7 +5416,7 @@ is_valid_constexpr_fn (tree fun, bool complain)
   tree parm = FUNCTION_FIRST_USER_PARM (fun);
   bool ret = true;
   for (; parm != NULL; parm = TREE_CHAIN (parm))
-    if (!valid_type_in_constexpr_fundecl_p (TREE_TYPE (parm)))
+    if (!literal_type_p (TREE_TYPE (parm)))
       {
 	ret = false;
 	if (complain)
@@ -5438,7 +5427,7 @@ is_valid_constexpr_fn (tree fun, bool complain)
   if (!DECL_CONSTRUCTOR_P (fun))
     {
       tree rettype = TREE_TYPE (TREE_TYPE (fun));
-      if (!valid_type_in_constexpr_fundecl_p (rettype))
+      if (!literal_type_p (rettype))
 	{
 	  ret = false;
 	  if (complain)

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

* Re: [C++ Patch] PR 48771
  2011-04-27  9:37 [C++ Patch] PR 48771 Paolo Carlini
@ 2011-04-28  7:41 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2011-04-28  7:41 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: gcc-patches

On 04/27/2011 04:50 AM, Paolo Carlini wrote:
> Tested x86_64-linux. Ok for mainline?

Yes.

> (not sure if it qualifies for the
> branch or we want to reconsider it in a couple of weeks?!?)

The latter, I think.

Jason

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

end of thread, other threads:[~2011-04-28  4:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27  9:37 [C++ Patch] PR 48771 Paolo Carlini
2011-04-28  7:41 ` 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).