Index: parse.c =================================================================== RCS file: /cvs/src/src/gdb/parse.c,v retrieving revision 1.36 diff -u -p -r1.36 parse.c --- parse.c 9 Sep 2003 08:05:42 -0000 1.36 +++ parse.c 10 Sep 2003 01:51:40 -0000 @@ -1107,6 +1107,7 @@ struct expression * parse_exp_1 (char **stringptr, struct block *block, int comma) { struct cleanup *old_chain; + const struct language_defn *lang = NULL; lexptr = *stringptr; prev_lexptr = NULL; @@ -1130,16 +1131,29 @@ parse_exp_1 (char **stringptr, struct bl else expression_context_block = get_selected_block (&expression_context_pc); + if (language_mode == language_mode_auto && expression_context_block != NULL) + { + /* Find the language associated to the context block. + Default to the current language if it can not be determined. */ + const struct symbol *func = block_function (expression_context_block); + if (func != NULL) + lang = language_def (SYMBOL_LANGUAGE (func)); + if (lang == NULL || lang->la_language == language_unknown) + lang = current_language; + } + else + lang = current_language; + namecopy = (char *) alloca (strlen (lexptr) + 1); expout_size = 10; expout_ptr = 0; expout = (struct expression *) xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size)); - expout->language_defn = current_language; + expout->language_defn = lang; make_cleanup (free_current_contents, &expout); - if (current_language->la_parser ()) - current_language->la_error (NULL); + if (lang->la_parser ()) + lang->la_error (NULL); discard_cleanups (old_chain);