2012-01-05 12:12:21 +08:00
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic-errors %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.
2008-10-16 07:21:32 +08:00
int fd ( T ( a ) ) ; // expected-warning {{parentheses were disambiguated as a function declarator}}
2008-12-18 00:19:15 +08:00
T ( * d ) ( int ( p ) ) ; // expected-warning {{parentheses were disambiguated as a function declarator}} expected-note {{previous definition is here}}
2012-01-05 12:12:21 +08:00
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 ;
__typeof ( * V ( ) ) f5 ( ) ;
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 ( ) ;
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
}
}
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
}