aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/semantics.cc15
-rw-r--r--gcc/testsuite/g++.dg/template/call9.C26
2 files changed, 36 insertions, 5 deletions
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 1656d02..c2df0b6 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -2957,13 +2957,18 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual,
if (TREE_CODE (result) == CALL_EXPR
&& really_overloaded_fn (orig_fn))
{
- orig_fn = CALL_EXPR_FN (result);
- if (TREE_CODE (orig_fn) == COMPONENT_REF)
+ tree sel_fn = CALL_EXPR_FN (result);
+ if (TREE_CODE (sel_fn) == COMPONENT_REF)
{
/* The non-dependent result of build_new_method_call. */
- orig_fn = TREE_OPERAND (orig_fn, 1);
- gcc_assert (BASELINK_P (orig_fn));
- }
+ sel_fn = TREE_OPERAND (sel_fn, 1);
+ gcc_assert (BASELINK_P (sel_fn));
+ }
+ else if (TREE_CODE (sel_fn) == ADDR_EXPR)
+ /* Our original callee wasn't wrapped in an ADDR_EXPR,
+ so strip this ADDR_EXPR added by build_over_call. */
+ sel_fn = TREE_OPERAND (sel_fn, 0);
+ orig_fn = sel_fn;
}
result = build_call_vec (TREE_TYPE (result), orig_fn, orig_args);
diff --git a/gcc/testsuite/g++.dg/template/call9.C b/gcc/testsuite/g++.dg/template/call9.C
new file mode 100644
index 0000000..6bdfd93
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/call9.C
@@ -0,0 +1,26 @@
+// PR c++/107461
+// { dg-do compile { target c++11 } }
+
+template<class T>
+constexpr T min(T t0, T t1) {
+ return t0 < t1 ? t0 : t1;
+}
+
+template<int MAX>
+struct Matrix;
+
+template<int MAXOP, int other_MAXOP>
+Matrix<min(MAXOP, other_MAXOP)>
+operator+(Matrix<MAXOP> const& lhs, Matrix<other_MAXOP> const& rhs); // #1
+
+template<int MAX>
+struct Matrix {
+ template<int MAXOP, int other_MAXOP>
+ friend Matrix<min(MAXOP, other_MAXOP)>
+ operator+(Matrix<MAXOP> const& lhs, Matrix<other_MAXOP> const& rhs); // #2
+};
+
+int main() {
+ Matrix<1> a;
+ a+a;
+}