commit fa430ccf08f60e0affd935854fd8b49f547d21a4
Author: Jason Merrill <jason@redhat.com>
Date: Tue Mar 26 14:26:29 2013 -0400
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.
@@ -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);
@@ -5276,16 +5276,16 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
expr = resolve_nondeduced_context (expr);
- if (type_unknown_p (expr))
- {
- if (complain & tf_error)
- error ("decltype cannot resolve address of overloaded function");
- return error_mark_node;
- }
-
if (invalid_nonstatic_memfn_p (expr, complain))
return error_mark_node;
+ if (type_unknown_p (expr))
+ {
+ if (complain & tf_error)
+ error ("decltype cannot resolve address of overloaded function");
+ 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");
new file mode 100644
@@ -0,0 +1,18 @@
+// 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" }
}