2014-01-07 11:57:02 +01:00
//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
2013-08-15 23:10:40 +02:00
// RUN: cat %s | %cling -Xclang -verify | FileCheck %s
2013-08-14 20:36:33 +02:00
//This file checks a call instruction. The called function has arguments with nonnull attribute.
# include <string.h>
2013-09-13 15:21:13 +02:00
// XFAIL: darwin
2013-08-16 19:44:35 +02:00
2013-08-15 23:10:40 +02:00
char * p = 0 ;
2014-04-01 16:52:35 +02:00
strcmp ( " a " , p ) ; // expected-warning {{null passed to a callee which requires a non-null argument}}
2013-08-15 23:10:40 +02:00
2014-04-01 16:52:35 +02:00
strcmp ( p , " a " ) ; // expected-warning {{null passed to a callee which requires a non-null argument}}
2013-08-15 23:10:40 +02:00
extern " C " int printf ( const char * fmt , . . . ) ;
. rawInput 1
extern " C " int cannotCallWithNull ( int * p = 0 ) ;
extern " C " int cannotCallWithNull ( int * p ) __attribute__ ( ( nonnull ( 1 ) ) ) ;
extern " C " int cannotCallWithNull ( int * p ) ;
extern " C " int cannotCallWithNull ( int * p ) ;
. rawInput 0
extern " C " int cannotCallWithNull ( int * p ) {
if ( ! p )
printf ( " Must not be called with p=0. \n " ) ;
return 1 ;
}
2013-09-09 15:32:53 +02:00
int * q = 0 ;
2013-10-03 09:47:06 +02:00
cannotCallWithNull ( q ) ; // expected-warning {{null passed to a callee which requires a non-null argument}}
2013-08-15 23:10:40 +02:00
//CHECK-NOT: Must not be called with p=0.
2013-08-16 22:47:00 +02:00
cannotCallWithNull ( new int ( 4 ) )
2013-08-15 23:10:40 +02:00
//CHECK: (int) 1
2013-08-14 20:36:33 +02:00
. q