diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 59717ca..0198981 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2236,6 +2236,7 @@ mi_cmd_execute (struct mi_parse *parse)
if (parse->language != language_unknown)
{
make_cleanup_restore_current_language ();
+ language_mode = language_mode_manual;
set_language (parse->language);
}
diff --git a/gdb/testsuite/gdb.mi/mi-language-c.cc b/gdb/testsuite/gdb.mi/mi-language-c.cc
new file mode 100644
index 0000000..0c8bd42
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-language-c.cc
@@ -0,0 +1,36 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2014 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+struct A
+{
+ virtual ~A ();
+ int a1;
+};
+
+A::~A ()
+{
+ a1 = 800;
+}
+
+int
+main (void)
+{
+ A alpha;
+ alpha.a1 = 100;
+
+ return alpha.a1; /* only bp. */
+}
diff --git a/gdb/testsuite/gdb.mi/mi-language-c.exp b/gdb/testsuite/gdb.mi/mi-language-c.exp
new file mode 100644
index 0000000..00f5210
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-language-c.exp
@@ -0,0 +1,60 @@
+# Copyright 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+if { [skip_cplus_tests] } { continue }
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi"
+
+gdb_exit
+if [mi_gdb_start] {
+ continue
+}
+
+standard_testfile .cc
+
+if [get_compiler_info "c++"] {
+ return -1
+}
+
+if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""} {
+ untested $testfile.exp
+ return -1
+}
+
+mi_gdb_load ${binfile}
+
+if ![mi_run_to_main] {
+ untested "could not run to main"
+ return -1
+}
+
+set lineno [gdb_get_line_number "only bp."]
+
+mi_create_breakpoint "$srcfile:$lineno" "add mi-language1 bp" keep {main\(\)} \
+ "$srcfile" $lineno $hex "create break at main"
+
+mi_execute_to "exec-continue" "breakpoint-hit" \
+ "main" "" ".*" ".*" {"" "disp=\"keep\""} \
+ "continue to main bp"
+
+mi_gdb_test "-var-create --language fortran alpha_1 * (alpha%a1)" \
+ "\\^done,name=\"alpha_1\",numchild=\"0\",value=\"100\",type=\"int\",thread-id=\"\[0-9\]+\",has_more=\"0\"" \
+ "-var-create from c using fortran language"
+
+mi_gdb_test "-var-create alpha_2 * (alpha.a1)" \
+ "\\^done,name=\"alpha_2\",numchild=\"0\",value=\"100\",type=\"int\",thread-id=\"\[0-9\]+\",has_more=\"0\"" \
+ "-var-create from c using default language"
+gdb_exit
\ No newline at end of file
diff --git a/gdb/testsuite/gdb.mi/mi-language-fortran.exp b/gdb/testsuite/gdb.mi/mi-language-fortran.exp
new file mode 100644
index 0000000..1f38a7b
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-language-fortran.exp
@@ -0,0 +1,54 @@
+# Copyright 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi"
+
+gdb_exit
+if [mi_gdb_start] {
+ continue
+}
+
+standard_testfile .f90
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
+ {debug f90}] != "" } {
+ untested mi-language-fortran.exp
+ return -1
+}
+
+mi_delete_breakpoints
+mi_gdb_reinitialize_dir $srcdir/$subdir
+mi_gdb_load ${binfile}
+
+set bp_lineno [gdb_get_line_number "only bp"]
+
+mi_create_breakpoint "-t $srcfile:$bp_lineno" "add bp"\
+ "del" "struct_test" ".*$srcfile" $bp_lineno $hex \
+ "MI-language-fortran insert breakpoint at line $bp_lineno (only bp)"
+
+mi_run_cmd
+
+mi_expect_stop "breakpoint-hit" "struct_test" "" ".*$srcfile" \
+ "$bp_lineno" { "" "disp=\"del\"" } "run to bp"
+
+mi_gdb_test "-var-create --language c alpha_1 * (p.c)" \
+ "\\^done,name=\"alpha_1\",numchild=\"0\",value=\"1\",type=\"integer\\(kind=4\\)\",thread-id=\"\[0-9\]+\",has_more=\"0\"" \
+ "-var-create from fortran using fortran language"
+
+mi_gdb_test "-var-create alpha_2 * (p%c)" \
+ "\\^done,name=\"alpha_2\",numchild=\"0\",value=\"1\",type=\"integer\\(kind=4\\)\",thread-id=\"\[0-9\]+\",has_more=\"0\"" \
+ "-var-create from fortran using default language"
+gdb_exit
diff --git a/gdb/testsuite/gdb.mi/mi-language-fortran.f90 b/gdb/testsuite/gdb.mi/mi-language-fortran.f90
new file mode 100644
index 0000000..f24d7d9
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-language-fortran.f90
@@ -0,0 +1,38 @@
+! Copyright 2006-2014 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 3 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program. If not, see .
+
+
+program struct_test
+
+ type bar
+ integer :: c
+ real :: d
+ end type
+ type foo
+ real :: a
+ type(bar) :: x
+ character*7 :: b
+ end type foo
+ type(foo) :: q
+ type(bar) :: p
+
+ p = bar(1, 2.375)
+ q%a = 3.125
+ q%b = "abcdefg"
+ q%x%c = 1
+ q%x%d = 2.375
+ print *,p,q ! only bp
+
+end program struct_test
diff --git a/gdb/utils.c b/gdb/utils.c
index 4da9501..cffa399 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -444,24 +444,36 @@ make_cleanup_free_so (struct so_list *so)
/* Helper for make_cleanup_restore_current_language. */
+struct saved_language_and_mode
+{
+ enum language lang;
+ enum language_mode mode;
+};
+
static void
do_restore_current_language (void *p)
{
- enum language saved_lang = (uintptr_t) p;
+ struct saved_language_and_mode *lang_and_mode = p;
+ enum language saved_lang = lang_and_mode->lang;
+ language_mode = lang_and_mode->mode;
set_language (saved_lang);
}
-/* Remember the current value of CURRENT_LANGUAGE and make it restored when
- the cleanup is run. */
+/* Remember the current value of CURRENT_LANGUAGE and
+ LANGUAGE_MODE restoring them when the cleanup is run. */
struct cleanup *
make_cleanup_restore_current_language (void)
{
- enum language saved_lang = current_language->la_language;
+ struct saved_language_and_mode *lang_and_mode
+ = XNEW (struct saved_language_and_mode);
+
+ lang_and_mode->lang = current_language->la_language;
+ lang_and_mode->mode = language_mode;
- return make_cleanup (do_restore_current_language,
- (void *) (uintptr_t) saved_lang);
+ return make_cleanup_dtor (do_restore_current_language,
+ (void *) lang_and_mode, xfree);
}
/* Helper function for make_cleanup_clear_parser_state. */