2013-04-13 08:34:48 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -pedantic-errors -triple x86_64-linux-gnu %s
|
2011-10-20 05:33:05 +08:00
|
|
|
|
|
|
|
// Make sure we know these are legitimate commas and not typos for ';'.
|
|
|
|
namespace Commas {
|
|
|
|
int a,
|
|
|
|
b [[ ]],
|
|
|
|
c alignas(double);
|
|
|
|
}
|
2012-03-12 16:56:40 +08:00
|
|
|
|
|
|
|
struct S {};
|
2012-07-23 13:45:25 +08:00
|
|
|
enum E { e, };
|
2012-03-12 16:56:40 +08:00
|
|
|
|
|
|
|
auto f() -> struct S {
|
|
|
|
return S();
|
|
|
|
}
|
|
|
|
auto g() -> enum E {
|
|
|
|
return E();
|
|
|
|
}
|
2012-07-23 13:45:25 +08:00
|
|
|
|
|
|
|
class ExtraSemiAfterMemFn {
|
|
|
|
// Due to a peculiarity in the C++11 grammar, a deleted or defaulted function
|
|
|
|
// is permitted to be followed by either one or two semicolons.
|
|
|
|
void f() = delete // expected-error {{expected ';' after delete}}
|
|
|
|
void g() = delete; // ok
|
|
|
|
void h() = delete;; // ok
|
2012-10-18 07:31:46 +08:00
|
|
|
void i() = delete;;; // expected-error {{extra ';' after member function definition}}
|
2012-07-23 13:45:25 +08:00
|
|
|
};
|
2012-07-25 04:24:58 +08:00
|
|
|
|
2012-10-18 07:31:46 +08:00
|
|
|
int *const const p = 0; // expected-error {{duplicate 'const' declaration specifier}}
|
|
|
|
const const int *q = 0; // expected-error {{duplicate 'const' declaration specifier}}
|
|
|
|
|
|
|
|
struct MultiCV {
|
|
|
|
void f() const const; // expected-error {{duplicate 'const' declaration specifier}}
|
|
|
|
};
|
2012-09-14 03:12:50 +08:00
|
|
|
|
|
|
|
static_assert(something, ""); // expected-error {{undeclared identifier}}
|
2012-11-16 06:54:20 +08:00
|
|
|
|
|
|
|
// PR9903
|
|
|
|
struct SS {
|
|
|
|
typedef void d() = default; // expected-error {{function definition declared 'typedef'}} expected-error {{only special member functions may be defaulted}}
|
|
|
|
};
|
2013-01-09 06:43:49 +08:00
|
|
|
|
|
|
|
using PR14855 = int S::; // expected-error {{expected ';' after alias declaration}}
|
2013-01-14 09:55:13 +08:00
|
|
|
|
|
|
|
// Ensure that 'this' has a const-qualified type in a trailing return type for
|
|
|
|
// a constexpr function.
|
|
|
|
struct ConstexprTrailingReturn {
|
|
|
|
int n;
|
2013-04-21 09:08:50 +08:00
|
|
|
constexpr auto f() const -> decltype((n));
|
2013-01-14 09:55:13 +08:00
|
|
|
};
|
|
|
|
constexpr const int &ConstexprTrailingReturn::f() const { return n; }
|
2013-01-19 11:48:05 +08:00
|
|
|
|
|
|
|
namespace TestIsValidAfterTypeSpecifier {
|
|
|
|
struct s {} v;
|
|
|
|
|
|
|
|
struct s
|
2013-04-13 06:46:28 +08:00
|
|
|
thread_local tl;
|
2013-01-19 11:48:05 +08:00
|
|
|
|
|
|
|
struct s
|
|
|
|
&r0 = v;
|
|
|
|
|
|
|
|
struct s
|
|
|
|
&&r1 = s();
|
|
|
|
|
|
|
|
struct s
|
|
|
|
bitand r2 = v;
|
|
|
|
|
|
|
|
struct s
|
|
|
|
and r3 = s();
|
|
|
|
|
|
|
|
enum E {};
|
|
|
|
enum E
|
|
|
|
[[]] e;
|
|
|
|
|
|
|
|
}
|
2013-07-11 13:10:21 +08:00
|
|
|
|
|
|
|
namespace PR5066 {
|
|
|
|
using T = int (*f)(); // expected-error {{type-id cannot have a name}}
|
|
|
|
template<typename T> using U = int (*f)(); // expected-error {{type-id cannot have a name}}
|
|
|
|
auto f() -> int (*f)(); // expected-error {{type-id cannot have a name}}
|
|
|
|
auto g = []() -> int (*f)() {}; // expected-error {{type-id cannot have a name}}
|
|
|
|
}
|
2013-10-14 06:12:28 +08:00
|
|
|
|
|
|
|
namespace FinalOverride {
|
|
|
|
struct Base {
|
2014-10-03 17:02:53 +08:00
|
|
|
virtual void *f();
|
2013-10-14 06:12:28 +08:00
|
|
|
virtual void *g();
|
|
|
|
virtual void *h();
|
|
|
|
virtual void *i();
|
|
|
|
};
|
|
|
|
struct Derived : Base {
|
2014-10-03 17:02:53 +08:00
|
|
|
virtual auto f() -> void *final;
|
2013-10-14 06:12:28 +08:00
|
|
|
virtual auto g() -> void *override;
|
|
|
|
virtual auto h() -> void *final override;
|
|
|
|
virtual auto i() -> void *override final;
|
|
|
|
};
|
|
|
|
}
|
2013-10-24 09:21:09 +08:00
|
|
|
|
|
|
|
namespace UsingDeclAttrs {
|
|
|
|
using T __attribute__((aligned(1))) = int;
|
|
|
|
using T [[gnu::aligned(1)]] = int;
|
|
|
|
static_assert(alignof(T) == 1, "");
|
|
|
|
|
|
|
|
using [[gnu::aligned(1)]] T = int; // expected-error {{an attribute list cannot appear here}}
|
|
|
|
using T = int [[gnu::aligned(1)]]; // expected-error {{'aligned' attribute cannot be applied to types}}
|
|
|
|
}
|
2014-01-11 05:27:55 +08:00
|
|
|
|
|
|
|
namespace DuplicateSpecifier {
|
|
|
|
constexpr constexpr int f(); // expected-warning {{duplicate 'constexpr' declaration specifier}}
|
|
|
|
constexpr int constexpr a = 0; // expected-warning {{duplicate 'constexpr' declaration specifier}}
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
friend constexpr int constexpr friend f(); // expected-warning {{duplicate 'friend' declaration specifier}} \
|
|
|
|
// expected-warning {{duplicate 'constexpr' declaration specifier}}
|
|
|
|
friend struct A friend; // expected-warning {{duplicate 'friend'}} expected-error {{'friend' must appear first}}
|
|
|
|
};
|
|
|
|
}
|
2014-01-24 07:53:27 +08:00
|
|
|
|
2014-10-04 09:57:39 +08:00
|
|
|
namespace ColonColonDecltype {
|
|
|
|
struct S { struct T {}; };
|
|
|
|
::decltype(S())::T invalid; // expected-error {{expected unqualified-id}}
|
|
|
|
}
|
|
|
|
|
2014-01-24 07:53:27 +08:00
|
|
|
struct Base { virtual void f() = 0; virtual void g() = 0; virtual void h() = 0; };
|
|
|
|
struct MemberComponentOrder : Base {
|
|
|
|
void f() override __asm__("foobar") __attribute__(( )) {}
|
2014-01-25 06:34:35 +08:00
|
|
|
void g() __attribute__(( )) override;
|
|
|
|
void h() __attribute__(( )) override {}
|
2014-01-24 07:53:27 +08:00
|
|
|
};
|
2014-08-13 10:13:15 +08:00
|
|
|
|
|
|
|
void NoMissingSemicolonHere(struct S
|
|
|
|
[3]);
|
|
|
|
template<int ...N> void NoMissingSemicolonHereEither(struct S
|
|
|
|
... [N]);
|
2015-07-21 08:23:34 +08:00
|
|
|
|
|
|
|
// This must be at the end of the file; we used to look ahead past the EOF token here.
|
|
|
|
// expected-error@+1 {{expected unqualified-id}}
|
|
|
|
using
|