From: Daniel Dunbar Date: Sat, 13 Jun 2009 06:16:36 +0000 (+0000) Subject: Add some random C++ standard tests. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb8845f3e358b8583c41ba9bdb9165670900a8e2;p=clang Add some random C++ standard tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73287 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp new file mode 100644 index 0000000000..3b0e345f01 --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp @@ -0,0 +1,11 @@ +// RUN: clang-cc -verify %s +// XFAIL + +void f0(void) { + inline void f1(); // expected-error {{'inline' is not allowed on block scope function declaration}} +} + +// FIXME: Add test for "If the inline specifier is used in a friend declaration, +// that declaration shall be a definition or the function shall have previously +// been declared inline. + diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp new file mode 100644 index 0000000000..0142dcbb05 --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp @@ -0,0 +1,7 @@ +// RUN: clang-cc -verify %s +// XFAIL + +void f0() { +} + +inline void f0(); // expected-error {{function definition cannot preceed inline declaration}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp new file mode 100644 index 0000000000..c5f0a51b22 --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp @@ -0,0 +1,13 @@ +// RUN: clang-cc -verify %s +// XFAIL + +class A { +public: + explicit A(); + + explicit operator int(); // expected-warning {{explicit conversion functions are a C++0x extension}} + + explicit void f0(); // expected-error {{'explicit' cannot only be applied to constructor or conversion function}} +}; + +explicit A::A() { } // expected-error {{'explicit' cannot be specified outside class definition}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp new file mode 100644 index 0000000000..62ae7bfded --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp @@ -0,0 +1,14 @@ +// RUN: clang-cc -verify %s +// XFAIL + +typedef const int T0; +typedef int& T1; + +struct s0 { + mutable const int f0; // expected-error{{'mutable' and 'const' cannot be mixed}} + mutable T0 f1; // expected-error{{'mutable' and 'const' cannot be mixed}} + mutable int &f2; // expected-error{{'mutable' cannot be applied to references}} + mutable T1 f3; // expected-error{{'mutable' cannot be applied to references}} + mutable struct s1 {}; // expected-error{{'mutable' cannot be applied to non-data members}} + mutable void im0(); // expected-error{{'mutable' cannot be applied to functions}} +}; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp new file mode 100644 index 0000000000..5d9f9e7a51 --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp @@ -0,0 +1,12 @@ +// RUN: clang-cc -verify %s + +struct S; // expected-note {{forward declaration of 'struct S'}} +extern S a; +extern S f(); +extern void g(S a); // expected-note {{candidate function}} + +void h() { + // FIXME: This diagnostic could be better. + g(a); // expected-error {{no matching function for call to 'g'}} + f(); // expected-error {{return type of called function ('struct S') is incomplete}} +} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp new file mode 100644 index 0000000000..867b4f03d4 --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp @@ -0,0 +1,8 @@ +// RUN: clang-cc -verify %s + +typedef struct s { int x; } s; +typedef int I; +typedef int I2; +typedef I2 I; // expected-note {{previous definition is here}} + +typedef char I; // expected-error {{typedef redefinition with different types}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp new file mode 100644 index 0000000000..f1413f9b41 --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp @@ -0,0 +1,9 @@ +// RUN: clang-cc -verify %s +// XFAIL + +struct S { + typedef struct A {} A; // expected-note {{previous definition is here}} + typedef struct B B; + typedef A A; // expected-error {{redefinition of 'A'}} +}; +