diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2011-04-28 09:21:23 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2011-04-28 09:21:23 +0000 |
commit | 83b6b866e6860bb7555d91c1f05f9215f15a60f0 (patch) | |
tree | b445fe20c14867fb8e479fb47f81ec43981c9619 /gcc | |
parent | 8576f20aedfbbdc1b82ce89be28fbf4a14d9a857 (diff) | |
download | gcc-83b6b866e6860bb7555d91c1f05f9215f15a60f0.zip gcc-83b6b866e6860bb7555d91c1f05f9215f15a60f0.tar.gz gcc-83b6b866e6860bb7555d91c1f05f9215f15a60f0.tar.bz2 |
re PR c++/48771 ([C++0x] is_literal_type incorrect for references to non-literal types)
/cp
2011-04-28 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-28 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/48771
* g++.dg/ext/is_literal_type1.C: New.
From-SVN: r173062
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/is_literal_type1.C | 11 |
4 files changed, 28 insertions, 15 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e1afe47..64cb011 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2011-04-28 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. + 2011-04-27 Jason Merrill <jason@redhat.com> PR libstdc++/48760 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 16fabb8..c636412 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cbad463..904848c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-04-28 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/48771 + * g++.dg/ext/is_literal_type1.C: New. + 2011-04-28 Tobias Burnus <burnus@net-b.de> PR fortran/48112 diff --git a/gcc/testsuite/g++.dg/ext/is_literal_type1.C b/gcc/testsuite/g++.dg/ext/is_literal_type1.C new file mode 100644 index 0000000..21570d2 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_literal_type1.C @@ -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"); |