diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2011-05-02 19:39:53 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2011-05-02 19:39:53 +0000 |
commit | 01af97d3b23bded2b2b21af19bbc6e4cce49e5b3 (patch) | |
tree | 64a10f4c4154739d4a8191d7e1b52ce497f4ebd6 /test/Parser | |
parent | c3b054d250cdca485c71845089c316e10610ebad (diff) |
Notes
Diffstat (limited to 'test/Parser')
-rw-r--r-- | test/Parser/DelayedTemplateParsing.cpp | 42 | ||||
-rw-r--r-- | test/Parser/MicrosoftExtensions.c | 2 | ||||
-rw-r--r-- | test/Parser/MicrosoftExtensions.cpp | 53 | ||||
-rw-r--r-- | test/Parser/altivec.c | 8 | ||||
-rw-r--r-- | test/Parser/attr-availability.c | 20 | ||||
-rw-r--r-- | test/Parser/c1x-generic-selection.c | 10 | ||||
-rw-r--r-- | test/Parser/cxx-casting.cpp | 34 | ||||
-rw-r--r-- | test/Parser/cxx-decl.cpp | 4 | ||||
-rw-r--r-- | test/Parser/cxx-exception-spec.cpp | 17 | ||||
-rw-r--r-- | test/Parser/cxx-member-crash.cpp | 15 | ||||
-rw-r--r-- | test/Parser/cxx-stmt.cpp | 2 | ||||
-rw-r--r-- | test/Parser/cxx-throw.cpp | 2 | ||||
-rw-r--r-- | test/Parser/cxx0x-attributes.cpp | 2 | ||||
-rw-r--r-- | test/Parser/cxx0x-override-control-keywords.cpp | 3 | ||||
-rw-r--r-- | test/Parser/expressions.c | 6 | ||||
-rw-r--r-- | test/Parser/objc-missing-impl.m | 2 | ||||
-rw-r--r-- | test/Parser/objcxx-at.mm | 15 | ||||
-rw-r--r-- | test/Parser/opencl-image-access.cl | 16 | ||||
-rw-r--r-- | test/Parser/recovery.m | 5 | ||||
-rw-r--r-- | test/Parser/selector-1.m | 26 | ||||
-rw-r--r-- | test/Parser/switch-recovery.cpp | 124 |
21 files changed, 365 insertions, 43 deletions
diff --git a/test/Parser/DelayedTemplateParsing.cpp b/test/Parser/DelayedTemplateParsing.cpp new file mode 100644 index 0000000000000..b447fff2f1c03 --- /dev/null +++ b/test/Parser/DelayedTemplateParsing.cpp @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 -fdelayed-template-parsing -fsyntax-only -verify %s + +template <class T> +class A { + void foo() { + undeclared(); + } + void foo2(); +}; + +template <class T> +class B { + void foo4() { } // expected-note {{previous definition is here}} expected-note {{previous definition is here}} + void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}} expected-note {{previous definition is here}} +}; + + +template <class T> +void B<T>::foo4() {// expected-error {{redefinition of 'foo4'}} +} + +template <class T> +void A<T>::foo2() { + undeclared(); +} + + +template <class T> +void foo3() { + undeclared(); +} + +template void A<int>::foo2(); + + +void undeclared() +{ + +} + +template <class T> void foo5() {} //expected-note {{previous definition is here}} +template <class T> void foo5() {} // expected-error {{redefinition of 'foo5'}} diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c index 9df8fa3a4e91a..2f5da5255b37f 100644 --- a/test/Parser/MicrosoftExtensions.c +++ b/test/Parser/MicrosoftExtensions.c @@ -43,7 +43,7 @@ char x = FOO(a); typedef enum E { e1 }; -
+ diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp index fd0d7d50d0eb0..32ed375889a65 100644 --- a/test/Parser/MicrosoftExtensions.cpp +++ b/test/Parser/MicrosoftExtensions.cpp @@ -95,6 +95,16 @@ void template_uuid() } +template <class T, const GUID* g = &__uuidof(T)> +class COM_CLASS_TEMPLATE { }; + +typedef COM_CLASS_TEMPLATE<struct_with_uuid, &__uuidof(struct_with_uuid)> COM_TYPE_1; +typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2; + +template <class T, const GUID& g> +class COM_CLASS_TEMPLATE_REF { }; +typedef COM_CLASS_TEMPLATE<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF; + class CtorCall { public: @@ -111,3 +121,46 @@ CtorCall& CtorCall::operator=(const CtorCall& that) } return *this; } + +template <class A> +class C1 { +public: + template <int B> + class Iterator { + }; +}; + +template<class T> +class C2 { + typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}} +}; + +template <class T> +void f(){ + typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}} +} + + + +class AAAA { }; + +template <class T> +void redundant_typename() { + typename T t;// expected-warning {{expected a qualified name after 'typename'}} + typename AAAA a;// expected-warning {{expected a qualified name after 'typename'}} + t = 3; +} + +int main() { + redundant_typename<int>(); + f<int>(); +} + + +__interface MicrosoftInterface; +__interface MicrosoftInterface { + virtual void foo1() = 0; + virtual void foo2() = 0; +}; + +__int64 x7 = __int64(0); diff --git a/test/Parser/altivec.c b/test/Parser/altivec.c index 64f82f7a563c1..d1e655213761b 100644 --- a/test/Parser/altivec.c +++ b/test/Parser/altivec.c @@ -113,9 +113,9 @@ void f() { } // bug 6895 - Vectorl literal casting confusion. -vector char v1 = (vector char)((vector int)(1, 2, 3, 4));
-vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f));
-vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd'));
-vector int v4 = (vector int)(1, 2, 3, 4);
+vector char v1 = (vector char)((vector int)(1, 2, 3, 4)); +vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f)); +vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd')); +vector int v4 = (vector int)(1, 2, 3, 4); vector float v5 = (vector float)(1.0f, 2.0f, 3.0f, 4.0f); vector char v6 = (vector char)((vector int)(1+2, -2, (int)(2.0 * 3), -(5-3))); diff --git a/test/Parser/attr-availability.c b/test/Parser/attr-availability.c new file mode 100644 index 0000000000000..269f90847d660 --- /dev/null +++ b/test/Parser/attr-availability.c @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +#if !__has_feature(attribute_availability) +# error 'availability' attribute is not available +#endif + +void f0() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); + +void f1() __attribute__((availability(macosx,deprecated=10.4,introduced=10.2,obsoleted=10.6))); + +void f2() __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6))); + +void f3() __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6,introduced=10.2))); // expected-error{{redundant 'introduced' availability change; only the last specified change will be used}} + +void f4() __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable))); + +void f5() __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable, unavailable))); // expected-error{{redundant 'unavailable' availability change; only the last specified change will be used}} + +void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{warning: 'unavailable' availability overrides all other availability information}} + diff --git a/test/Parser/c1x-generic-selection.c b/test/Parser/c1x-generic-selection.c new file mode 100644 index 0000000000000..ee23059cc4def --- /dev/null +++ b/test/Parser/c1x-generic-selection.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s + +void foo(void) { + _Generic; // expected-error {{expected '('}} + (void) _Generic(0); // expected-error {{expected ','}} + (void) _Generic(0, void); // expected-error {{expected ':'}} + (void) _Generic(0, + default: 0, // expected-note {{previous default generic association is here}} + default: 0); // expected-error {{duplicate default generic association}} +} diff --git a/test/Parser/cxx-casting.cpp b/test/Parser/cxx-casting.cpp index 98d962ad0998f..4a0bb4d1e4e54 100644 --- a/test/Parser/cxx-casting.cpp +++ b/test/Parser/cxx-casting.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only %s +// RUN: %clang_cc1 -fsyntax-only -verify %s char *const_cast_test(const char *var) { @@ -34,6 +34,36 @@ char postfix_expr_test() // This was being incorrectly tentatively parsed. namespace test1 { - template <class T> class A {}; + template <class T> class A {}; // expected-note 2{{here}} void foo() { A<int>(*(A<int>*)0); } } + +typedef char* c; +typedef A* a; +void test2(char x, struct B * b) { + (void)const_cast<::c>(&x); // expected-error{{found '<::' after a const_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} + (void)dynamic_cast<::a>(b); // expected-error{{found '<::' after a dynamic_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} + (void)reinterpret_cast<::c>(x); // expected-error{{found '<::' after a reinterpret_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} + (void)static_cast<::c>(&x); // expected-error{{found '<::' after a static_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} + + // Do not do digraph correction. + (void)static_cast<: :c>(&x); //\ + expected-error {{expected '<' after 'static_cast'}} \ + expected-error {{expected expression}}\ + expected-error {{expected ']'}}\ + expected-note {{to match this '['}} + (void)static_cast<: // expected-error {{expected '<' after 'static_cast'}} \ + expected-note {{to match this '['}} + :c>(&x); // expected-error {{expected expression}} \ + expected-error {{expected ']'}} +#define LC <: +#define C : + test1::A LC:B> c; // expected-error {{cannot refer to class template 'A' without a template argument list}} expected-error 2{{}} expected-note{{}} + (void)static_cast LC:c>(&x); // expected-error {{expected '<' after 'static_cast'}} expected-error 2{{}} expected-note{{}} + test1::A<:C B> d; // expected-error {{cannot refer to class template 'A' without a template argument list}} expected-error 2{{}} expected-note{{}} + (void)static_cast<:C c>(&x); // expected-error {{expected '<' after 'static_cast'}} expected-error 2{{}} expected-note{{}} + +#define LCC <:: + test1::A LCC B> e; // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} + (void)static_cast LCC c>(&x); // expected-error{{found '<::' after a static_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +} diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp index 6d720d36a259f..70eff973e0e1b 100644 --- a/test/Parser/cxx-decl.cpp +++ b/test/Parser/cxx-decl.cpp @@ -7,8 +7,8 @@ struct Type { }; // rdar://8365458 -typedef char bool; // expected-error {{redeclaration of C++ built-in type 'bool'}} \ - // expected-warning {{declaration does not declare anything}} +// rdar://9132143 +typedef char bool; // expected-error {{redeclaration of C++ built-in type 'bool'}} // PR4451 - We should recover well from the typo of '::' as ':' in a2. namespace y { diff --git a/test/Parser/cxx-exception-spec.cpp b/test/Parser/cxx-exception-spec.cpp deleted file mode 100644 index e6c3c757f012e..0000000000000 --- a/test/Parser/cxx-exception-spec.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only %s - -struct X { }; - -struct Y { }; - -void f() throw() { } - -void g(int) throw(X) { } - -void h() throw(X, Y) { } - -class Class { - void foo() throw (X, Y) { } -}; - -void (*fptr)() throw(); diff --git a/test/Parser/cxx-member-crash.cpp b/test/Parser/cxx-member-crash.cpp new file mode 100644 index 0000000000000..2b31a608a5837 --- /dev/null +++ b/test/Parser/cxx-member-crash.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only %s 2>&1|FileCheck %s + +// <rdar://problem/9221993> + +// We only care to chek whether the compiler crashes; the actual +// diagnostics are uninteresting. +// CHECK: 8 errors generated. +template<class _CharT> struct char_traits; +template<typename _CharT, typename _Traits = char_traits<_CharT> > class basic_ios; +template<typename _CharT, typename _Traits = char_traits<_CharT> > class ostreambuf_iterator; +template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> > class num_get; +template<typename _CharT, typename _Traits> class basic_ostream : virtual public basic_ios<_CharT, _Traits> { + template<typename _CharT, typename _InIter> _InIter num_get<_CharT, _InIter>:: _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io, ios_base::iostate& __err, string& __xtrc) const { + const bool __plus = __c == __lit[__num_base::_S_iplus]; + if ((__plus || __c == __lit[__num_base::_S_iminus]) && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) && !(__c == __lc->_M_decimal_point)) { diff --git a/test/Parser/cxx-stmt.cpp b/test/Parser/cxx-stmt.cpp index 795aca6e93c01..7677ca880128e 100644 --- a/test/Parser/cxx-stmt.cpp +++ b/test/Parser/cxx-stmt.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s void f1() { diff --git a/test/Parser/cxx-throw.cpp b/test/Parser/cxx-throw.cpp index 20b8f4b754abc..d63b6d4cae6c1 100644 --- a/test/Parser/cxx-throw.cpp +++ b/test/Parser/cxx-throw.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s int i; diff --git a/test/Parser/cxx0x-attributes.cpp b/test/Parser/cxx0x-attributes.cpp index 3147de9404181..f65e290709575 100644 --- a/test/Parser/cxx0x-attributes.cpp +++ b/test/Parser/cxx0x-attributes.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify -std=c++0x %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++0x %s // Declaration syntax checks [[]] int before_attr; diff --git a/test/Parser/cxx0x-override-control-keywords.cpp b/test/Parser/cxx0x-override-control-keywords.cpp index f959f7a9952ca..91d5132febe81 100644 --- a/test/Parser/cxx0x-override-control-keywords.cpp +++ b/test/Parser/cxx0x-override-control-keywords.cpp @@ -7,9 +7,6 @@ struct Base { struct S : Base { virtual void final() final; virtual void override() override; - virtual void n() new; - int i : 3 new; - int j new; }; struct T { diff --git a/test/Parser/expressions.c b/test/Parser/expressions.c index 6015e918a340e..0d1b6c945c5c0 100644 --- a/test/Parser/expressions.c +++ b/test/Parser/expressions.c @@ -51,3 +51,9 @@ int test6(void) { test5(1) ; // expected-error {{expected ')'}} } + +// PR8394 +void test7() { + ({} // expected-note {{to match}} + ; // expected-error {{expected ')'}} +} diff --git a/test/Parser/objc-missing-impl.m b/test/Parser/objc-missing-impl.m index 05d9d6c0b2326..e9c37ab1b1587 100644 --- a/test/Parser/objc-missing-impl.m +++ b/test/Parser/objc-missing-impl.m @@ -1,2 +1,2 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -@end // expected-warning {{@end must appear in an @implementation context}} +@end // expected-error {{@end must appear in an @implementation context}} diff --git a/test/Parser/objcxx-at.mm b/test/Parser/objcxx-at.mm new file mode 100644 index 0000000000000..37aee4dd6aa99 --- /dev/null +++ b/test/Parser/objcxx-at.mm @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +@interface B { + int i; +} +@end + +struct Z { + @defs(B); // expected-error{{@defs is not supported in Objective-C++}} +}; + +struct Y { // expected-note{{to match this '{'}} + struct X { } // expected-error{{expected ';' after struct}} + @interface A // expected-error{{unexpected '@' in member specification}} +} // expected-error{{expected '}'}} expected-error{{expected ';' after struct}} diff --git a/test/Parser/opencl-image-access.cl b/test/Parser/opencl-image-access.cl new file mode 100644 index 0000000000000..313587c1d2259 --- /dev/null +++ b/test/Parser/opencl-image-access.cl @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 %s -fsyntax-only + +typedef void* image2d_t; + +__kernel void f__ro(__read_only image2d_t a) { } + +__kernel void f__wo(__write_only image2d_t a) { } + +__kernel void f__rw(__read_write image2d_t a) { } + + +__kernel void fro(read_only image2d_t a) { } + +__kernel void fwo(write_only image2d_t a) { } + +__kernel void frw(read_write image2d_t a) { } diff --git a/test/Parser/recovery.m b/test/Parser/recovery.m new file mode 100644 index 0000000000000..e1265262b1b2b --- /dev/null +++ b/test/Parser/recovery.m @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fblocks %s + +@interface Test0 +@property (assign) id x // expected-error {{expected ';' at end of declaration list}} +@end diff --git a/test/Parser/selector-1.m b/test/Parser/selector-1.m index 0f35ce79b20fb..5ba2da9931cf8 100644 --- a/test/Parser/selector-1.m +++ b/test/Parser/selector-1.m @@ -1,14 +1,20 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s +// rdar://8366474 int main() { - SEL s = @selector(retain); - SEL s1 = @selector(meth1:); - SEL s2 = @selector(retainArgument::); - SEL s3 = @selector(retainArgument:::::); - SEL s4 = @selector(retainArgument:with:); - SEL s5 = @selector(meth1:with:with:); - SEL s6 = @selector(getEnum:enum:bool:); - SEL s7 = @selector(char:float:double:unsigned:short:long:); - - SEL s9 = @selector(:enum:bool:); + SEL s = @selector(retain); + SEL s1 = @selector(meth1:); + SEL s2 = @selector(retainArgument::); + SEL s3 = @selector(retainArgument:::::); + SEL s4 = @selector(retainArgument:with:); + SEL s5 = @selector(meth1:with:with:); + SEL s6 = @selector(getEnum:enum:bool:); + SEL s7 = @selector(char:float:double:unsigned:short:long:); + SEL s9 = @selector(:enum:bool:); + + (void) @selector(foo:); + (void) @selector(foo::); + (void) @selector(foo:::); + (void) @selector(foo::::); } diff --git a/test/Parser/switch-recovery.cpp b/test/Parser/switch-recovery.cpp index f11babc5b600f..0e4dcfa3c6370 100644 --- a/test/Parser/switch-recovery.cpp +++ b/test/Parser/switch-recovery.cpp @@ -31,4 +31,128 @@ struct B { break; } } + + int test3(int i) { + switch (i) { + case 1: return 0; + 2: return 1; // expected-error {{expected 'case' keyword before expression}} + default: return 5; + } + } }; + +int test4(int i) { + switch (i) + 1: return -1; // expected-error {{expected 'case' keyword before expression}} + return 0; +} + +int test5(int i) { + switch (i) { + case 1: case 2: case 3: return 1; + { + 4:5:6:7: return 2; // expected-error 4{{expected 'case' keyword before expression}} + } + default: return -1; + } +} + +int test6(int i) { + switch (i) { + case 1: + case 4: + // This class provides extra single colon tokens. Make sure no + // errors are seen here. + class foo{ + public: + protected: + private: + }; + case 2: + 5: // expected-error {{expected 'case' keyword before expression}} + default: return 1; + } +} + +int test7(int i) { + switch (i) { + case false ? 1 : 2: + true ? 1 : 2: // expected-error {{expected 'case' keyword before expression}} + case 10: + 14 ? 3 : 4; + default: + return 1; + } +} + +enum foo { A, B, C}; +int test8( foo x ) { + switch (x) { + A: return 0; // FIXME: give a warning for unused labels that could also be + // a case expression. + default: return 1; + } +} + +// Stress test to make sure Clang doesn't crash. +void test9(int x) { + switch(x) { + case 1: return; + 2: case; // expected-error {{expected 'case' keyword before expression}} \ + expected-error {{expected expression}} + 4:5:6: return; // expected-error 3{{expected 'case' keyword before expression}} + 7: :x; // expected-error {{expected 'case' keyword before expression}} \ + expected-error {{expected expression}} + 8:: x; // expected-error {{expected ';' after expression}} \ + expected-error {{no member named 'x' in the global namespace}} \ + expected-warning {{expression result unused}} + 9:: :y; // expected-error {{expected ';' after expression}} \ + expected-error {{expected unqualified-id}} \ + expected-warning {{expression result unused}} + :; // expected-error {{expected expression}} + ::; // expected-error {{expected unqualified-id}} + } +} + +void test10(int x) { + switch (x) { + case 1: { + struct Inner { + void g(int y) { + 2: y++; // expected-error {{expected ';' after expression}} \ + // expected-warning {{expression result unused}} + } + }; + break; + } + } +} + +template<typename T> +struct test11 { + enum { E }; + + void f(int x) { + switch (x) { + E: break; // FIXME: give a 'case' fix-it for unused labels that + // could also be an expression an a case label. + E+1: break; // expected-error {{expected 'case' keyword before expression}} + } + } +}; + +void test12(int x) { + switch (x) { + 0: // expected-error {{expected 'case' keyword before expression}} + while (x) { + 1: // expected-error {{expected 'case' keyword before expression}} + for (;x;) { + 2: // expected-error {{expected 'case' keyword before expression}} + if (x > 0) { + 3: // expected-error {{expected 'case' keyword before expression}} + --x; + } + } + } + } +} |