From patchwork Mon Sep 27 22:50:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 65923 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 2BA40B70DA for ; Tue, 28 Sep 2010 08:50:28 +1000 (EST) Received: (qmail 21566 invoked by alias); 27 Sep 2010 22:50:27 -0000 Received: (qmail 21549 invoked by uid 22791); 27 Sep 2010 22:50:25 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_CP X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Sep 2010 22:50:19 +0000 Received: from [192.168.178.22] (port-92-204-109-183.dynamic.qsc.de [92.204.109.183]) by mx01.qsc.de (Postfix) with ESMTP id B40F63D6BC; Tue, 28 Sep 2010 00:50:15 +0200 (CEST) Message-ID: <4CA11FA7.5090201@net-b.de> Date: Tue, 28 Sep 2010 00:50:15 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.9) Gecko/20100914 SUSE/3.1.4 Thunderbird/3.1.4 MIME-Version: 1.0 To: "Joseph S. Myers" CC: gcc patches Subject: Re: Compiler options as string? References: <4C9DEBA3.8080409@net-b.de> In-Reply-To: Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Joseph S. Myers wrote: >> The bare strings are only available in toplev.c: toplev_main directly gets > They are only available in gcc.c. If you want what the user used then you > need to get it from gcc.c; if you want canonical forms after specs > processing, removal of overridden options etc. then use the canonical > forms of the decoded options to produce such a string as you wish I decided that the latter produces good output. Joseph, do you think that following patch basically OK? I export the decoded arguments via toplev.{c,o} - or should this be handled differently? Tobias Index: gcc/toplev.c =================================================================== --- gcc/toplev.c (Revision 164670) +++ gcc/toplev.c (Arbeitskopie) @@ -127,8 +127,8 @@ static bool no_backend; #define MAX_LINE 75 /* Decoded options, and number of such options. */ -static struct cl_decoded_option *save_decoded_options; -static unsigned int save_decoded_options_count; +struct cl_decoded_option *save_decoded_options; +unsigned int save_decoded_options_count; /* Name of top-level original source file (what was input to cpp). This comes from the #-command at the beginning of the actual input. Index: gcc/toplev.h =================================================================== --- gcc/toplev.h (Revision 164670) +++ gcc/toplev.h (Arbeitskopie) @@ -29,6 +29,11 @@ along with GCC; see the file COPYING3. #define skip_leading_substring(whole, part) \ (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part)) +/* Decoded options, and number of such options. */ +extern struct cl_decoded_option *save_decoded_options; +extern unsigned int save_decoded_options_count; + + extern int toplev_main (int, char **); extern void strip_off_ending (char *, int); extern void rest_of_decl_compilation (tree, int, int); Index: gcc/fortran/interface.c =================================================================== --- gcc/fortran/interface.c (Revision 164670) +++ gcc/fortran/interface.c (Arbeitskopie) @@ -949,7 +949,20 @@ generic_correspondence (gfc_formal_argli goto next; if (f2 != NULL && compare_type_rank (f1->sym, f2->sym)) - goto next; + { + /* Fortran 2008, 12.4.3.4.5 adds more checks to distinguish + interfaces of generics procedures. */ + if (!(gfc_option.allow_std & GFC_STD_F2008) + || !((f1->sym->attr.procedure && !f2->sym->attr.procedure) + || (!f1->sym->attr.procedure && f2->sym->attr.procedure) + || (f1->sym->attr.pointer && f2->sym->attr.allocatable) + || (f1->sym->attr.allocatable && f2->sym->attr.pointer) + || (f1->sym->attr.function && f1->sym->as + && f1->sym->as->rank && !f2->sym->attr.function) + || (f2->sym->attr.function && f2->sym->as + && f2->sym->as->rank && !f1->sym->attr.function))) + goto next; + } /* Now search for a disambiguating keyword argument starting at the current non-match. */ Index: gcc/fortran/gfortran.h =================================================================== --- gcc/fortran/gfortran.h (Revision 164670) +++ gcc/fortran/gfortran.h (Arbeitskopie) @@ -2403,6 +2403,7 @@ void gfc_init_options (unsigned int, bool gfc_handle_option (size_t, const char *, int, int, const struct cl_option_handlers *); bool gfc_post_options (const char **); +char *gfc_get_option_string (void); /* f95-lang.c */ void gfc_maybe_initialize_eh (void); Index: gcc/fortran/options.c =================================================================== --- gcc/fortran/options.c (Revision 164670) +++ gcc/fortran/options.c (Arbeitskopie) @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. #include "flags.h" #include "intl.h" #include "opts.h" +#include "toplev.h" /* For decoded options. */ #include "options.h" #include "params.h" #include "tree-inline.h" @@ -966,3 +967,68 @@ gfc_handle_option (size_t scode, const c return result; } + + +char * +gfc_get_option_string (void) +{ + unsigned j; + size_t len, pos; + char *result; + + /* Determine required string length. */ + + len = 0; + for (j = 1; j < save_decoded_options_count; j++) + { + switch (save_decoded_options[j].opt_index) + { + case OPT_o: + case OPT_d: + case OPT_dumpbase: + case OPT_dumpdir: + case OPT_auxbase: + case OPT_quiet: + case OPT_version: + case OPT_fintrinsic_modules_path: + /* Ignore these. */ + continue; + } + + /* Ignore file names. */ + if (save_decoded_options[j].orig_option_with_args_text[0] == '-') + len += 1 + strlen (save_decoded_options[j].orig_option_with_args_text); + } + + result = (char *) gfc_getmem (len); + + pos = 0; + for (j = 1; j < save_decoded_options_count; j++) + { + switch (save_decoded_options[j].opt_index) + { + case OPT_o: + case OPT_d: + case OPT_dumpbase: + case OPT_dumpdir: + case OPT_auxbase: + case OPT_quiet: + case OPT_version: + case OPT_fintrinsic_modules_path: + /* Ignore these. */ + continue; + } + + /* Ignore file names. */ + if (save_decoded_options[j].orig_option_with_args_text[0] == '-') + { + len = strlen (save_decoded_options[j].orig_option_with_args_text); + memcpy (&result[pos], save_decoded_options[j].orig_option_with_args_text, len); + pos += len; + result[pos++] = ' '; + } + } + + result[--pos] = '\0'; + return result; +} Index: gcc/fortran/simplify.c =================================================================== --- gcc/fortran/simplify.c (Revision 164670) +++ gcc/fortran/simplify.c (Arbeitskopie) @@ -6739,9 +6739,14 @@ gfc_convert_char_constant (gfc_expr *e, gfc_expr * gfc_simplify_compiler_options (void) { - /* FIXME: PR40569 - return the proper compiler arguments. */ - return gfc_get_character_expr (gfc_default_character_kind, - &gfc_current_locus, "", 0); + char *str; + gfc_expr *result; + + str = gfc_get_option_string (); + result = gfc_get_character_expr (gfc_default_character_kind, + &gfc_current_locus, str, strlen (str)); + gfc_free (str); + return result; }