forked from OSchip/llvm-project
Nested function test in compiler-rt should not be run under Clang.
llvm-svn: 85456
This commit is contained in:
parent
a8eceedb82
commit
07d6005bdc
|
|
@ -1,11 +1,12 @@
|
||||||
//===-- trampoline_setup_test.c - Test __trampoline_setup -----------------===//
|
/* ===-- trampoline_setup_test.c - Test __trampoline_setup -----------------===
|
||||||
//
|
*
|
||||||
// The LLVM Compiler Infrastructure
|
* The LLVM Compiler Infrastructure
|
||||||
//
|
*
|
||||||
// This file is distributed under the University of Illinois Open Source
|
* This file is distributed under the University of Illinois Open Source
|
||||||
// License. See LICENSE.TXT for details.
|
* License. See LICENSE.TXT for details.
|
||||||
//
|
*
|
||||||
//===----------------------------------------------------------------------===//
|
* ===----------------------------------------------------------------------===
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -13,11 +14,17 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
//
|
/*
|
||||||
// Tests nested functions
|
* Tests nested functions
|
||||||
// The ppc compiler generates a call to __trampoline_setup
|
* The ppc compiler generates a call to __trampoline_setup
|
||||||
// The i386 and x86_64 compilers generate a call to ___enable_execute_stack
|
* The i386 and x86_64 compilers generate a call to ___enable_execute_stack
|
||||||
//
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note that, nested functions are not ISO C and are not supported in Clang.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __gcc__ && !__clang__
|
||||||
|
|
||||||
typedef int (*nested_func_t)(int x);
|
typedef int (*nested_func_t)(int x);
|
||||||
|
|
||||||
|
|
@ -25,18 +32,18 @@ nested_func_t proc;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// some locals
|
/* Some locals */
|
||||||
int c = 10;
|
int c = 10;
|
||||||
int d = 7;
|
int d = 7;
|
||||||
|
|
||||||
// define a nested function
|
/* Define a nested function: */
|
||||||
int bar(int x) { return x*5 + c*d; };
|
int bar(int x) { return x*5 + c*d; };
|
||||||
|
|
||||||
// assign global to point to nested function
|
/* Assign global to point to nested function
|
||||||
// (really points to trampoline)
|
* (really points to trampoline). */
|
||||||
proc = bar;
|
proc = bar;
|
||||||
|
|
||||||
// invoke nested function
|
/* Invoke nested function: */
|
||||||
c = 4;
|
c = 4;
|
||||||
if ( (*proc)(3) != 43 )
|
if ( (*proc)(3) != 43 )
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -44,6 +51,8 @@ int main()
|
||||||
if ( (*proc)(4) != 40 )
|
if ( (*proc)(4) != 40 )
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// success
|
/* Success. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* __clang__ */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue