1 // RUN: %clang_cc1 -verify -std=c++11 -Wno-anonymous-pack-parens %s
3 // RUN: not %clang_cc1 -x c++ -std=c++11 -fixit %t
4 // RUN: %clang_cc1 -Wall -pedantic -x c++ -std=c++11 %t
6 /* This is a test of the various code modification hints that only
9 explicit operator int(); // expected-note{{conversion to integral type}}
13 switch(A()) { // expected-error{{explicit conversion to}}
17 using ::T
= void; // expected-error {{name defined in alias declaration must be an identifier}}
18 using typename U
= void; // expected-error {{name defined in alias declaration must be an identifier}}
19 using typename ::V
= void; // expected-error {{name defined in alias declaration must be an identifier}}
21 namespace SemiCommaTypo
{
23 n
[[]], // expected-error {{expected ';' at end of declaration}}
27 virtual void f2(), f3();
29 struct MemberDeclarator
: Base
{
31 //[[]] : 1, FIXME: test this once we support attributes here
32 : 9, // expected-error {{expected ';' at end of declaration}}
33 char c
, // expected-error {{expected ';' at end of declaration}}
34 typedef void F(), // expected-error {{expected ';' at end of declaration}}
37 f3 override
, // expected-error {{expected ';' at end of declaration}}
41 namespace ScopedEnum
{
44 enum class E b
= E::a
; // expected-error {{must use 'enum' not 'enum class'}}
46 friend enum class E
; // expected-error {{must use 'enum' not 'enum class'}}
56 (void)[&, &i
, &i
]{}; // expected-error 2{{'&' cannot precede a capture when the capture default is '&'}}
57 (void)[i
, i
]{ }; // expected-error{{'i' can appear only once in a capture list}}
58 (void)[&, i
, i
]{ }; // expected-error{{'i' can appear only once in a capture list}}
61 #if __cplusplus <= 202002L
62 // expected-warning@-3{{is a C++2b extension}}
63 // expected-warning@-3{{is a C++2b extension}}
66 delete []() { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
67 delete [] { return new int; }(); // expected-error{{'[]' after delete interpreted as 'delete[]'}}
71 const char *p
= "foo"bar
; // expected-error {{requires a space between}}
73 int k
= '4'ord
; // expected-error {{requires a space between}}
75 void operator"x" _y(char); // expected-error {{must be '""'}}
76 void operator L
"" _z(char); // expected-error {{encoding prefix}}
77 void operator "x" "y" U
"z" ""_whoops
"z" "y"(char); // expected-error {{must be '""'}}
85 template<typename
...Ts
> struct MisplacedEllipsis
{
86 int a(Ts
...(x
)); // expected-error {{'...' must immediately precede declared identifier}}
87 int b(Ts
...&x
); // expected-error {{'...' must immediately precede declared identifier}}
88 int c(Ts
...&); // expected-error {{'...' must be innermost component of anonymous pack declaration}}
89 int d(Ts
...(...&...)); // expected-error 2{{'...' must be innermost component of anonymous pack declaration}}
90 int e(Ts
...*[]); // expected-error {{'...' must be innermost component of anonymous pack declaration}}
91 int f(Ts
...(...*)()); // expected-error 2{{'...' must be innermost component of anonymous pack declaration}}
92 int g(Ts
...()); // ok
94 namespace TestMisplacedEllipsisRecovery
{
95 MisplacedEllipsis
<int, char> me
;
98 int ifn(); char kfn();
103 int e
= me
.e(&ip
, &kp
);
104 int f
= me
.f(ifn
, kfn
);
105 int g
= me
.g(ifn
, kfn
);
108 template<template<typename
> ...Foo
, // expected-error {{template template parameter requires 'class' after the parameter list}}
109 template<template<template<typename
>>>> // expected-error 3 {{template template parameter requires 'class' after the parameter list}}
112 template<int *ip
> struct IP
{ }; // expected-note{{declared here}}
113 IP
<0> ip0
; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
115 namespace MissingSemi
{
116 struct a
// expected-error {{expected ';' after struct}}
117 struct b
// expected-error {{expected ';' after struct}}
118 enum x
: int { x1
, x2
, x3
} // expected-error {{expected ';' after enum}}
119 struct c
// expected-error {{expected ';' after struct}}
120 enum x
: int // expected-error {{expected ';' after enum}}
121 // FIXME: The following gives a poor diagnostic (we parse the 'int' and the
122 // 'struct' as part of the same enum-base.
126 struct d
// expected-error {{expected ';' after struct}}
130 namespace NonStaticConstexpr
{
132 constexpr int i
; // expected-error {{non-static data member cannot be constexpr; did you intend to make it const?}}
133 constexpr int j
= 7; // expected-error {{non-static data member cannot be constexpr; did you intend to make it static?}}
134 constexpr const int k
; // expected-error {{non-static data member cannot be constexpr; did you intend to make it const?}}
143 int RegisterVariable() {
144 register int n
; // expected-warning {{'register' storage class specifier is deprecated}}
148 namespace MisplacedParameterPack
{
149 template <typename Args
...> // expected-error {{'...' must immediately precede declared identifier}}
150 void misplacedEllipsisInTypeParameter(Args
...);
152 template <typename
... Args
...> // expected-error {{'...' must immediately precede declared identifier}}
153 void redundantEllipsisInTypeParameter(Args
...);
155 template <template <typename
> class Args
...> // expected-error {{'...' must immediately precede declared identifier}}
156 void misplacedEllipsisInTemplateTypeParameter(Args
<int>...);
158 template <template <typename
> class... Args
...> // expected-error {{'...' must immediately precede declared identifier}}
159 void redundantEllipsisInTemplateTypeParameter(Args
<int>...);
161 template <int N
...> // expected-error {{'...' must immediately precede declared identifier}}
162 void misplacedEllipsisInNonTypeTemplateParameter();
164 template <int... N
...> // expected-error {{'...' must immediately precede declared identifier}}
165 void redundantEllipsisInNonTypeTemplateParameter();
168 namespace MisplacedDeclAndRefSpecAfterVirtSpec
{
171 virtual void f() volatile const;
174 virtual void f() override
;
175 virtual void f() override final
const volatile; // expected-error {{'const' qualifier may not appear after the virtual specifier 'final'}} expected-error {{'volatile' qualifier may not appear after the virtual specifier 'final'}}
179 virtual void f() volatile const &&;
182 virtual void f() override
&; // expected-error {{'&' qualifier may not appear after the virtual specifier 'override'}}
183 virtual void f() override final
const volatile &&; // expected-error {{'const' qualifier may not appear after the virtual specifier 'final'}} expected-error {{'volatile' qualifier may not appear after the virtual specifier 'final'}} expected-error {{'&&' qualifier may not appear after the virtual specifier 'final'}}