Skip to content

Commit c631131

Browse files
authored
[clang] Move CWG2390 test into cwg23xx.cpp (#94206)
This patch refactors an existing test for [CWG2390](https://cplusplus.github.io/CWG/issues/2390.html) "Is the argument of `__has_cpp_attribute` macro-expanded?" to use `#error` instead of emitting a variable in IRGen and checking it via FileCheck. As a bonus, this makes it possible to move the test into `cwg23xx.cpp`.
1 parent c0e6dd1 commit c631131

File tree

2 files changed

+36
-48
lines changed

2 files changed

+36
-48
lines changed

clang/test/CXX/drs/cwg2390.cpp

Lines changed: 0 additions & 47 deletions
This file was deleted.

clang/test/CXX/drs/cwg23xx.cpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,42 @@ namespace cwg2387 { // cwg2387: 9
317317
#endif
318318
}
319319

320-
// cwg2390 is in cwg2390.cpp
320+
namespace cwg2390 { // cwg2390: 14
321+
// Test that macro expansion of the builtin argument works.
322+
#define C clang
323+
#define F fallthrough
324+
#define CF clang::fallthrough
325+
326+
#if !__has_cpp_attribute(F)
327+
#error "doesn't have fallthrough"
328+
#endif
329+
330+
#if !__has_cpp_attribute(C::F)
331+
#error "doesn't have clang::fallthrough 1"
332+
#endif
333+
334+
#if !__has_cpp_attribute(clang::F)
335+
#error "doesn't have clang::fallthrough 2"
336+
#endif
337+
338+
#if !__has_cpp_attribute(C::fallthrough)
339+
#error "doesn't have clang::fallthrough 3"
340+
#endif
341+
342+
#if !__has_cpp_attribute(CF)
343+
#error "doesn't have clang::fallthrough 4"
344+
#endif
345+
346+
#define FUNCLIKE1(x) clang::x
347+
#if !__has_cpp_attribute(FUNCLIKE1(fallthrough))
348+
#error "doesn't have clang::fallthrough through func-like macro 1"
349+
#endif
350+
351+
#define FUNCLIKE2(x) _Clang::x
352+
#if !__has_cpp_attribute(FUNCLIKE2(fallthrough))
353+
#error "doesn't have clang::fallthrough through func-like macro 2"
354+
#endif
355+
} // namespace cwg2390
321356

322357
namespace cwg2394 { // cwg2394: 15
323358

0 commit comments

Comments
 (0)