diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2014-12-10 22:58:14 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2014-12-10 22:58:14 +0000 |
| commit | 18fac3b1dd8026953dbac543c85696cd9388ba42 (patch) | |
| tree | 0ebab8aa0383d26a6f503467df1ea786e4ba4c00 /clang | |
| parent | 41d7656d5a7a41b95af7a3c6a1e13f5a4571c2b9 (diff) | |
| download | bcm5719-llvm-18fac3b1dd8026953dbac543c85696cd9388ba42.tar.gz bcm5719-llvm-18fac3b1dd8026953dbac543c85696cd9388ba42.zip | |
AST: Properly calculate the linkage of a IndirectFieldDecl
getLVForNamespaceScopeDecl believed that it wasn't possible for it to
ever see an IndirectFieldDecl. However, this can occur when determining
whether or not something is a redeclaration of a member of an anonymous
static union.
This fixes PR21858.
llvm-svn: 223975
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 7 | ||||
| -rw-r--r-- | clang/test/SemaCXX/anonymous-union.cpp | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index a937fdf0920..3e398ae9178 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -619,9 +619,12 @@ static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D, // Explicitly declared static. if (Function->getCanonicalDecl()->getStorageClass() == SC_Static) return LinkageInfo(InternalLinkage, DefaultVisibility, false); + } else if (const auto *IFD = dyn_cast<IndirectFieldDecl>(D)) { + // - a data member of an anonymous union. + const VarDecl *VD = IFD->getVarDecl(); + assert(VD && "Expected a VarDecl in this IndirectFieldDecl!"); + return getLVForNamespaceScopeDecl(VD, computation); } - // - a data member of an anonymous union. - assert(!isa<IndirectFieldDecl>(D) && "Didn't expect an IndirectFieldDecl!"); assert(!isa<FieldDecl>(D) && "Didn't expect a FieldDecl!"); if (D->isInAnonymousNamespace()) { diff --git a/clang/test/SemaCXX/anonymous-union.cpp b/clang/test/SemaCXX/anonymous-union.cpp index fde27b049d8..3b568fd8704 100644 --- a/clang/test/SemaCXX/anonymous-union.cpp +++ b/clang/test/SemaCXX/anonymous-union.cpp @@ -84,6 +84,10 @@ static union { float float_val2; }; +void PR21858() { + void int_val2(); +} + void f() { int_val2 = 0; float_val2 = 0.0; |

