This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/48771] [C++0x] is_literal_type incorrect for references to non-literal types


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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]