llvm-project/clang/test/SemaCXX/PR49534.cpp
Yuanfang Chen 7562c64197 [Sema] Mark virtual method declaration in union as invalid
Currently, this is only diagnosed but the decl is not marked invalid. This may hit assertions down the path.

This also reverts the fix for PR49534 since it is not needed anymore.

Reviewed By: hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D113145
2021-11-09 10:57:38 -08:00

6 lines
214 B
C++

// 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}}
};