On Mon, Mar 16, 2026 at 03:00:44PM -0400, Jason Merrill wrote:
> On 3/16/26 10:40 AM, Marek Polacek wrote:
> > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
> > 
> > -- >8 --
> > This test with invalid ^^decltype crashes.  finish_decltype_type
> > can now see a USING_DECL because they sometimes aren't stripped when
> > using -freflection.  We should give an error like we do for TYPE_DECL,
> > otherwise finish_decltype_type returns NULL_TREE and eventually we
> > crash in cp_parser_qualifying_entity after calling cp_parser_decltype.
> 
> The USING_DECL should be stripped in this case, we only want to avoid
> stripping it for the immediate operand of ^^.

Fortunately this change is no longer needed after r16-8132.  This patch
just adds the test.  Pushing.

-- >8 --
This test with invalid ^^decltype crashes.  finish_decltype_type
got a USING_DECL because they sometimes aren't stripped when
using -freflection.  We should give an error like we do for TYPE_DECL,
otherwise finish_decltype_type returns NULL_TREE and eventually we
crash in cp_parser_qualifying_entity after calling cp_parser_decltype.

Fixed by r16-8132 which moved the cp_preserve_using_decl overriding.

        PR c++/124494

gcc/testsuite/ChangeLog:

        * g++.dg/reflect/decltype1.C: New test.
---
 gcc/testsuite/g++.dg/reflect/decltype1.C | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/reflect/decltype1.C

diff --git a/gcc/testsuite/g++.dg/reflect/decltype1.C 
b/gcc/testsuite/g++.dg/reflect/decltype1.C
new file mode 100644
index 00000000000..2f9948b7a35
--- /dev/null
+++ b/gcc/testsuite/g++.dg/reflect/decltype1.C
@@ -0,0 +1,9 @@
+// PR c++/124494
+// { dg-do compile { target c++26 } }
+// { dg-additional-options "-freflection" }
+
+typedef signed char int8_t;
+namespace std {
+  using ::int8_t;
+}
+auto rr = ^^decltype(std::int8_t); // { dg-error "argument to .decltype. must 
be an expression" }

base-commit: 8655ef0b65515b823f8b0a1fd13826cf2d74c73b
-- 
2.53.0

Reply via email to