From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22318 invoked by alias); 20 Sep 2011 03:32:43 -0000 Received: (qmail 22310 invoked by uid 22791); 20 Sep 2011 03:32:42 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-fx0-f47.google.com (HELO mail-fx0-f47.google.com) (209.85.161.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Sep 2011 03:32:25 +0000 Received: by fxi1 with SMTP id 1so133972fxi.20 for ; Mon, 19 Sep 2011 20:32:24 -0700 (PDT) Received: by 10.223.9.69 with SMTP id k5mr513500fak.62.1316489544281; Mon, 19 Sep 2011 20:32:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.152.37.170 with HTTP; Mon, 19 Sep 2011 20:32:04 -0700 (PDT) From: Sandeep Soni Date: Tue, 20 Sep 2011 03:32:00 -0000 Message-ID: Subject: [gimplefe] Ran into a internal compiler error To: GCC LIST Cc: Diego Novillo Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00193.txt.bz2 Hi, I was trying to make a symbol table for all the variable declarations for the gimple front end. Following is a patch: Index: parser.c =================================================================== --- parser.c (revision 174754) +++ parser.c (working copy) @@ -28,6 +28,7 @@ #include "tree.h" #include "gimple.h" #include "parser.h" +#include "hashtab.h" #include "ggc.h" /* The GIMPLE parser. Note: do not use this variable directly. It is @@ -807,6 +808,31 @@ } } + +struct gimple_symtab_entry_def +{ + tree decl; +}; + +static hashval_t +gimple_symtab_entry_hash (const void *entry) +{ + const struct gimple_symtab_entry_def *base = + (const struct gimple_symtab_entry_def *)entry; + return IDENTIFIER_HASH_VALUE (base->decl); +} + +static int +gimple_symtab_eq_hash (const void *entry1, const void *entry2) +{ + const struct gimple_symtab_entry_def *p1 = + (const struct gimple_symtab_entry_def *)entry1; + const struct gimple_symtab_entry_def *p2 = + (const struct gimple_symtab_entry_def *)entry2; + + return (p1->decl == p2->decl); +} + /* The Declaration section within a .gimple file can consist of a) Declaration of variables. b) Declaration of functions. @@ -871,10 +897,29 @@ gp_parse_var_decl (gimple_parser *parser) { const gimple_token *next_token; + const gimple_token *name_token; + const char* name; enum tree_code code ; + htab_t gimple_symtab; + void **slot1, **slot2; + struct gimple_symtab_entry_def e; + + gimple_symtab = htab_create_ggc (10, gimple_symtab_entry_hash, gimple_symtab_eq_hash, NULL); gl_consume_expected_token (parser->lexer, CPP_LESS); - gl_consume_expected_token (parser->lexer, CPP_NAME); + name_token = gl_consume_expected_token (parser->lexer, CPP_NAME); + name = gl_token_as_text(name_token); + e.decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier(name), void_type_node); + slot1 = htab_find_slot (gimple_symtab ,&e, INSERT); + slot2 = htab_find_slot (gimple_symtab, &e, NO_INSERT); + if (slot1 == slot2) + { + printf ("I think this is right\n"); + } + else + { + printf ("Or this is wrong\n"); + } gl_consume_expected_token (parser->lexer, CPP_COMMA); next_token = gl_consume_token (parser->lexer); @@ -1391,7 +1436,6 @@ parser_gc_root__ = NULL; } - /* Main entry point for the GIMPLE front end. */ void @@ -1402,7 +1446,6 @@ parser_gc_root__ = parser = gp_init (main_input_filename); if (parser->lexer->filename == NULL) return; - gl_lex (parser->lexer); gp_parse (parser); gp_finish (parser); It gives me a internal compiler error saying: gimple1: internal compiler error: tree check: expected identifier_node, have var_decl in gimple_symtab_entry_hash Is there something that I have gotten wrong or something that I had to do before that I missed? -- Cheers Sandy