aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-03-31 08:40:39 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-03-31 08:40:39 +0200
commitaf88f55707d3373b94c02237af2863d2ad700063 (patch)
treecdd1f27aaae10888509d5ce06f0f1ca486071e92 /gcc/cp
parent7d790165457c7c6912ed98da4a64d9b020c6f483 (diff)
downloadgcc-af88f55707d3373b94c02237af2863d2ad700063.zip
gcc-af88f55707d3373b94c02237af2863d2ad700063.tar.gz
gcc-af88f55707d3373b94c02237af2863d2ad700063.tar.bz2
re PR libstdc++/80251 (Is the is_aggregate meta function missing?)
PR libstdc++/80251 c-family/ * c-common.h (enum rid): Add RID_IS_AGGREGATE. * c-common.c (c_common_reswords): Add __is_aggregate trait. cp/ * cp-tree.h (enum cp_trait_kind): Add CPTK_IS_AGGREGATE. * cxx-pretty-print.c (pp_cxx_trait_expression): Handle CPTK_IS_AGGREGATE. * semantics.c (trait_expr_value): Handle CPTK_IS_AGGREGATE. Remove extraneous parens. (finish_trait_expr): Handle CPTK_IS_AGGREGATE. * parser.c (cp_parser_primary_expression): Handle RID_IS_AGGREGATE. (cp_parser_trait_expr): Likewise. testsuite/ * g++.dg/ext/is_aggregate.C: New test. From-SVN: r246609
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/cxx-pretty-print.c3
-rw-r--r--gcc/cp/parser.c4
-rw-r--r--gcc/cp/semantics.c28
5 files changed, 36 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1d75be5..14eee1c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,15 @@
+2017-03-31 Jakub Jelinek <jakub@redhat.com>
+
+ PR libstdc++/80251
+ * cp-tree.h (enum cp_trait_kind): Add CPTK_IS_AGGREGATE.
+ * cxx-pretty-print.c (pp_cxx_trait_expression): Handle
+ CPTK_IS_AGGREGATE.
+ * semantics.c (trait_expr_value): Handle CPTK_IS_AGGREGATE.
+ Remove extraneous parens.
+ (finish_trait_expr): Handle CPTK_IS_AGGREGATE.
+ * parser.c (cp_parser_primary_expression): Handle RID_IS_AGGREGATE.
+ (cp_parser_trait_expr): Likewise.
+
2017-03-27 Jakub Jelinek <jakub@redhat.com>
PR middle-end/80162
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index daa1a81..57c1401 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -728,6 +728,7 @@ enum cp_trait_kind
CPTK_HAS_UNIQUE_OBJ_REPRESENTATIONS,
CPTK_HAS_VIRTUAL_DESTRUCTOR,
CPTK_IS_ABSTRACT,
+ CPTK_IS_AGGREGATE,
CPTK_IS_BASE_OF,
CPTK_IS_CLASS,
CPTK_IS_EMPTY,
diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
index 150b603..470d124 100644
--- a/gcc/cp/cxx-pretty-print.c
+++ b/gcc/cp/cxx-pretty-print.c
@@ -2585,6 +2585,9 @@ pp_cxx_trait_expression (cxx_pretty_printer *pp, tree t)
case CPTK_IS_ABSTRACT:
pp_cxx_ws_string (pp, "__is_abstract");
break;
+ case CPTK_IS_AGGREGATE:
+ pp_cxx_ws_string (pp, "__is_aggregate");
+ break;
case CPTK_IS_BASE_OF:
pp_cxx_ws_string (pp, "__is_base_of");
break;
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index c1b6496..e93855f 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -5121,6 +5121,7 @@ cp_parser_primary_expression (cp_parser *parser,
case RID_HAS_UNIQUE_OBJ_REPRESENTATIONS:
case RID_HAS_VIRTUAL_DESTRUCTOR:
case RID_IS_ABSTRACT:
+ case RID_IS_AGGREGATE:
case RID_IS_BASE_OF:
case RID_IS_CLASS:
case RID_IS_EMPTY:
@@ -9611,6 +9612,9 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword)
case RID_IS_ABSTRACT:
kind = CPTK_IS_ABSTRACT;
break;
+ case RID_IS_AGGREGATE:
+ kind = CPTK_IS_AGGREGATE;
+ break;
case RID_IS_BASE_OF:
kind = CPTK_IS_BASE_OF;
binary = true;
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index ad5299a..c572646 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -9144,7 +9144,10 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
return type_has_unique_obj_representations (type1);
case CPTK_IS_ABSTRACT:
- return (ABSTRACT_CLASS_TYPE_P (type1));
+ return ABSTRACT_CLASS_TYPE_P (type1);
+
+ case CPTK_IS_AGGREGATE:
+ return CP_AGGREGATE_TYPE_P (type1);
case CPTK_IS_BASE_OF:
return (NON_UNION_CLASS_TYPE_P (type1) && NON_UNION_CLASS_TYPE_P (type2)
@@ -9152,34 +9155,34 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
|| DERIVED_FROM_P (type1, type2)));
case CPTK_IS_CLASS:
- return (NON_UNION_CLASS_TYPE_P (type1));
+ return NON_UNION_CLASS_TYPE_P (type1);
case CPTK_IS_EMPTY:
- return (NON_UNION_CLASS_TYPE_P (type1) && CLASSTYPE_EMPTY_P (type1));
+ return NON_UNION_CLASS_TYPE_P (type1) && CLASSTYPE_EMPTY_P (type1);
case CPTK_IS_ENUM:
- return (type_code1 == ENUMERAL_TYPE);
+ return type_code1 == ENUMERAL_TYPE;
case CPTK_IS_FINAL:
- return (CLASS_TYPE_P (type1) && CLASSTYPE_FINAL (type1));
+ return CLASS_TYPE_P (type1) && CLASSTYPE_FINAL (type1);
case CPTK_IS_LITERAL_TYPE:
- return (literal_type_p (type1));
+ return literal_type_p (type1);
case CPTK_IS_POD:
- return (pod_type_p (type1));
+ return pod_type_p (type1);
case CPTK_IS_POLYMORPHIC:
- return (CLASS_TYPE_P (type1) && TYPE_POLYMORPHIC_P (type1));
+ return CLASS_TYPE_P (type1) && TYPE_POLYMORPHIC_P (type1);
case CPTK_IS_SAME_AS:
return same_type_p (type1, type2);
case CPTK_IS_STD_LAYOUT:
- return (std_layout_type_p (type1));
+ return std_layout_type_p (type1);
case CPTK_IS_TRIVIAL:
- return (trivial_type_p (type1));
+ return trivial_type_p (type1);
case CPTK_IS_TRIVIALLY_ASSIGNABLE:
return is_trivially_xible (MODIFY_EXPR, type1, type2);
@@ -9188,10 +9191,10 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
return is_trivially_xible (INIT_EXPR, type1, type2);
case CPTK_IS_TRIVIALLY_COPYABLE:
- return (trivially_copyable_p (type1));
+ return trivially_copyable_p (type1);
case CPTK_IS_UNION:
- return (type_code1 == UNION_TYPE);
+ return type_code1 == UNION_TYPE;
default:
gcc_unreachable ();
@@ -9253,6 +9256,7 @@ finish_trait_expr (cp_trait_kind kind, tree type1, tree type2)
case CPTK_HAS_UNIQUE_OBJ_REPRESENTATIONS:
case CPTK_HAS_VIRTUAL_DESTRUCTOR:
case CPTK_IS_ABSTRACT:
+ case CPTK_IS_AGGREGATE:
case CPTK_IS_EMPTY:
case CPTK_IS_FINAL:
case CPTK_IS_LITERAL_TYPE: