Commit 6c74ff23 by Jason Merrill Committed by Jason Merrill

re PR c++/52597 ([C++11] confusing diagnostics for invalid use of non-static…

re PR c++/52597 ([C++11] confusing diagnostics for invalid use of non-static member function in decltype)

	PR c++/52597
	* typeck.c (invalid_nonstatic_memfn_p): Use get_first_fn.  Take tree.
	* semantics.c (finish_decltype_type): Check it before type_unknown_p.
	* cp-tree.h: Adjust prototype.

From-SVN: r197131
parent 845367eb
2013-03-26 Jason Merrill <jason@redhat.com>
PR c++/52597
* typeck.c (invalid_nonstatic_memfn_p): Use get_first_fn. Take tree.
* semantics.c (finish_decltype_type): Check it before type_unknown_p.
* cp-tree.h: Adjust prototype.
PR c++/45282
* typeck2.c (build_m_component_ref): Handle prvalue object.
......
......@@ -5988,7 +5988,7 @@ extern tree build_typed_address (tree, tree);
extern tree build_nop (tree, tree);
extern tree non_reference (tree);
extern tree lookup_anon_field (tree, tree);
extern bool invalid_nonstatic_memfn_p (const_tree, tsubst_flags_t);
extern bool invalid_nonstatic_memfn_p (tree, tsubst_flags_t);
extern tree convert_member_func_to_ptr (tree, tree, tsubst_flags_t);
extern tree convert_ptrmem (tree, tree, bool, bool,
tsubst_flags_t);
......
......@@ -5275,6 +5275,9 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
expr = resolve_nondeduced_context (expr);
if (invalid_nonstatic_memfn_p (expr, complain))
return error_mark_node;
if (type_unknown_p (expr))
{
if (complain & tf_error)
......@@ -5282,9 +5285,6 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
return error_mark_node;
}
if (invalid_nonstatic_memfn_p (expr, complain))
return error_mark_node;
/* To get the size of a static data member declared as an array of
unknown bound, we need to instantiate it. */
if (TREE_CODE (expr) == VAR_DECL
......
......@@ -1766,9 +1766,16 @@ cxx_alignas_expr (tree e)
violates these rules. */
bool
invalid_nonstatic_memfn_p (const_tree expr, tsubst_flags_t complain)
invalid_nonstatic_memfn_p (tree expr, tsubst_flags_t complain)
{
if (expr && DECL_NONSTATIC_MEMBER_FUNCTION_P (expr))
if (expr == NULL_TREE)
return false;
/* Don't enforce this in MS mode. */
if (flag_ms_extensions)
return false;
if (is_overloaded_fn (expr) && !really_overloaded_fn (expr))
expr = get_first_fn (expr);
if (DECL_NONSTATIC_MEMBER_FUNCTION_P (expr))
{
if (complain & tf_error)
error ("invalid use of non-static member function");
......
// PR c++/52597
// { dg-require-effective-target c++11 }
struct A {
int zip();
decltype(zip) bar0; // { dg-error "invalid use of non-static member function" }
void bar1() {
typedef decltype(this->A::zip) x; // { dg-error "invalid use of non-static member function" }
}
void bar2() {
typedef decltype(A::zip) x; // { dg-error "invalid use of non-static member function" }
}
};
typedef decltype(A().zip) x; // { dg-error "invalid use of non-static member function" }
// { dg-prune-output "invalid type in declaration" }
......@@ -4,7 +4,7 @@
// PR 21592:ICE
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
template<typename T> void unique(T,T); // { dg-message "note" }
template<typename T> void unique(T,T);
struct A
{
......@@ -13,6 +13,5 @@ struct A
template<int> void foo()
{
unique(A().begin); // { dg-error "no matching function" "" }
// { dg-message "candidate" "candidate note" { target *-*-* } 16 }
unique(A().begin); // { dg-error "invalid use of non-static member function" }
}
......@@ -6,7 +6,7 @@
// Pointer to member function template argument deduction ICE.
template <class CONT> void queryAliases(CONT& fill_me); // { dg-message "queryAliases|no known conversion" }
template <class CONT> void queryAliases(CONT& fill_me);
struct SpyExample
{
......@@ -16,5 +16,5 @@ struct SpyExample
void SpyExample::ready()
{
queryAliases(inputs); // { dg-error "matching|unresolved" }
queryAliases(inputs); // { dg-error "invalid" }
}
......@@ -6,7 +6,7 @@ class data;
class conatiner {
public:
virtual void* first ();
virtual data* contents (void* i); // { dg-message "conatiner::contents|no known conversion" }
virtual data* contents (void* i);
};
class user {
......@@ -17,6 +17,5 @@ private:
};
data* user::data1() const {
return (_c.contents (_c.first)); // { dg-error "match" }
// { dg-message "candidate" "candidate note" { target *-*-* } 20 }
return (_c.contents (_c.first)); // { dg-error "invalid use of non-static member function" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment