2016-12-22 02:33:17 +08:00
// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ -std=c++98 %s
// RUN: cp %s %t-98
// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ -std=c++98 %t-98
// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ -std=c++98 %t-98
2014-09-26 05:13:02 +08:00
// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s
2016-12-22 02:33:17 +08:00
// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ -std=c++11 %s
// RUN: cp %s %t-11
// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ -std=c++11 %t-11
// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ -std=c++11 %t-11
2009-04-02 06:41:11 +08:00
/* This is a test of the various code modification hints that are
2009-04-02 11:20:30 +08:00
provided as part of warning or extension diagnostics . All of the
warnings will be fixed by - fixit , and the resulting file should
compile cleanly with - Werror - pedantic . */
2009-04-02 06:41:11 +08:00
2010-04-24 09:30:46 +08:00
struct C1 {
2009-04-02 07:51:29 +08:00
virtual void f ( ) ;
static void g ( ) ;
} ;
2009-04-02 06:41:11 +08:00
struct C2 : virtual public virtual C1 { } ; // expected-error{{duplicate}}
2009-04-02 07:51:29 +08:00
virtual void C1 : : f ( ) { } // expected-error{{'virtual' can only be specified inside the class definition}}
static void C1 : : g ( ) { } // expected-error{{'static' can only be specified inside the class definition}}
2014-04-17 11:29:33 +08:00
template < int Value > struct CT { template < typename > struct Inner ; } ; // expected-note{{previous use is here}}
2009-04-02 06:41:11 +08:00
2016-12-22 02:33:17 +08:00
// FIXME: In C++11 this gets 'expected unqualified-id' which fixit can't fix.
// Probably parses as `CT<10> > 2 > ct;` rather than `CT<(10 >> 2)> ct;`.
# if __cplusplus < 201103L
2009-04-02 06:41:11 +08:00
CT < 10 > > 2 > ct ; // expected-warning{{require parentheses}}
2016-12-22 02:33:17 +08:00
# endif
2009-04-02 07:51:29 +08:00
class C3 {
public :
C3 ( C3 , int i = 0 ) ; // expected-error{{copy constructor must pass its first argument by reference}}
} ;
struct CT < 0 > { } ; // expected-error{{'template<>'}}
2011-10-20 09:41:28 +08:00
template < > union CT < 1 > { } ; // expected-error{{tag type}}
2009-11-10 11:24:44 +08:00
2014-04-17 11:29:33 +08:00
struct CT < 2 > : : Inner < int > { } ; // expected-error 2{{'template<>'}}
2010-02-02 07:46:27 +08:00
// Access declarations
class A {
protected :
int foo ( ) ;
} ;
2009-11-10 11:24:44 +08:00
2010-02-02 07:46:27 +08:00
class B : public A {
2016-12-22 02:33:17 +08:00
# if __cplusplus >= 201103L
A : : foo ; // expected-error{{ISO C++11 does not allow access declarations}}
# else
2010-02-02 07:46:27 +08:00
A : : foo ; // expected-warning{{access declarations are deprecated}}
2016-12-22 02:33:17 +08:00
# endif
2010-02-02 07:46:27 +08:00
} ;
2010-03-24 15:14:45 +08:00
2011-10-20 09:41:28 +08:00
void f ( ) throw ( ) ; // expected-note{{previous}}
2015-09-30 08:48:50 +08:00
void f ( ) ; // expected-error{{missing exception specification}}
2010-04-15 04:27:54 +08:00
namespace rdar7853795 {
struct A {
bool getNumComponents ( ) const ; // expected-note{{declared here}}
2010-04-24 09:30:46 +08:00
void dump ( ) const {
2010-04-15 04:27:54 +08:00
getNumComponenets ( ) ; // expected-error{{use of undeclared identifier 'getNumComponenets'; did you mean 'getNumComponents'?}}
}
} ;
}
2010-09-07 22:35:10 +08:00
namespace rdar7796492 {
2012-06-12 00:06:57 +08:00
struct A { int x , y ; A ( ) ; } ;
2010-09-07 22:35:10 +08:00
A : : A ( )
: x ( 1 ) y ( 2 ) { // expected-error{{missing ',' between base or member initializers}}
}
}
2010-09-08 08:31:13 +08:00
2010-10-02 05:19:28 +08:00
// extra qualification on member
class C {
2012-09-14 04:16:20 +08:00
int C : : foo ( ) ; // expected-error {{extra qualification}}
2010-10-02 05:19:28 +08:00
} ;
2010-10-08 10:39:23 +08:00
namespace rdar8488464 {
Extend the error of invalid token after declarations to include fixits for
!=, %=, ^=, &=, *=, -=, |=, /=, <<=, <=, >=, and >>= to =.
llvm-svn: 148499
2012-01-20 06:01:51 +08:00
int x = 0 ;
int x1 & = 0 ; // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
int x2 * = 0 ; // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
int x3 + = 0 ; // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
int x4 - = 0 ; // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
int x5 ! = 0 ; // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
int x6 / = 0 ; // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
int x7 % = 0 ; // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
int x8 < = 0 ; // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
int x9 < < = 0 ; // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
int x10 > = 0 ; // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
int x11 > > = 0 ; // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
int x12 ^ = 0 ; // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
int x13 | = 0 ; // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
int x14 = = 0 ; // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
2010-10-08 10:39:23 +08:00
void f ( ) {
Extend the error of invalid token after declarations to include fixits for
!=, %=, ^=, &=, *=, -=, |=, /=, <<=, <=, >=, and >>= to =.
llvm-svn: 148499
2012-01-20 06:01:51 +08:00
int x = 0 ;
2010-10-08 10:39:23 +08:00
( void ) x ;
Extend the error of invalid token after declarations to include fixits for
!=, %=, ^=, &=, *=, -=, |=, /=, <<=, <=, >=, and >>= to =.
llvm-svn: 148499
2012-01-20 06:01:51 +08:00
int x1 & = 0 ; // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
( void ) x1 ;
int x2 * = 0 ; // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
( void ) x2 ;
int x3 + = 0 ; // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
( void ) x3 ;
int x4 - = 0 ; // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
( void ) x4 ;
int x5 ! = 0 ; // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
( void ) x5 ;
int x6 / = 0 ; // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
( void ) x6 ;
int x7 % = 0 ; // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
( void ) x7 ;
int x8 < = 0 ; // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
( void ) x8 ;
int x9 < < = 0 ; // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
( void ) x9 ;
int x10 > = 0 ; // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
( void ) x10 ;
int x11 > > = 0 ; // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
( void ) x11 ;
int x12 ^ = 0 ; // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
( void ) x12 ;
int x13 | = 0 ; // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
( void ) x13 ;
int x14 = = 0 ; // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
( void ) x14 ;
if ( int x = 0 ) { ( void ) x ; }
if ( int x1 & = 0 ) { ( void ) x1 ; } // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
if ( int x2 * = 0 ) { ( void ) x2 ; } // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
if ( int x3 + = 0 ) { ( void ) x3 ; } // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
if ( int x4 - = 0 ) { ( void ) x4 ; } // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
if ( int x5 ! = 0 ) { ( void ) x5 ; } // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
if ( int x6 / = 0 ) { ( void ) x6 ; } // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
if ( int x7 % = 0 ) { ( void ) x7 ; } // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
if ( int x8 < = 0 ) { ( void ) x8 ; } // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
if ( int x9 < < = 0 ) { ( void ) x9 ; } // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
if ( int x10 > = 0 ) { ( void ) x10 ; } // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
if ( int x11 > > = 0 ) { ( void ) x11 ; } // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
if ( int x12 ^ = 0 ) { ( void ) x12 ; } // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
if ( int x13 | = 0 ) { ( void ) x13 ; } // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
if ( int x14 = = 0 ) { ( void ) x14 ; } // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
2010-10-08 10:39:23 +08:00
}
}
2011-03-28 03:41:34 +08:00
template < class A >
class F1 {
public :
template < int B >
class Iterator {
} ;
} ;
template < class T >
class F2 {
typename F1 < T > : : /*template*/ Iterator < 0 > Mypos ; // expected-error {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
} ;
template < class T >
void f ( ) {
typename F1 < T > : : /*template*/ Iterator < 0 > Mypos ; // expected-error {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
}
2011-07-29 03:51:27 +08:00
// Tests for &/* fixits radar 7113438.
class AD { } ;
class BD : public AD { } ;
void test ( BD & br ) {
AD * aPtr ;
BD b ;
aPtr = b ; // expected-error {{assigning to 'AD *' from incompatible type 'BD'; take the address with &}}
2011-10-20 09:41:28 +08:00
aPtr = br ; // expected-error {{assigning to 'AD *' from incompatible type 'BD'; take the address with &}}
2011-07-29 03:51:27 +08:00
}
2012-02-10 19:05:11 +08:00
void foo1 ( ) const { } // expected-error {{non-member function cannot have 'const' qualifier}}
void foo2 ( ) volatile { } // expected-error {{non-member function cannot have 'volatile' qualifier}}
void foo3 ( ) const volatile { } // expected-error {{non-member function cannot have 'const volatile' qualifier}}
2011-03-28 03:41:34 +08:00
2011-10-20 05:33:05 +08:00
struct S { void f ( int , char ) ; } ;
int itsAComma ,
itsAComma2 = 0 ,
2011-10-20 09:41:28 +08:00
oopsAComma ( 42 ) , // expected-error {{expected ';' at end of declaration}}
2011-10-20 05:33:05 +08:00
AD oopsMoreCommas ( ) {
2011-10-20 09:41:28 +08:00
static int n = 0 , // expected-error {{expected ';' at end of declaration}}
2011-10-20 05:33:05 +08:00
static char c ,
2011-10-20 09:41:28 +08:00
& d = c , // expected-error {{expected ';' at end of declaration}}
S s , // expected-error {{expected ';' at end of declaration}}
2011-10-20 05:33:05 +08:00
s . f ( n , d ) ;
2011-10-20 09:41:28 +08:00
AD ad , // expected-error {{expected ';' at end of declaration}}
2011-10-20 05:33:05 +08:00
return ad ;
}
2012-01-10 06:31:44 +08:00
struct MoreAccidentalCommas {
int a : 5 ,
b : 7 ,
: 4 , // expected-error {{expected ';' at end of declaration}}
char c , // expected-error {{expected ';' at end of declaration}}
double d , // expected-error {{expected ';' at end of declaration}}
MoreAccidentalCommas * next , // expected-error {{expected ';' at end of declaration}}
public :
int k , // expected-error {{expected ';' at end of declaration}}
friend void f ( MoreAccidentalCommas ) { }
int k2 , // expected-error {{expected ';' at end of declaration}}
virtual void g ( ) , / / expected - error { { expected ' ; ' at end of declaration } }
} ;
2011-11-29 13:27:40 +08:00
2011-11-29 17:09:06 +08:00
template < class T > struct Mystery ;
template < class T > typedef Mystery < T > : : type getMysteriousThing ( ) { / / \
expected - error { { function definition declared ' typedef ' } } \
expected - error { { missing ' typename ' prior to dependent } }
return Mystery < T > : : get ( ) ;
}
2012-04-03 03:15:28 +08:00
2012-04-06 14:28:32 +08:00
template < template < typename > Foo , // expected-error {{template template parameter requires 'class' after the parameter list}}
2017-08-14 06:26:53 +08:00
template < typename > typename Bar , // expected-warning {{template template parameter using 'typename' is a C++17 extension}}
2012-04-06 14:28:32 +08:00
template < typename > struct Baz > // expected-error {{template template parameter requires 'class' after the parameter list}}
2012-04-03 03:15:28 +08:00
void func ( ) ;
2012-04-20 07:17:45 +08:00
namespace ShadowedTagType {
class Foo {
public :
enum Bar { X , Y } ;
void SetBar ( Bar bar ) ;
2012-04-28 02:26:49 +08:00
Bar Bar ( ) ; // expected-note 2 {{enum 'Bar' is hidden by a non-type declaration of 'Bar' here}}
2012-04-20 07:17:45 +08:00
private :
Bar bar_ ; // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}}
} ;
void Foo : : SetBar ( Bar bar ) { bar_ = bar ; } // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}}
2012-04-20 07:26:12 +08:00
}
2012-04-26 03:49:54 +08:00
2012-05-01 02:27:22 +08:00
# define NULL __null
char c = NULL ; // expected-warning {{implicit conversion of NULL constant to 'char'}}
2012-06-20 05:19:06 +08:00
double dbl = NULL ; // expected-warning {{implicit conversion of NULL constant to 'double'}}
2012-05-01 02:27:22 +08:00
2012-04-26 03:49:54 +08:00
namespace arrow_suggest {
template < typename T >
class wrapped_ptr {
public :
wrapped_ptr ( T * ptr ) : ptr_ ( ptr ) { }
T * operator - > ( ) { return ptr_ ; }
private :
T * ptr_ ;
} ;
class Worker {
public :
void DoSomething ( ) ;
} ;
void test ( ) {
wrapped_ptr < Worker > worker ( new Worker ) ;
worker . DoSomething ( ) ; // expected-error {{no member named 'DoSomething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}}
}
} // namespace arrow_suggest
2012-06-08 07:57:12 +08:00
// Make sure fixing namespace-qualified identifiers functions properly with
// namespace-aware typo correction/
namespace redecl_typo {
namespace Foo {
void BeEvil ( ) ; // expected-note {{'BeEvil' declared here}}
}
namespace Bar {
namespace Foo {
bool isGood ( ) ; // expected-note {{'Bar::Foo::isGood' declared here}}
void beEvil ( ) ;
}
}
bool Foo : : isGood ( ) { // expected-error {{out-of-line definition of 'isGood' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'Bar::Foo::isGood'?}}
return true ;
}
void Foo : : beEvil ( ) { } // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}}
}
2012-06-18 14:11:04 +08:00
// Test behavior when a template-id is ended by a token which starts with '>'.
namespace greatergreater {
template < typename T > struct S { S ( ) ; S ( T ) ; } ;
void f ( S < int > = 0 ) ; // expected-error {{a space is required between a right angle bracket and an equals sign (use '> =')}}
// FIXME: The fix-its here overlap so -fixit mode can't apply the second one.
//void f(S<S<int>>=S<int>());
struct Shr {
template < typename T > Shr ( T ) ;
template < typename T > void operator > > = ( T ) ;
} ;
template < template < typename > > struct TemplateTemplateParam ; // expected-error {{requires 'class'}}
template < typename T > void t ( ) ;
void g ( ) {
void ( * p ) ( ) = & t < int > ;
( void ) ( & t < int > = = p ) ; // expected-error {{use '> ='}}
( void ) ( & t < int > > = p ) ; // expected-error {{use '> >'}}
2016-12-22 02:33:17 +08:00
# if __cplusplus < 201103L
2012-06-18 14:11:04 +08:00
( void ) ( & t < S < int > > > = p ) ; // expected-error {{use '> >'}}
( Shr ) & t < S < int > > > > = p ; // expected-error {{use '> >'}}
2016-12-22 02:33:17 +08:00
# endif
2012-06-18 14:11:04 +08:00
// FIXME: We correct this to '&t<int> > >= p;' not '&t<int> >>= p;'
//(Shr)&t<int>>>=p;
// FIXME: The fix-its here overlap.
//(void)(&t<S<int>>==p);
}
}
2012-10-12 06:55:07 +08:00
class foo {
static void test ( ) {
( void ) & i ; // expected-error{{must explicitly qualify name of member function when taking its address}}
}
int i ( ) ;
} ;
2013-03-21 01:42:13 +08:00
namespace dtor_fixit {
class foo {
~ bar ( ) { } // expected-error {{expected the class name after '~' to name a destructor}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:6-[[@LINE-1]]:9}:"foo"
} ;
2014-09-06 10:06:12 +08:00
class bar {
~ bar ( ) ;
} ;
~ bar : : bar ( ) { } // expected-error {{'~' in destructor name should be after nested name specifier}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:4}:""
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:9-[[@LINE-2]]:9}:"~"
2013-03-21 01:42:13 +08:00
}
2013-07-11 13:10:21 +08:00
namespace PR5066 {
template < typename T > struct X { } ;
X < int * p > x ; // expected-error {{type-id cannot have a name}}
}
2013-07-12 06:38:30 +08:00
2013-07-13 05:43:02 +08:00
namespace PR5898 {
class A {
public :
const char * str ( ) ;
} ;
const char * foo ( A & x )
{
return x . str . ( ) ; // expected-error {{unexpected '.' in function call; perhaps remove the '.'?}}
}
bool bar ( A x , const char * y ) {
return foo - > ( x ) = = y ; // expected-error {{unexpected '->' in function call; perhaps remove the '->'?}}
}
}
2013-08-01 04:16:17 +08:00
namespace PR15045 {
class Cl0 {
public :
int a ;
} ;
int f ( ) {
Cl0 c ;
2015-04-03 06:10:06 +08:00
return c - > a ; // expected-error {{member reference type 'PR15045::Cl0' is not a pointer; did you mean to use '.'?}}
2013-08-01 04:16:17 +08:00
}
}
2014-09-26 05:13:02 +08:00
namespace curly_after_base_clause {
struct A { void f ( ) ; } ;
struct B : A // expected-error{{expected '{' after base class list}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
int i ;
} ;
struct C : A // expected-error{{expected '{' after base class list}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
using A : : f ;
} ;
struct D : A // expected-error{{expected '{' after base class list}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
protected :
} ;
struct E : A // expected-error{{expected '{' after base class list}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
template < typename T > struct inner { } ;
} ;
struct F : A // expected-error{{expected '{' after base class list}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
F ( ) { }
} ;
# if __cplusplus >= 201103L
struct G : A // expected-error{{expected '{' after base class list}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
constexpr G ( int ) { }
} ;
struct H : A // expected-error{{expected '{' after base class list}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:" {"
static_assert ( true , " " ) ;
} ;
# endif
}
2014-12-19 10:07:47 +08:00
struct conversion_operator {
conversion_operator : : * const operator int ( ) ; // expected-error {{put the complete type after 'operator'}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:32}:""
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:44-[[@LINE-2]]:44}:" conversion_operator::* const"
} ;
Move fixit for const init from note to diag, weaken to warning in MS mode.
r235046 turned "extern __declspec(selectany) int a;" from a declaration into
a definition to fix PR23242 (required for compatibility with mc.exe output).
However, this broke parsing Windows headers: A d3d11 headers contain something
like
struct SomeStruct {};
extern const __declspec(selectany) SomeStruct some_struct;
This is now a definition, and const objects either need an explicit default
ctor or an initializer so this errors out with
d3d11.h(1065,48) :
error: default initialization of an object of const type
'const CD3D11_DEFAULT' without a user-provided default constructor
(cl.exe just doesn't implement this rule, independent of selectany.)
To work around this, weaken this error into a warning for selectany decls
in microsoft mode, and recover with zero-initialization.
Doing this is a bit hairy since it adds a fixit on an error emitted
by InitializationSequence – this means it needs to build a correct AST, which
in turn means InitializationSequence::Failed() cannot return true when this
fixit is applied. As a workaround, the patch adds a fixit member to
InitializationSequence, and InitializationSequence::Perform() prints the
diagnostic if the fixit member is set right after its call to Diagnose.
That function is usually called when InitializationSequences are used –
InitListChecker::PerformEmptyInit() doesn't call it, but the InitListChecker
case never performs default-initialization, so this is technically OK.
This is the alternative, original fix for PR20208 that got reviewed in the
thread "[patch] Improve diagnostic on default-initializing const variables
(PR20208)". This change basically reverts r213725, adds the original fix for
PR20208, and makes the error a warning in Microsoft mode.
llvm-svn: 235166
2015-04-17 16:32:38 +08:00
struct const_zero_init {
int a ;
} ;
const const_zero_init czi ; // expected-error {{default initialization of an object of const type 'const const_zero_init'}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:26-[[@LINE-1]]:26}:"{}"
int use_czi = czi . a ;
2017-01-20 23:38:58 +08:00
namespace dotPointerDestructor {
struct Bar {
~ Bar ( ) ;
} ;
void bar ( Bar * o ) {
o . ~ Bar ( ) ; // expected-error {{member reference type 'dotPointerDestructor::Bar *' is a pointer; did you mean to use '->'}}
} // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:5}:"->"
}