https://github.com/hongtaihu created 
https://github.com/llvm/llvm-project/pull/244118

This is a test-only cleanup. `expression-traits.cpp` still disables the 
assertion that `typeid(1)` is an lvalue. A `typeid` expression has static type 
`const std::type_info` and is an lvalue, so `ASSERT_LVALUE` is the correct 
coverage.

The block could not be enabled as-is because the test file has no 
`std::type_info` declaration and Sema requires that name for `typeid`. Add a 
forward declaration; the operand of `typeid(1)` is `int`, so a complete 
`type_info` definition is not needed for these syntax-only checks.

Validation with an assertions-enabled clang:

- `-cc1 -std=c++98 -fsyntax-only -verify -fcxx-exceptions`
- the same command with `-fexperimental-new-constant-interpreter`

Both original RUN lines pass.

>From cec55938426c5989a6a1e8dfaa9e1e87f2a0295a Mon Sep 17 00:00:00 2001
From: hongtaihu <[email protected]>
Date: Thu, 19 Nov 2026 15:14:07 +0800
Subject: [PATCH] [Clang][NFC] Re-enable typeid lvalue expression trait test

The disabled block has no declaration for std::type_info, so enabling it 
directly fails before the expression trait is checked. A forward declaration is 
sufficient for typeid(1), whose operand is not a class type, and lets the 
standard-mandated lvalue assertions run without pulling in a standard library 
header.
---
 clang/test/SemaCXX/expression-traits.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/test/SemaCXX/expression-traits.cpp 
b/clang/test/SemaCXX/expression-traits.cpp
index 64ddca091e948..27140978d6445 100644
--- a/clang/test/SemaCXX/expression-traits.cpp
+++ b/clang/test/SemaCXX/expression-traits.cpp
@@ -433,13 +433,12 @@ void expr_dynamic_cast_5()
 // defect that is being corrected by the response to UK65 (see
 // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2841.html).
 
-#if 0
+namespace std { class type_info; }
 void expr_typeid_1()
 {
     // expr.typeid/1: The result of a typeid expression is an lvalue...
     ASSERT_LVALUE(typeid(1));
 }
-#endif
 
 void expr_static_cast_1(int x)
 {

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to