gcc/testsuite/g++.old-deja/g++.other/comdat1.C
raw| 1 | // { dg-do run } |
| 2 | // { dg-additional-sources " comdat1-aux.cc" } |
| 3 | // { dg-options "-O" } |
| 4 | // Test that statics in inline functions are unified between |
| 5 | // translation units. Currently we handle this by just suppressing |
| 6 | // inling and relying on unification of the function itself. |
| 7 | |
| 8 | inline int f () |
| 9 | { |
| 10 | static int i; |
| 11 | return ++i; |
| 12 | } |
| 13 | |
| 14 | int g (); |
| 15 | |
| 16 | int main () |
| 17 | { |
| 18 | if (f() != 1 |
| 19 | || g() != 2 |
| 20 | || f() != 3) |
| 21 | return 1; |
| 22 | return 0; |
| 23 | } |