summaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-07-20 10:21:05 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-07-20 10:21:05 -0400
commit34429675140b34e3d1c9f4ccb1021d15cb92edb5 (patch)
tree9e56cc48852c32e97103a681ceb85db78262ad17 /gcc/c-family
parentff3ac0f47166f4ef3c6a22623bfadba6e419dbb1 (diff)
downloadgcc-34429675140b34e3d1c9f4ccb1021d15cb92edb5.tar.gz
PR c++/6709 (DR 743)
PR c++/6709 (DR 743) PR c++/42603 (DR 950) gcc/cp/ * parser.c (token_is_decltype, cp_lexer_next_token_is_decltype): New. (cp_parser_nested_name_specifier_opt): Allow decltype. (cp_parser_qualifying_entity): Likewise. (cp_parser_decltype): Replace source tokens with CPP_DECLTYPE. (cp_parser_simple_type_specifier): Handle decltype as scope. (cp_parser_base_specifier): Allow decltype. (cp_parser_base_clause): Don't crash on null base. * parser.h (CPP_KEYWORD, CPP_TEMPLATE_ID): Move to c-common.h. (CPP_NESTED_NAME_SPECIFIER, N_CP_TTYPES): Likewise. gcc/c-family/ * c-common.h (CPP_KEYWORD, CPP_TEMPLATE_ID): Move from cp/parser.h. (CPP_NESTED_NAME_SPECIFIER, N_CP_TTYPES): Likewise. (CPP_DECLTYPE): New. * c-common.c (c_parse_error): Handle CPP_DECLTYPE. From-SVN: r176513
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog9
-rw-r--r--gcc/c-family/c-common.c2
-rw-r--r--gcc/c-family/c-common.h24
3 files changed, 35 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 9ff311c90bb..c5f2306ca62 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,12 @@
+2011-07-20 Jason Merrill <jason@redhat.com>
+
+ PR c++/6709 (DR 743)
+ PR c++/42603 (DR 950)
+ * c-common.h (CPP_KEYWORD, CPP_TEMPLATE_ID): Move from cp/parser.h.
+ (CPP_NESTED_NAME_SPECIFIER, N_CP_TTYPES): Likewise.
+ (CPP_DECLTYPE): New.
+ * c-common.c (c_parse_error): Handle CPP_DECLTYPE.
+
2011-07-19 Richard Guenther <rguenther@suse.de>
* c-common.c (pointer_int_sum): Use fold_build_pointer_plus.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index ecb0c8463e7..6078d948ae4 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -8329,6 +8329,8 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token_type,
message = catenate_messages (gmsgid, " before %<#pragma%>");
else if (token_type == CPP_PRAGMA_EOL)
message = catenate_messages (gmsgid, " before end of line");
+ else if (token_type == CPP_DECLTYPE)
+ message = catenate_messages (gmsgid, " before %<decltype%>");
else if (token_type < N_TTYPES)
{
message = catenate_messages (gmsgid, " before %qs token");
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index a80c0eaec40..13aae0f3ecc 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -320,6 +320,30 @@ struct c_common_resword
const unsigned int disable : 16;
};
+/* Extra cpp_ttype values for C++. */
+
+/* A token type for keywords, as opposed to ordinary identifiers. */
+#define CPP_KEYWORD ((enum cpp_ttype) (N_TTYPES + 1))
+
+/* A token type for template-ids. If a template-id is processed while
+ parsing tentatively, it is replaced with a CPP_TEMPLATE_ID token;
+ the value of the CPP_TEMPLATE_ID is whatever was returned by
+ cp_parser_template_id. */
+#define CPP_TEMPLATE_ID ((enum cpp_ttype) (CPP_KEYWORD + 1))
+
+/* A token type for nested-name-specifiers. If a
+ nested-name-specifier is processed while parsing tentatively, it is
+ replaced with a CPP_NESTED_NAME_SPECIFIER token; the value of the
+ CPP_NESTED_NAME_SPECIFIER is whatever was returned by
+ cp_parser_nested_name_specifier_opt. */
+#define CPP_NESTED_NAME_SPECIFIER ((enum cpp_ttype) (CPP_TEMPLATE_ID + 1))
+
+/* A token type for pre-parsed C++0x decltype. */
+#define CPP_DECLTYPE ((enum cpp_ttype) (CPP_NESTED_NAME_SPECIFIER + 1))
+
+/* The number of token types, including C++-specific ones. */
+#define N_CP_TTYPES ((int) (CPP_DECLTYPE + 1))
+
/* Disable mask. Keywords are disabled if (reswords[i].disable &
mask) is _true_. Thus for keywords which are present in all
languages the disable field is zero. */