cxx-stmt.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
  2. void f1()
  3. {
  4. try {
  5. ;
  6. } catch(int i) {
  7. ;
  8. } catch(...) {
  9. }
  10. }
  11. void f2()
  12. {
  13. try; // expected-error {{expected '{'}}
  14. try {}
  15. catch; // expected-error {{expected '('}}
  16. try {}
  17. catch (...); // expected-error {{expected '{'}}
  18. try {}
  19. catch {} // expected-error {{expected '('}}
  20. }
  21. void f3() try {
  22. } catch(...) {
  23. }
  24. struct A {
  25. int i;
  26. A(int);
  27. A(char);
  28. A() try : i(0) {} catch(...) {}
  29. void f() try {} catch(...) {}
  30. A(float) : i(0) try {} // expected-error {{expected '{' or ','}}
  31. };
  32. A::A(char) : i(0) try {} // expected-error {{expected '{' or ','}}
  33. A::A(int j) try : i(j) {} catch(...) {}
  34. // PR5740
  35. struct Type { };
  36. enum { Type } Kind;
  37. void f4() {
  38. int i = 0;
  39. switch (Kind) {
  40. case Type: i = 7; break; // no error.
  41. }
  42. }
  43. // PR5500
  44. void f5() {
  45. asm volatile ("":: :"memory");
  46. asm volatile ("": ::"memory");
  47. }
  48. int f6() {
  49. int k, // expected-note {{change this ',' to a ';' to call 'f6'}}
  50. f6(), // expected-error {{expected ';'}} expected-warning {{interpreted as a function declaration}} expected-note {{replace paren}}
  51. int n = 0, // expected-error {{expected ';'}}
  52. return f5(), // ok
  53. int(n);
  54. }