summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-05-11 14:05:46 -0400
committerJason Merrill <jason@redhat.com>2020-05-11 15:09:42 -0400
commite5ccab839a24a9c5ac1ddbb6e0ad1c339df3165e (patch)
tree9da88fa1a19781b4a8783ecac449bbe134bb9370
parentf3f9cc41a1a793375a9fff09bfb7a103ce259e07 (diff)
c++: Improve print_tree of static_assert.
We weren't printing the condition and message of a STATIC_ASSERT. It's also unnecessary to duplicate the code for instantiating a STATIC_ASSERT between tsubst_expr and instantiate_class_template_1. gcc/cp/ChangeLog 2020-05-11 Jason Merrill <jason@redhat.com> * pt.c (instantiate_class_template_1): Call tsubst_expr for STATIC_ASSERT member. * ptree.c (cxx_print_xnode): Handle STATIC_ASSERT.
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c17
-rw-r--r--gcc/cp/ptree.c11
3 files changed, 19 insertions, 15 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index adbe287c5dc..1fdc3880fff 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2020-05-11 Jason Merrill <jason@redhat.com>
+ * pt.c (instantiate_class_template_1): Call tsubst_expr for
+ STATIC_ASSERT member.
+ * ptree.c (cxx_print_xnode): Handle STATIC_ASSERT.
+
+2020-05-11 Jason Merrill <jason@redhat.com>
+
* pt.c (find_parameter_packs_r) [LAMBDA_EXPR]: Remove redundant
walking of capture list.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 112426af72a..28f3c90f17b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11809,21 +11809,8 @@ instantiate_class_template_1 (tree type)
{
/* Build new TYPE_FIELDS. */
if (TREE_CODE (t) == STATIC_ASSERT)
- {
- tree condition;
-
- ++c_inhibit_evaluation_warnings;
- condition =
- tsubst_expr (STATIC_ASSERT_CONDITION (t), args,
- tf_warning_or_error, NULL_TREE,
- /*integral_constant_expression_p=*/true);
- --c_inhibit_evaluation_warnings;
-
- finish_static_assert (condition,
- STATIC_ASSERT_MESSAGE (t),
- STATIC_ASSERT_SOURCE_LOCATION (t),
- /*member_p=*/true);
- }
+ tsubst_expr (t, args, tf_warning_or_error, NULL_TREE,
+ /*integral_constant_expression_p=*/true);
else if (TREE_CODE (t) != CONST_DECL)
{
tree r;
diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c
index 285028a4841..ab18eecd0e6 100644
--- a/gcc/cp/ptree.c
+++ b/gcc/cp/ptree.c
@@ -269,6 +269,17 @@ cxx_print_xnode (FILE *file, tree node, int indent)
case LAMBDA_EXPR:
cxx_print_lambda_node (file, node, indent);
break;
+ case STATIC_ASSERT:
+ if (location_t loc = STATIC_ASSERT_SOURCE_LOCATION (node))
+ {
+ expanded_location xloc = expand_location (loc);
+ indent_to (file, indent+4);
+ fprintf (file, "%s:%d:%d", xloc.file, xloc.line, xloc.column);
+ }
+ print_node (file, "condition", STATIC_ASSERT_CONDITION (node), indent+4);
+ if (tree message = STATIC_ASSERT_MESSAGE (node))
+ print_node (file, "message", message, indent+4);
+ break;
default:
break;
}