summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-07-06 01:04:39 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-07-06 01:04:39 +0000
commita60a6db73f36f72ed7ad1474b713630d938c42eb (patch)
tree93699dcad63fa186ad264079026c93aec9c7c477 /clang/lib/Sema
parentff35c338dc3df3699f497a046d400ec146bfcf00 (diff)
downloadbcm5719-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.cpp11
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();
OpenPOWER on IntegriCloud