aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/cxx-pretty-print.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-04-14 14:22:31 -0400
committerPatrick Palka <ppalka@redhat.com>2020-04-14 14:22:31 -0400
commit58a29af8ef14bfa2d595deed5144891bff821eff (patch)
tree9c328539d5e9ef52e34dc7aebecda7faad0d4c9c /gcc/cp/cxx-pretty-print.c
parent9707b593f88041e74e5cf5640ec64fea13a0387c (diff)
downloadgcc-58a29af8ef14bfa2d595deed5144891bff821eff.zip
gcc-58a29af8ef14bfa2d595deed5144891bff821eff.tar.gz
gcc-58a29af8ef14bfa2d595deed5144891bff821eff.tar.bz2
c++: "'decltype_type' not supported" in diagnostic [PR85278]
This fixes a garbled concepts diagnostic by moving the handling of DECLTYPE_TYPE from pp_cxx_type_specifier_seq to cxx_pretty_printer::simple_type_specifier, a move which also seems to be more consistent with the language grammar. This patch also fixes pretty printing of rvalue reference types via cxx_pretty_printer::type_id, which eventually calls pp_c_pointer which currently doesn't distinguish between lvalue and rvalue references. gcc/c-family/ChangeLog: PR c++/85278 * c-pretty-print.c (pp_c_pointer) <case REFERENCE_TYPE>: Print a double ampersand if it's an rvalue reference type. gcc/cp/ChangeLog: PR c++/85278 * cxx-pretty-print.c (cxx_pretty_printer:simple_type_specifier) <case DECLTYPE_TYPE>: Handle DECLTYPE_TYPE here instead of ... (pp_cxx_type_specifier_seq) <case DECLTYPE_TYPE>: ... here. (cxx_pretty_printer::direct_abstract_declarator) <case DECLTYPE_TYPE>: New no-op case. gcc/testsuite/ChangeLog: PR c++/85278 * g++.dg/concepts/diagnostic9.C: New test.
Diffstat (limited to 'gcc/cp/cxx-pretty-print.c')
-rw-r--r--gcc/cp/cxx-pretty-print.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
index 840b5a8..a26291e 100644
--- a/gcc/cp/cxx-pretty-print.c
+++ b/gcc/cp/cxx-pretty-print.c
@@ -1325,6 +1325,7 @@ cxx_pretty_printer::declaration_specifiers (tree t)
/* simple-type-specifier:
::(opt) nested-name-specifier(opt) type-name
::(opt) nested-name-specifier(opt) template(opt) template-id
+ decltype-specifier
char
wchar_t
bool
@@ -1363,6 +1364,13 @@ cxx_pretty_printer::simple_type_specifier (tree t)
pp_cxx_unqualified_id (this, TYPENAME_TYPE_FULLNAME (t));
break;
+ case DECLTYPE_TYPE:
+ pp_cxx_ws_string (this, "decltype");
+ pp_cxx_left_paren (this);
+ this->expression (DECLTYPE_TYPE_EXPR (t));
+ pp_cxx_right_paren (this);
+ break;
+
default:
c_pretty_printer::simple_type_specifier (t);
break;
@@ -1389,6 +1397,7 @@ pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t)
case TEMPLATE_TEMPLATE_PARM:
case TYPE_DECL:
case BOUND_TEMPLATE_TEMPLATE_PARM:
+ case DECLTYPE_TYPE:
pp_cxx_cv_qualifier_seq (pp, t);
pp->simple_type_specifier (t);
break;
@@ -1399,13 +1408,6 @@ pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t)
pp_cxx_nested_name_specifier (pp, TYPE_METHOD_BASETYPE (t));
break;
- case DECLTYPE_TYPE:
- pp_cxx_ws_string (pp, "decltype");
- pp_cxx_left_paren (pp);
- pp->expression (DECLTYPE_TYPE_EXPR (t));
- pp_cxx_right_paren (pp);
- break;
-
case RECORD_TYPE:
if (TYPE_PTRMEMFUNC_P (t))
{
@@ -1799,6 +1801,7 @@ cxx_pretty_printer::direct_abstract_declarator (tree t)
case TEMPLATE_TEMPLATE_PARM:
case BOUND_TEMPLATE_TEMPLATE_PARM:
case UNBOUND_CLASS_TEMPLATE:
+ case DECLTYPE_TYPE:
break;
default: