cxx0x-member-initializers.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
  2. // Make sure we don't run off the end of the stream when parsing a deferred
  3. // initializer.
  4. int a; // expected-note {{previous}}
  5. struct S {
  6. int n = 4 + ; // expected-error {{expected expression}}
  7. } a; // expected-error {{redefinition}}
  8. // Make sure we use all of the tokens.
  9. struct T {
  10. int a = 1 // expected-error {{expected ';' at end of declaration list}}
  11. int b = 2;
  12. int c = b; // expected-error {{undeclared identifier}}
  13. };
  14. // Test recovery for bad constructor initializers
  15. struct R1 {
  16. int a;
  17. R1() : a {}
  18. }; // expected-error {{expected '{' or ','}}
  19. // Test correct parsing.
  20. struct V1 {
  21. int a, b;
  22. V1() : a(), b{} {}
  23. };
  24. template <typename, typename> struct T1 { enum {V};};
  25. template <int, int> struct T2 { enum {V};};
  26. struct A {
  27. T1<int, int> a1 = T1<int, int>(), *a2 = new T1<int,int>;
  28. T2<0,0> b1 = T2<0,0>(), b2 = T2<0,0>(), b3;
  29. bool c1 = 1 < 2, c2 = 2 < 1, c3 = false;
  30. bool d1 = T1<int, T1<int, int>>::V < 3, d2;
  31. T1<int, int()> e = T1<int, int()>();
  32. };
  33. struct PR19993 {
  34. static int n = delete; // expected-error {{only functions can have deleted definitions}}
  35. };