diff options
author | Marek Polacek <polacek@redhat.com> | 2019-03-01 15:57:46 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2019-03-01 15:57:46 +0000 |
commit | 6fe7ce18d0173b16d80f28c29ef7540725e069ea (patch) | |
tree | ac2f628c744bbf22c002a129b05491cb0e9cc4c5 | |
parent | d724d2aff687414567caad50eda806a28480c771 (diff) | |
download | gcc-6fe7ce18d0173b16d80f28c29ef7540725e069ea.zip gcc-6fe7ce18d0173b16d80f28c29ef7540725e069ea.tar.gz gcc-6fe7ce18d0173b16d80f28c29ef7540725e069ea.tar.bz2 |
PR c++/89537 - missing location for error with non-static member fn.
* call.c (resolve_args): Use EXPR_LOCATION.
* typeck.c (build_class_member_access_expr): Use input_location.
* g++.dg/diagnostic/member-fn-1.C: New test.
From-SVN: r269318
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/call.c | 2 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/diagnostic/member-fn-1.C | 38 |
5 files changed, 48 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ae5fd56..bc6754e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2019-03-01 Marek Polacek <polacek@redhat.com> + PR c++/89537 - missing location for error with non-static member fn. + * call.c (resolve_args): Use EXPR_LOCATION. + * typeck.c (build_class_member_access_expr): Use input_location. + PR c++/89532 - ICE with incomplete type in decltype. * semantics.c (finish_compound_literal): Return error_mark_node if digest_init_flags returns error_mark_node. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index fb67d905..d9073d7 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4246,7 +4246,7 @@ resolve_args (vec<tree, va_gc> *args, tsubst_flags_t complain) error ("invalid use of void expression"); return NULL; } - else if (invalid_nonstatic_memfn_p (arg->exp.locus, arg, complain)) + else if (invalid_nonstatic_memfn_p (EXPR_LOCATION (arg), arg, complain)) return NULL; } return args; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 1db9333..1bf9ad8 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2562,7 +2562,8 @@ build_class_member_access_expr (cp_expr object, tree member, type = unknown_type_node; /* Note that we do not convert OBJECT to the BASELINK_BINFO base. That will happen when the function is called. */ - result = build3 (COMPONENT_REF, type, object, member, NULL_TREE); + result = build3_loc (input_location, COMPONENT_REF, type, object, member, + NULL_TREE); } else if (TREE_CODE (member) == CONST_DECL) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 88cda1a..398b45e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-03-01 Marek Polacek <polacek@redhat.com> + PR c++/89537 - missing location for error with non-static member fn. + * g++.dg/diagnostic/member-fn-1.C: New test. + PR c++/89532 - ICE with incomplete type in decltype. * g++.dg/cpp2a/nontype-class14.C: New test. diff --git a/gcc/testsuite/g++.dg/diagnostic/member-fn-1.C b/gcc/testsuite/g++.dg/diagnostic/member-fn-1.C new file mode 100644 index 0000000..6d965d4 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/member-fn-1.C @@ -0,0 +1,38 @@ +// PR c++/89537 +// { dg-do compile { target c++11 } } + +template <typename> class A {}; +template <typename, typename, typename, typename> class B; +class C { + using mapped_type = int; + +public: + template <typename _Compare> + C(B<mapped_type, _Compare, A<int>, A<int>> *p1, unsigned) + : keys(p1->keys), // { dg-error "18: invalid use of non-static member function" } + values(p1->values) {} // { dg-error "20: invalid use of non-static member function" } + A<int> keys; + A<int> values; +}; +class D { +public: + using key_compare = int; + template <typename _Alloc> D(key_compare, _Alloc); +}; +template <typename _Tp, typename, typename, typename = A<_Tp>> class B { + using _Impl = D; + _Impl _M_impl; + +public: + using key_compare = int; + using iterator = C; + template <typename _Alloc> B(key_compare p1, _Alloc p2) : _M_impl(p1, p2) {} + template <typename _Alloc> B(_Alloc p1) : B(key_compare(), p1) {} + iterator begin() { return {this, 0}; } + void keys(); + void values(); +}; +void fn1() { + B<int, int, A<int>> m(fn1); + m.begin(); +} |