Commit ccbe00a4 by Jason Merrill Committed by Jason Merrill

re PR c++/26696 (ICE with statement forming unused static member function reference)

        PR c++/26696
        * cvt.c (convert_to_void): Replace a subexpression with no side
        effects with void_zero_node.
        * tree.c (is_overloaded_fn): Look through COMPONENT_REF.
        (get_first_fn): Ditto.
        * decl.c (grokdeclarator): No need to look through COMPONENT_REF.

From-SVN: r116724
parent 16ceb301
2006-09-06 Jason Merrill <jason@redhat.com>
PR c++/26696
* cvt.c (convert_to_void): Replace a subexpression with no side
effects with void_zero_node.
* tree.c (is_overloaded_fn): Look through COMPONENT_REF.
(get_first_fn): Ditto.
* decl.c (grokdeclarator): No need to look through COMPONENT_REF.
2006-09-05 Jason Merrill <jason@redhat.com> 2006-09-05 Jason Merrill <jason@redhat.com>
PR c++/26571 PR c++/26571
......
...@@ -960,6 +960,8 @@ convert_to_void (tree expr, const char *implicit) ...@@ -960,6 +960,8 @@ convert_to_void (tree expr, const char *implicit)
} }
expr = build1 (CONVERT_EXPR, void_type_node, expr); expr = build1 (CONVERT_EXPR, void_type_node, expr);
} }
if (! TREE_SIDE_EFFECTS (expr))
expr = void_zero_node;
return expr; return expr;
} }
......
...@@ -7014,8 +7014,6 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -7014,8 +7014,6 @@ grokdeclarator (const cp_declarator *declarator,
tree fns = TREE_OPERAND (decl, 0); tree fns = TREE_OPERAND (decl, 0);
dname = fns; dname = fns;
if (TREE_CODE (dname) == COMPONENT_REF)
dname = TREE_OPERAND (dname, 1);
if (TREE_CODE (dname) != IDENTIFIER_NODE) if (TREE_CODE (dname) != IDENTIFIER_NODE)
{ {
gcc_assert (is_overloaded_fn (dname)); gcc_assert (is_overloaded_fn (dname));
......
...@@ -853,7 +853,8 @@ int ...@@ -853,7 +853,8 @@ int
is_overloaded_fn (tree x) is_overloaded_fn (tree x)
{ {
/* A baselink is also considered an overloaded function. */ /* A baselink is also considered an overloaded function. */
if (TREE_CODE (x) == OFFSET_REF) if (TREE_CODE (x) == OFFSET_REF
|| TREE_CODE (x) == COMPONENT_REF)
x = TREE_OPERAND (x, 1); x = TREE_OPERAND (x, 1);
if (BASELINK_P (x)) if (BASELINK_P (x))
x = BASELINK_FUNCTIONS (x); x = BASELINK_FUNCTIONS (x);
...@@ -880,6 +881,8 @@ get_first_fn (tree from) ...@@ -880,6 +881,8 @@ get_first_fn (tree from)
{ {
gcc_assert (is_overloaded_fn (from)); gcc_assert (is_overloaded_fn (from));
/* A baselink is also considered an overloaded function. */ /* A baselink is also considered an overloaded function. */
if (TREE_CODE (from) == COMPONENT_REF)
from = TREE_OPERAND (from, 1);
if (BASELINK_P (from)) if (BASELINK_P (from))
from = BASELINK_FUNCTIONS (from); from = BASELINK_FUNCTIONS (from);
return OVL_CURRENT (from); return OVL_CURRENT (from);
......
...@@ -23,7 +23,7 @@ void Foo () { ...@@ -23,7 +23,7 @@ void Foo () {
c.f; // { dg-error "statement cannot resolve" "" } c.f; // { dg-error "statement cannot resolve" "" }
c.f<int>; // { dg-error "statement cannot resolve" "" } c.f<int>; // { dg-error "statement cannot resolve" "" }
c.g == 1; // { dg-error "invalid use of" "" } c.g == 1; // { dg-error "invalid" "" }
c.f == 1; // { dg-error "invalid use of" "" } c.f == 1; // { dg-error "invalid" "" }
c.f<int> == 1; // { dg-error "invalid use of" "" } c.f<int> == 1; // { dg-error "invalid" "" }
} }
// PR c++/26696
struct A
{
static void f() {}
};
int main()
{
A a;
a.f; // { dg-warning "not call" }
}
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