p2.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -fexceptions -verify %s
  2. void func1(int i) { // expected-note{{previous definition is here}}
  3. int i; // expected-error{{redefinition of 'i'}}
  4. }
  5. void func2(int i) try { // expected-note{{previous definition is here}}
  6. int i; // expected-error{{redefinition of 'i'}}
  7. } catch (...) {
  8. }
  9. void func3(int i) try { // expected-note {{previous definition is here}}
  10. } catch (int i) { // expected-error {{redefinition of 'i'}}
  11. }
  12. void func4(int i) try { // expected-note{{previous definition is here}}
  13. } catch (...) {
  14. int i; // expected-error{{redefinition of 'i'}}
  15. }
  16. void func5() try {
  17. int i;
  18. } catch (...) {
  19. int j = i; // expected-error{{use of undeclared identifier 'i'}}
  20. }
  21. void func6() try {
  22. } catch (int i) { // expected-note{{previous definition is here}}
  23. int i; // expected-error{{redefinition of 'i'}}
  24. }
  25. void func7() {
  26. try {
  27. } catch (int i) { // expected-note{{previous definition is here}}
  28. int i; // expected-error{{redefinition of 'i'}}
  29. }
  30. }
  31. void func8() {
  32. int i;
  33. try {
  34. int i;
  35. } catch (...) {
  36. }
  37. }
  38. void func9() {
  39. if (bool b = true)
  40. try {
  41. int b; // FIXME: this probably should be invalid, maybe
  42. } catch (...) {
  43. }
  44. }
  45. void func10() {
  46. if (bool b = true)
  47. if (true) {
  48. int b; // FIXME: decide whether this is valid
  49. }
  50. }
  51. void func11(int a) {
  52. try {
  53. } catch (int a) { // OK
  54. }
  55. }