summaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-14 17:11:26 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-14 17:11:26 +0000
commitcbe90ad7e5dd01f1cc91a508fb8b6407265a1796 (patch)
tree17e7c0c5e67697891aacab0d2bf544225acf4854 /gcc/cp/decl2.c
parent98ae66be2c78504d85159510c1caf6e11b94dbed (diff)
downloadgcc-cbe90ad7e5dd01f1cc91a508fb8b6407265a1796.tar.gz
PR c++/62101
* decl.c (grokdeclarator): Move the check for friend initializers.. * decl2.c (grokfield) ..here. Postpone early return for friends until after the initializer check. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@213974 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 1740a2e7340..de28cb712c3 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -870,11 +870,6 @@ grokfield (const cp_declarator *declarator,
if (value == void_type_node)
return value;
- /* Pass friend decls back. */
- if ((TREE_CODE (value) == FUNCTION_DECL
- || TREE_CODE (value) == TEMPLATE_DECL)
- && DECL_CONTEXT (value) != current_class_type)
- return value;
name = DECL_NAME (value);
@@ -926,7 +921,9 @@ grokfield (const cp_declarator *declarator,
return value;
}
- if (DECL_IN_AGGR_P (value))
+ int friendp = decl_spec_seq_has_spec_p (declspecs, ds_friend);
+
+ if (!friendp && DECL_IN_AGGR_P (value))
{
error ("%qD is already defined in %qT", value, DECL_CONTEXT (value));
return void_type_node;
@@ -939,8 +936,6 @@ grokfield (const cp_declarator *declarator,
{
if (TREE_CODE (value) == FUNCTION_DECL)
{
- /* Initializers for functions are rejected early in the parser.
- If we get here, it must be a pure specifier for a method. */
if (init == ridpointers[(int)RID_DELETE])
{
DECL_DELETED_FN (value) = 1;
@@ -971,8 +966,12 @@ grokfield (const cp_declarator *declarator,
else
{
gcc_assert (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE);
- error ("initializer specified for static member function %qD",
- value);
+ if (friendp)
+ error ("initializer specified for friend function %qD",
+ value);
+ else
+ error ("initializer specified for static member function %qD",
+ value);
}
}
else if (TREE_CODE (value) == FIELD_DECL)
@@ -981,6 +980,12 @@ grokfield (const cp_declarator *declarator,
gcc_unreachable ();
}
+ /* Pass friend decls back. */
+ if ((TREE_CODE (value) == FUNCTION_DECL
+ || TREE_CODE (value) == TEMPLATE_DECL)
+ && DECL_CONTEXT (value) != current_class_type)
+ return value;
+
if (processing_template_decl && VAR_OR_FUNCTION_DECL_P (value))
{
value = push_template_decl (value);