From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18332 invoked by alias); 5 Nov 2012 15:32:42 -0000 Received: (qmail 18275 invoked by uid 48); 5 Nov 2012 15:32:25 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/55210] cannot use macro #define FOO 'a' in a conditional Date: Mon, 05 Nov 2012 15:32:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status Last reconfirmed CC Ever Confirmed Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg00382.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55210 Tobias Burnus changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2012-11-05 CC| |burnus at gcc dot gnu.org Ever Confirmed|0 |1 --- Comment #1 from Tobias Burnus 2012-11-05 15:32:24 UTC --- If fails in cpp_interpret_string at 1426 if (!APPLY_CONVERSION (cvt, base, p - base, &tbuf)) Because "func" is a NULL pointer: (gdb) p cvt $13 = {func = 0x0, cd = 0x0, width = 0} Backtrace: #0 cpp_interpret_string (pfile=pfile@entry=0x15d9a90, from=from@entry=0x15da320, count=count@entry=1, to=to@entry=0x7fffffffd1c0, type=) at /home/tob/projects/gcc-git/gcc/libcpp/charset.c:1426 #1 0x0000000000e71b7d in cpp_interpret_charconst (pfile=0x15d9a90, token=0x15da318, pchars_seen=0x7fffffffd30c, unsignedp=0x7fffffffd3f0) at /home/tob/projects/gcc-git/gcc/libcpp/charset.c:1615 #2 0x0000000000e5fe85 in eval_token (virtual_location=4868, token=0x15da318, pfile=0x15d9a90) at /home/tob/projects/gcc-git/gcc/libcpp/expr.c:964 #3 _cpp_parse_expr (pfile=, is_if=) at /home/tob/projects/gcc-git/gcc/libcpp/expr.c:1150 #4 0x0000000000e599b4 in do_if (pfile=0x15d9a90) at /home/tob/projects/gcc-git/gcc/libcpp/directives.c:1953 #5 0x0000000000e5b1b1 in _cpp_handle_directive (pfile=0x15d9a90, indented=) at /home/tob/projects/gcc-git/gcc/libcpp/directives.c:492 #6 0x0000000000e6ea6f in _cpp_scan_out_logical_line (pfile=pfile@entry=0x15d9a90, macro=macro@entry=0x0) at /home/tob/projects/gcc-git/gcc/libcpp/traditional.c:635 #7 0x0000000000e6ef6a in _cpp_read_logical_line_trad (pfile=0x15d9a90) at /home/tob/projects/gcc-git/gcc/libcpp/traditional.c:306 #8 0x000000000056fa20 in scan_translation_unit_trad (pfile=) at /home/tob/projects/gcc-git/gcc/gcc/fortran/cpp.c:773 The cvt variable is set via a call to "converter_for_type" with the argument type=CPP_CHAR. The function contains: 1346 switch (type) 1347 { 1348 default: 1349 return pfile->narrow_cset_desc; (and also handles CPP_UTF8STRING, CPP_CHAR16, CPP_CHAR32, CPP_WCHAR and CPP_WSTRING). The CPP_CHAR is probably generated in lex.c's lex_string The function narrow_cset_desc should get set via: cpp_init_iconv (cpp_reader *pfile) which has: pfile->narrow_cset_desc = init_iconv_desc (pfile, ncset, SOURCE_CHARSET); where "nset" gets set via: const char *ncset = CPP_OPTION (pfile, narrow_charset); If one calls "cpp" for the file (which matches calling "cc1 -E"), the type is also CPP_CHAR, but pfile->narrow_cset_desc alias cvt.func is convert_no_conversion. * * * I wonder whether one should call cpp_init_iconv - as C/C++ does in ../gcc/c-family/c-opts.c's c_common_init: /* Set up preprocessor arithmetic. Must be done after call to c_common_nodes_and_builtins for type nodes to be good. */ cpp_opts->precision = TYPE_PRECISION (intmax_type_node); cpp_opts->char_precision = TYPE_PRECISION (char_type_node); cpp_opts->int_precision = TYPE_PRECISION (integer_type_node); cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node); cpp_opts->unsigned_wchar = TYPE_UNSIGNED (wchar_type_node); cpp_opts->bytes_big_endian = BYTES_BIG_ENDIAN; /* This can't happen until after wchar_precision and bytes_big_endian are known. */ cpp_init_iconv (parse_in);