From 492cca24891e2927d0604e2297ab228950d889a6 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 11 Nov 2000 18:50:20 -0500 Subject: [PATCH] decl.c (maybe_commonize_var): Set DECL_UNINLINABLE for statics in inlines. * decl.c (maybe_commonize_var): Set DECL_UNINLINABLE for statics in inlines. From-SVN: r37394 --- gcc/cp/ChangeLog | 13 ++++++---- gcc/cp/decl.c | 1 + .../g++.old-deja/g++.other/comdat1-aux.cc | 10 ++++++++ .../g++.old-deja/g++.other/comdat1.C | 24 +++++++++++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/comdat1-aux.cc create mode 100644 gcc/testsuite/g++.old-deja/g++.other/comdat1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a84276e3f8b..12947e1da4c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-11-09 Jason Merrill + + * decl.c (maybe_commonize_var): Set DECL_UNINLINABLE for statics + in inlines. + 2000-11-10 Kaveh R. Ghazi * decl.c (grokdeclarator, save_function_data): Use memcpy, not bcopy. @@ -28,10 +33,10 @@ 2000-11-07 Eric Christopher - * decl.c (init_decl_processing): Change definition of - __wchar_t to wchar_t. Remove artificial declaration of - wchar_t. - * lex.c: Change instances of __wchar_t to wchar_t. + * decl.c (init_decl_processing): Change definition of + __wchar_t to wchar_t. Remove artificial declaration of + wchar_t. + * lex.c: Change instances of __wchar_t to wchar_t. 2000-11-09 Nathan Sidwell diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d23ef2f75f8..0d677febb11 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7655,6 +7655,7 @@ maybe_commonize_var (decl) inlining of such functions. */ current_function_cannot_inline = "function with static variable cannot be inline"; + DECL_UNINLINABLE (current_function_decl) = 1; /* If flag_weak, we don't need to mess with this, as we can just make the function weak, and let it refer to its unique local diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat1-aux.cc b/gcc/testsuite/g++.old-deja/g++.other/comdat1-aux.cc new file mode 100644 index 00000000000..4f5a73ca3a0 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat1-aux.cc @@ -0,0 +1,10 @@ +inline int f () +{ + static int k; + return ++k; +} + +int g () +{ + return f(); +} diff --git a/gcc/testsuite/g++.old-deja/g++.other/comdat1.C b/gcc/testsuite/g++.old-deja/g++.other/comdat1.C new file mode 100644 index 00000000000..5dd43a8c6d5 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/comdat1.C @@ -0,0 +1,24 @@ +// Test that statics in inline functions are unified between +// translation units. Currently we handle this by just suppressing +// inling and relying on unification of the function itself. + +// Special g++ Options: -O + +// Additional sources: comdat1-aux.cc + +inline int f () +{ + static int i; + return ++i; +} + +int g (); + +int main () +{ + if (f() != 1 + || g() != 2 + || f() != 3) + return 1; + return 0; +} -- 2.30.2