diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-07-06 01:04:39 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-07-06 01:04:39 +0000 |
commit | a60a6db73f36f72ed7ad1474b713630d938c42eb (patch) | |
tree | 93699dcad63fa186ad264079026c93aec9c7c477 /clang/lib/Sema | |
parent | ff35c338dc3df3699f497a046d400ec146bfcf00 (diff) | |
download | bcm5719-llvm-a60a6db73f36f72ed7ad1474b713630d938c42eb.tar.gz bcm5719-llvm-a60a6db73f36f72ed7ad1474b713630d938c42eb.zip |
When we see something that looks like a constructor with a return type, only issue one error, not two.
llvm-svn: 241424
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 6508d6f04bb..3c0e83c5a25 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4742,15 +4742,16 @@ NamedDecl *Sema::HandleDeclarator(Scope *S, Declarator &D, } } - if (DiagnoseClassNameShadow(DC, NameInfo)) + TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); + QualType R = TInfo->getType(); + + if (!R->isFunctionType() && DiagnoseClassNameShadow(DC, NameInfo)) // If this is a typedef, we'll end up spewing multiple diagnostics. - // Just return early; it's safer. + // Just return early; it's safer. If this is a function, let the + // "constructor cannot have a return type" diagnostic handle it. if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) return nullptr; - TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S); - QualType R = TInfo->getType(); - if (DiagnoseUnexpandedParameterPack(D.getIdentifierLoc(), TInfo, UPPC_DeclarationType)) D.setInvalidType(); |