re PR c++/33506 (TYPE_RAISES_EXCEPTIONS dumped with attributes)
authorJakub Jelinek <jakub@redhat.com>
Mon, 24 Sep 2007 15:16:23 +0000 (17:16 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 24 Sep 2007 15:16:23 +0000 (17:16 +0200)
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

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.h
gcc/cp/cp-tree.h
gcc/cp/tree.c
gcc/langhooks-def.h
gcc/langhooks.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/attrib29.C [new file with mode: 0644]
gcc/tree.c

index 81bdc4c889088bcc206aa48d29c77bab5dc33666..4ef90d38a7c1f281825d78bea1bb789e1bd96be1 100644 (file)
@@ -1,3 +1,13 @@
+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>
        Ramana Radhakrishnan  <ramana@hercules.pun.celunite.com>
 
index f8a6875497c091d6e60e65f7f718a63d7590d59e..5e9b1875b2eb558e0b1596c853e3333c195d0f76 100644 (file)
@@ -1,3 +1,10 @@
+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>
 
        PR c++/33185    
index dd236131f0a3386138db29f1914c7048a54b8a7a..7f8138c6e60431805c96402336ecf631de5145c8 100644 (file)
@@ -88,6 +88,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t,
 #define LANG_HOOKS_COMDAT_GROUP cxx_comdat_group
 #undef  LANG_HOOKS_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
 #define LANG_HOOKS_FUNCTION_INIT cxx_push_function_context
index fbe1bcc01706b908c673fc5391b3cf96c97f915e..83f4d4232316972ae757c73130e8e7a6a79640fe 100644 (file)
@@ -4752,6 +4752,7 @@ extern tree rvalue                                (tree);
 extern tree convert_bitfield_to_declared_type   (tree);
 extern tree cp_save_expr                       (tree);
 extern bool cast_valid_in_integral_constant_expression_p (tree);
+extern bool cxx_type_hash_eq                   (const_tree, const_tree);
 
 /* in typeck.c */
 extern int string_conv_p                       (const_tree, const_tree, int);
index 78ba4282b4471b66a376fa5568c4939783a92a4e..77aac702f208d0e6b3aca1194d6cb6069b7cbf5d 100644 (file)
@@ -2261,6 +2261,20 @@ cp_build_type_attribute_variant (tree type, tree attributes)
   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
    traversal.  Called from walk_tree.  */
 
index 523fc0b4766c8613e3bdf5e81cb557cf3bbae6fa..28efd6beb49c86ef0bceb0408550e5e546def565 100644 (file)
@@ -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_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_FOR_TYPES_INITIALIZER { \
@@ -192,6 +193,7 @@ extern tree lhd_make_node (enum tree_code);
   LANG_HOOKS_INCOMPLETE_TYPE_ERROR, \
   LANG_HOOKS_TYPE_MAX_SIZE, \
   LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES, \
+  LANG_HOOKS_TYPE_HASH_EQ, \
   LANG_HOOKS_HASH_TYPES \
 }
 
index ad925a84c3b15ea219dabff3829a9e9dfd75ac94..7efe7425eb814d4bcc9a18147382603fbe66b4a0 100644 (file)
@@ -129,6 +129,12 @@ struct lang_hooks_for_types
      firstprivate variables.  */
   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
      one copy is kept.  If a language requires unique types for each
      user-specified type, such as Ada, this should be set to TRUE.  */
index 2e3b520d1a3c6a269ec92a57db82c00392733b02..8e146d2917a89ba45c8554563c8d9998571fbc7a 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * gcc.dg/fold-bitand-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/ext/attrib29.C b/gcc/testsuite/g++.dg/ext/attrib29.C
new file mode 100644 (file)
index 0000000..710a5ce
--- /dev/null
@@ -0,0 +1,10 @@
+// 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 ();
index 2e5bf5c933763422fd657ba22ee051bf7d95d15d..88ec29e13e37d287c0574efcd0d8e49e366dbbef 100644 (file)
@@ -4608,17 +4608,24 @@ type_hash_eq (const void *va, const void *vb)
                                      TYPE_FIELDS (b->type))));
 
     case FUNCTION_TYPE:
-      return (TYPE_ARG_TYPES (a->type) == TYPE_ARG_TYPES (b->type)
-             || (TYPE_ARG_TYPES (a->type)
-                 && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST
-                 && TYPE_ARG_TYPES (b->type)
-                 && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST
-                 && type_list_equal (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)
+             && TREE_CODE (TYPE_ARG_TYPES (a->type)) == TREE_LIST
+             && TYPE_ARG_TYPES (b->type)
+             && TREE_CODE (TYPE_ARG_TYPES (b->type)) == TREE_LIST
+             && type_list_equal (TYPE_ARG_TYPES (a->type),
+                                 TYPE_ARG_TYPES (b->type))))
+       break;
+      return 0;
 
     default:
       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.  */