aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2017-06-23 11:05:47 +0200
committerMarc Glisse <glisse@gcc.gnu.org>2017-06-23 09:05:47 +0000
commit2db9b7cd422b63fe0a87218128cc0939b439859e (patch)
tree8874bb67d61acd34ac953c902f78942ea9e4d604 /gcc/cp
parent70fdc808941016567f8e55caea593324b15df230 (diff)
downloadgcc-2db9b7cd422b63fe0a87218128cc0939b439859e.zip
gcc-2db9b7cd422b63fe0a87218128cc0939b439859e.tar.gz
gcc-2db9b7cd422b63fe0a87218128cc0939b439859e.tar.bz2
Refactor fileptr_type_node handling
2017-06-23 Marc Glisse <marc.glisse@inria.fr> gcc/ * tree.h (builtin_structptr_type): New type. (builtin_structptr_types): Declare new array. * tree.c (builtin_structptr_types): New array. (free_lang_data, build_common_tree_nodes): Use it. gcc/c-family/ * c-common.c (c_common_nodes_and_builtins): Use builtin_structptr_types. gcc/cp/ * decl.c (duplicate_decls): Use builtin_structptr_types. gcc/lto/ * lto-lang.c (lto_init): Use builtin_structptr_types. From-SVN: r249585
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl.c76
2 files changed, 36 insertions, 44 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6acbe8b..92f478a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,7 @@
+2017-06-23 Marc Glisse <marc.glisse@inria.fr>
+
+ * decl.c (duplicate_decls): Use builtin_structptr_types.
+
2017-06-22 Nathan Sidwell <nathan@acm.org>
Reorder IDENTIFIER flags
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index b0a34de..0361357 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1470,53 +1470,41 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
t2 = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
t1 || t2;
t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
- if (!t1 || !t2)
- break;
- /* Deal with fileptr_type_node. FILE type is not known
- at the time we create the builtins. */
- else if (TREE_VALUE (t2) == fileptr_type_node)
- {
- tree t = TREE_VALUE (t1);
-
- if (TYPE_PTR_P (t)
- && TYPE_IDENTIFIER (TREE_TYPE (t))
- == get_identifier ("FILE")
- && compparms (TREE_CHAIN (t1), TREE_CHAIN (t2)))
+ {
+ if (!t1 || !t2)
+ break;
+ /* FILE, tm types are not known at the time
+ we create the builtins. */
+ for (unsigned i = 0;
+ i < sizeof (builtin_structptr_types)
+ / sizeof (builtin_structptr_type);
+ ++i)
+ if (TREE_VALUE (t2) == builtin_structptr_types[i].node)
{
- tree oldargs = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
-
- TYPE_ARG_TYPES (TREE_TYPE (olddecl))
- = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
- types_match = decls_match (newdecl, olddecl);
- if (types_match)
- return duplicate_decls (newdecl, olddecl,
- newdecl_is_friend);
- TYPE_ARG_TYPES (TREE_TYPE (olddecl)) = oldargs;
- }
- }
- /* Likewise for const struct tm*. */
- else if (TREE_VALUE (t2) == const_tm_ptr_type_node)
- {
- tree t = TREE_VALUE (t1);
+ tree t = TREE_VALUE (t1);
- if (TYPE_PTR_P (t)
- && TYPE_IDENTIFIER (TREE_TYPE (t))
- == get_identifier ("tm")
- && compparms (TREE_CHAIN (t1), TREE_CHAIN (t2)))
- {
- tree oldargs = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
-
- TYPE_ARG_TYPES (TREE_TYPE (olddecl))
- = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
- types_match = decls_match (newdecl, olddecl);
- if (types_match)
- return duplicate_decls (newdecl, olddecl,
- newdecl_is_friend);
- TYPE_ARG_TYPES (TREE_TYPE (olddecl)) = oldargs;
+ if (TYPE_PTR_P (t)
+ && TYPE_IDENTIFIER (TREE_TYPE (t))
+ == get_identifier (builtin_structptr_types[i].str)
+ && compparms (TREE_CHAIN (t1), TREE_CHAIN (t2)))
+ {
+ tree oldargs = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
+
+ TYPE_ARG_TYPES (TREE_TYPE (olddecl))
+ = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
+ types_match = decls_match (newdecl, olddecl);
+ if (types_match)
+ return duplicate_decls (newdecl, olddecl,
+ newdecl_is_friend);
+ TYPE_ARG_TYPES (TREE_TYPE (olddecl)) = oldargs;
+ }
+ goto next_arg;
}
- }
- else if (! same_type_p (TREE_VALUE (t1), TREE_VALUE (t2)))
- break;
+
+ if (! same_type_p (TREE_VALUE (t1), TREE_VALUE (t2)))
+ break;
+next_arg:;
+ }
warning_at (DECL_SOURCE_LOCATION (newdecl),
OPT_Wbuiltin_declaration_mismatch,