On 6/11/24 23:53, Andi Kleen wrote:
Sorry I must have misunderstood you. I thought the patch was already approved earlier and I did commit. I can revert or do additional changes.
I only meant to approve the refactoring patch, but no worries.
On Tue, Jun 11, 2024 at 04:31:30PM -0400, Jason Merrill wrote:+ if (tok->type == CPP_OPEN_PAREN) + { + matching_parens parens; + parens.consume_open (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);What in the testcases needs this wrapper stripping?Without the stripping I get /home/ak/gcc/gcc/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C: In function 'void f()': /home/ak/gcc/gcc/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C:27:16: error: request for member 'size' in '(const char*)"foo %1,%0"', which is of non-class type 'const char*' /home/ak/gcc/gcc/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C:27:7: error: constexpr string must be a string literal or object with 'size' and 'data' members /home/ak/gcc/gcc/gcc/testsuite/g++.dg/cpp1z/constexpr-asm-1.C:27:19: error: expected primary-expression before ':' token compiler exited with status 1 presumably because it fails this test: if (TREE_CODE (message) != STRING_CST && !type_dependent_expression_p (message))
Ah, yes, because you want to use a function returning const char *, which is not allowed for static_assert; rather, static_assert wants the function to return a wrapper class like std::string_view. Only the return type needs to change; the return statement can still return a string-literal.
This extension relative to static_assert seems unnecessary to me.
+ "expected string-literal or constexpr in brackets");
parentheses, not brackets. Jason
