diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-08-28 22:54:55 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-08-28 22:54:55 +0000 |
commit | 90820ee62a9217e6da4ee0a7e1ae768ab3bcade3 (patch) | |
tree | c567d84a95d6b476b4532331b5235a0bcf04bf5b | |
parent | 601d6e4c7b012ff5dcda4089029c416014cb85c6 (diff) | |
download | bcm5719-llvm-90820ee62a9217e6da4ee0a7e1ae768ab3bcade3.tar.gz bcm5719-llvm-90820ee62a9217e6da4ee0a7e1ae768ab3bcade3.zip |
Make sure we actually found a redeclaration before complaining about attributes added to a redeclaration in C++
llvm-svn: 80403
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/attr-after-definition.cpp | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 85b5963a39d..d1bb6fb453e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2736,7 +2736,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, 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); diff --git a/clang/test/SemaCXX/attr-after-definition.cpp b/clang/test/SemaCXX/attr-after-definition.cpp new file mode 100644 index 00000000000..2ef5acfbc0f --- /dev/null +++ b/clang/test/SemaCXX/attr-after-definition.cpp @@ -0,0 +1,9 @@ +// RUN: clang-cc -fsyntax-only -verify %s +struct X { }; +struct Y { }; + +bool f0(X) { return true; } // expected-note{{definition}} +bool f1(X) { return true; } + +__attribute__ ((__visibility__("hidden"))) bool f0(X); // expected-warning{{attribute}} +__attribute__ ((__visibility__("hidden"))) bool f1(Y); |