aboutsummaryrefslogtreecommitdiff
path: root/test/Parser/cxx0x-decl.cpp
blob: b9441fd6813cb3e2581aa0b5d5b67ed67904ced4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -pedantic-errors %s

// Make sure we know these are legitimate commas and not typos for ';'.
namespace Commas {
  int a,
  b [[ ]],
  c alignas(double);
}

struct S {};
enum E { e, };

auto f() -> struct S {
  return S();
}
auto g() -> enum E {
  return E();
}

class ExtraSemiAfterMemFn {
  // Due to a peculiarity in the C++11 grammar, a deleted or defaulted function
  // is permitted to be followed by either one or two semicolons.
  void f() = delete // expected-error {{expected ';' after delete}}
  void g() = delete; // ok
  void h() = delete;; // ok
  void i() = delete;;; // expected-error {{extra ';' after member function definition}}
};

int *const const p = 0; // expected-error {{duplicate 'const' declaration specifier}}
const const int *q = 0; // expected-error {{duplicate 'const' declaration specifier}}

struct MultiCV {
  void f() const const; // expected-error {{duplicate 'const' declaration specifier}}
};

static_assert(something, ""); // expected-error {{undeclared identifier}}

// PR9903
struct SS {
  typedef void d() = default; // expected-error {{function definition declared 'typedef'}} expected-error {{only special member functions may be defaulted}}
};

using PR14855 = int S::; // expected-error {{expected ';' after alias declaration}}

// Ensure that 'this' has a const-qualified type in a trailing return type for
// a constexpr function.
struct ConstexprTrailingReturn {
  int n;
  constexpr auto f() -> decltype((n));
};
constexpr const int &ConstexprTrailingReturn::f() const { return n; }

namespace TestIsValidAfterTypeSpecifier {
struct s {} v;

// FIXME: We should accept this once we support thread_local.
struct s
thread_local tl; // expected-error {{expected unqualified-id}}

struct s
&r0 = v;

struct s
&&r1 = s();

struct s
bitand r2 = v;

struct s
and r3 = s();

enum E {};
enum E
[[]] e;

}