diff options
-rw-r--r-- | Makefile | 3 | ||||
-rwxr-xr-x | build.sh | 5 | ||||
-rw-r--r-- | copy.c | 2 | ||||
-rw-r--r-- | identifiers.c | 13 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | test.toc | 8 | ||||
-rw-r--r-- | toc.c | 15 |
7 files changed, 29 insertions, 18 deletions
@@ -2,6 +2,7 @@ debug: *.[ch] build.sh ./build.sh release: *.[ch] build.sh ./build.sh release - +profile: *.[ch] build.sh + ./build.sh profile clean: rm toc *.o @@ -47,10 +47,13 @@ if [ "$CC" = "gcc" ]; then elif [ "$CC" = "clang" ]; then DEBUG_FLAGS="$DEBUG_FLAGS -no-pie -gdwarf-2 -pipe" fi -RELEASE_FLAGS="-O3 -s -DNDEBUG $WARNINGS -std=c11" +RELEASE_FLAGS="-O3 -s -DNDEBUG $WARNINGS" +PROFILE_FLAGS="-O3 -g -pg -DNDEBUG $WARNINGS" if [ "$1" = "release" ]; then FLAGS="$RELEASE_FLAGS $ADDITIONAL_FLAGS" +elif [ "$1" = "profile" ]; then + FLAGS="$PROFILE_FLAGS $ADDITIONAL_FLAGS" else FLAGS="$DEBUG_FLAGS $ADDITIONAL_FLAGS" fi @@ -138,7 +138,9 @@ static void copy_type(Copier *c, Type *out, Type *in) { *outfn = *infn; size_t constness_bytes = (ntypes-1) * sizeof *outfn->constness; outfn->constness = allocr_malloc(c->allocr, constness_bytes); + gcc_no_bounds_warnings_start memmove(outfn->constness, infn->constness, constness_bytes); + gcc_no_bounds_warnings_end outfn->types = NULL; arr_set_lena(outfn->types, ntypes, c->allocr); diff --git a/identifiers.c b/identifiers.c index c3f64b7..3232811 100644 --- a/identifiers.c +++ b/identifiers.c @@ -80,18 +80,9 @@ static char *ident_to_str(Identifier i) { char *str = err_malloc(i->len + 1); /* for some reason, GCC thinks that i->len is -1 when this is called from type_to_str_ (in release mode) */ -#if !defined(__clang__) && defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-overflow" -#pragma GCC diagnostic ignored "-Wrestrict" -#pragma GCC diagnostic ignored "-Warray-bounds" -#endif +gcc_no_bounds_warnings_start memcpy(str, i->str, i->len); - - -#if !defined(__clang__) && defined(__GNUC__) -#pragma GCC diagnostic pop -#endif +gcc_no_bounds_warnings_end str[i->len] = 0; return str; } @@ -8,7 +8,6 @@ /* @TODO: -start passing Types instead of pointers to Type figure out how printf is gonna work if we do #include "foo.toc", bar; and foo.toc fails, bar should be declared as TYPE_UNKNOWN (right now it's undeclared) fix #foreign not at global scope - right now the cgen'd definition doesn't use the proper type @@ -2,8 +2,12 @@ #include "std/mem.toc"; main ::= fn() { - for i, v : (float, int) = 10,-1,.0 { - io.puti(i as int); + file, err := io.fopen_write("test.txt"); + + for i := 0.,1000000 { + io.fputs(file, "!"); } + + io.fclose(file); } main(); @@ -46,14 +46,25 @@ #endif -#else +#else /* __STDC_VERSION >= 201112 ... */ #define toc_alignof sizeof #define possibly_static_assert(cond) assert(cond) +#endif /* __STDC_VERSION >= 201112 ... */ + +/* this is to prevent erroneous warnings from GCC (v. 8.3.0) with -O3 */ +#if !defined(__clang__) && defined(__GNUC__) +#define gcc_no_bounds_warnings_start _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wstringop-overflow\"") \ + _Pragma("GCC diagnostic ignored \"-Wrestrict\"") \ + _Pragma("GCC diagnostic ignored \"-Warray-bounds\"") +#define gcc_no_bounds_warnings_end _Pragma("GCC diagnostic pop") +#else +#define gcc_no_bounds_warnings_start +#define gcc_no_bounds_warnings_end #endif - #include "types.h" /* forward declarations for debugging */ |