Commit 7c355bca by Martin v. Löwis Committed by Martin v. Löwis

cp-tree.h (VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK): New macro.

	* cp-tree.h (VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK): New macro.
	(DECL_TEMPLATE_INFO): Use it.
	* decl.c (warn_extern_redeclared_static): Do nothing for
	TEMPLATE_DECLs.
	* decl2.c (mark_used): Explicitly check for function or variable.
	* semantics.c (finish_unary_op_expr): Check whether result is also
	an INTEGER_CST.

From-SVN: r30426
parent 32c8d1bc
1999-11-05 Martin v. Lwis <loewis@informatik.hu-berlin.de>
* cp-tree.h (VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK): New macro.
(DECL_TEMPLATE_INFO): Use it.
* decl.c (warn_extern_redeclared_static): Do nothing for
TEMPLATE_DECLs.
* decl2.c (mark_used): Explicitly check for function or variable.
* semantics.c (finish_unary_op_expr): Check whether result is also
an INTEGER_CST.
1999-11-05 Mark Mitchell <mark@codesourcery.com> 1999-11-05 Mark Mitchell <mark@codesourcery.com>
* Makefile.in (typeck2.o): Depend on output.h. * Makefile.in (typeck2.o): Depend on output.h.
......
...@@ -134,6 +134,17 @@ Boston, MA 02111-1307, USA. */ ...@@ -134,6 +134,17 @@ Boston, MA 02111-1307, USA. */
__LINE__, __PRETTY_FUNCTION__); \ __LINE__, __PRETTY_FUNCTION__); \
__t; }) __t; })
#define VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK(NODE) \
({ const tree __t = NODE; \
enum tree_code __c = TREE_CODE(__t); \
if (__c != VAR_DECL \
&& __c != FUNCTION_DECL \
&& __c != TYPE_DECL \
&& __c != TEMPLATE_DECL) \
tree_check_failed (__t, VAR_DECL, __FILE__, \
__LINE__, __PRETTY_FUNCTION__); \
__t; })
#define RECORD_OR_UNION_TYPE_CHECK(NODE) \ #define RECORD_OR_UNION_TYPE_CHECK(NODE) \
({ const tree __t = NODE; \ ({ const tree __t = NODE; \
enum tree_code __c = TREE_CODE(__t); \ enum tree_code __c = TREE_CODE(__t); \
...@@ -145,6 +156,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -145,6 +156,7 @@ Boston, MA 02111-1307, USA. */
#else /* not ENABLE_CHECKING, or not gcc */ #else /* not ENABLE_CHECKING, or not gcc */
#define VAR_OR_FUNCTION_DECL_CHECK(NODE) NODE #define VAR_OR_FUNCTION_DECL_CHECK(NODE) NODE
#define VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK(NODE) NODE
#define RECORD_OR_UNION_TYPE_CHECK(NODE) NODE #define RECORD_OR_UNION_TYPE_CHECK(NODE) NODE
#endif #endif
...@@ -1601,7 +1613,8 @@ struct lang_decl_flags ...@@ -1601,7 +1613,8 @@ struct lang_decl_flags
tree context; tree context;
union { union {
/* In a FUNCTION_DECL or a VAR_DECL, this is DECL_TEMPLATE_INFO. */ /* In a FUNCTION_DECL, VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this
is DECL_TEMPLATE_INFO. */
tree template_info; tree template_info;
/* In a NAMESPACE_DECL, this is NAMESPACE_LEVEL. */ /* In a NAMESPACE_DECL, this is NAMESPACE_LEVEL. */
...@@ -1838,9 +1851,10 @@ struct lang_decl ...@@ -1838,9 +1851,10 @@ struct lang_decl
#define DECL_SAVED_INLINE(DECL) \ #define DECL_SAVED_INLINE(DECL) \
(DECL_LANG_SPECIFIC(DECL)->decl_flags.saved_inline) (DECL_LANG_SPECIFIC(DECL)->decl_flags.saved_inline)
/* For a VAR_DECL or FUNCTION_DECL: template-specific information. */ /* For a VAR_DECL, FUNCTION_DECL, TYPE_DECL or TEMPLATE_DECL:
template-specific information. */
#define DECL_TEMPLATE_INFO(NODE) \ #define DECL_TEMPLATE_INFO(NODE) \
(DECL_LANG_SPECIFIC(VAR_OR_FUNCTION_DECL_CHECK (NODE))->decl_flags.u.template_info) (DECL_LANG_SPECIFIC(VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK (NODE))->decl_flags.u.template_info)
/* Template information for a RECORD_TYPE or UNION_TYPE. */ /* Template information for a RECORD_TYPE or UNION_TYPE. */
#define CLASSTYPE_TEMPLATE_INFO(NODE) \ #define CLASSTYPE_TEMPLATE_INFO(NODE) \
......
...@@ -2900,7 +2900,8 @@ warn_extern_redeclared_static (newdecl, olddecl) ...@@ -2900,7 +2900,8 @@ warn_extern_redeclared_static (newdecl, olddecl)
tree name; tree name;
if (TREE_CODE (newdecl) == TYPE_DECL) if (TREE_CODE (newdecl) == TYPE_DECL
|| TREE_CODE (newdecl) == TEMPLATE_DECL)
return; return;
/* Don't get confused by static member functions; that's a different /* Don't get confused by static member functions; that's a different
......
...@@ -5152,11 +5152,9 @@ mark_used (decl) ...@@ -5152,11 +5152,9 @@ mark_used (decl)
/* If this is a function or variable that is an instance of some /* If this is a function or variable that is an instance of some
template, we now know that we will need to actually do the template, we now know that we will need to actually do the
instantiation. A TEMPLATE_DECL may also have DECL_TEMPLATE_INFO, instantiation. We check that DECL is not an explicit
if it's a partial instantiation, but there's no need to
instantiate such a thing. We check that DECL is not an explicit
instantiation because that is not checked in instantiate_decl. */ instantiation because that is not checked in instantiate_decl. */
if (TREE_CODE (decl) != TEMPLATE_DECL if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
&& DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl) && DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl)
&& !DECL_EXPLICIT_INSTANTIATION (decl)) && !DECL_EXPLICIT_INSTANTIATION (decl))
instantiate_decl (decl); instantiate_decl (decl);
......
...@@ -1597,7 +1597,11 @@ finish_unary_op_expr (code, expr) ...@@ -1597,7 +1597,11 @@ finish_unary_op_expr (code, expr)
tree expr; tree expr;
{ {
tree result = build_x_unary_op (code, expr); tree result = build_x_unary_op (code, expr);
if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST) /* Inside a template, build_x_unary_op does not fold the
expression. So check whether the result is folded before
setting TREE_NEGATED_INT. */
if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST
&& TREE_CODE (result) == INTEGER_CST)
TREE_NEGATED_INT (result) = 1; TREE_NEGATED_INT (result) = 1;
overflow_warning (result); overflow_warning (result);
return result; return result;
......
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