p4-0x.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
  2. void f() {
  3. int b;
  4. int arr[] = {1, 2, 3};
  5. if (bool b = true) // expected-note 2{{previous definition}}
  6. bool b; // expected-error {{redefinition}}
  7. else
  8. int b; // expected-error {{redefinition}}
  9. while (bool b = true) // expected-note {{previous definition}}
  10. int b; // expected-error {{redefinition}}
  11. for (int c; // expected-note 2{{previous definition}}
  12. bool c = true;) // expected-error {{redefinition}}
  13. double c; // expected-error {{redefinition}}
  14. switch (int n = 37 + 5) // expected-note {{previous definition}}
  15. int n; // expected-error {{redefinition}}
  16. for (int a : arr) // expected-note {{previous definition}}
  17. int a = 0; // expected-error {{redefinition}}
  18. if (bool b = true) { // expected-note 2{{previous definition}}
  19. int b; // expected-error {{redefinition}}
  20. } else {
  21. int b; // expected-error {{redefinition}}
  22. }
  23. while (bool b = true) { // expected-note {{previous definition}}
  24. int b; // expected-error {{redefinition}}
  25. }
  26. for (int c; // expected-note 2{{previous definition}}
  27. bool c = true;) { // expected-error {{redefinition}}
  28. double c; // expected-error {{redefinition}}
  29. }
  30. switch (int n = 37 + 5) { // expected-note {{previous definition}}
  31. int n; // expected-error {{redefinition}}
  32. }
  33. for (int &a : arr) { // expected-note {{previous definition}}
  34. int a = 0; // expected-error {{redefinition}}
  35. }
  36. if (bool b = true) {{ // expected-note {{previous definition}}
  37. bool b;
  38. }} else {
  39. int b; // expected-error {{redefinition}}
  40. }
  41. if (bool b = true) { // expected-note {{previous definition}}
  42. bool b; // expected-error {{redefinition}}
  43. } else {{
  44. int b;
  45. }}
  46. if (bool b = true) {{
  47. bool b;
  48. }} else {{
  49. int b;
  50. }}
  51. while (bool b = true) {{
  52. int b;
  53. }}
  54. for (int c; // expected-note {{previous definition}}
  55. bool c = true; ) {{ // expected-error {{redefinition}}
  56. double c;
  57. }}
  58. switch (int n = 37 + 5) {{
  59. int n;
  60. }}
  61. for (int &a : arr) {{
  62. int a = 0;
  63. }}
  64. }