aboutsummaryrefslogtreecommitdiff
path: root/test/Parser
diff options
context:
space:
mode:
Diffstat (limited to 'test/Parser')
-rw-r--r--test/Parser/MicrosoftExtensions.c2
-rw-r--r--test/Parser/MicrosoftExtensions.cpp29
-rw-r--r--test/Parser/asm.c6
-rw-r--r--test/Parser/atomic.c35
-rw-r--r--test/Parser/attributes.mm25
-rw-r--r--test/Parser/c11-noreturn.c6
-rw-r--r--test/Parser/captured-statements.c14
-rw-r--r--test/Parser/crash-report.c9
-rw-r--r--test/Parser/cxx-class.cpp11
-rw-r--r--test/Parser/cxx0x-ambig.cpp22
-rw-r--r--test/Parser/cxx0x-decl.cpp7
-rw-r--r--test/Parser/missing-closing-rbrace.m3
-rw-r--r--test/Parser/objc-boxing.m8
-rw-r--r--test/Parser/objc-error-qualified-implementation.m21
-rw-r--r--test/Parser/objcxx11-initialized-temps.mm38
-rw-r--r--test/Parser/pragma-options.c12
-rw-r--r--test/Parser/pragma-pack.c14
-rw-r--r--test/Parser/prefix-attributes.m8
18 files changed, 253 insertions, 17 deletions
diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c
index 4c6f4f891d..35c63d4b55 100644
--- a/test/Parser/MicrosoftExtensions.c
+++ b/test/Parser/MicrosoftExtensions.c
@@ -6,7 +6,7 @@ void (*__fastcall fastpfunc)();
struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {}; /* expected-warning{{__declspec attribute 'novtable' is not supported}} */
extern __declspec(dllimport) void __stdcall VarR4FromDec();
__declspec(deprecated) __declspec(deprecated) char * __cdecl ltoa( long _Val, char * _DstBuf, int _Radix);
-__declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory ); /* expected-warning{{__declspec attribute 'noalias' is not supported}} expected-warning{{__declspec attribute 'restrict' is not supported}} */
+__declspec(safebuffers) __declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory ); /* expected-warning{{__declspec attribute 'safebuffers' is not supported}} expected-warning{{__declspec attribute 'noalias' is not supported}} expected-warning{{__declspec attribute 'restrict' is not supported}} */
typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR;
void * __ptr64 PtrToPtr64(const void *p)
diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp
index fd38dca194..d8a597a8cc 100644
--- a/test/Parser/MicrosoftExtensions.cpp
+++ b/test/Parser/MicrosoftExtensions.cpp
@@ -331,3 +331,32 @@ namespace Inheritance {
class __multiple_inheritance B;
class __virtual_inheritance C;
}
+
+struct StructWithProperty {
+ __declspec(property) int V0; // expected-error {{expected '(' after 'property'}}
+ __declspec(property()) int V1; // expected-error {{property does not specify a getter or a putter}}
+ __declspec(property(set)) int V2; // expected-error {{putter for property must be specified as 'put', not 'set'}} expected-error {{expected '=' after 'set'}}
+ __declspec(property(ptu)) int V3; // expected-error {{missing 'get=' or 'put='}}
+ __declspec(property(ptu=PutV)) int V4; // expected-error {{expected 'get' or 'put' in property declaration}}
+ __declspec(property(get)) int V5; // expected-error {{expected '=' after 'get'}}
+ __declspec(property(get&)) int V6; // expected-error {{expected '=' after 'get'}}
+ __declspec(property(get=)) int V7; // expected-error {{expected name of accessor method}}
+ __declspec(property(get=GetV)) int V8; // no-warning
+ __declspec(property(get=GetV=)) int V9; // expected-error {{expected ',' or ')' at end of property accessor list}}
+ __declspec(property(get=GetV,)) int V10; // expected-error {{expected 'get' or 'put' in property declaration}}
+ __declspec(property(get=GetV,put=SetV)) int V11; // no-warning
+ __declspec(property(get=GetV,put=SetV,get=GetV)) int V12; // expected-error {{property declaration specifies 'get' accessor twice}}
+
+ int GetV() { return 123; }
+ void SetV(int v) {}
+};
+void TestProperty() {
+ StructWithProperty sp;
+ sp.V8;
+ sp.V8 = 0; // expected-error {{no setter defined for property 'V8'}}
+ int i = sp.V11;
+ sp.V11 = i++;
+ sp.V11 += 8;
+ sp.V11++;
+ ++sp.V11;
+}
diff --git a/test/Parser/asm.c b/test/Parser/asm.c
index 23052c389e..b95e08bcca 100644
--- a/test/Parser/asm.c
+++ b/test/Parser/asm.c
@@ -8,6 +8,12 @@ void f1() {
void f2() {
asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}}
+
+ asm const (""); // expected-warning {{ignored const qualifier on asm}}
+ asm volatile ("");
+ asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
+ // FIXME: Once GCC supports _Atomic, check whether it allows this.
+ asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
}
diff --git a/test/Parser/atomic.c b/test/Parser/atomic.c
new file mode 100644
index 0000000000..432deeb59c
--- /dev/null
+++ b/test/Parser/atomic.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c11 %s -fsyntax-only -verify -pedantic
+
+typedef _Atomic(int) atomic_int;
+typedef _Atomic int atomic_int;
+typedef _Atomic _Atomic _Atomic(int) atomic_int; // expected-warning {{duplicate '_Atomic' declaration specifier}}
+
+typedef const int const_int;
+
+typedef const atomic_int const_atomic_int;
+typedef _Atomic const int const_atomic_int;
+typedef const _Atomic int const_atomic_int;
+typedef const _Atomic(int) const_atomic_int;
+typedef const _Atomic(_Atomic int) const_atomic_int; // expected-error {{_Atomic cannot be applied to atomic type '_Atomic(int)'}}
+typedef _Atomic const_int const_atomic_int;
+typedef _Atomic(const_int) const_atomic_int; // expected-error {{_Atomic cannot be applied to qualified type 'const_int' (aka 'const int')}}
+
+typedef int *_Atomic atomic_int_ptr;
+typedef _Atomic(int *) atomic_int_ptr;
+typedef int (*_Atomic atomic_int_ptr);
+
+typedef int _Atomic *int_atomic_ptr;
+typedef _Atomic(int) *int_atomic_ptr;
+
+typedef int int_fn();
+typedef _Atomic int_fn atomic_int_fn; // expected-error {{_Atomic cannot be applied to function type 'int_fn' (aka 'int ()')}}
+typedef _Atomic int atomic_int_array[3];
+typedef _Atomic atomic_int_array atomic_int_atomic_array; // expected-error {{_Atomic cannot be applied to array type 'atomic_int_array' (aka '_Atomic(int) [3]')}}
+
+_Atomic struct S { int n; }; // expected-warning {{'_Atomic' ignored on this declaration}}
+
+typedef _Atomic int __attribute__((address_space(1))) atomic_addr_space_int;
+typedef _Atomic(int) __attribute__((address_space(1))) atomic_addr_space_int;
+
+typedef _Atomic int __attribute__((vector_size(16))) atomic_vector_int;
+typedef _Atomic(int __attribute__((vector_size(16)))) atomic_vector_int;
diff --git a/test/Parser/attributes.mm b/test/Parser/attributes.mm
new file mode 100644
index 0000000000..d92e3d35cf
--- /dev/null
+++ b/test/Parser/attributes.mm
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
+
+__attribute__((deprecated)) @class B; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+
+__attribute__((deprecated)) @interface A @end
+__attribute__((deprecated)) @protocol P0;
+__attribute__((deprecated)) @protocol P1
+@end
+
+#define EXP __attribute__((visibility("default")))
+class EXP C {};
+EXP class C2 {}; // expected-warning {{attribute 'visibility' is ignored, place it after "class" to apply attribute to type declaration}}
+
+@interface EXP I @end // expected-error {{postfix attributes are not allowed on Objective-C directives, place them in front of '@interface'}}
+EXP @interface I2 @end
+
+@implementation EXP I @end // expected-error-re {{postfix attributes are not allowed on Objective-C directives$}}
+// FIXME: Prefix attribute recovery skips until ';'
+EXP @implementation I2 @end; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+
+@class EXP OC; // expected-error-re {{postfix attributes are not allowed on Objective-C directives$}}
+EXP @class OC2; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+
+@protocol EXP P @end // expected-error {{postfix attributes are not allowed on Objective-C directives, place them in front of '@protocol'}}
+EXP @protocol P2 @end
diff --git a/test/Parser/c11-noreturn.c b/test/Parser/c11-noreturn.c
index 7a2fe50f88..e61901dfb7 100644
--- a/test/Parser/c11-noreturn.c
+++ b/test/Parser/c11-noreturn.c
@@ -4,11 +4,15 @@
_Noreturn int f();
int _Noreturn f(); // expected-note {{previous}}
int f _Noreturn(); // expected-error {{expected ';'}} expected-error 2{{}}
-int f() _Noreturn; // expected-error {{expected ';'}} expected-warning {{does not declare anything}}
+int f() _Noreturn; // expected-error {{expected ';'}} expected-warning {{does not declare anything}} expected-error {{'_Noreturn' can only appear on functions}}
_Noreturn char c1; // expected-error {{'_Noreturn' can only appear on functions}}
char _Noreturn c2; // expected-error {{'_Noreturn' can only appear on functions}}
typedef _Noreturn int g(); // expected-error {{'_Noreturn' can only appear on functions}}
+_Noreturn int; // expected-error {{'_Noreturn' can only appear on functions}} expected-warning {{does not declare anything}}
+_Noreturn struct S; // expected-error {{'_Noreturn' can only appear on functions}}
+_Noreturn enum E { e }; // expected-error {{'_Noreturn' can only appear on functions}}
+
// CHECK-EXT: _Noreturn functions are a C11-specific feature
diff --git a/test/Parser/captured-statements.c b/test/Parser/captured-statements.c
new file mode 100644
index 0000000000..30dddb549c
--- /dev/null
+++ b/test/Parser/captured-statements.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify %s
+
+void test1()
+{
+ #pragma clang __debug captured x // expected-warning {{extra tokens at end of #pragma clang __debug captured directive}}
+ {
+ }
+}
+
+void test2()
+{
+ #pragma clang __debug captured
+ int x; // expected-error {{expected '{'}}
+}
diff --git a/test/Parser/crash-report.c b/test/Parser/crash-report.c
new file mode 100644
index 0000000000..42481aa7d0
--- /dev/null
+++ b/test/Parser/crash-report.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s 2>&1 | FileCheck %s
+// REQUIRES: crash-recovery
+
+#prag\
+ma clang __debug crash
+
+// CHECK: prag\
+// CHECK-NEXT: ma
+
diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp
index 8ed5882a28..5fac797285 100644
--- a/test/Parser/cxx-class.cpp
+++ b/test/Parser/cxx-class.cpp
@@ -88,6 +88,17 @@ namespace ctor_error {
// expected-error{{unknown type name 'UnknownType'}}
}
+namespace nns_decl {
+ struct A {
+ struct B;
+ };
+ namespace N {
+ union C;
+ }
+ struct A::B; // expected-error {{forward declaration of struct cannot have a nested name specifier}}
+ union N::C; // expected-error {{forward declaration of union cannot have a nested name specifier}}
+}
+
// PR13775: Don't assert here.
namespace PR13775 {
class bar
diff --git a/test/Parser/cxx0x-ambig.cpp b/test/Parser/cxx0x-ambig.cpp
index dac3c099fc..4c22ed3a9b 100644
--- a/test/Parser/cxx0x-ambig.cpp
+++ b/test/Parser/cxx0x-ambig.cpp
@@ -38,8 +38,8 @@ namespace bitfield {
constexpr T() {}
constexpr T(int) {}
constexpr T(T, T, T, T) {}
- constexpr T operator=(T) { return *this; }
- constexpr operator int() { return 4; }
+ constexpr T operator=(T) const { return *this; }
+ constexpr operator int() const { return 4; }
};
constexpr T a, b, c, d;
@@ -68,7 +68,7 @@ namespace bitfield {
};
struct U {
- constexpr operator T() { return T(); } // expected-note 2{{candidate}}
+ constexpr operator T() const { return T(); } // expected-note 2{{candidate}}
};
// This could be a bit-field.
struct S7 {
@@ -133,3 +133,19 @@ namespace ellipsis {
void l(int(S<int>::*...)(T)); // expected-warning {{ISO C++11 requires a parenthesized pack declaration to have a name}}
};
}
+
+namespace braced_init_list {
+ struct X {
+ void foo() {}
+ };
+
+ void (*pf1)() {};
+ void (X::*pmf1)() {&X::foo};
+ void (X::*pmf2)() = {&X::foo};
+
+ void test() {
+ void (*pf2)() {};
+ void (X::*pmf3)() {&X::foo};
+ void (X::*pmf4)() = {&X::foo};
+ }
+}
diff --git a/test/Parser/cxx0x-decl.cpp b/test/Parser/cxx0x-decl.cpp
index b9441fd681..e6cba726ab 100644
--- a/test/Parser/cxx0x-decl.cpp
+++ b/test/Parser/cxx0x-decl.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -pedantic-errors %s
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -pedantic-errors -triple x86_64-linux-gnu %s
// Make sure we know these are legitimate commas and not typos for ';'.
namespace Commas {
@@ -46,16 +46,15 @@ using PR14855 = int S::; // expected-error {{expected ';' after alias declaratio
// a constexpr function.
struct ConstexprTrailingReturn {
int n;
- constexpr auto f() -> decltype((n));
+ constexpr auto f() const -> 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}}
+thread_local tl;
struct s
&r0 = v;
diff --git a/test/Parser/missing-closing-rbrace.m b/test/Parser/missing-closing-rbrace.m
new file mode 100644
index 0000000000..d811421e48
--- /dev/null
+++ b/test/Parser/missing-closing-rbrace.m
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: //6854840
+@interface A {@end // expected-error {{'@end' appears where closing brace '}' is expected}}
diff --git a/test/Parser/objc-boxing.m b/test/Parser/objc-boxing.m
index a16a137b8f..a6bb0243cf 100644
--- a/test/Parser/objc-boxing.m
+++ b/test/Parser/objc-boxing.m
@@ -24,3 +24,11 @@ id missing_parentheses() {
return @(5; // expected-error {{expected ')'}} \
// expected-note {{to match this '('}}
}
+
+// rdar://10679157
+void bar(id p);
+void foo(id p) {
+ bar(@{p, p}); // expected-error {{expected ':'}}
+ bar(0);
+ bar(0);
+}
diff --git a/test/Parser/objc-error-qualified-implementation.m b/test/Parser/objc-error-qualified-implementation.m
new file mode 100644
index 0000000000..444fb5dab4
--- /dev/null
+++ b/test/Parser/objc-error-qualified-implementation.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-objc-root-class -verify %s
+// rdar://12233858
+
+@protocol P
+@end
+
+@interface I @end
+
+@implementation I<P> @end // expected-error {{@implementation declaration can not be protocol qualified}}
+
+@interface J < P,P >
+@end
+
+
+@implementation J < P,P > // expected-error {{@implementation declaration can not be protocol qualified}}
+@end
+
+@interface K @end
+
+@implementation K <P // expected-error {{@implementation declaration can not be protocol qualified}}
+@end // expected-error {{expected '>'}}
diff --git a/test/Parser/objcxx11-initialized-temps.mm b/test/Parser/objcxx11-initialized-temps.mm
new file mode 100644
index 0000000000..96f19fe6a5
--- /dev/null
+++ b/test/Parser/objcxx11-initialized-temps.mm
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// expected-no-diagnostics
+// rdar://12788429
+
+struct CGPoint {
+ double x;
+ double y;
+};
+typedef struct CGPoint CGPoint;
+
+struct CGSize {
+ double width;
+ double height;
+};
+typedef struct CGSize CGSize;
+
+struct CGRect {
+ CGPoint origin;
+ CGSize size;
+};
+typedef struct CGRect CGRect;
+
+typedef CGRect NSRect;
+
+void HappySetFrame(NSRect frame) {}
+
+__attribute__((objc_root_class))
+@interface NSObject @end
+
+@implementation NSObject
+- (void) sadSetFrame: (NSRect)frame {}
+
+- (void) nothing
+{
+ HappySetFrame({{0,0}, {13,14}});
+ [self sadSetFrame: {{0,0}, {13,14}}];
+}
+@end
diff --git a/test/Parser/pragma-options.c b/test/Parser/pragma-options.c
index 7844e71080..d168a2751a 100644
--- a/test/Parser/pragma-options.c
+++ b/test/Parser/pragma-options.c
@@ -20,3 +20,15 @@
#pragma align=reset
#pragma align=mac68k
#pragma align=power
+
+// PR13580
+struct S
+{
+ char a[3];
+#pragma align=packed
+ struct T
+ {
+ char b;
+ int c;
+ } d;
+};
diff --git a/test/Parser/pragma-pack.c b/test/Parser/pragma-pack.c
index 84778cd501..172a332510 100644
--- a/test/Parser/pragma-pack.c
+++ b/test/Parser/pragma-pack.c
@@ -30,3 +30,17 @@
_Pragma("pack(push)")
/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ _Pragma("pack(push,)")
+
+// PR13580
+struct S
+{
+ char a[3];
+#pragma pack(1)
+ struct T
+ {
+ char b;
+ int c;
+ } d;
+#pragma pack()
+ int e;
+};
diff --git a/test/Parser/prefix-attributes.m b/test/Parser/prefix-attributes.m
deleted file mode 100644
index 399421fd72..0000000000
--- a/test/Parser/prefix-attributes.m
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s
-
-__attribute__((deprecated)) @class B; // expected-error {{prefix attribute must be followed by an interface or protocol}}
-
-__attribute__((deprecated)) @interface A @end
-__attribute__((deprecated)) @protocol P0;
-__attribute__((deprecated)) @protocol P1
-@end