blob: 6d720d36a259faacb7ec9619817deba1c05b786f [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -verify -fsyntax-only %s
Chris Lattner8129edb2009-04-12 22:23:27 +00002
3int x(*g); // expected-error {{use of undeclared identifier 'g'}}
Chris Lattner46646492009-12-07 01:36:53 +00004
Chris Lattnera69d0ed2009-12-10 02:02:58 +00005struct Type {
6 int Type;
7};
Chris Lattnera1efc8c2009-12-10 01:59:24 +00008
Argyrios Kyrtzidis4383e182010-11-16 18:18:13 +00009// rdar://8365458
10typedef char bool; // expected-error {{redeclaration of C++ built-in type 'bool'}} \
11 // expected-warning {{declaration does not declare anything}}
Chris Lattner46646492009-12-07 01:36:53 +000012
13// PR4451 - We should recover well from the typo of '::' as ':' in a2.
14namespace y {
Chris Lattner932dff72009-12-10 02:08:07 +000015 struct a { };
16 typedef int b;
Chris Lattner46646492009-12-07 01:36:53 +000017}
18
19y::a a1;
20y:a a2; // expected-error {{unexpected ':' in nested name specifier}}
21y::a a3 = a2;
22
23// Some valid colons:
24void foo() {
25y: // label
26 y::a s;
27
28 int a = 4;
29 a = a ? a : a+1;
30}
31
32struct b : y::a {};
33
34template <typename T>
35class someclass {
36
37 int bar() {
38 T *P;
39 return 1 ? P->x : P->y;
40 }
41};
Chris Lattnera1efc8c2009-12-10 01:59:24 +000042
Chris Lattnere6563252010-06-13 05:34:18 +000043class asm_class_test {
44 void foo() __asm__("baz");
45};
46
Chris Lattnera1efc8c2009-12-10 01:59:24 +000047enum { fooenum = 1 };
48
49struct a {
50 int Type : fooenum;
51};
52
Chris Lattnera69d0ed2009-12-10 02:02:58 +000053void test(struct Type *P) {
54 int Type;
55 Type = 1 ? P->Type : Type;
Chris Lattner932dff72009-12-10 02:08:07 +000056
57 Type = (y:b) 4; // expected-error {{unexpected ':' in nested name specifier}}
58 Type = 1 ? (
59 (y:b) // expected-error {{unexpected ':' in nested name specifier}}
60 4) : 5;
Daniel Dunbara5728872009-12-15 20:14:24 +000061}
Chris Lattnerae50d502010-02-02 00:43:15 +000062
63struct test4 {
64 int x // expected-error {{expected ';' at end of declaration list}}
65 int y;
66 int z // expected-error {{expected ';' at end of declaration list}}
67};
John McCall2e0a7152010-03-01 18:20:46 +000068
69// PR5825
70struct test5 {};
71::new(static_cast<void*>(0)) test5; // expected-error {{expected unqualified-id}}
Chris Lattner5c5db552010-04-05 18:18:31 +000072
73
74// PR6782
75template<class T>
76class Class1;
77
78class Class2 {
79} // no ;
80
81typedef Class1<Class2> Type1; // expected-error {{cannot combine with previous 'class' declaration specifier}}
Fariborz Jahaniand6577422010-08-16 17:58:53 +000082
83// rdar : // 8307865
84struct CodeCompleteConsumer {
85};
86
87void CodeCompleteConsumer::() { // expected-error {{xpected unqualified-id}}
88}
Chris Lattner729ad832010-11-09 20:14:26 +000089
90;
91
92// PR8380
93extern "" // expected-error {{unknown linkage language}}
94test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \
95 // expected-error {{expected ';' after top level declarator}}
96
97 int test6b;
98
99