[gcc r15-1235] Remove const char * support for asm constexpr
Andi Kleen
ak@gcc.gnu.org
Thu Jun 13 05:08:35 GMT 2024
https://gcc.gnu.org/g:6f1f1657cd7a8472b4a4aeef60f1c59606ee011b
commit r15-1235-g6f1f1657cd7a8472b4a4aeef60f1c59606ee011b
Author: Andi Kleen <ak@linux.intel.com>
Date: Wed Jun 12 09:09:37 2024 -0700
Remove const char * support for asm constexpr
asm constexpr now only accepts the same string types as C++26 assert,
e.g. string_view and string. Adjust test suite and documentation.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_asm_string_expression): Remove support
for const char * for asm constexpr.
gcc/ChangeLog:
* doc/extend.texi: Use std::string_view in asm constexpr
example.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/constexpr-asm-1.C: Use std::std_string_view.
* g++.dg/cpp1z/constexpr-asm-3.C: Dito.
Diff:
---
gcc/cp/parser.cc | 7 -------
gcc/doc/extend.texi | 3 ++-
gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C | 12 +++++++-----
gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C | 12 +++++++-----
4 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index de5f0483c120..98e8ca10ac40 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -22852,13 +22852,6 @@ cp_parser_asm_string_expression (cp_parser *parser)
tree string = cp_parser_constant_expression (parser);
if (string != error_mark_node)
string = cxx_constant_value (string, tf_error);
- if (TREE_CODE (string) == NOP_EXPR)
- string = TREE_OPERAND (string, 0);
- if (TREE_CODE (string) == ADDR_EXPR
- && TREE_CODE (TREE_OPERAND (string, 0)) == STRING_CST)
- string = TREE_OPERAND (string, 0);
- if (TREE_CODE (string) == VIEW_CONVERT_EXPR)
- string = TREE_OPERAND (string, 0);
cexpr_str cstr (string);
if (!cstr.type_check (tok->location))
return error_mark_node;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 17e26c5004c1..ee3644a52645 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -10716,7 +10716,8 @@ message. Any string is converted to the character set of the source code.
When this feature is available the @code{__GXX_CONSTEXPR_ASM__} cpp symbol is defined.
@example
-constexpr const char *genfoo() @{ return "foo"; @}
+#include <string>
+constexpr std::string_view genfoo() @{ return "foo"; @}
void function()
@{
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C
index 7cc6b37d6208..311209acb43b 100644
--- a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C
+++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C
@@ -1,22 +1,24 @@
/* { dg-do compile } */
-/* { dg-options "-std=gnu++11" } */
+/* { dg-options "-std=gnu++17" } */
-constexpr const char *genfoo ()
+#include <string>
+
+constexpr std::string_view genfoo ()
{
return "foo %1,%0";
}
-constexpr const char *genoutput ()
+constexpr std::string_view genoutput ()
{
return "=r";
}
-constexpr const char *geninput ()
+constexpr std::string_view geninput ()
{
return "r";
}
-constexpr const char *genclobber ()
+constexpr std::string_view genclobber ()
{
return "memory";
}
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C
index d33631876bdc..ef8a35a0b3ba 100644
--- a/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C
+++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-3.C
@@ -1,22 +1,24 @@
/* { dg-do compile } */
-/* { dg-options "-std=gnu++11" } */
+/* { dg-options "-std=gnu++17" } */
-constexpr const char *genfoo ()
+#include <string>
+
+constexpr std::string_view genfoo ()
{
return "foo %1,%0";
}
-constexpr const char *genoutput ()
+constexpr std::string_view genoutput ()
{
return "=r";
}
-constexpr const char *geninput ()
+constexpr std::string_view geninput ()
{
return "r";
}
-constexpr const char *genclobber ()
+constexpr std::string_view genclobber ()
{
return "memory";
}
More information about the Gcc-cvs
mailing list