mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-11 14:25:31 +08:00
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
This commit is contained in:
parent
16ceb301d3
commit
ccbe00a43a
@ -1,3 +1,12 @@
|
||||
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>
|
||||
|
||||
PR c++/26571
|
||||
|
@ -960,6 +960,8 @@ convert_to_void (tree expr, const char *implicit)
|
||||
}
|
||||
expr = build1 (CONVERT_EXPR, void_type_node, expr);
|
||||
}
|
||||
if (! TREE_SIDE_EFFECTS (expr))
|
||||
expr = void_zero_node;
|
||||
return expr;
|
||||
}
|
||||
|
||||
|
@ -7014,8 +7014,6 @@ grokdeclarator (const cp_declarator *declarator,
|
||||
tree fns = TREE_OPERAND (decl, 0);
|
||||
|
||||
dname = fns;
|
||||
if (TREE_CODE (dname) == COMPONENT_REF)
|
||||
dname = TREE_OPERAND (dname, 1);
|
||||
if (TREE_CODE (dname) != IDENTIFIER_NODE)
|
||||
{
|
||||
gcc_assert (is_overloaded_fn (dname));
|
||||
|
@ -853,7 +853,8 @@ int
|
||||
is_overloaded_fn (tree x)
|
||||
{
|
||||
/* 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);
|
||||
if (BASELINK_P (x))
|
||||
x = BASELINK_FUNCTIONS (x);
|
||||
@ -880,6 +881,8 @@ get_first_fn (tree from)
|
||||
{
|
||||
gcc_assert (is_overloaded_fn (from));
|
||||
/* A baselink is also considered an overloaded function. */
|
||||
if (TREE_CODE (from) == COMPONENT_REF)
|
||||
from = TREE_OPERAND (from, 1);
|
||||
if (BASELINK_P (from))
|
||||
from = BASELINK_FUNCTIONS (from);
|
||||
return OVL_CURRENT (from);
|
||||
|
@ -23,7 +23,7 @@ void Foo () {
|
||||
c.f; // { dg-error "statement cannot resolve" "" }
|
||||
c.f<int>; // { dg-error "statement cannot resolve" "" }
|
||||
|
||||
c.g == 1; // { dg-error "invalid use of" "" }
|
||||
c.f == 1; // { dg-error "invalid use of" "" }
|
||||
c.f<int> == 1; // { dg-error "invalid use of" "" }
|
||||
c.g == 1; // { dg-error "invalid" "" }
|
||||
c.f == 1; // { dg-error "invalid" "" }
|
||||
c.f<int> == 1; // { dg-error "invalid" "" }
|
||||
}
|
||||
|
12
gcc/testsuite/g++.dg/warn/noeffect8.C
Normal file
12
gcc/testsuite/g++.dg/warn/noeffect8.C
Normal file
@ -0,0 +1,12 @@
|
||||
// PR c++/26696
|
||||
|
||||
struct A
|
||||
{
|
||||
static void f() {}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
A a;
|
||||
a.f; // { dg-warning "not call" }
|
||||
}
|
Loading…
Reference in New Issue
Block a user