#include "language.h"
#include "parser-defs.h"
#include "gdbcmd.h"
-#include "symfile.h" /* for overlay functions */
+#include "symfile.h"
#include "inferior.h"
#include "target-float.h"
#include "block.h"
#include "objfiles.h"
#include "user-regs.h"
#include <algorithm>
-#include "gdbsupport/gdb_optional.h"
+#include <optional>
#include "c-exp.h"
static unsigned int expressiondebug = 0;
/* True if an expression parser should set yydebug. */
-bool parser_debug;
+static bool parser_debug;
static void
show_parserdebug (struct ui_file *file, int from_tty,
if (tracker == nullptr)
tracker = &local_tracker;
- /* If no context specified, try using the current frame, if any. */
- if (!expression_context_block)
- expression_context_block = get_selected_block (&expression_context_pc);
- else if (pc == 0)
- expression_context_pc = expression_context_block->entry_pc ();
- else
- expression_context_pc = pc;
+ if ((flags & PARSER_LEAVE_BLOCK_ALONE) == 0)
+ {
+ /* If no context specified, try using the current frame, if any. */
+ if (!expression_context_block)
+ expression_context_block
+ = get_selected_block (&expression_context_pc);
+ else if (pc == 0)
+ expression_context_pc = expression_context_block->entry_pc ();
+ else
+ expression_context_pc = pc;
- /* Fall back to using the current source static context, if any. */
+ /* Fall back to using the current source static context, if any. */
- if (!expression_context_block)
- {
- struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+ if (!expression_context_block)
+ {
+ struct symtab_and_line cursal
+ = get_current_source_symtab_and_line ();
- if (cursal.symtab)
- expression_context_block
- = cursal.symtab->compunit ()->blockvector ()->static_block ();
+ if (cursal.symtab)
+ expression_context_block
+ = cursal.symtab->compunit ()->blockvector ()->static_block ();
- if (expression_context_block)
- expression_context_pc = expression_context_block->entry_pc ();
+ if (expression_context_block)
+ expression_context_pc = expression_context_block->entry_pc ();
+ }
}
if (language_mode == language_mode_auto && block != NULL)
expression_up
parse_expression_with_language (const char *string, enum language lang)
{
- gdb::optional<scoped_restore_current_language> lang_saver;
+ std::optional<scoped_restore_current_language> lang_saver;
if (current_language->la_language != lang)
{
lang_saver.emplace ();