summaryrefslogtreecommitdiffstats
path: root/test/Parser/cxx0x-attributes.cpp
blob: a66e3e0597666f842ae72f8d51868a76518004fe (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
// RUN: clang-cc -fsyntax-only -verify -std=c++0x %s

// Declaration syntax checks
[[]] int before_attr;
int after_attr [[]];
int * [[]] ptr_attr;
int array_attr [1] [[]];
[[align(8)]] int aligned_attr;
[[test::valid(for 42 [very] **** '+' symbols went on a trip; the end.)]]
  int garbage_attr;
void fn_attr () [[]];
class [[]] class_attr {};
extern "C++" [[]] int extern_attr;
template <typename T> [[]] void template_attr ();

int comma_attr [[,]]; // expected-error {{expected identifier}}
int scope_attr [[foo::]]; // expected-error {{expected identifier}}
int & [[]] ref_attr = after_attr; // expected-error {{an attribute list cannot appear here}}
class foo {
  void after_const_attr () const [[]]; // expected-error {{expected expression}}
};
extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}}
[[]] template <typename T> void before_template_attr (); // expected-error {{an attribute list cannot appear here}}
[[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}}
[[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
[[]] asm(""); // expected-error {{an attribute list cannot appear here}}

[[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
[[]] using namespace ns;

// Argument tests
[[final()]] int final_params; // expected-error {{C++0x attribute 'final' cannot have an argument list}}
[[align]] int aligned_no_params; // expected-error {{C++0x attribute 'align' must have an argument list}}
[[align(i)]] int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}}

// Statement tests
void foo () {
  [[]] ;
  [[]] { }
  [[]] if (0) { }
  [[]] for (;;);
  [[]] do {
    [[]] continue;
  } while (0);
  [[]] while (0);
  
  [[]] switch (i) {
    [[]] case 0:
    [[]] default:
      [[]] break;
  }
  
  [[]] goto there;
  [[]] there:
  
  [[]] try {
  } [[]] catch (...) { // expected-error {{an attribute list cannot appear here}}
  }
  
  [[]] return;
}
OpenPOWER on IntegriCloud