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.
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);
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)
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
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");
--- /dev/null
+// 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" }
// 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
{
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" }
}
// 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
{
void SpyExample::ready()
{
- queryAliases(inputs); // { dg-error "matching|unresolved" }
+ queryAliases(inputs); // { dg-error "invalid" }
}
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 {
};
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" }
}