2
0
mirror of https://frontier.innolan.net/github/amigaos-cross-toolchain6.git synced 2024-10-19 10:29:55 +00:00

@R using -Os

This commit is contained in:
bebbo
2017-07-11 13:05:21 +02:00
parent 2cc4e738f1
commit d1196c0eba
3 changed files with 69 additions and 7 deletions

View File

@ -2,12 +2,13 @@ CC = m68k-amigaos-gcc
CXX = m68k-amigaos-g++
CFLAGS = -Os -Wall -fomit-frame-pointer
CXXFLAGS = -Os -Wall -fomit-frame-pointer -fno-rtti -fno-exceptions
CXXFLAGSX = -Os -Wall
BINS = hello-ks13 hello-ks20 hello-ks20.clib2 \
hello-stdio hello-stdio.clib2 hello-stdio.nix13 \
hello-mui test-mmu \
simple.library simple.library_r simple.device \
test-ctors hello-iostream
test-ctors hello-iostream test-exceptions
all: $(BINS) $(OBJS)
@ -38,6 +39,9 @@ test-ctors: test-ctors.cpp
$(CXX) -noixemul -m68020 $(CXXFLAGS) -c -o test-ctors.o $<
$(CXX) -noixemul -m68020 $(CXXFLAGS) -o $@ test-ctors*.o
test-exceptions: test-exceptions.cpp
$(CXX) -noixemul $(CXXFLAGSX) -o $@ $^
hello-mui: hello-mui.c
$(CC) -noixemul -m68020 -msmall-code $(CFLAGS) -o $@ $< -lmui

58
examples/test-exceptions.cpp Executable file
View File

@ -0,0 +1,58 @@
#include <stdio.h>
struct A
{
int x;
A (A const & a) :
x (a.x)
{
printf ("copy ctor A %d\n", x);
}
A (int i) :
x (i)
{
printf ("ctor A %d\n", x);
}
~A ()
{
printf ("dtor A %d\n", x);
}
};
void
foo (int x)
{
A a (42);
try
{
A ax (x);
if (x == 1)
throw x;
if (x == 3)
throw ax;
}
catch (int y)
{
printf ("foo catch %d\n", y);
}
}
int
main ()
{
try
{
for (int i = 0; i < 4; ++i)
{
printf ("call foo(%d)\n", i);
foo (i);
}
}
catch (A const & a)
{
printf ("main catch A %d\n", a.x);
}
printf (" back in main\n");
return 0;
}