]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Move cexpr_stree tree string build into utility function
authorAndi Kleen <ak@linux.intel.com>
Wed, 12 Jun 2024 13:59:37 +0000 (06:59 -0700)
committerAndi Kleen <ak@linux.intel.com>
Wed, 12 Jun 2024 15:24:07 +0000 (08:24 -0700)
No semantics changes.

gcc/cp/ChangeLog:

* cp-tree.h (extract): Add new overload to return tree.
* parser.cc (cp_parser_asm_string_expression): Use tree extract.
* semantics.cc (cexpr_str::extract): Add new overload to return
tree.

gcc/cp/cp-tree.h
gcc/cp/parser.cc
gcc/cp/semantics.cc

index 62718ff126a28ac1eba0499f8c2a1a8fb7935d72..416c60b7311e03d787cce562bda79ff20d420762 100644 (file)
@@ -9026,6 +9026,7 @@ public:
 
   bool type_check (location_t location);
   bool extract (location_t location, const char * & msg, int &len);
+  bool extract (location_t location, tree &str);
   tree message;
 private:
   tree message_data = NULL_TREE;
index 6cd7274046da40390b13151a0b2605e97845c329..de5f0483c12030c60a0cda5bf2e4e5f26c08f8ee 100644 (file)
@@ -22862,12 +22862,9 @@ cp_parser_asm_string_expression (cp_parser *parser)
       cexpr_str cstr (string);
       if (!cstr.type_check (tok->location))
        return error_mark_node;
-      const char *msg;
-      int len;
-      if (!cstr.extract (tok->location, msg, len))
+      if (!cstr.extract (tok->location, string))
        return error_mark_node;
       parens.require_close (parser);
-      string = build_string (len, msg);
       return string;
     }
   else if (!cp_parser_is_string_literal (tok))
index 20f4675833e2f1b921045e807c638a2dc35fb4f0..08f5f245e7d11a76b975bb04c0075ded1b3ca8ba 100644 (file)
@@ -11728,6 +11728,20 @@ cexpr_str::type_check (location_t location)
   return true;
 }
 
+/* Extract constant string at LOCATON into output string STR.
+   Returns true if successful, otherwise false.  */
+
+bool
+cexpr_str::extract (location_t location, tree &str)
+{
+  const char *msg;
+  int len;
+  if (!extract (location, msg, len))
+    return false;
+  str = build_string (len, msg);
+  return true;
+}
+
 /* Extract constant string at LOCATION into output string MSG with LEN.
    Returns true if successful, otherwise false.  */