Commit 2dff8956 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/33506 (TYPE_RAISES_EXCEPTIONS dumped with attributes)

	PR c++/33506
	* langhooks.h (struct lang_hooks_for_types): Add type_hash_eq
	field.
	* langhooks-def.h (LANG_HOOKS_TYPE_HASH_EQ): Define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add LANG_HOOKS_TYPE_HASH_EQ.
	* tree.c (type_hash_eq): For FUNCTION_TYPE use
	lang_hooks.type.type_hash_eq in addition to generic tests.

	* cp-tree.h (cxx_type_hash_eq): New prototype.
	* cp-objcp-common.h (LANG_HOOKS_TYPE_HASH_EQ): Redefine.
	* tree.c (cxx_type_hash_eq): New function.

	* g++.dg/ext/attrib29.C: New test.

From-SVN: r128718
parent c946ce8b
2007-09-24 Jakub Jelinek <jakub@redhat.com>
PR c++/33506
* langhooks.h (struct lang_hooks_for_types): Add type_hash_eq
field.
* langhooks-def.h (LANG_HOOKS_TYPE_HASH_EQ): Define.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add LANG_HOOKS_TYPE_HASH_EQ.
* tree.c (type_hash_eq): For FUNCTION_TYPE use
lang_hooks.type.type_hash_eq in addition to generic tests.
2007-09-24 Pranav Bhandarkar <pranav.bhandarkar@celunite.com> 2007-09-24 Pranav Bhandarkar <pranav.bhandarkar@celunite.com>
Ramana Radhakrishnan <ramana@hercules.pun.celunite.com> Ramana Radhakrishnan <ramana@hercules.pun.celunite.com>
2007-09-24 Jakub Jelinek <jakub@redhat.com>
PR c++/33506
* cp-tree.h (cxx_type_hash_eq): New prototype.
* cp-objcp-common.h (LANG_HOOKS_TYPE_HASH_EQ): Redefine.
* tree.c (cxx_type_hash_eq): New function.
2007-09-24 Douglas Gregor <doug.gregor@gmail.com> 2007-09-24 Douglas Gregor <doug.gregor@gmail.com>
PR c++/33185 PR c++/33185
......
...@@ -88,6 +88,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, ...@@ -88,6 +88,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t,
#define LANG_HOOKS_COMDAT_GROUP cxx_comdat_group #define LANG_HOOKS_COMDAT_GROUP cxx_comdat_group
#undef LANG_HOOKS_BUILTIN_FUNCTION #undef LANG_HOOKS_BUILTIN_FUNCTION
#define LANG_HOOKS_BUILTIN_FUNCTION cxx_builtin_function #define LANG_HOOKS_BUILTIN_FUNCTION cxx_builtin_function
#undef LANG_HOOKS_TYPE_HASH_EQ
#define LANG_HOOKS_TYPE_HASH_EQ cxx_type_hash_eq
#undef LANG_HOOKS_FUNCTION_INIT #undef LANG_HOOKS_FUNCTION_INIT
#define LANG_HOOKS_FUNCTION_INIT cxx_push_function_context #define LANG_HOOKS_FUNCTION_INIT cxx_push_function_context
......
...@@ -4752,6 +4752,7 @@ extern tree rvalue (tree); ...@@ -4752,6 +4752,7 @@ extern tree rvalue (tree);
extern tree convert_bitfield_to_declared_type (tree); extern tree convert_bitfield_to_declared_type (tree);
extern tree cp_save_expr (tree); extern tree cp_save_expr (tree);
extern bool cast_valid_in_integral_constant_expression_p (tree); extern bool cast_valid_in_integral_constant_expression_p (tree);
extern bool cxx_type_hash_eq (const_tree, const_tree);
/* in typeck.c */ /* in typeck.c */
extern int string_conv_p (const_tree, const_tree, int); extern int string_conv_p (const_tree, const_tree, int);
......
...@@ -2261,6 +2261,20 @@ cp_build_type_attribute_variant (tree type, tree attributes) ...@@ -2261,6 +2261,20 @@ cp_build_type_attribute_variant (tree type, tree attributes)
return new_type; return new_type;
} }
/* Return TRUE if TYPE1 and TYPE2 are identical for type hashing purposes.
Called only after doing all language independent checks. Only
to check TYPE_RAISES_EXCEPTIONS for FUNCTION_TYPE, the rest is already
compared in type_hash_eq. */
bool
cxx_type_hash_eq (const_tree typea, const_tree typeb)
{
gcc_assert (TREE_CODE (typea) == FUNCTION_TYPE);
return comp_except_specs (TYPE_RAISES_EXCEPTIONS (typea),
TYPE_RAISES_EXCEPTIONS (typeb), 1);
}
/* Apply FUNC to all language-specific sub-trees of TP in a pre-order /* Apply FUNC to all language-specific sub-trees of TP in a pre-order
traversal. Called from walk_tree. */ traversal. Called from walk_tree. */
......
...@@ -180,6 +180,7 @@ extern tree lhd_make_node (enum tree_code); ...@@ -180,6 +180,7 @@ extern tree lhd_make_node (enum tree_code);
#define LANG_HOOKS_TYPE_MAX_SIZE lhd_return_null_const_tree #define LANG_HOOKS_TYPE_MAX_SIZE lhd_return_null_const_tree
#define LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES \ #define LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES \
lhd_omp_firstprivatize_type_sizes lhd_omp_firstprivatize_type_sizes
#define LANG_HOOKS_TYPE_HASH_EQ NULL
#define LANG_HOOKS_HASH_TYPES true #define LANG_HOOKS_HASH_TYPES true
#define LANG_HOOKS_FOR_TYPES_INITIALIZER { \ #define LANG_HOOKS_FOR_TYPES_INITIALIZER { \
...@@ -192,6 +193,7 @@ extern tree lhd_make_node (enum tree_code); ...@@ -192,6 +193,7 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_INCOMPLETE_TYPE_ERROR, \ LANG_HOOKS_INCOMPLETE_TYPE_ERROR, \
LANG_HOOKS_TYPE_MAX_SIZE, \ LANG_HOOKS_TYPE_MAX_SIZE, \
LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES, \ LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES, \
LANG_HOOKS_TYPE_HASH_EQ, \
LANG_HOOKS_HASH_TYPES \ LANG_HOOKS_HASH_TYPES \
} }
......
...@@ -129,6 +129,12 @@ struct lang_hooks_for_types ...@@ -129,6 +129,12 @@ struct lang_hooks_for_types
firstprivate variables. */ firstprivate variables. */
void (*omp_firstprivatize_type_sizes) (struct gimplify_omp_ctx *, tree); void (*omp_firstprivatize_type_sizes) (struct gimplify_omp_ctx *, tree);
/* Return TRUE if TYPE1 and TYPE2 are identical for type hashing purposes.
Called only after doing all language independent checks.
At present, this function is only called when both TYPE1 and TYPE2 are
FUNCTION_TYPEs. */
bool (*type_hash_eq) (const_tree, const_tree);
/* Nonzero if types that are identical are to be hashed so that only /* Nonzero if types that are identical are to be hashed so that only
one copy is kept. If a language requires unique types for each one copy is kept. If a language requires unique types for each
user-specified type, such as Ada, this should be set to TRUE. */ user-specified type, such as Ada, this should be set to TRUE. */
......
2007-09-24 Jakub Jelinek <jakub@redhat.com>
PR c++/33506
* g++.dg/ext/attrib29.C: New test.
2007-09-23 Ollie Wild <aaw@google.com> 2007-09-23 Ollie Wild <aaw@google.com>
* gcc.dg/fold-bitand-1.c: New test. * gcc.dg/fold-bitand-1.c: New test.
// PR c++/33506
// { dg-do compile }
extern int f1 (char *) __attribute__ ((warn_unused_result));
extern int f2 (char *) throw () __attribute__ ((warn_unused_result));
extern int f2 (char *) throw ();
extern int f3 (char *) __attribute__ ((nonnull (1)));
extern int f4 (char *) throw () __attribute__ ((nonnull (1)));
extern int f4 (char *) throw ();
...@@ -4608,17 +4608,24 @@ type_hash_eq (const void *va, const void *vb) ...@@ -4608,17 +4608,24 @@ type_hash_eq (const void *va, const void *vb)
TYPE_FIELDS (b->type)))); TYPE_FIELDS (b->type))));
case FUNCTION_TYPE: case FUNCTION_TYPE:
return (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type) if (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type)
|| (TYPE_ARG_TYPES (a->type) || (TYPE_ARG_TYPES (a->type)
&& TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST
&& TYPE_ARG_TYPES (b->type) && TYPE_ARG_TYPES (b->type)
&& TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST
&& type_list_equal (TYPE_ARG_TYPES (a->type), && type_list_equal (TYPE_ARG_TYPES (a->type),
TYPE_ARG_TYPES (b->type)))); TYPE_ARG_TYPES (b->type))))
break;
return 0;
default: default:
return 0; return 0;
} }
if (lang_hooks.types.type_hash_eq != NULL)
return lang_hooks.types.type_hash_eq (a->type, b->type);
return 1;
} }
/* Return the cached hash value. */ /* Return the cached hash value. */
......
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