missing_key_func.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh
  2. # missing_key_func.sh -- a test case for printing error messages when
  3. # a class is missing its key function.
  4. # Copyright (C) 2013-2022 Free Software Foundation, Inc.
  5. # Written by Cary Coutant <ccoutant@google.com>
  6. # This file is part of gold.
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 3 of the License, or
  10. # (at your option) any later version.
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  18. # MA 02110-1301, USA.
  19. # This file goes with debug_msg.cc, a C++ source file constructed to
  20. # have undefined references. We compile that file with debug
  21. # information and then try to link it, and make sure the proper errors
  22. # are displayed. The errors will be found in debug_msg.err.
  23. check()
  24. {
  25. if ! grep -q "$2" "$1"
  26. then
  27. echo "Did not find expected error in $1:"
  28. echo " $2"
  29. echo ""
  30. echo "Actual error output below:"
  31. cat "$1"
  32. exit 1
  33. fi
  34. }
  35. check_missing()
  36. {
  37. if grep -q "$2" "$1"
  38. then
  39. echo "Found unexpected error in $1:"
  40. echo " $2"
  41. echo ""
  42. echo "Actual error output below:"
  43. cat "$1"
  44. exit 1
  45. fi
  46. }
  47. check missing_key_func.err "error: undefined reference to 'vtable for C'"
  48. check missing_key_func.err "class is missing its key function"