[clang] Update test for C++20 defaulting compilers after #173236 changed the expected diagnostic message. (PR #174377)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 5 02:00:52 PST 2026


https://github.com/dyung created https://github.com/llvm/llvm-project/pull/174377

Change #173236 changed the emitted error message which caused the test `clang/test/SemaCXX/typeid.cpp` to fail if tested with a compiler that defaults to C++20 because the error message has changed. This change updates the test to expect the correct error message depending on whether the compiler defaults to C++20 or earlier.

>From 13952669f2d4a0b8d3852980e2943565d3ee6330 Mon Sep 17 00:00:00 2001
From: Douglas Yung <douglas.yung at sony.com>
Date: Mon, 5 Jan 2026 09:56:41 +0000
Subject: [PATCH] Update test for C++20 defaulting compilers after #173236
 changed the expected diagnostic message.

---
 clang/test/SemaCXX/typeid.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/clang/test/SemaCXX/typeid.cpp b/clang/test/SemaCXX/typeid.cpp
index 26cad1c88f4d6..51a18e624c23d 100644
--- a/clang/test/SemaCXX/typeid.cpp
+++ b/clang/test/SemaCXX/typeid.cpp
@@ -2,7 +2,12 @@
 
 void f()
 {
-  (void)typeid(int); // expected-error {{you need to include <typeinfo> before using the 'typeid' operator}}
+  (void)typeid(int);
+#if __cplusplus >= 202002L
+   // expected-error at -2 {{you need to include <typeinfo> or import std before using the 'typeid' operator}}
+#else
+   // expected-error at -4 {{you need to include <typeinfo> before using the 'typeid' operator}}
+#endif
 }
 
 namespace std {



More information about the cfe-commits mailing list