Deleted Added
full compact
decl.c (146906) decl.c (161660)
1/* Process declarations and variables for C++ compiler.
2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 Contributed by Michael Tiemann (tiemann@cygnus.com)
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify

--- 1366 unchanged lines hidden (view full) ---

1375 TYPE_ARG_TYPES (TREE_TYPE (olddecl))))
1376 {
1377 error ("new declaration `%#D'", newdecl);
1378 cp_error_at ("ambiguates old declaration `%#D'", olddecl);
1379 }
1380 else
1381 return NULL_TREE;
1382 }
1/* Process declarations and variables for C++ compiler.
2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 Contributed by Michael Tiemann (tiemann@cygnus.com)
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify

--- 1366 unchanged lines hidden (view full) ---

1375 TYPE_ARG_TYPES (TREE_TYPE (olddecl))))
1376 {
1377 error ("new declaration `%#D'", newdecl);
1378 cp_error_at ("ambiguates old declaration `%#D'", olddecl);
1379 }
1380 else
1381 return NULL_TREE;
1382 }
1383
1384 /* Already complained about this, so don't do so again. */
1385 else if (current_class_type == NULL_TREE
1386 || IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (newdecl)) != current_class_type)
1383 else
1387 {
1388 error ("conflicting declaration '%#D'", newdecl);
1389 cp_error_at ("'%D' has a previous declaration as `%#D'",
1390 olddecl, olddecl);
1391 return NULL_TREE;
1392 }
1393 }
1394 else if (TREE_CODE (newdecl) == FUNCTION_DECL

--- 1247 unchanged lines hidden (view full) ---

2642 name = TREE_OPERAND (fullname, 0) = DECL_NAME (name);
2643 }
2644 if (TREE_CODE (name) == TEMPLATE_DECL)
2645 {
2646 error ("`%D' used without template parameters", name);
2647 return error_mark_node;
2648 }
2649 my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 20030802);
1384 {
1385 error ("conflicting declaration '%#D'", newdecl);
1386 cp_error_at ("'%D' has a previous declaration as `%#D'",
1387 olddecl, olddecl);
1388 return NULL_TREE;
1389 }
1390 }
1391 else if (TREE_CODE (newdecl) == FUNCTION_DECL

--- 1247 unchanged lines hidden (view full) ---

2639 name = TREE_OPERAND (fullname, 0) = DECL_NAME (name);
2640 }
2641 if (TREE_CODE (name) == TEMPLATE_DECL)
2642 {
2643 error ("`%D' used without template parameters", name);
2644 return error_mark_node;
2645 }
2646 my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 20030802);
2650
2651 if (TREE_CODE (context) == NAMESPACE_DECL)
2652 {
2653 /* We can get here from typename_sub0 in the explicit_template_type
2654 expansion. Just fail. */
2655 if (complain & tf_error)
2656 error ("no class template named `%#T' in `%#T'",
2657 name, context);
2658 return error_mark_node;
2659 }
2647 my_friendly_assert (TYPE_P (context), 20050905);
2660
2661 if (!dependent_type_p (context)
2662 || currently_open_class (context))
2663 {
2664 if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR)
2665 {
2666 tree tmpl = NULL_TREE;
2667 if (IS_AGGR_TYPE (context))

--- 2246 unchanged lines hidden (view full) ---

4914 init = check_initializer (decl, init, flags, &cleanup);
4915 /* Thread-local storage cannot be dynamically initialized. */
4916 if (DECL_THREAD_LOCAL (decl) && init)
4917 {
4918 error ("`%D' is thread-local and so cannot be dynamically "
4919 "initialized", decl);
4920 init = NULL_TREE;
4921 }
2648
2649 if (!dependent_type_p (context)
2650 || currently_open_class (context))
2651 {
2652 if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR)
2653 {
2654 tree tmpl = NULL_TREE;
2655 if (IS_AGGR_TYPE (context))

--- 2246 unchanged lines hidden (view full) ---

4902 init = check_initializer (decl, init, flags, &cleanup);
4903 /* Thread-local storage cannot be dynamically initialized. */
4904 if (DECL_THREAD_LOCAL (decl) && init)
4905 {
4906 error ("`%D' is thread-local and so cannot be dynamically "
4907 "initialized", decl);
4908 init = NULL_TREE;
4909 }
4910 if (DECL_EXTERNAL (decl) && init)
4911 {
4912 /* The static data member cannot be initialized by a
4913 non-constant when being declared. */
4914 error ("`%D' cannot be initialized by a non-constant expression"
4915 " when being declared", decl);
4916 DECL_INITIALIZED_IN_CLASS_P (decl) = 0;
4917 init = NULL_TREE;
4918 }
4919
4922 /* Handle:
4923
4924 [dcl.init]
4925
4926 The memory occupied by any object of static storage
4927 duration is zero-initialized at program startup before
4928 any other initialization takes place.
4929

--- 783 unchanged lines hidden (view full) ---

5713 if (quals != NULL_TREE && TREE_CODE (type) == FUNCTION_TYPE)
5714 {
5715 error ("%smember function `%D' cannot have `%T' method qualifier",
5716 (ctype ? "static " : "non-"), decl, TREE_VALUE (quals));
5717 quals = NULL_TREE;
5718 }
5719
5720 if (IDENTIFIER_OPNAME_P (DECL_NAME (decl)))
4920 /* Handle:
4921
4922 [dcl.init]
4923
4924 The memory occupied by any object of static storage
4925 duration is zero-initialized at program startup before
4926 any other initialization takes place.
4927

--- 783 unchanged lines hidden (view full) ---

5711 if (quals != NULL_TREE && TREE_CODE (type) == FUNCTION_TYPE)
5712 {
5713 error ("%smember function `%D' cannot have `%T' method qualifier",
5714 (ctype ? "static " : "non-"), decl, TREE_VALUE (quals));
5715 quals = NULL_TREE;
5716 }
5717
5718 if (IDENTIFIER_OPNAME_P (DECL_NAME (decl)))
5721 grok_op_properties (decl, friendp, /*complain=*/true);
5719 grok_op_properties (decl, /*complain=*/true);
5722
5723 if (ctype && decl_function_context (decl))
5724 DECL_NO_STATIC_CHAIN (decl) = 1;
5725
5726 for (t = TYPE_ARG_TYPES (TREE_TYPE (decl)); t; t = TREE_CHAIN (t))
5727 if (TREE_PURPOSE (t)
5728 && TREE_CODE (TREE_PURPOSE (t)) == DEFAULT_ARG)
5729 {

--- 158 unchanged lines hidden (view full) ---

5888grokvardecl (tree type,
5889 tree name,
5890 RID_BIT_TYPE * specbits_in,
5891 int initialized,
5892 int constp,
5893 tree scope)
5894{
5895 tree decl;
5720
5721 if (ctype && decl_function_context (decl))
5722 DECL_NO_STATIC_CHAIN (decl) = 1;
5723
5724 for (t = TYPE_ARG_TYPES (TREE_TYPE (decl)); t; t = TREE_CHAIN (t))
5725 if (TREE_PURPOSE (t)
5726 && TREE_CODE (TREE_PURPOSE (t)) == DEFAULT_ARG)
5727 {

--- 158 unchanged lines hidden (view full) ---

5886grokvardecl (tree type,
5887 tree name,
5888 RID_BIT_TYPE * specbits_in,
5889 int initialized,
5890 int constp,
5891 tree scope)
5892{
5893 tree decl;
5894 tree explicit_scope;
5896 RID_BIT_TYPE specbits;
5897
5898 my_friendly_assert (!name || TREE_CODE (name) == IDENTIFIER_NODE,
5899 20020808);
5900
5901 specbits = *specbits_in;
5902
5895 RID_BIT_TYPE specbits;
5896
5897 my_friendly_assert (!name || TREE_CODE (name) == IDENTIFIER_NODE,
5898 20020808);
5899
5900 specbits = *specbits_in;
5901
5903 /* Compute the scope in which to place the variable. */
5902 /* Compute the scope in which to place the variable, but remember
5903 whether or not that scope was explicitly specified by the user. */
5904 explicit_scope = scope;
5904 if (!scope)
5905 {
5906 /* An explicit "extern" specifier indicates a namespace-scope
5907 variable. */
5908 if (RIDBIT_SETP (RID_EXTERN, specbits))
5909 scope = current_namespace;
5910 else if (!at_function_scope_p ())
5911 {

--- 12 unchanged lines hidden (view full) ---

5924 || (TREE_CODE (scope) == NAMESPACE_DECL
5925 && current_lang_name != lang_name_cplusplus)
5926 /* Similarly for static data members. */
5927 || TYPE_P (scope)))
5928 decl = build_lang_decl (VAR_DECL, name, type);
5929 else
5930 decl = build_decl (VAR_DECL, name, type);
5931
5905 if (!scope)
5906 {
5907 /* An explicit "extern" specifier indicates a namespace-scope
5908 variable. */
5909 if (RIDBIT_SETP (RID_EXTERN, specbits))
5910 scope = current_namespace;
5911 else if (!at_function_scope_p ())
5912 {

--- 12 unchanged lines hidden (view full) ---

5925 || (TREE_CODE (scope) == NAMESPACE_DECL
5926 && current_lang_name != lang_name_cplusplus)
5927 /* Similarly for static data members. */
5928 || TYPE_P (scope)))
5929 decl = build_lang_decl (VAR_DECL, name, type);
5930 else
5931 decl = build_decl (VAR_DECL, name, type);
5932
5932 if (scope && TREE_CODE (scope) == NAMESPACE_DECL)
5933 set_decl_namespace (decl, scope, 0);
5933 if (explicit_scope && TREE_CODE (explicit_scope) == NAMESPACE_DECL)
5934 set_decl_namespace (decl, explicit_scope, 0);
5934 else
5935 DECL_CONTEXT (decl) = scope;
5936
5937 if (name && scope && current_lang_name != lang_name_c)
5938 /* We can't mangle lazily here because we don't have any
5939 way to recover whether or not a variable was `extern
5940 "C"' later. */
5941 mangle_decl (decl);

--- 1240 unchanged lines hidden (view full) ---

7182 explicitp = RIDBIT_SETP (RID_EXPLICIT, specbits) != 0;
7183 RIDBIT_RESET (RID_EXPLICIT, specbits);
7184
7185 if (RIDBIT_SETP (RID_STATIC, specbits))
7186 staticp = 1 + (decl_context == FIELD);
7187
7188 if (virtualp && staticp == 2)
7189 {
5935 else
5936 DECL_CONTEXT (decl) = scope;
5937
5938 if (name && scope && current_lang_name != lang_name_c)
5939 /* We can't mangle lazily here because we don't have any
5940 way to recover whether or not a variable was `extern
5941 "C"' later. */
5942 mangle_decl (decl);

--- 1240 unchanged lines hidden (view full) ---

7183 explicitp = RIDBIT_SETP (RID_EXPLICIT, specbits) != 0;
7184 RIDBIT_RESET (RID_EXPLICIT, specbits);
7185
7186 if (RIDBIT_SETP (RID_STATIC, specbits))
7187 staticp = 1 + (decl_context == FIELD);
7188
7189 if (virtualp && staticp == 2)
7190 {
7190 error ("member `%D' cannot be declared both virtual and static",
7191 dname);
7191 error ("member `%D' cannot be declared both virtual and static", dname);
7192 RIDBIT_RESET (RID_STATIC, specbits);
7192 staticp = 0;
7193 }
7194 friendp = RIDBIT_SETP (RID_FRIEND, specbits);
7195 RIDBIT_RESET (RID_FRIEND, specbits);
7196
7197 if (dependant_name && !friendp)
7198 {
7199 error ("`%T::%D' is not a valid declarator", ctype, dependant_name);

--- 1799 unchanged lines hidden (view full) ---

8999 || code == TYPE_EXPR);
9000}
9001
9002/* DECL is a declaration for an overloaded operator. Returns true if
9003 the declaration is valid; false otherwise. If COMPLAIN is true,
9004 errors are issued for invalid declarations. */
9005
9006bool
7193 staticp = 0;
7194 }
7195 friendp = RIDBIT_SETP (RID_FRIEND, specbits);
7196 RIDBIT_RESET (RID_FRIEND, specbits);
7197
7198 if (dependant_name && !friendp)
7199 {
7200 error ("`%T::%D' is not a valid declarator", ctype, dependant_name);

--- 1799 unchanged lines hidden (view full) ---

9000 || code == TYPE_EXPR);
9001}
9002
9003/* DECL is a declaration for an overloaded operator. Returns true if
9004 the declaration is valid; false otherwise. If COMPLAIN is true,
9005 errors are issued for invalid declarations. */
9006
9007bool
9007grok_op_properties (tree decl, int friendp, bool complain)
9008grok_op_properties (tree decl, bool complain)
9008{
9009 tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl));
9010 tree argtype;
9011 int methodp = (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE);
9012 tree name = DECL_NAME (decl);
9013 enum tree_code operator_code;
9014 int arity;
9009{
9010 tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl));
9011 tree argtype;
9012 int methodp = (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE);
9013 tree name = DECL_NAME (decl);
9014 enum tree_code operator_code;
9015 int arity;
9016 bool ellipsis_p;
9015 bool ok;
9017 bool ok;
9018 tree class_type;
9016
9017 /* Assume that the declaration is valid. */
9018 ok = true;
9019
9019
9020 /* Assume that the declaration is valid. */
9021 ok = true;
9022
9020 /* Count the number of arguments. */
9023 /* Count the number of arguments. and check for ellipsis */
9021 for (argtype = argtypes, arity = 0;
9022 argtype && argtype != void_list_node;
9023 argtype = TREE_CHAIN (argtype))
9024 ++arity;
9024 for (argtype = argtypes, arity = 0;
9025 argtype && argtype != void_list_node;
9026 argtype = TREE_CHAIN (argtype))
9027 ++arity;
9028 ellipsis_p = !argtype;
9025
9029
9026 if (current_class_type == NULL_TREE)
9027 friendp = 1;
9028
9030 class_type = DECL_CONTEXT (decl);
9031 if (class_type && !CLASS_TYPE_P (class_type))
9032 class_type = NULL_TREE;
9033
9029 if (DECL_CONV_FN_P (decl))
9030 operator_code = TYPE_EXPR;
9031 else
9032 do
9033 {
9034#define DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, ASSN_P) \
9035 if (ansi_opname (CODE) == name) \
9036 { \

--- 11 unchanged lines hidden (view full) ---

9048#undef DEF_OPERATOR
9049
9050 abort ();
9051 }
9052 while (0);
9053 my_friendly_assert (operator_code != LAST_CPLUS_TREE_CODE, 20000526);
9054 SET_OVERLOADED_OPERATOR_CODE (decl, operator_code);
9055
9034 if (DECL_CONV_FN_P (decl))
9035 operator_code = TYPE_EXPR;
9036 else
9037 do
9038 {
9039#define DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, ASSN_P) \
9040 if (ansi_opname (CODE) == name) \
9041 { \

--- 11 unchanged lines hidden (view full) ---

9053#undef DEF_OPERATOR
9054
9055 abort ();
9056 }
9057 while (0);
9058 my_friendly_assert (operator_code != LAST_CPLUS_TREE_CODE, 20000526);
9059 SET_OVERLOADED_OPERATOR_CODE (decl, operator_code);
9060
9056 if (! friendp)
9057 {
9058 switch (operator_code)
9059 {
9060 case NEW_EXPR:
9061 TYPE_HAS_NEW_OPERATOR (current_class_type) = 1;
9062 break;
9061 if (class_type)
9062 switch (operator_code)
9063 {
9064 case NEW_EXPR:
9065 TYPE_HAS_NEW_OPERATOR (class_type) = 1;
9066 break;
9063
9067
9064 case DELETE_EXPR:
9065 TYPE_GETS_DELETE (current_class_type) |= 1;
9066 break;
9068 case DELETE_EXPR:
9069 TYPE_GETS_DELETE (class_type) |= 1;
9070 break;
9067
9071
9068 case VEC_NEW_EXPR:
9069 TYPE_HAS_ARRAY_NEW_OPERATOR (current_class_type) = 1;
9070 break;
9072 case VEC_NEW_EXPR:
9073 TYPE_HAS_ARRAY_NEW_OPERATOR (class_type) = 1;
9074 break;
9071
9075
9072 case VEC_DELETE_EXPR:
9073 TYPE_GETS_DELETE (current_class_type) |= 2;
9074 break;
9076 case VEC_DELETE_EXPR:
9077 TYPE_GETS_DELETE (class_type) |= 2;
9078 break;
9075
9079
9076 default:
9077 break;
9078 }
9079 }
9080 default:
9081 break;
9082 }
9080
9081 if (operator_code == NEW_EXPR || operator_code == VEC_NEW_EXPR)
9082 TREE_TYPE (decl) = coerce_new_type (TREE_TYPE (decl));
9083 else if (operator_code == DELETE_EXPR || operator_code == VEC_DELETE_EXPR)
9084 TREE_TYPE (decl) = coerce_delete_type (TREE_TYPE (decl));
9085 else
9086 {
9087 /* An operator function must either be a non-static member function

--- 37 unchanged lines hidden (view full) ---

9125 }
9126 }
9127
9128 /* There are no restrictions on the arguments to an overloaded
9129 "operator ()". */
9130 if (operator_code == CALL_EXPR)
9131 return ok;
9132
9083
9084 if (operator_code == NEW_EXPR || operator_code == VEC_NEW_EXPR)
9085 TREE_TYPE (decl) = coerce_new_type (TREE_TYPE (decl));
9086 else if (operator_code == DELETE_EXPR || operator_code == VEC_DELETE_EXPR)
9087 TREE_TYPE (decl) = coerce_delete_type (TREE_TYPE (decl));
9088 else
9089 {
9090 /* An operator function must either be a non-static member function

--- 37 unchanged lines hidden (view full) ---

9128 }
9129 }
9130
9131 /* There are no restrictions on the arguments to an overloaded
9132 "operator ()". */
9133 if (operator_code == CALL_EXPR)
9134 return ok;
9135
9133 if (IDENTIFIER_TYPENAME_P (name) && ! DECL_TEMPLATE_INFO (decl))
9136 /* Warn about conversion operators that will never be used. */
9137 if (IDENTIFIER_TYPENAME_P (name)
9138 && ! DECL_TEMPLATE_INFO (decl)
9139 && warn_conversion
9140 /* Warn only declaring the function; there is no need to
9141 warn again about out-of-class definitions. */
9142 && class_type == current_class_type)
9134 {
9135 tree t = TREE_TYPE (name);
9143 {
9144 tree t = TREE_TYPE (name);
9136 if (! friendp)
9145 int ref = (TREE_CODE (t) == REFERENCE_TYPE);
9146 const char *what = 0;
9147
9148 if (ref)
9149 t = TYPE_MAIN_VARIANT (TREE_TYPE (t));
9150
9151 if (TREE_CODE (t) == VOID_TYPE)
9152 what = "void";
9153 else if (class_type)
9137 {
9154 {
9138 int ref = (TREE_CODE (t) == REFERENCE_TYPE);
9139 const char *what = 0;
9140
9141 if (ref)
9142 t = TYPE_MAIN_VARIANT (TREE_TYPE (t));
9143
9144 if (TREE_CODE (t) == VOID_TYPE)
9145 what = "void";
9146 else if (t == current_class_type)
9155 if (t == class_type)
9147 what = "the same type";
9148 /* Don't force t to be complete here. */
9149 else if (IS_AGGR_TYPE (t)
9150 && COMPLETE_TYPE_P (t)
9156 what = "the same type";
9157 /* Don't force t to be complete here. */
9158 else if (IS_AGGR_TYPE (t)
9159 && COMPLETE_TYPE_P (t)
9151 && DERIVED_FROM_P (t, current_class_type))
9160 && DERIVED_FROM_P (t, class_type))
9152 what = "a base class";
9161 what = "a base class";
9153
9154 if (what && warn_conversion)
9155 warning ("conversion to %s%s will never use a type conversion operator",
9156 ref ? "a reference to " : "", what);
9157 }
9162 }
9163
9164 if (what)
9165 warning ("conversion to %s%s will never use a type conversion operator",
9166 ref ? "a reference to " : "", what);
9158 }
9167 }
9168
9159 if (operator_code == COND_EXPR)
9160 {
9161 /* 13.4.0.3 */
9162 error ("ISO C++ prohibits overloading operator ?:");
9163 }
9169 if (operator_code == COND_EXPR)
9170 {
9171 /* 13.4.0.3 */
9172 error ("ISO C++ prohibits overloading operator ?:");
9173 }
9174 else if (ellipsis_p)
9175 error ("`%D' must not have variable number of arguments", decl);
9164 else if (ambi_op_p (operator_code))
9165 {
9166 if (arity == 1)
9167 /* We pick the one-argument operator codes by default, so
9168 we don't have to change anything. */
9169 ;
9170 else if (arity == 2)
9171 {

--- 148 unchanged lines hidden (view full) ---

9320{
9321 switch (code)
9322 {
9323 case record_type:
9324 return "struct";
9325 case class_type:
9326 return "class";
9327 case union_type:
9176 else if (ambi_op_p (operator_code))
9177 {
9178 if (arity == 1)
9179 /* We pick the one-argument operator codes by default, so
9180 we don't have to change anything. */
9181 ;
9182 else if (arity == 2)
9183 {

--- 148 unchanged lines hidden (view full) ---

9332{
9333 switch (code)
9334 {
9335 case record_type:
9336 return "struct";
9337 case class_type:
9338 return "class";
9339 case union_type:
9328 return "union ";
9340 return "union";
9329 case enum_type:
9330 return "enum";
9341 case enum_type:
9342 return "enum";
9343 case typename_type:
9344 return "typename";
9331 default:
9332 abort ();
9333 }
9334}
9335
9336/* Name lookup in an elaborated-type-specifier (after the keyword
9337 indicated by TAG_CODE) has found the TYPE_DECL DECL. If the
9338 elaborated-type-specifier is invalid, issue a diagnostic and return

--- 21 unchanged lines hidden (view full) ---

9360 /* [dcl.type.elab]
9361
9362 If the identifier resolves to a typedef-name or a template
9363 type-parameter, the elaborated-type-specifier is ill-formed.
9364
9365 In other words, the only legitimate declaration to use in the
9366 elaborated type specifier is the implicit typedef created when
9367 the type is declared. */
9345 default:
9346 abort ();
9347 }
9348}
9349
9350/* Name lookup in an elaborated-type-specifier (after the keyword
9351 indicated by TAG_CODE) has found the TYPE_DECL DECL. If the
9352 elaborated-type-specifier is invalid, issue a diagnostic and return

--- 21 unchanged lines hidden (view full) ---

9374 /* [dcl.type.elab]
9375
9376 If the identifier resolves to a typedef-name or a template
9377 type-parameter, the elaborated-type-specifier is ill-formed.
9378
9379 In other words, the only legitimate declaration to use in the
9380 elaborated type specifier is the implicit typedef created when
9381 the type is declared. */
9368 if (!DECL_IMPLICIT_TYPEDEF_P (decl))
9382 if (!DECL_IMPLICIT_TYPEDEF_P (decl)
9383 && tag_code != typename_type)
9369 {
9370 error ("using typedef-name `%D' after `%s'", decl, tag_name (tag_code));
9371 return IS_AGGR_TYPE (type) ? type : error_mark_node;
9372 }
9373
9374 if (TREE_CODE (type) == TEMPLATE_TYPE_PARM)
9375 {
9376 error ("using template type parameter `%T' after `%s'",
9377 type, tag_name (tag_code));
9378 return error_mark_node;
9379 }
9380 else if (TREE_CODE (type) != RECORD_TYPE
9381 && TREE_CODE (type) != UNION_TYPE
9384 {
9385 error ("using typedef-name `%D' after `%s'", decl, tag_name (tag_code));
9386 return IS_AGGR_TYPE (type) ? type : error_mark_node;
9387 }
9388
9389 if (TREE_CODE (type) == TEMPLATE_TYPE_PARM)
9390 {
9391 error ("using template type parameter `%T' after `%s'",
9392 type, tag_name (tag_code));
9393 return error_mark_node;
9394 }
9395 else if (TREE_CODE (type) != RECORD_TYPE
9396 && TREE_CODE (type) != UNION_TYPE
9382 && tag_code != enum_type)
9397 && tag_code != enum_type
9398 && tag_code != typename_type)
9383 {
9384 error ("`%T' referred to as `%s'", type, tag_name (tag_code));
9385 return error_mark_node;
9386 }
9387 else if (TREE_CODE (type) != ENUMERAL_TYPE
9388 && tag_code == enum_type)
9389 {
9390 error ("`%T' referred to as enum", type);

--- 905 unchanged lines hidden (view full) ---

10296 (This does not mean `static' in the C sense!) */
10297 TREE_STATIC (decl1) = 1;
10298
10299 /* We must call push_template_decl after current_class_type is set
10300 up. (If we are processing inline definitions after exiting a
10301 class scope, current_class_type will be NULL_TREE until set above
10302 by push_nested_class.) */
10303 if (processing_template_decl)
9399 {
9400 error ("`%T' referred to as `%s'", type, tag_name (tag_code));
9401 return error_mark_node;
9402 }
9403 else if (TREE_CODE (type) != ENUMERAL_TYPE
9404 && tag_code == enum_type)
9405 {
9406 error ("`%T' referred to as enum", type);

--- 905 unchanged lines hidden (view full) ---

10312 (This does not mean `static' in the C sense!) */
10313 TREE_STATIC (decl1) = 1;
10314
10315 /* We must call push_template_decl after current_class_type is set
10316 up. (If we are processing inline definitions after exiting a
10317 class scope, current_class_type will be NULL_TREE until set above
10318 by push_nested_class.) */
10319 if (processing_template_decl)
10304 decl1 = push_template_decl (decl1);
10320 {
10321 tree newdecl1 = push_template_decl (decl1);
10322 if (newdecl1 != error_mark_node)
10323 decl1 = newdecl1;
10324 }
10305
10306 /* We are now in the scope of the function being defined. */
10307 current_function_decl = decl1;
10308
10309 /* Save the parm names or decls from this function's declarator
10310 where store_parm_decls will find them. */
10311 current_function_parms = DECL_ARGUMENTS (decl1);
10312
10313 /* Make sure the parameter and return types are reasonable. When
10314 you declare a function, these types can be incomplete, but they
10315 must be complete when you define the function. */
10316 if (! processing_template_decl)
10317 check_function_type (decl1, current_function_parms);
10325
10326 /* We are now in the scope of the function being defined. */
10327 current_function_decl = decl1;
10328
10329 /* Save the parm names or decls from this function's declarator
10330 where store_parm_decls will find them. */
10331 current_function_parms = DECL_ARGUMENTS (decl1);
10332
10333 /* Make sure the parameter and return types are reasonable. When
10334 you declare a function, these types can be incomplete, but they
10335 must be complete when you define the function. */
10336 if (! processing_template_decl)
10337 check_function_type (decl1, current_function_parms);
10338 /* Make sure no default arg is missing. */
10339 check_default_args (decl1);
10318
10319 /* Build the return declaration for the function. */
10320 restype = TREE_TYPE (fntype);
10321 /* Promote the value to int before returning it. */
10322 if (c_promoting_integer_type_p (restype))
10323 restype = type_promotes_to (restype);
10324 if (DECL_RESULT (decl1) == NULL_TREE)
10325 {

--- 47 unchanged lines hidden (view full) ---

10373 the same function or DECL1 itself. */
10374 decl1 = olddecl;
10375 }
10376 else
10377 {
10378 /* We need to set the DECL_CONTEXT. */
10379 if (!DECL_CONTEXT (decl1) && DECL_TEMPLATE_INFO (decl1))
10380 DECL_CONTEXT (decl1) = DECL_CONTEXT (DECL_TI_TEMPLATE (decl1));
10340
10341 /* Build the return declaration for the function. */
10342 restype = TREE_TYPE (fntype);
10343 /* Promote the value to int before returning it. */
10344 if (c_promoting_integer_type_p (restype))
10345 restype = type_promotes_to (restype);
10346 if (DECL_RESULT (decl1) == NULL_TREE)
10347 {

--- 47 unchanged lines hidden (view full) ---

10395 the same function or DECL1 itself. */
10396 decl1 = olddecl;
10397 }
10398 else
10399 {
10400 /* We need to set the DECL_CONTEXT. */
10401 if (!DECL_CONTEXT (decl1) && DECL_TEMPLATE_INFO (decl1))
10402 DECL_CONTEXT (decl1) = DECL_CONTEXT (DECL_TI_TEMPLATE (decl1));
10381 /* And make sure we have enough default args. */
10382 check_default_args (decl1);
10383 }
10384 fntype = TREE_TYPE (decl1);
10385 }
10386
10387 /* Reset these in case the call to pushdecl changed them. */
10388 current_function_decl = decl1;
10389 cfun->decl = decl1;
10390

--- 960 unchanged lines hidden ---
10403 }
10404 fntype = TREE_TYPE (decl1);
10405 }
10406
10407 /* Reset these in case the call to pushdecl changed them. */
10408 current_function_decl = decl1;
10409 cfun->decl = decl1;
10410

--- 960 unchanged lines hidden ---