bool alias_p = decl_spec_seq_has_spec_p (declspecs, ds_alias);
tree decl;
+ if (funcdef_flag)
+ {
+ if (decl_context == NORMAL)
+ error_at (id_loc,
+ "typedef may not be a function definition");
+ else
+ error_at (id_loc,
+ "typedef may not be a member function definition");
+ return error_mark_node;
+ }
+
/* This declaration:
typedef void f(int) const;
invoke_plugin_callbacks (PLUGIN_START_PARSE_FUNCTION, decl1);
if (decl1 == error_mark_node)
return false;
- /* If the declarator is not suitable for a function definition,
- cause a syntax error. */
- if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL)
- {
- error ("invalid function declaration");
- return false;
- }
if (DECL_MAIN_P (decl1))
/* main must return int. grokfndecl should have corrected it
if (fndecl == error_mark_node)
return error_mark_node;
- if (fndecl == NULL || TREE_CODE (fndecl) != FUNCTION_DECL)
- {
- error ("invalid member function declaration");
- return error_mark_node;
- }
-
if (attrlist)
cplus_decl_attributes (&fndecl, attrlist, 0);
// PR c++/38794
// { dg-do compile }
-typedef void foo () {} // { dg-error "invalid function declaration" }
+typedef void foo () {} // { dg-error "14:typedef may not be a function definition" }
struct S
{
- typedef int bar (void) { return 0; } // { dg-error "invalid member function declaration" }
+ typedef int bar (void) { return 0; } // { dg-error "15:typedef may not be a member function definition" }
};