diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-01-10 10:32:36 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-01-10 10:32:36 +0100 |
commit | 38a13ea4117b96e467f78b3f86d737ecbe326935 (patch) | |
tree | 282426171edc144a459cadc402dab8dee18be034 /gcc/c | |
parent | 933f0c20d4ce1dba85e85d9d117cfd9f5376a945 (diff) | |
download | gcc-38a13ea4117b96e467f78b3f86d737ecbe326935.zip gcc-38a13ea4117b96e467f78b3f86d737ecbe326935.tar.gz gcc-38a13ea4117b96e467f78b3f86d737ecbe326935.tar.bz2 |
c++: Fix up ICEs on constexpr inline asm strings in templates [PR118277]
The following patch fixes ICEs when the new inline asm syntax
to use C++26 static_assert-like constant expressions in place
of string literals is used in templates.
As finish_asm_stmt doesn't do any checking for
processing_template_decl, this patch also just defers handling
those strings in templates rather than say trying fold_non_dependent_expr
and if the result is non-dependent and usable, try to extract.
The patch also reverts changes to cp_parser_asm_specification_opt
which allowed something like
void foo () asm ((std::string_view ("bar")));
but it would be really hard to support
template <int N>
void baz () asm ((std::string_view ("qux")));
(especially with dependent constant expression).
And the patch adds extensive test coverage for the various errors.
2025-01-10 Jakub Jelinek <jakub@redhat.com>
PR c++/118277
* cp-tree.h (finish_asm_string_expression): Declare.
* semantics.cc (finish_asm_string_expression): New function.
(finish_asm_stmt): Use it.
* parser.cc (cp_parser_asm_string_expression): Likewise.
Wrap string into PAREN_EXPR in the ("") case.
(cp_parser_asm_definition): Don't ICE if finish_asm_stmt
returns error_mark_node.
(cp_parser_asm_specification_opt): Revert 2024-06-24 changes.
* pt.cc (tsubst_stmt): Don't ICE if finish_asm_stmt returns
error_mark_node.
* g++.dg/cpp1z/constexpr-asm-4.C: New test.
* g++.dg/cpp1z/constexpr-asm-5.C: New test.
Diffstat (limited to 'gcc/c')
0 files changed, 0 insertions, 0 deletions