1// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -pedantic-errors -triple x86_64-linux-gnu %s 2 3// Make sure we know these are legitimate commas and not typos for ';'. 4namespace Commas { 5 int a, 6 b [[ ]], 7 c alignas(double); 8} 9 10struct S {}; 11enum E { e, }; 12 13auto f() -> struct S { 14 return S(); 15} 16auto g() -> enum E { 17 return E(); 18} 19 20int decltype(f())::*ptr_mem_decltype; 21 22class ExtraSemiAfterMemFn { 23 // Due to a peculiarity in the C++11 grammar, a deleted or defaulted function 24 // is permitted to be followed by either one or two semicolons. 25 void f() = delete // expected-error {{expected ';' after delete}} 26 void g() = delete; // ok 27 void h() = delete;; // ok 28 void i() = delete;;; // expected-error {{extra ';' after member function definition}} 29}; 30 31int *const const p = 0; // expected-error {{duplicate 'const' declaration specifier}} 32const const int *q = 0; // expected-error {{duplicate 'const' declaration specifier}} 33 34struct MultiCV { 35 void f() const const; // expected-error {{duplicate 'const' declaration specifier}} 36}; 37 38static_assert(something, ""); // expected-error {{undeclared identifier}} 39 40// PR9903 41struct SS { 42 typedef void d() = default; // expected-error {{function definition declared 'typedef'}} expected-error {{only special member functions may be defaulted}} 43}; 44 45using PR14855 = int S::; // expected-error {{expected ';' after alias declaration}} 46 47// Ensure that 'this' has a const-qualified type in a trailing return type for 48// a constexpr function. 49struct ConstexprTrailingReturn { 50 int n; 51 constexpr auto f() const -> decltype((n)); 52}; 53constexpr const int &ConstexprTrailingReturn::f() const { return n; } 54 55namespace TestIsValidAfterTypeSpecifier { 56struct s {} v; 57 58struct s 59thread_local tl; 60 61struct s 62&r0 = v; 63 64struct s 65&&r1 = s(); 66 67struct s 68bitand r2 = v; 69 70struct s 71and r3 = s(); 72 73enum E {}; 74enum E 75[[]] e; 76 77} 78 79namespace PR5066 { 80 using T = int (*f)(); // expected-error {{type-id cannot have a name}} 81 template<typename T> using U = int (*f)(); // expected-error {{type-id cannot have a name}} 82 auto f() -> int (*f)(); // expected-error {{type-id cannot have a name}} 83 auto g = []() -> int (*f)() {}; // expected-error {{type-id cannot have a name}} 84} 85 86namespace FinalOverride { 87 struct Base { 88 virtual void *f(); 89 virtual void *g(); 90 virtual void *h(); 91 virtual void *i(); 92 }; 93 struct Derived : Base { 94 virtual auto f() -> void *final; 95 virtual auto g() -> void *override; 96 virtual auto h() -> void *final override; 97 virtual auto i() -> void *override final; 98 }; 99} 100 101namespace UsingDeclAttrs { 102 using T __attribute__((aligned(1))) = int; 103 using T [[gnu::aligned(1)]] = int; 104 static_assert(alignof(T) == 1, ""); 105 106 using [[gnu::aligned(1)]] T = int; // expected-error {{an attribute list cannot appear here}} 107 using T = int [[gnu::aligned(1)]]; // expected-error {{'aligned' attribute cannot be applied to types}} 108} 109 110namespace DuplicateSpecifier { 111 constexpr constexpr int f(); // expected-warning {{duplicate 'constexpr' declaration specifier}} 112 constexpr int constexpr a = 0; // expected-warning {{duplicate 'constexpr' declaration specifier}} 113 114 struct A { 115 friend constexpr int constexpr friend f(); // expected-warning {{duplicate 'friend' declaration specifier}} \ 116 // expected-warning {{duplicate 'constexpr' declaration specifier}} 117 friend struct A friend; // expected-warning {{duplicate 'friend'}} expected-error {{'friend' must appear first}} 118 }; 119} 120 121namespace ColonColonDecltype { 122 struct S { struct T {}; }; 123 ::decltype(S())::T invalid; // expected-error {{expected unqualified-id}} 124} 125 126struct Base { virtual void f() = 0; virtual void g() = 0; virtual void h() = 0; }; 127struct MemberComponentOrder : Base { 128 void f() override __asm__("foobar") __attribute__(( )) {} 129 void g() __attribute__(( )) override; 130 void h() __attribute__(( )) override {} 131}; 132 133void NoMissingSemicolonHere(struct S 134 [3]); 135template<int ...N> void NoMissingSemicolonHereEither(struct S 136 ... [N]); 137 138// This must be at the end of the file; we used to look ahead past the EOF token here. 139// expected-error@+1 {{expected unqualified-id}} 140using 141