This fixes https://bugs.llvm.org/show_bug.cgi?id=49534, where the call to the constructor
of the anonymous union is checked and triggers assertion failure when trying to retrieve
the alignment of the `this` argument (which is a union with virtual function).
The extra check for alignment was introduced in D97187.
Reviewed By: tmatheson
Differential Revision: https://reviews.llvm.org/D98548
// trivial in almost all cases, except if a union member has an in-class
// initializer:
// union { int n = 0; };
- ActOnUninitializedDecl(Anon);
+ if (!Invalid)
+ ActOnUninitializedDecl(Anon);
}
Anon->setImplicit();
--- /dev/null
+// RUN: %clang_cc1 -x c++ -fsyntax-only %s -verify
+
+static union { // expected-warning {{declaration does not declare anything}}
+ virtual int a(); // expected-error {{unions cannot have virtual functions}} \
+ // expected-error {{functions cannot be declared in an anonymous union}}
+};