Skip to content

Commit

Permalink
PR c++/28991
Browse files Browse the repository at this point in the history
	* cp-objcp-common.c (cxx_staticp): New function.
	* cp-objcp-common.h (LANG_HOOOKS_STATICP): Use it.
	* cp-tree.h (cxx_staticp): New function.
	PR c++/289991
	* g++.dg/init/static3.C: New test.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116838 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
mmitchel committed Sep 11, 2006
1 parent 239f44d commit dd4df4a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gcc/cp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2006-09-10 Mark Mitchell <[email protected]>

PR c++/28991
* cp-objcp-common.c (cxx_staticp): New function.
* cp-objcp-common.h (LANG_HOOOKS_STATICP): Use it.
* cp-tree.h (cxx_staticp): New function.

2006-09-09 Jason Merrill <[email protected]>

PR c++/28996
Expand Down
15 changes: 15 additions & 0 deletions gcc/cp/cp-objcp-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,21 @@ cxx_types_compatible_p (tree x, tree y)
return 0;
}

tree
cxx_staticp (tree arg)
{
switch (TREE_CODE (arg))
{
case BASELINK:
return staticp (BASELINK_FUNCTIONS (arg));

default:
break;
}

return NULL_TREE;
}

/* Stubs to keep c-opts.c happy. */
void
push_file_scope (void)
Expand Down
2 changes: 2 additions & 0 deletions gcc/cp/cp-objcp-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t,
#define LANG_HOOKS_EXPAND_DECL c_expand_decl
#undef LANG_HOOKS_PARSE_FILE
#define LANG_HOOKS_PARSE_FILE c_common_parse_file
#undef LANG_HOOKS_STATICP
#define LANG_HOOKS_STATICP cxx_staticp
#undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL cxx_dup_lang_specific_decl
#undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
Expand Down
1 change: 1 addition & 0 deletions gcc/cp/cp-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4519,6 +4519,7 @@ extern bool cp_var_mod_type_p (tree, tree);
extern void cxx_initialize_diagnostics (struct diagnostic_context *);
extern int cxx_types_compatible_p (tree, tree);
extern void init_shadowed_var_for_decl (void);
extern tree cxx_staticp (tree);

/* in cp-gimplify.c */
extern int cp_gimplify_expr (tree *, tree *, tree *);
Expand Down
5 changes: 5 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2006-09-10 Mark Mitchell <[email protected]>

PR c++/28991
* g++.dg/init/static3.C: New test.

2006-09-10 Andrew Pinski <[email protected]>

PR testsuite/29007
Expand Down
26 changes: 26 additions & 0 deletions gcc/testsuite/g++.dg/init/static3.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// { dg-do run }

struct T
{
static void (*handler)();
static void func() {};
};

bool fail;

struct S {
S() {
if (T::handler != T::func)
fail = true;
}
};

static S s;

void (*T::handler)() = func;

int main()
{
if (fail)
return 1;
}

0 comments on commit dd4df4a

Please sign in to comment.