aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-11-16 07:37:05 +0100
committerJakub Jelinek <jakub@redhat.com>2022-11-16 07:37:05 +0100
commit7f014022861b5b3f00be9bb32fe3fe772517ddac (patch)
treeed009c2de327bf023de96fb16d0e71d14c749985 /gcc/c-family
parent7c6cd9c05efca29a1a9635b81c86cbad25bbdbbe (diff)
downloadgcc-7f014022861b5b3f00be9bb32fe3fe772517ddac.zip
gcc-7f014022861b5b3f00be9bb32fe3fe772517ddac.tar.gz
gcc-7f014022861b5b3f00be9bb32fe3fe772517ddac.tar.bz2
c++: Allow attributes on concepts - DR 2428
The following patch adds parsing of attributes to concept definition, allows deprecated attribute to be specified (as CONCEPT_DECL now needs to be checked in c-family/c-attribs.cc, I had to move its declaration from cp/*.def to c-family/*.def) and checks TREE_DEPRECATED in build_standard_check (not sure if that is the right spot, or whether it shouldn't be checked also for variable and function concepts and how to write testcase coverage for that). 2022-11-16 Jakub Jelinek <jakub@redhat.com> gcc/c-family/ * c-common.def (CONCEPT_DECL): New tree, moved here from cp-tree.def. * c-common.cc (c_common_init_ts): Handle CONCEPT_DECL. * c-attribs.cc (handle_deprecated_attribute): Allow deprecated attribute on CONCEPT_DECL. gcc/cp/ * cp-tree.def (CONCEPT_DECL): Move to c-common.def. * cp-objcp-common.cc (cp_common_init_ts): Don't handle CONCEPT_DECL here. * cp-tree.h (finish_concept_definition): Add ATTRS parameter. * parser.cc (cp_parser_concept_definition): Parse attributes in between identifier and =. Adjust finish_concept_definition caller. * pt.cc (finish_concept_definition): Add ATTRS parameter. Call cplus_decl_attributes. * constraint.cc (build_standard_check): If CONCEPT_DECL is TREE_DEPRECATED, emit -Wdeprecated-declaration warnings. gcc/testsuite/ * g++.dg/cpp2a/concepts-dr2428.C: New test.
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-attribs.cc3
-rw-r--r--gcc/c-family/c-common.cc2
-rw-r--r--gcc/c-family/c-common.def8
3 files changed, 12 insertions, 1 deletions
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 92ac93b..07bca68 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -4211,7 +4211,8 @@ handle_deprecated_attribute (tree *node, tree name,
|| VAR_OR_FUNCTION_DECL_P (decl)
|| TREE_CODE (decl) == FIELD_DECL
|| TREE_CODE (decl) == CONST_DECL
- || objc_method_decl (TREE_CODE (decl)))
+ || objc_method_decl (TREE_CODE (decl))
+ || TREE_CODE (decl) == CONCEPT_DECL)
TREE_DEPRECATED (decl) = 1;
else if (TREE_CODE (decl) == LABEL_DECL)
{
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 71507d4..6f1f21b 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -8497,6 +8497,8 @@ c_common_init_ts (void)
MARK_TS_EXP (FOR_STMT);
MARK_TS_EXP (SWITCH_STMT);
MARK_TS_EXP (WHILE_STMT);
+
+ MARK_TS_DECL_COMMON (CONCEPT_DECL);
}
/* Build a user-defined numeric literal out of an integer constant type VALUE
diff --git a/gcc/c-family/c-common.def b/gcc/c-family/c-common.def
index dd8be7f..64956fc 100644
--- a/gcc/c-family/c-common.def
+++ b/gcc/c-family/c-common.def
@@ -81,6 +81,14 @@ DEFTREECODE (CONTINUE_STMT, "continue_stmt", tcc_statement, 0)
SWITCH_STMT_SCOPE, respectively. */
DEFTREECODE (SWITCH_STMT, "switch_stmt", tcc_statement, 4)
+/* Extensions for C++ Concepts. */
+
+/* Concept definition. This is not entirely different than a VAR_DECL
+ except that a) it must be a template, and b) doesn't have the wide
+ range of value and linkage options available to variables. Used
+ by C++ FE and in c-family attribute handling. */
+DEFTREECODE (CONCEPT_DECL, "concept_decl", tcc_declaration, 0)
+
/*
Local variables:
mode:c