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