1 // RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -pedantic-errors -triple x86_64-linux-gnu %s
3 // Make sure we know these are legitimate commas and not typos for ';'.
13 auto f() -> struct S {
20 class ExtraSemiAfterMemFn {
21 // Due to a peculiarity in the C++11 grammar, a deleted or defaulted function
22 // is permitted to be followed by either one or two semicolons.
23 void f() = delete // expected-error {{expected ';' after delete}}
24 void g() = delete; // ok
25 void h() = delete;; // ok
26 void i() = delete;;; // expected-error {{extra ';' after member function definition}}
29 int *const const p = 0; // expected-error {{duplicate 'const' declaration specifier}}
30 const const int *q = 0; // expected-error {{duplicate 'const' declaration specifier}}
33 void f() const const; // expected-error {{duplicate 'const' declaration specifier}}
36 static_assert(something, ""); // expected-error {{undeclared identifier}}
40 typedef void d() = default; // expected-error {{function definition declared 'typedef'}} expected-error {{only special member functions may be defaulted}}
43 using PR14855 = int S::; // expected-error {{expected ';' after alias declaration}}
45 // Ensure that 'this' has a const-qualified type in a trailing return type for
46 // a constexpr function.
47 struct ConstexprTrailingReturn {
49 constexpr auto f() const -> decltype((n));
51 constexpr const int &ConstexprTrailingReturn::f() const { return n; }
53 namespace TestIsValidAfterTypeSpecifier {
78 using T = int (*f)(); // expected-error {{type-id cannot have a name}}
79 template<typename T> using U = int (*f)(); // expected-error {{type-id cannot have a name}}
80 auto f() -> int (*f)(); // expected-error {{type-id cannot have a name}}
81 auto g = []() -> int (*f)() {}; // expected-error {{type-id cannot have a name}}
84 namespace FinalOverride {
91 struct Derived : Base {
92 virtual auto f() -> void *final;
93 virtual auto g() -> void *override;
94 virtual auto h() -> void *final override;
95 virtual auto i() -> void *override final;
99 namespace UsingDeclAttrs {
100 using T __attribute__((aligned(1))) = int;
101 using T [[gnu::aligned(1)]] = int;
102 static_assert(alignof(T) == 1, "");
104 using [[gnu::aligned(1)]] T = int; // expected-error {{an attribute list cannot appear here}}
105 using T = int [[gnu::aligned(1)]]; // expected-error {{'aligned' attribute cannot be applied to types}}
108 namespace DuplicateSpecifier {
109 constexpr constexpr int f(); // expected-warning {{duplicate 'constexpr' declaration specifier}}
110 constexpr int constexpr a = 0; // expected-warning {{duplicate 'constexpr' declaration specifier}}
113 friend constexpr int constexpr friend f(); // expected-warning {{duplicate 'friend' declaration specifier}} \
114 // expected-warning {{duplicate 'constexpr' declaration specifier}}
115 friend struct A friend; // expected-warning {{duplicate 'friend'}} expected-error {{'friend' must appear first}}
119 namespace ColonColonDecltype {
120 struct S { struct T {}; };
121 ::decltype(S())::T invalid; // expected-error {{expected unqualified-id}}
124 struct Base { virtual void f() = 0; virtual void g() = 0; virtual void h() = 0; };
125 struct MemberComponentOrder : Base {
126 void f() override __asm__("foobar") __attribute__(( )) {}
127 void g() __attribute__(( )) override;
128 void h() __attribute__(( )) override {}
131 void NoMissingSemicolonHere(struct S
133 template<int ...N> void NoMissingSemicolonHereEither(struct S
136 // This must be at the end of the file; we used to look ahead past the EOF token here.
137 // expected-error@+1 {{expected unqualified-id}}