This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to nested_name_specifier
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 15 Nov 2001 15:02:19 +0000
- Subject: C++ PATCH to nested_name_specifier
At the C++ meeting in Seattle a couple of weeks ago, there was talk of
resolving the friend A::B ::C issue by saying that anything that looks like
a nested-name-specifier is one, even if the identifier doesn't denote a
type. This patch implements that, and gives better error messages for
invalid nested-name-specifiers into the bargain.
2001-11-14 Jason Merrill <jason@redhat.com>
* parse.y: Add ... IDENTIFIER SCOPE and ... PTYPENAME SCOPE expansions.
* decl.c (make_typename_type): Handle getting a class template.
* search.c (lookup_field_r): A class template is good enough for
want_type.
*** decl.c.~1~ Wed Nov 14 11:04:39 2001
--- decl.c Wed Nov 14 10:58:49 2001
*************** make_typename_type (context, name, compl
*** 5652,5657 ****
--- 5652,5662 ----
if (TREE_CODE (name) == TEMPLATE_DECL)
name = TREE_OPERAND (fullname, 0) = DECL_NAME (name);
}
+ if (TREE_CODE (name) == TEMPLATE_DECL)
+ {
+ cp_error ("`%D' used without template parameters", name);
+ return error_mark_node;
+ }
if (TREE_CODE (name) != IDENTIFIER_NODE)
my_friendly_abort (2000);
*** parse.y.~1~ Wed Nov 14 11:04:39 2001
--- parse.y Wed Nov 14 10:54:17 2001
*************** nested_name_specifier:
*** 3021,3026 ****
--- 3021,3033 ----
| nested_name_specifier TEMPLATE explicit_template_type SCOPE
{ got_scope = $$
= make_typename_type ($1, $3, /*complain=*/1); }
+ /* Error handling per Core 125. */
+ | nested_name_specifier IDENTIFIER SCOPE
+ { got_scope = $$
+ = make_typename_type ($1, $2, /*complain=*/1); }
+ | nested_name_specifier PTYPENAME SCOPE
+ { got_scope = $$
+ = make_typename_type ($1, $2, /*complain=*/1); }
;
/* Why the @#$%^& do type_name and notype_identifier need to be expanded
*************** nested_name_specifier_1:
*** 3050,3065 ****
}
| template_type SCOPE
{ got_scope = $$ = complete_type (TREE_TYPE ($1)); }
- /* These break 'const i;'
- | IDENTIFIER SCOPE
- {
- failed_scope:
- cp_error ("`%D' is not an aggregate typedef",
- lastiddecl ? lastiddecl : $$);
- $$ = error_mark_node;
- }
- | PTYPENAME SCOPE
- { goto failed_scope; } */
;
typename_sub:
--- 3057,3062 ----
*** search.c.~1~ Wed Nov 14 11:04:39 2001
--- search.c Sun Nov 4 23:13:52 2001
*************** lookup_field_r (binfo, data)
*** 1367,1373 ****
/* If we're looking up a type (as with an elaborated type specifier)
we ignore all non-types we find. */
! if (lfi->want_type && TREE_CODE (nval) != TYPE_DECL)
{
if (lfi->name == TYPE_IDENTIFIER (type))
{
--- 1367,1374 ----
/* If we're looking up a type (as with an elaborated type specifier)
we ignore all non-types we find. */
! if (lfi->want_type && TREE_CODE (nval) != TYPE_DECL
! && !DECL_CLASS_TEMPLATE_P (nval))
{
if (lfi->name == TYPE_IDENTIFIER (type))
{