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.
//------------------------------------------------------------------------------
2012-09-05 09:37:39 +00:00
// RUN: cat %s | %cling -I%p | FileCheck %s
// This file should be used as regression test for the meta processing subsystem
// Reproducers of fixed bugs should be put here
// PR #96277
# include "cling/Interpreter/Interpreter.h"
2014-03-09 13:53:19 +01:00
# include "cling/Interpreter/Value.h"
2012-09-05 09:37:39 +00:00
# include <stdio.h>
2019-03-16 23:24:34 +02:00
# include <iostream>
2012-09-05 09:37:39 +00:00
gCling - > declare ( " int print() { printf( \" print is run. \\ n \" ); return 1; } " ) ;
2014-03-09 13:53:19 +01:00
cling : : Value V ;
2012-09-05 09:37:39 +00:00
gCling - > process ( " int a = print(); " , & V ) ;
//CHECK: print is run.
gCling - > process ( " a " , & V ) ;
2012-10-15 13:42:09 +00:00
//CHECK: (int) 1
2012-09-05 09:37:39 +00:00
gCling - > process ( " a; " , & V ) ;
//CHECK-NOT: print is run.
// End PR #96277
2012-10-15 13:57:36 +00:00
// PR #98146
gCling - > process ( " \" Root \" " , & V ) ;
2023-07-21 15:29:30 +02:00
// CHECK: (const char[5]) "Root"
2012-10-15 13:57:36 +00:00
V
2023-07-21 15:29:30 +02:00
// CHECK: (cling::Value &) boxes [(const char[5]) "Root"]
2014-02-14 10:12:00 +01:00
// End PR #98146
2016-02-04 18:02:36 +01:00
. rawInput 1
typedef enum { k1 = 0 , k2 } enumName ;
enumName var = k1 ;
. rawInput 0
var
2016-04-28 10:18:44 +02:00
// CHECK: (enumName) (k1) : ({{(unsigned )?}}int) 0
2014-02-19 15:52:01 +01:00
const enumName constVar = ( enumName ) 1 // k2 is invisible!
2016-04-28 10:18:44 +02:00
// CHECK: (const enumName) (k2) : ({{(unsigned )?}}int) 1
2016-06-26 20:04:52 +02:00
// ROOT-8036: check that library symbols do not override interpreter symbols
int step = 10 // CHECK: (int) 10
step // CHECK: (int) 10
2016-09-01 17:04:22 -04:00
gCling - > process ( " #ifdef __UNDEFINED__ \n 42 \n #endif " )
2020-04-18 20:53:16 +00:00
//CHECK: (cling::Interpreter::CompilationResult) (cling::Interpreter::kSuccess) : ({{(unsigned )?}}int) 0
2016-09-05 12:48:33 +02:00
2016-07-09 20:12:27 -04:00
// User input variants of above:
# ifdef NOTDEFINED
gCling - > echo ( " 9 " )
# else
gCling - > echo ( " 12 " )
# endif
//CHECK: (int) 12
2020-04-18 20:53:16 +00:00
//CHECK: (cling::Interpreter::CompilationResult) (cling::Interpreter::kSuccess) : ({{(unsigned )?}}int) 0
2016-07-09 20:12:27 -04:00
# ifdef __CLING__
gCling - > echo ( " 19 " ) ;
# else
gCling - > echo ( " 156 " )
# endif
//CHECK: (int) 19
2016-09-05 12:48:33 +02:00
// ROOT-8300
struct B { static void * fgStaticVar ; B ( ) { printf ( " B::B() \n " ) ; } } ;
B b ; // CHECK: B::B()
2016-09-05 12:54:53 +02:00
// ROOT-7857
template < class T > void tfunc ( T ) { }
struct ROOT7857 {
void func ( ) { tfunc ( ( ROOT7857 * ) 0 ) ; }
} ;
ROOT7857 * root7857 ;
2016-09-05 12:58:43 +02:00
// ROOT-5248
class MyClass ;
extern MyClass * my ;
class MyClass { public : MyClass * getMyClass ( ) { return 0 ; } } cl ;
MyClass * my = cl . getMyClass ( ) ;
2019-03-13 09:12:28 +02:00
//
printf ( " Auto flush printf \n " ) ;
//CHECK-NEXT: Auto flush printf
2019-03-16 23:24:34 +02:00
std : : cout < < " Auto flush cout \n " ;
2019-03-13 09:12:28 +02:00
//CHECK-NEXT: Auto flush cout
2019-03-16 23:24:34 +02:00
printf ( " Must flush printf \n " ) ; std : : cout . flush ( ) ;
2019-03-13 09:12:28 +02:00
//CHECK-NEXT: Must flush printf
. q