diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-11 22:33:48 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-11 22:33:48 +0000 |
commit | ec3bd728cc6505c98543b001a1988c237f5fb9a9 (patch) | |
tree | d09c14bc89326623b761885792cc44ae464289fa /lib/Sema/SemaDecl.cpp | |
parent | dc98cd0cdd2eee8290b624ef69c6d91ce626d85e (diff) |
Improve the diagnostic when trying to redefine a typedef with a
variably-modified type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147973 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 588fc14044..f30f1fa5be 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1383,10 +1383,21 @@ bool Sema::isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New) { OldType = Context.getTypeDeclType(Old); QualType NewType = New->getUnderlyingType(); + if (NewType->isVariablyModifiedType()) { + // Must not redefine a typedef with a variably-modified type. + int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0; + Diag(New->getLocation(), diag::err_redefinition_variably_modified_typedef) + << Kind << NewType; + if (Old->getLocation().isValid()) + Diag(Old->getLocation(), diag::note_previous_definition); + New->setInvalidDecl(); + return true; + } + if (OldType != NewType && !OldType->isDependentType() && !NewType->isDependentType() && - !Context.hasSameType(OldType, NewType)) { + !Context.hasSameType(OldType, NewType)) { int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0; Diag(New->getLocation(), diag::err_redefinition_different_typedef) << Kind << NewType << OldType; |