Commit f2e2cbd4 by Jason Merrill Committed by Jason Merrill

decl.c (xref_tag): Only complain once about using a typedef-name with 'struct'.

	* decl.c (xref_tag): Only complain once about using a typedef-name
	with 'struct'.  Downgrade to pedwarn.
	* decl.c (grokdeclarator): Allow [] syntax for zero-length array.

From-SVN: r26392
parent 20c39572
1999-04-12 Jason Merrill <jason@yorick.cygnus.com> 1999-04-12 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (xref_tag): Only complain once about using a typedef-name
with 'struct'. Downgrade to pedwarn.
* decl.c (grokdeclarator): Allow [] syntax for zero-length array.
* parse.y (absdcl_intern): New nonterminal. * parse.y (absdcl_intern): New nonterminal.
(absdcl, direct_abstract_declarator): Use it. (absdcl, direct_abstract_declarator): Use it.
......
...@@ -10090,6 +10090,10 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -10090,6 +10090,10 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
if (type == error_mark_node) if (type == error_mark_node)
continue; continue;
/* VC++ spells a zero-sized array with []. */
if (size == NULL_TREE && decl_context == FIELD && ! staticp)
size = integer_zero_node;
if (size) if (size)
{ {
/* Must suspend_momentary here because the index /* Must suspend_momentary here because the index
...@@ -12354,9 +12358,17 @@ xref_tag (code_type_node, name, globalize) ...@@ -12354,9 +12358,17 @@ xref_tag (code_type_node, name, globalize)
{ {
if (t) if (t)
{ {
if (t != TYPE_MAIN_VARIANT (t)) /* [dcl.type.elab] If the identifier resolves to a
typedef-name or a template type-parameter, the
elaborated-type-specifier is ill-formed. */
if (t != TYPE_MAIN_VARIANT (t)
|| (CLASS_TYPE_P (t) && TYPE_WAS_ANONYMOUS (t)))
cp_pedwarn ("using typedef-name `%D' after `%s'", cp_pedwarn ("using typedef-name `%D' after `%s'",
TYPE_NAME (t), tag_name (tag_code)); TYPE_NAME (t), tag_name (tag_code));
else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM)
cp_error ("using template type parameter `%T' after `%s'",
t, tag_name (tag_code));
ref = t; ref = t;
} }
else else
...@@ -12481,19 +12493,6 @@ xref_tag (code_type_node, name, globalize) ...@@ -12481,19 +12493,6 @@ xref_tag (code_type_node, name, globalize)
TREE_TYPE (ref) = attributes; TREE_TYPE (ref) = attributes;
if (ref && TYPE_P (ref))
{
/* [dcl.type.elab]
If the identifier resolves to a typedef-name or a template
type-parameter, the elaborated-type-specifier is
ill-formed. */
if (TYPE_LANG_SPECIFIC (ref) && TYPE_WAS_ANONYMOUS (ref))
cp_error ("`%T' is a typedef name", ref);
else if (TREE_CODE (ref) == TEMPLATE_TYPE_PARM)
cp_error ("`%T' is a template type paramter", ref);
}
return ref; return ref;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment