diff --git a/base/client.jl b/base/client.jl index 3518498795e83..dd67b6f85248f 100644 --- a/base/client.jl +++ b/base/client.jl @@ -129,6 +129,11 @@ end _repl_start = Condition() +function syntax_deprecation_warnings(warn::Bool) + ccall(:jl_parse_depwarn, Void, (Cint,), warn) + warn +end + function parse_input_line(s::AbstractString) # s = bytestring(s) # (expr, pos) = parse(s, 1) diff --git a/base/util.jl b/base/util.jl index 2269303af4b85..2ceffd09ac738 100644 --- a/base/util.jl +++ b/base/util.jl @@ -241,3 +241,18 @@ end warn(err::Exception; prefix="ERROR: ", kw...) = warn(sprint(io->showerror(io,err)), prefix=prefix; kw...) + +# Julia compiler options struct +immutable JLCompilerOpts + build_path::Ptr{Cchar} + code_coverage::Int8 + malloc_log::Int8 + check_bounds::Int8 + dumpbitcode::Int8 + int_literals::Cint + compile_enabled::Int8 + opt_level::Int8 + no_depwarn::Int8 +end + +compileropts() = unsafe_load(cglobal(:jl_compileropts, JLCompilerOpts)) diff --git a/src/ast.c b/src/ast.c index f743641d1cf73..433d9608f7429 100644 --- a/src/ast.c +++ b/src/ast.c @@ -114,6 +114,8 @@ static builtinspec_t julia_flisp_ast_ext[] = { { NULL, NULL } }; +extern void jl_parse_depwarn(int warn); + DLLEXPORT void jl_init_frontend(void) { fl_init(4*1024*1024); @@ -136,6 +138,9 @@ DLLEXPORT void jl_init_frontend(void) false_sym = symbol("false"); fl_error_sym = symbol("error"); fl_null_sym = symbol("null"); + + // Enable / disable syntax deprecation warnings + jl_parse_depwarn((int)jl_compileropts.depwarn); } DLLEXPORT void jl_lisp_prompt(void) @@ -507,6 +512,11 @@ void jl_stop_parsing(void) fl_applyn(0, symbol_value(symbol("jl-parser-close-stream"))); } +DLLEXPORT void jl_parse_depwarn(int warn) +{ + fl_applyn(1, symbol_value(symbol("jl-parser-depwarn")), warn? FL_T : FL_F); +} + extern int jl_lineno; jl_value_t *jl_parse_next(void) diff --git a/src/init.c b/src/init.c index 5c758b144197b..865e5a62ca9ef 100644 --- a/src/init.c +++ b/src/init.c @@ -87,7 +87,8 @@ jl_compileropts_t jl_compileropts = { NULL, // build_path JL_COMPILEROPT_DUMPBITCODE_OFF, 0, // int_literals JL_COMPILEROPT_COMPILE_DEFAULT, - 0 // opt_level + 0, // opt_level + 1, // depwarn }; int jl_boot_file_loaded = 0; diff --git a/src/jlfrontend.scm b/src/jlfrontend.scm index e32c05a35aa20..10296ef5bd451 100644 --- a/src/jlfrontend.scm +++ b/src/jlfrontend.scm @@ -187,6 +187,10 @@ (set! *filename-stack* (cdr *filename-stack*)) (set! *ts-stack* (cdr *ts-stack*))) +(define *depwarn* #t) +(define (jl-parser-depwarn w) + (set! *depwarn* (eq? w #t))) + (define (jl-parser-next) (let* ((err (parser-wrap (lambda () diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 5e3714f8dd15b..b9e4826cba807 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -501,17 +501,18 @@ ;; --- misc --- (define (syntax-deprecation-warning s what instead) - (io.write - *stderr* - (string - #\newline "WARNING: deprecated syntax \"" what "\"" - (if (eq? current-filename 'none) - "" - (string " at " current-filename ":" (input-port-line (ts:port s)))) - "." - (if (equal? instead "") - "" - (string #\newline "Use \"" instead "\" instead." #\newline))))) + (if *depwarn* + (io.write + *stderr* + (string + #\newline "WARNING: deprecated syntax \"" what "\"" + (if (eq? current-filename 'none) + "" + (string " at " current-filename ":" (input-port-line (ts:port s)))) + "." + (if (equal? instead "") + "" + (string #\newline "Use \"" instead "\" instead." #\newline)))))) ;; --- parser --- diff --git a/src/julia.h b/src/julia.h index 5311e5a321893..464b79888b117 100644 --- a/src/julia.h +++ b/src/julia.h @@ -872,6 +872,7 @@ void jl_init_restored_modules(); // front end interface DLLEXPORT jl_value_t *jl_parse_input_line(const char *str); DLLEXPORT jl_value_t *jl_parse_string(const char *str, int pos0, int greedy); +DLLEXPORT void jl_parse_depwarn(int warn); int jl_start_parsing_file(const char *fname); void jl_stop_parsing(void); jl_value_t *jl_parse_next(void); @@ -1336,6 +1337,7 @@ typedef struct { int int_literals; int8_t compile_enabled; int8_t opt_level; + int8_t depwarn; } jl_compileropts_t; extern DLLEXPORT jl_compileropts_t jl_compileropts; diff --git a/ui/repl.c b/ui/repl.c index 31634902aacbc..74a23da8a316c 100644 --- a/ui/repl.c +++ b/ui/repl.c @@ -87,7 +87,8 @@ static const char *opts = " --check-bounds={yes|no} Emit bounds checks always or never (ignoring declarations)\n" " -O, --optimize Run time-intensive code optimizations\n" " --int-literals={32|64} Select integer literal size independent of platform\n" - " --dump-bitcode={yes|no} Dump bitcode for the system image (used with --build)\n"; + " --dump-bitcode={yes|no} Dump bitcode for the system image (used with --build)\n" + " --no-depwarn Turn off deprecated syntax warnings\n"; void parse_opts(int *argcp, char ***argvp) { @@ -106,6 +107,7 @@ void parse_opts(int *argcp, char ***argvp) { "int-literals", required_argument, 0, 301 }, { "dump-bitcode", required_argument, 0, 302 }, { "compile", required_argument, 0, 303 }, + { "no-depwarn", optional_argument, 0, 304 }, { 0, 0, 0, 0 } }; int c; @@ -198,6 +200,9 @@ void parse_opts(int *argcp, char ***argvp) exit(1); } break; + case 304: + jl_compileropts.depwarn = 0; + break; default: ios_printf(ios_stderr, "julia: unhandled option -- %c\n", c); ios_printf(ios_stderr, "This is a bug, please report it.\n");