[clang] [Clang] [Sema] Error on reference types inside a union with msvc 1900+ (PR #102851)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 14 10:04:18 PDT 2024
================
@@ -619,6 +616,20 @@ template<typename T> struct A {};
template<typename T> struct B : A<A<T>> { A<T>::C::D d; }; // expected-warning {{implicit 'typename' is a C++20 extension}}
}
+#elif TEST4
+
+union u {
+ int *i1;
+ int &i2; // expected-warning {{union member 'i2' has reference type 'int &', which is a Microsoft extension}}
+};
+
+#elif TEST5
+
+union u {
+ int *i1;
+ int &i2; // expected-error {{union member 'i2' has reference type 'int &'}}
+};
+
----------------
AaronBallman wrote:
A better way to do this is to use one conditional block and use different `-verify` prefixes so that we don't have to duplicate the code (it makes it more clear what's going on with the tests). https://github.com/llvm/llvm-project/blob/main/clang/test/Sema/empty-init.c is an example of how to do this.
https://github.com/llvm/llvm-project/pull/102851
More information about the cfe-commits
mailing list