Commit a6d9bc9d by Simon Martin Committed by Simon Martin

re PR c++/35320 (ICE with invalid friend declaration)

gcc/cp/

2008-06-14  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/35320
	* decl2.c (grokbitfield): Receive the list of attributes, pass it to
	grokdeclarator and apply it to the created declaration.
	* cp-tree.h (grokbitfield): Update prototype.
	* parser.c (cp_parser_member_declaration): Don't apply the attributes
	since they are now applied in grokbitfield. Adjusted the call to
	grokbitfield.
	(cp_parser_objc_class_ivars): Likewise.

gcc/testsuite/

2008-06-14  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/35320
	* g++.dg/parse/bitfield3.C: New test.

From-SVN: r136778
parent 74bae98e
2008-06-14 Simon Martin <simartin@users.sourceforge.net> 2008-06-14 Simon Martin <simartin@users.sourceforge.net>
PR c++/35320
* decl2.c (grokbitfield): Receive the list of attributes, pass it to
grokdeclarator and apply it to the created declaration.
* cp-tree.h (grokbitfield): Update prototype.
* parser.c (cp_parser_member_declaration): Don't apply the attributes
since they are now applied in grokbitfield. Adjusted the call to
grokbitfield.
(cp_parser_objc_class_ivars): Likewise.
2008-06-14 Simon Martin <simartin@users.sourceforge.net>
PR c++/35317 PR c++/35317
* class.c (type_requires_array_cookie): Do not consider delete[] * class.c (type_requires_array_cookie): Do not consider delete[]
operators with an ellipsis as second argument. operators with an ellipsis as second argument.
......
...@@ -4283,7 +4283,7 @@ extern void check_member_template (tree); ...@@ -4283,7 +4283,7 @@ extern void check_member_template (tree);
extern tree grokfield (const cp_declarator *, cp_decl_specifier_seq *, extern tree grokfield (const cp_declarator *, cp_decl_specifier_seq *,
tree, bool, tree, tree); tree, bool, tree, tree);
extern tree grokbitfield (const cp_declarator *, cp_decl_specifier_seq *, extern tree grokbitfield (const cp_declarator *, cp_decl_specifier_seq *,
tree); tree, tree);
extern tree cp_reconstruct_complex_type (tree, tree); extern tree cp_reconstruct_complex_type (tree, tree);
extern void cplus_decl_attributes (tree *, tree, int); extern void cplus_decl_attributes (tree *, tree, int);
extern void finish_anon_union (tree); extern void finish_anon_union (tree);
......
...@@ -914,9 +914,10 @@ grokfield (const cp_declarator *declarator, ...@@ -914,9 +914,10 @@ grokfield (const cp_declarator *declarator,
tree tree
grokbitfield (const cp_declarator *declarator, grokbitfield (const cp_declarator *declarator,
cp_decl_specifier_seq *declspecs, tree width) cp_decl_specifier_seq *declspecs, tree width,
tree attrlist)
{ {
tree value = grokdeclarator (declarator, declspecs, BITFIELD, 0, NULL); tree value = grokdeclarator (declarator, declspecs, BITFIELD, 0, &attrlist);
if (value == error_mark_node) if (value == error_mark_node)
return NULL_TREE; /* friends went bad. */ return NULL_TREE; /* friends went bad. */
...@@ -972,6 +973,10 @@ grokbitfield (const cp_declarator *declarator, ...@@ -972,6 +973,10 @@ grokbitfield (const cp_declarator *declarator,
} }
DECL_IN_AGGR_P (value) = 1; DECL_IN_AGGR_P (value) = 1;
if (attrlist)
cplus_decl_attributes (&value, attrlist, /*flags=*/0);
return value; return value;
} }
......
...@@ -15238,9 +15238,8 @@ cp_parser_member_declaration (cp_parser* parser) ...@@ -15238,9 +15238,8 @@ cp_parser_member_declaration (cp_parser* parser)
sfk_none) sfk_none)
: NULL, : NULL,
&decl_specifiers, &decl_specifiers,
width); width,
/* Apply the attributes. */ attributes);
cplus_decl_attributes (&decl, attributes, /*flags=*/0);
} }
else else
{ {
...@@ -19150,11 +19149,10 @@ cp_parser_objc_class_ivars (cp_parser* parser) ...@@ -19150,11 +19149,10 @@ cp_parser_objc_class_ivars (cp_parser* parser)
attributes = chainon (prefix_attributes, attributes); attributes = chainon (prefix_attributes, attributes);
if (width) if (width)
{
/* Create the bitfield declaration. */ /* Create the bitfield declaration. */
decl = grokbitfield (declarator, &declspecs, width); decl = grokbitfield (declarator, &declspecs,
cplus_decl_attributes (&decl, attributes, /*flags=*/0); width,
} attributes);
else else
decl = grokfield (declarator, &declspecs, decl = grokfield (declarator, &declspecs,
NULL_TREE, /*init_const_expr_p=*/false, NULL_TREE, /*init_const_expr_p=*/false,
......
2008-06-14 Simon Martin <simartin@users.sourceforge.net>
PR c++/35320
* g++.dg/parse/bitfield3.C: New test.
2008-06-14 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2008-06-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/36538 PR fortran/36538
......
/* PR c++/35320 */
/* { dg-do "compile" } */
typedef void (func_type)();
struct A
{
friend func_type f : 2; /* { dg-error "with non-integral type" } */
};
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