* c-common.c (c_common_reswords): Add __is_literal_type.
* c-common.h (enum rid): Add RID_IS_LITERAL_TYPE.
gcc/cp/
* cp-tree.h (cp_trait_kind): Add CPTK_IS_LITERAL_TYPE.
* cxx-pretty-print.c (pp_cxx_trait_expression): Handle it.
* semantics.c (trait_expr_value, finish_trait_expr): Likewise.
* parser.c (cp_parser_primary_expression): Handle RID_IS_LITERAL_TYPE.
(cp_parser_trait_expr): Likewise.
libstdc++-v3/
* include/std/type_traits (is_literal_type): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166020
138bc75d-0d04-0410-961f-
82ee72b054a4
2010-10-27 Jason Merrill <jason@redhat.com>
+ * c-common.c (c_common_reswords): Add __is_literal_type.
+ * c-common.h (enum rid): Add RID_IS_LITERAL_TYPE.
+
* c-common.c (check_case_value): Remove special C++ code.
2010-10-27 Nicola Pero <nicola.pero@meta-innovation.com>
{ "__is_standard_layout", RID_IS_STD_LAYOUT, D_CXXONLY },
{ "__is_trivial", RID_IS_TRIVIAL, D_CXXONLY },
{ "__is_union", RID_IS_UNION, D_CXXONLY },
+ { "__is_literal_type", RID_IS_LITERAL_TYPE, D_CXXONLY },
{ "__imag", RID_IMAGPART, 0 },
{ "__imag__", RID_IMAGPART, 0 },
{ "__inline", RID_INLINE, 0 },
RID_IS_EMPTY, RID_IS_ENUM,
RID_IS_POD, RID_IS_POLYMORPHIC,
RID_IS_STD_LAYOUT, RID_IS_TRIVIAL,
- RID_IS_UNION,
+ RID_IS_UNION, RID_IS_LITERAL_TYPE,
/* C++0x */
RID_CONSTEXPR, RID_DECLTYPE, RID_NOEXCEPT, RID_NULLPTR, RID_STATIC_ASSERT,
+2010-10-27 Jason Merrill <jason@redhat.com>
+
+ * cp-tree.h (cp_trait_kind): Add CPTK_IS_LITERAL_TYPE.
+ * cxx-pretty-print.c (pp_cxx_trait_expression): Handle it.
+ * semantics.c (trait_expr_value, finish_trait_expr): Likewise.
+ * parser.c (cp_parser_primary_expression): Handle RID_IS_LITERAL_TYPE.
+ (cp_parser_trait_expr): Likewise.
+
2010-10-27 Gabriel Dos Reis <gdr@cse.tamu.edu>
Jason Merrill <jason@redhat.com>
CPTK_IS_POLYMORPHIC,
CPTK_IS_STD_LAYOUT,
CPTK_IS_TRIVIAL,
+ CPTK_IS_LITERAL_TYPE,
CPTK_IS_UNION
} cp_trait_kind;
case CPTK_IS_UNION:
pp_cxx_ws_string (pp, "__is_union");
break;
+ case CPTK_IS_LITERAL_TYPE:
+ pp_cxx_ws_string (pp, "__is_literal_type");
+ break;
default:
gcc_unreachable ();
case RID_IS_STD_LAYOUT:
case RID_IS_TRIVIAL:
case RID_IS_UNION:
+ case RID_IS_LITERAL_TYPE:
return cp_parser_trait_expr (parser, token->keyword);
/* Objective-C++ expressions. */
case RID_IS_UNION:
kind = CPTK_IS_UNION;
break;
+ case RID_IS_LITERAL_TYPE:
+ kind = CPTK_IS_LITERAL_TYPE;
+ break;
default:
gcc_unreachable ();
}
case CPTK_IS_UNION:
return (type_code1 == UNION_TYPE);
+ case CPTK_IS_LITERAL_TYPE:
+ return (literal_type_p (type1));
+
default:
gcc_unreachable ();
return false;
|| kind == CPTK_IS_POLYMORPHIC
|| kind == CPTK_IS_STD_LAYOUT
|| kind == CPTK_IS_TRIVIAL
+ || kind == CPTK_IS_LITERAL_TYPE
|| kind == CPTK_IS_UNION);
if (kind == CPTK_IS_CONVERTIBLE_TO)
case CPTK_IS_POLYMORPHIC:
case CPTK_IS_STD_LAYOUT:
case CPTK_IS_TRIVIAL:
+ case CPTK_IS_LITERAL_TYPE:
if (!check_trait_type (type1))
{
error ("incomplete type %qT not allowed", type1);
+2010-10-27 Jason Merrill <jason@redhat.com>
+
+ * g++.dg/cpp0x/constexpr-is_literal.C: New.
+
2010-10-27 Janus Weil <janus@gcc.gnu.org>
PR fortran/46161
--- /dev/null
+// { dg-options -std=c++0x }
+
+#include <type_traits>
+
+#define IS_LIT(T) (std::is_literal_type<T>::value)
+#define SA(X) static_assert (X, #X)
+#define YES(T) SA(IS_LIT(T))
+#define NO(T) SA(!IS_LIT(T))
+
+enum E1 { };
+enum class E2 { };
+struct Literal {};
+
+struct NotLiteral {
+ ~NotLiteral();
+};
+
+YES(int);
+YES(int[]);
+YES(int[3]);
+YES(double);
+YES(void *);
+YES(decltype (nullptr));
+YES(int Literal::*);
+YES(void (Literal::*)());
+YES(E1);
+YES(E2);
+YES(Literal);
+NO (NotLiteral);
+YES(NotLiteral *);
+YES(NotLiteral NotLiteral::*);
+YES(NotLiteral (NotLiteral::*)(NotLiteral));
+
+struct A {
+ A(const A&) = default;
+};
+
+NO(A); // no constexpr ctor other than copy
+2010-10-27 Jason Merrill <jason@redhat.com>
+
+ * include/std/type_traits (is_literal_type): New.
+ * testsuite/20_util/declval/requirements/1_neg.cc: Adjust.
+ * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust.
+ * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust.
+
2010-10-26 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp ([check_v3_target_normal_mode]): Add.
: public integral_constant<bool, __is_pod(_Tp)>
{ };
+ /// is_literal_type
+ template<typename _Tp>
+ struct is_literal_type
+ : public integral_constant<bool, __is_literal_type(_Tp)>
+ { };
+
template<typename _Tp>
typename add_rvalue_reference<_Tp>::type declval() noexcept;
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-error "static assertion failed" "" { target *-*-* } 682 }
+// { dg-error "static assertion failed" "" { target *-*-* } 688 }
#include <utility>
// { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 645 }
-// { dg-error "declaration of" "" { target *-*-* } 609 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 651 }
+// { dg-error "declaration of" "" { target *-*-* } 615 }
// { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 568 }
-// { dg-error "declaration of" "" { target *-*-* } 532 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 574 }
+// { dg-error "declaration of" "" { target *-*-* } 538 }