2012-01-05 08:12:21 +04:00
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic-errors %s
2008-10-05 04:06:24 +04:00
void f ( ) {
int a ;
struct S { int m ; } ;
typedef S * T ;
// Expressions.
T ( a ) - > m = 7 ;
2010-12-04 06:47:34 +03:00
int ( a ) + + ; // expected-error {{assignment to cast is illegal}}
__extension__ int ( a ) + + ; // expected-error {{assignment to cast is illegal}}
2010-09-09 01:40:08 +04:00
__typeof ( int ) ( a , 5 ) < < a ; // expected-error {{excess elements in scalar initializer}}
2010-03-12 10:11:26 +03:00
void ( a ) , + + a ;
2008-10-05 19:03:47 +04:00
if ( int ( a ) + 1 ) { }
2010-09-20 03:03:35 +04:00
for ( int ( a ) + 1 ; ; ) { } // expected-warning {{expression result unused}}
2008-10-05 23:56:22 +04:00
a = sizeof ( int ( ) + 1 ) ;
2008-10-06 01:10:08 +04:00
a = sizeof ( int ( 1 ) ) ;
2009-04-28 07:59:15 +04:00
typeof ( int ( ) + 1 ) a2 ; // expected-error {{extension used}}
2010-09-20 03:03:35 +04:00
( int ( 1 ) ) ; // expected-warning {{expression result unused}}
2008-10-06 01:10:08 +04:00
// type-id
2009-07-25 19:41:38 +04:00
( int ( ) ) 1 ; // expected-error {{C-style cast from 'int' to 'int ()' is not allowed}}
2008-10-05 04:06:24 +04:00
// Declarations.
2012-07-31 01:30:52 +04: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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148072 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-13 03:53:29 +04:00
T d3 ( ) ; // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
2012-01-09 22:30:34 +04:00
T d3v ( void ) ;
2012-01-06 06:30:50 +04: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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148072 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-13 03:53:29 +04:00
__typeof ( * T ( ) ) f4 ( ) ; // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
2012-01-09 22:30:34 +04: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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148072 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-13 03:53:29 +04:00
multi2 ( ) ; // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
2008-12-17 19:19:15 +03:00
T ( d ) [ 5 ] ; // expected-error {{redefinition of 'd'}}
2009-04-28 07:59:15 +04:00
typeof ( int [ ] ) ( f ) = { 1 , 2 } ; // expected-error {{extension used}}
2008-10-05 04:06:24 +04:00
void ( b ) ( int ) ;
2012-01-05 08:12:21 +04:00
int ( d2 ) __attribute__ ( ( ) ) ;
2008-10-05 19:19:49 +04:00
if ( int ( a ) = 1 ) { }
2008-12-17 19:19:15 +03:00
int ( d3 ( int ( ) ) ) ;
2008-10-05 04:06:24 +04:00
}
2008-10-06 01:10:08 +04: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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148072 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-13 03:53:29 +04:00
struct RAII {
RAII ( ) ;
~ RAII ( ) ;
} ;
void func ( ) ;
2012-07-31 01:42:05 +04: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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148072 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-13 03:53:29 +04:00
namespace N {
2012-01-13 06:14:39 +04: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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148072 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-13 03:53:29 +04: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 06:14:39 +04: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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148072 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-13 03:53:29 +04:00
}
2012-07-31 01:42:05 +04: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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148072 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-13 03:53:29 +04:00
}
2008-10-06 01:10:08 +04:00
class C { } ;
2009-02-04 03:32:51 +03:00
void fn ( int ( C ) ) { } // void fn(int(*fp)(C c)) { } expected-note{{candidate function}}
2008-10-06 01:10:08 +04:00
// not: void fn(int C);
int g ( C ) ;
void foo ( ) {
2009-02-04 03:32:51 +03:00
fn ( 1 ) ; // expected-error {{no matching function}}
2008-10-06 01:10:08 +04:00
fn ( g ) ; // OK
}
2012-05-02 04:11:40 +04: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}}
}
}