2012-10-17 02:53:14 +08:00
// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors %s
2013-05-08 03:54:28 +08:00
// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -x objective-c++ %s
2008-10-05 08:06:24 +08:00
void f ( ) {
int a ;
struct S { int m ; } ;
typedef S * T ;
// Expressions.
T ( a ) - > m = 7 ;
2010-12-04 11:47:34 +08:00
int ( a ) + + ; // expected-error {{assignment to cast is illegal}}
__extension__ int ( a ) + + ; // expected-error {{assignment to cast is illegal}}
2010-09-09 05:40:08 +08:00
__typeof ( int ) ( a , 5 ) < < a ; // expected-error {{excess elements in scalar initializer}}
2010-03-12 15:11:26 +08:00
void ( a ) , + + a ;
2008-10-05 23:03:47 +08:00
if ( int ( a ) + 1 ) { }
2010-09-20 07:03:35 +08:00
for ( int ( a ) + 1 ; ; ) { } // expected-warning {{expression result unused}}
2008-10-06 03:56:22 +08:00
a = sizeof ( int ( ) + 1 ) ;
2008-10-06 05:10:08 +08:00
a = sizeof ( int ( 1 ) ) ;
2009-04-28 11:59:15 +08:00
typeof ( int ( ) + 1 ) a2 ; // expected-error {{extension used}}
2010-09-20 07:03:35 +08:00
( int ( 1 ) ) ; // expected-warning {{expression result unused}}
2008-10-06 05:10:08 +08:00
// type-id
2009-07-25 23:41:38 +08:00
( int ( ) ) 1 ; // expected-error {{C-style cast from 'int' to 'int ()' is not allowed}}
2008-10-05 08:06:24 +08:00
// Declarations.
2012-07-31 05:30:52 +08:00
int fd ( T ( a ) ) ; // expected-warning {{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}}
T ( * d ) ( int ( p ) ) ; // expected-note {{previous}}
typedef T td ( int ( p ) ) ;
extern T tp ( int ( p ) ) ;
Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
another declarator and ended with a comma, then that comma was probably a
typo for a semicolon:
int n = 0, m = 1, l = 2, // k = 5;
myImportantFunctionCall(); // oops!
- If removing the parentheses would correctly initialize the object, then
produce a note suggesting that fix.
- Otherwise, if there is a simple initializer we can suggest which performs
value-initialization, then provide a note suggesting a correction to that
initializer.
Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.
llvm-svn: 148072
2012-01-13 07:53:29 +08:00
T d3 ( ) ; // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
2012-01-10 02:30:34 +08:00
T d3v ( void ) ;
2012-01-06 10:30:50 +08:00
typedef T d3t ( ) ;
extern T f3 ( ) ;
Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
another declarator and ended with a comma, then that comma was probably a
typo for a semicolon:
int n = 0, m = 1, l = 2, // k = 5;
myImportantFunctionCall(); // oops!
- If removing the parentheses would correctly initialize the object, then
produce a note suggesting that fix.
- Otherwise, if there is a simple initializer we can suggest which performs
value-initialization, then provide a note suggesting a correction to that
initializer.
Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.
llvm-svn: 148072
2012-01-13 07:53:29 +08:00
__typeof ( * T ( ) ) f4 ( ) ; // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
2012-01-10 02:30:34 +08:00
typedef void * V ;
2014-05-08 05:53:27 +08:00
__typeof ( * V ( ) ) f5 ( ) ; // expected-error {{ISO C++ does not allow indirection on operand of type 'V' (aka 'void *')}}
2012-01-10 02:30:34 +08:00
T multi1 ,
Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
another declarator and ended with a comma, then that comma was probably a
typo for a semicolon:
int n = 0, m = 1, l = 2, // k = 5;
myImportantFunctionCall(); // oops!
- If removing the parentheses would correctly initialize the object, then
produce a note suggesting that fix.
- Otherwise, if there is a simple initializer we can suggest which performs
value-initialization, then provide a note suggesting a correction to that
initializer.
Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.
llvm-svn: 148072
2012-01-13 07:53:29 +08:00
multi2 ( ) ; // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
2008-12-18 00:19:15 +08:00
T ( d ) [ 5 ] ; // expected-error {{redefinition of 'd'}}
2009-04-28 11:59:15 +08:00
typeof ( int [ ] ) ( f ) = { 1 , 2 } ; // expected-error {{extension used}}
2008-10-05 08:06:24 +08:00
void ( b ) ( int ) ;
2012-01-05 12:12:21 +08:00
int ( d2 ) __attribute__ ( ( ) ) ;
2008-10-05 23:19:49 +08:00
if ( int ( a ) = 1 ) { }
2008-12-18 00:19:15 +08:00
int ( d3 ( int ( ) ) ) ;
2008-10-05 08:06:24 +08:00
}
2008-10-06 05:10:08 +08:00
Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
another declarator and ended with a comma, then that comma was probably a
typo for a semicolon:
int n = 0, m = 1, l = 2, // k = 5;
myImportantFunctionCall(); // oops!
- If removing the parentheses would correctly initialize the object, then
produce a note suggesting that fix.
- Otherwise, if there is a simple initializer we can suggest which performs
value-initialization, then provide a note suggesting a correction to that
initializer.
Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.
llvm-svn: 148072
2012-01-13 07:53:29 +08:00
struct RAII {
RAII ( ) ;
~ RAII ( ) ;
} ;
void func ( ) ;
2012-07-31 05:42:05 +08:00
void func2 ( short ) ;
Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
another declarator and ended with a comma, then that comma was probably a
typo for a semicolon:
int n = 0, m = 1, l = 2, // k = 5;
myImportantFunctionCall(); // oops!
- If removing the parentheses would correctly initialize the object, then
produce a note suggesting that fix.
- Otherwise, if there is a simple initializer we can suggest which performs
value-initialization, then provide a note suggesting a correction to that
initializer.
Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.
llvm-svn: 148072
2012-01-13 07:53:29 +08:00
namespace N {
2012-01-13 10:14:39 +08:00
struct S ;
Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
another declarator and ended with a comma, then that comma was probably a
typo for a semicolon:
int n = 0, m = 1, l = 2, // k = 5;
myImportantFunctionCall(); // oops!
- If removing the parentheses would correctly initialize the object, then
produce a note suggesting that fix.
- Otherwise, if there is a simple initializer we can suggest which performs
value-initialization, then provide a note suggesting a correction to that
initializer.
Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.
llvm-svn: 148072
2012-01-13 07:53:29 +08:00
void emptyParens ( ) {
RAII raii ( ) ; // expected-warning {{function declaration}} expected-note {{remove parentheses to declare a variable}}
int a , b , c , d , e , // expected-note {{change this ',' to a ';' to call 'func'}}
func ( ) ; // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
2012-01-13 10:14:39 +08:00
S s ( ) ; // expected-warning {{function declaration}}
Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
another declarator and ended with a comma, then that comma was probably a
typo for a semicolon:
int n = 0, m = 1, l = 2, // k = 5;
myImportantFunctionCall(); // oops!
- If removing the parentheses would correctly initialize the object, then
produce a note suggesting that fix.
- Otherwise, if there is a simple initializer we can suggest which performs
value-initialization, then provide a note suggesting a correction to that
initializer.
Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.
llvm-svn: 148072
2012-01-13 07:53:29 +08:00
}
2012-07-31 05:42:05 +08:00
void nonEmptyParens ( ) {
int f = 0 , // g = 0; expected-note {{change this ',' to a ';' to call 'func2'}}
func2 ( short ( f ) ) ; // expected-warning {{function declaration}} expected-note {{add a pair of parentheses}}
}
Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
another declarator and ended with a comma, then that comma was probably a
typo for a semicolon:
int n = 0, m = 1, l = 2, // k = 5;
myImportantFunctionCall(); // oops!
- If removing the parentheses would correctly initialize the object, then
produce a note suggesting that fix.
- Otherwise, if there is a simple initializer we can suggest which performs
value-initialization, then provide a note suggesting a correction to that
initializer.
Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.
llvm-svn: 148072
2012-01-13 07:53:29 +08:00
}
2008-10-06 05:10:08 +08:00
class C { } ;
2009-02-04 08:32:51 +08:00
void fn ( int ( C ) ) { } // void fn(int(*fp)(C c)) { } expected-note{{candidate function}}
2008-10-06 05:10:08 +08:00
// not: void fn(int C);
int g ( C ) ;
void foo ( ) {
2009-02-04 08:32:51 +08:00
fn ( 1 ) ; // expected-error {{no matching function}}
2008-10-06 05:10:08 +08:00
fn ( g ) ; // OK
}
2012-05-02 08:11:40 +08:00
namespace PR11874 {
void foo ( ) ; // expected-note 3 {{class 'foo' is hidden by a non-type declaration of 'foo' here}}
class foo { } ;
class bar {
bar ( ) {
const foo * f1 = 0 ; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
foo * f2 = 0 ; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
foo f3 ; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
}
} ;
int baz ; // expected-note 2 {{class 'baz' is hidden by a non-type declaration of 'baz' here}}
class baz { } ;
void fizbin ( ) {
const baz * b1 = 0 ; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}}
baz * b2 ; // expected-error {{use of undeclared identifier 'b2'}}
baz b3 ; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}}
}
}