This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/48771] [C++0x] is_literal_type incorrect for references to non-literal types
- From: "paolo.carlini at oracle dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 26 Apr 2011 14:40:15 +0000
- Subject: [Bug c++/48771] [C++0x] is_literal_type incorrect for references to non-literal types
- Auto-submitted: auto-generated
- References: <bug-48771-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48771
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |paolo.carlini at oracle dot
| |com
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-04-26 14:39:36 UTC ---
The below patchlet fixes the problem and passes the testsuite.
Jason, let me know if you consider it safe, for 4_6-branch too, in case.
Paolo.
//////////////
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 172961)
+++ 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);