diff options
author | Davide Italiano <davide@freebsd.org> | 2015-06-27 19:18:55 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2015-06-27 19:18:55 +0000 |
commit | 43899d44c2f47e2fbd29e8d3745f1f68e29ba306 (patch) | |
tree | 55b864cef63f3ab1e955b86a127504fa05e7dee4 /clang/lib/Sema | |
parent | 21065ec50edbcfdb8b340377aea7c316ebc89fce (diff) | |
download | bcm5719-llvm-43899d44c2f47e2fbd29e8d3745f1f68e29ba306.tar.gz bcm5719-llvm-43899d44c2f47e2fbd29e8d3745f1f68e29ba306.zip |
[Sema] Unions cannot have virtual functions.
PR: PR23931
Differential Revision: http://reviews.llvm.org/D10752
Reviewed by: rsmith
llvm-svn: 240889
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 19bc7f99c8c..ae97b24f853 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7202,6 +7202,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, dyn_cast<CXXRecordDecl>(NewFD->getDeclContext())) { if (Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided()) NewFD->setPure(true); + + // C++ [class.union]p2 + // A union can have member functions, but not virtual functions. + if (isVirtual && Parent->isUnion()) + Diag(D.getDeclSpec().getVirtualSpecLoc(), diag::err_virtual_in_union); } SetNestedNameSpecifier(NewFD, D); |