Make sure we actually found a redeclaration before complaining about attributes added to a redeclaration in C++

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80403 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 85b5963..d1bb6fb 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2736,7 +2736,7 @@
   ProcessDeclAttributes(S, NewFD, D);
 
   // attributes declared post-definition are currently ignored
-  if (PrevDecl) {
+  if (Redeclaration && PrevDecl) {
     const FunctionDecl *Def, *PrevFD = dyn_cast<FunctionDecl>(PrevDecl);
     if (PrevFD && PrevFD->getBody(Def) && D.hasAttributes()) {
       Diag(NewFD->getLocation(), diag::warn_attribute_precede_definition);