GCC Bugzilla – Attachment 25181 Details for
Bug 2316
g++ fails to overload on language linkage
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
remember linkage of a function type (3)
pp (text/plain), 7.17 KB, created by
Marc Glisse
on 2011-09-03 13:00:20 UTC
(
hide
)
Description:
remember linkage of a function type (3)
Filename:
MIME Type:
Creator:
Marc Glisse
Created:
2011-09-03 13:00:20 UTC
Size:
7.17 KB
patch
obsolete
>Index: gcc/tree.c >=================================================================== >--- gcc/tree.c (revision 178498) >+++ gcc/tree.c (working copy) >@@ -7521,7 +7521,7 @@ > If such a type has already been constructed, reuse it. */ > > tree >-build_function_type (tree value_type, tree arg_types) >+build_function_type2 (tree value_type, tree arg_types, int extern_c) > { > tree t; > hashval_t hashcode = 0; >@@ -7538,10 +7538,15 @@ > t = make_node (FUNCTION_TYPE); > TREE_TYPE (t) = value_type; > TYPE_ARG_TYPES (t) = arg_types; >+ if(extern_c) >+ { >+ TYPE_MINVAL (t) = integer_one_node; >+ } > > /* If we already have such a type, use the old one. */ > hashcode = iterative_hash_object (TYPE_HASH (value_type), hashcode); > hashcode = type_hash_list (arg_types, hashcode); >+ hashcode = iterative_hash_object (extern_c, hashcode); > t = type_hash_canon (hashcode, t); > > /* Set up the canonical type. */ >@@ -7553,13 +7558,18 @@ > if (any_structural_p) > SET_TYPE_STRUCTURAL_EQUALITY (t); > else if (any_noncanonical_p) >- TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type), >- canon_argtypes); >+ TYPE_CANONICAL (t) = build_function_type2 (TYPE_CANONICAL (value_type), >+ canon_argtypes, extern_c); > > if (!COMPLETE_TYPE_P (t)) > layout_type (t); > return t; > } >+tree >+build_function_type (tree value_type, tree arg_types) >+{ >+ return build_function_type2 (value_type, arg_types, 0); >+} > > /* Build variant of function type ORIG_TYPE skipping ARGS_TO_SKIP. */ > >Index: gcc/tree.h >=================================================================== >--- gcc/tree.h (revision 178498) >+++ gcc/tree.h (working copy) >@@ -4337,6 +4337,7 @@ > extern tree build_nonshared_array_type (tree, tree); > extern tree build_array_type_nelts (tree, unsigned HOST_WIDE_INT); > extern tree build_function_type (tree, tree); >+extern tree build_function_type2 (tree, tree, int); > extern tree build_function_type_list (tree, ...); > extern tree build_function_type_skip_args (tree, bitmap); > extern tree build_function_decl_skip_args (tree, bitmap); >Index: gcc/cp/typeck.c >=================================================================== >--- gcc/cp/typeck.c (revision 178498) >+++ gcc/cp/typeck.c (working copy) >@@ -1277,10 +1277,12 @@ > > case METHOD_TYPE: > case FUNCTION_TYPE: >- if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2))) >+ if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2), strict & COMPARE_IGNOREEXTC)) > return false; >- if (!compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2))) >+ if (!compparms2 (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2), strict & COMPARE_IGNOREEXTC)) > return false; >+ if (!(strict & COMPARE_IGNOREEXTC) && (TYPE_MINVAL (t1) != TYPE_MINVAL (t2))) >+ return false; > break; > > case ARRAY_TYPE: >@@ -1473,7 +1475,7 @@ > element by element. */ > > bool >-compparms (const_tree parms1, const_tree parms2) >+compparms2 (const_tree parms1, const_tree parms2, int strict) > { > const_tree t1, t2; > >@@ -1488,11 +1490,16 @@ > they fail to match. */ > if (!t1 || !t2) > return false; >- if (!same_type_p (TREE_VALUE (t1), TREE_VALUE (t2))) >+ if (!comptypes (TREE_VALUE (t1), TREE_VALUE (t2), strict)) > return false; > } > return true; > } >+bool >+compparms (const_tree parms1, const_tree parms2) >+{ >+ return compparms2 (parms1, parms2, COMPARE_STRICT); >+} > > > /* Process a sizeof or alignof expression where the operand is a >Index: gcc/cp/class.c >=================================================================== >--- gcc/cp/class.c (revision 178498) >+++ gcc/cp/class.c (working copy) >@@ -6469,6 +6469,8 @@ > are the TREE_PURPOSE, not the TREE_VALUE, in this list, for easy > interoperability with most_specialized_instantiation. */ > tree matches = NULL_TREE; >+ tree matches2 = NULL_TREE; >+ bool hasmatch2 = 0; > tree fn; > tree target_fn_type; > >@@ -6538,12 +6540,16 @@ > /* See if there's a match. */ > if (same_type_p (target_fn_type, static_fn_type (fn))) > matches = tree_cons (fn, NULL_TREE, matches); >+ /* See if there's a match. */ >+ if (comptypes (target_fn_type, static_fn_type (fn), COMPARE_IGNOREEXTC)) >+ matches2 = tree_cons (fn, NULL_TREE, matches2); > } > } > > /* Now, if we've already got a match (or matches), there's no need > to proceed to the template functions. But, if we don't have a > match we need to look at them, too. */ >+ hasmatch2 = !matches2; > if (!matches) > { > tree target_arg_types; >@@ -6597,6 +6603,9 @@ > /* See if there's a match. */ > if (same_type_p (target_fn_type, static_fn_type (instantiation))) > matches = tree_cons (instantiation, fn, matches); >+ /* See if there's a match. */ >+ if (!hasmatch2 && comptypes (target_fn_type, static_fn_type (instantiation), COMPARE_IGNOREEXTC)) >+ matches2 = tree_cons (instantiation, fn, matches2); > } > > /* Now, remove all but the most specialized of the matches. */ >@@ -6612,6 +6621,7 @@ > } > > /* Now we should have exactly one function in MATCHES. */ >+ if (matches == NULL_TREE) matches = matches2; > if (matches == NULL_TREE) > { > /* There were *no* matches. */ >Index: gcc/cp/decl.c >=================================================================== >--- gcc/cp/decl.c (revision 178498) >+++ gcc/cp/decl.c (working copy) >@@ -9180,7 +9180,7 @@ > parms = NULL_TREE; > } > >- type = build_function_type (type, arg_types); >+ type = build_function_type2 (type, arg_types, current_lang_name == lang_name_c); > } > break; > >Index: gcc/cp/tree.c >=================================================================== >--- gcc/cp/tree.c (revision 178498) >+++ gcc/cp/tree.c (working copy) >@@ -1151,8 +1151,8 @@ > } > else > { >- result = build_function_type (type, >- arg_types); >+ result = build_function_type2 (type, arg_types, >+ TYPE_MINVAL (t) != 0); > result = apply_memfn_quals (result, type_memfn_quals (t)); > } > >Index: gcc/cp/mangle.c >=================================================================== >--- gcc/cp/mangle.c (revision 178498) >+++ gcc/cp/mangle.c (working copy) >@@ -2264,6 +2264,8 @@ > } > > write_char ('F'); >+ if(TYPE_MINVAL (type)) >+ write_char ('Y'); > /* We don't track whether or not a type is `extern "C"'. Note that > you can have an `extern "C"' function that does not have > `extern "C"' type, and vice versa: >Index: gcc/cp/cp-tree.h >=================================================================== >--- gcc/cp/cp-tree.h (revision 178498) >+++ gcc/cp/cp-tree.h (working copy) >@@ -4350,6 +4350,8 @@ > structural. The actual comparison > will be identical to > COMPARE_STRICT. */ >+#define COMPARE_IGNOREEXTC 16 /* The comparison should ignore >+ extern "C" on function types. */ > > /* Used with push_overloaded_decl. */ > #define PUSH_GLOBAL 0 /* Push the DECL into namespace scope, >@@ -5614,6 +5616,7 @@ > extern bool comptypes (tree, tree, int); > extern bool same_type_ignoring_top_level_qualifiers_p (tree, tree); > extern bool compparms (const_tree, const_tree); >+extern bool compparms2 (const_tree, const_tree, int); > extern int comp_cv_qualification (const_tree, const_tree); > extern int comp_cv_qual_signature (tree, tree); > extern tree cxx_sizeof_or_alignof_expr (tree, enum tree_code, bool);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 2316
:
25134
|
25140
|
25181
|
26214
|
26237