odr_violation2.cc 971 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <algorithm>
  2. #include "odr_header1.h"
  3. class Ordering {
  4. public:
  5. bool operator()(int a, int b) __attribute__((never_inline));
  6. };
  7. // This comment makes the line numbers in Ordering::operator() all have
  8. // two digits, which causes gold's output to be independent of which
  9. // instruction the compiler optimizes into the front of the function.
  10. bool Ordering::operator()(int a, int b) {
  11. // Optimization makes this operator() a different size than the one
  12. // in odr_violation1.cc.
  13. return a + 12345 > b / 67;
  14. }
  15. void SortDescending(int array[], int size) {
  16. std::sort(array, array + size, Ordering());
  17. }
  18. // This is weak in odr_violation1.cc.
  19. extern "C" int OverriddenCFunction(int i) {
  20. return i * i;
  21. }
  22. // This is inline in debug_msg.cc, which makes it a weak symbol too.
  23. int SometimesInlineFunction(int i) {
  24. return i * i;
  25. }
  26. // Instantiate the Derived vtable, with optimization (see Makefile.am).
  27. OdrBase* CreateOdrDerived2() {
  28. return new OdrDerived;
  29. }