[clang] Add C++20 diagnostic to macro-braces-recovery.cpp. (PR #192654)

Tom Weaver via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 17 06:38:34 PDT 2026


https://github.com/TomWeaver18 created https://github.com/llvm/llvm-project/pull/192654

maco-braces-recovery.cpp was added in the following commit:

https://github.com/llvm/llvm-project/commit/d8f63bbc8e20a68e764852a15d67a06fcd14c5bd

for c++17 (clang's default standard)  this test passes fine. For C++20 or above standards as default this test produces an additional diagnostic for reverse order candidate conversion functions.

To fix this I've added a --std=c++17 to the original run line, introduced a second run line for C++20 and a cxx20-note expectation for the new language spec diagnostic. 

Thanks for your time reviewing this patch :)

>From 1f16592a7da01cdd19b2c3f31ee2d648497af350 Mon Sep 17 00:00:00 2001
From: Tom Weaver <tom.weaver at sony.com>
Date: Fri, 17 Apr 2026 14:10:09 +0100
Subject: [PATCH] Add C++20 diagnostic to macro-braces-recovery.cpp.

This test generates an additional diagnostic for C++20 standards, add the
note along with a C++20 std run line and c++17 specifier for the original.

Changes to be committed:
  modified:   clang/test/Parser/macro-braces-recovery.cpp
---
 clang/test/Parser/macro-braces-recovery.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/test/Parser/macro-braces-recovery.cpp b/clang/test/Parser/macro-braces-recovery.cpp
index e8842f44bd623..bb58c2b8fe689 100644
--- a/clang/test/Parser/macro-braces-recovery.cpp
+++ b/clang/test/Parser/macro-braces-recovery.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected -std=c++17 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx20 -std=c++20 %s
 
 namespace GH21755 {
 #define M(x) f x // expected-note {{macro 'M' defined here}}
@@ -16,7 +17,8 @@ class Foo { // expected-note {{candidate constructor (the implicit copy construc
             // expected-note {{candidate constructor (the implicit move constructor) not viable}}
 public:
   Foo(int); // expected-note {{candidate constructor not viable: requires 1 argument, but 2 were provided}}
-  bool operator==(const int l); // expected-note {{candidate function not viable: no known conversion from 'Foo' to 'const int' for 1st argument}}
+  bool operator==(const int l); // expected-note {{candidate function not viable: no known conversion from 'Foo' to 'const int' for 1st argument}} \
+                                // cxx20-note {{candidate function (with reversed parameter order) not viable: no known conversion from 'Foo' to 'const int' for object argument}}
 };
 #define EQ(x,y) (void)(x == y) // expected-note {{macro 'EQ' defined here}}
 



More information about the cfe-commits mailing list