summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td3
-rw-r--r--clang/lib/Sema/SemaDecl.cpp5
-rw-r--r--clang/test/Sema/arg-duplicate.c3
-rw-r--r--clang/test/Sema/block-args.c3
-rw-r--r--clang/test/SemaCXX/default2.cpp3
5 files changed, 9 insertions, 8 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 682f20348df..7c75f2fc7bf 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -492,8 +492,7 @@ def err_implicit_object_parameter_init : Error<
def note_field_decl : Note<"member is declared here">;
def note_bitfield_decl : Note<"bit-field is declared here">;
-def note_previous_decl : Note<
- "%0 declared here">;
+def note_previous_decl : Note<"%0 declared here">;
def note_member_synthesized_at : Note<
"implicit default %select{constructor|copy constructor|"
"copy assignment operator|destructor}0 for %1 first required here">;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2a9885c6a3c..c59e8bad667 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3878,9 +3878,7 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
<< Context.getTypeDeclType(OwnedDecl);
}
- // TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope.
- // Can this happen for params? We already checked that they don't conflict
- // among each other. Here they can only shadow globals, which is ok.
+ // Check for redeclaration of parameters, e.g. int foo(int x, int x);
IdentifierInfo *II = D.getIdentifier();
if (II) {
if (NamedDecl *PrevDecl = LookupSingleName(S, II, LookupOrdinaryName)) {
@@ -3891,6 +3889,7 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
PrevDecl = 0;
} else if (S->isDeclScope(DeclPtrTy::make(PrevDecl))) {
Diag(D.getIdentifierLoc(), diag::err_param_redefinition) << II;
+ Diag(PrevDecl->getLocation(), diag::note_previous_declaration);
// Recover by removing the name
II = 0;
diff --git a/clang/test/Sema/arg-duplicate.c b/clang/test/Sema/arg-duplicate.c
index ca091eb309e..feeb458a3f4 100644
--- a/clang/test/Sema/arg-duplicate.c
+++ b/clang/test/Sema/arg-duplicate.c
@@ -2,7 +2,8 @@
int f3(y, x,
x) // expected-error {{redefinition of parameter}}
- int y, x,
+ int y,
+ x, // expected-note {{previous declaration is here}}
x; // expected-error {{redefinition of parameter}}
{
return x + y;
diff --git a/clang/test/Sema/block-args.c b/clang/test/Sema/block-args.c
index a07c82e75af..970c60d51dd 100644
--- a/clang/test/Sema/block-args.c
+++ b/clang/test/Sema/block-args.c
@@ -6,7 +6,8 @@ void test() {
take(^(int x){});
take(^(int x, int y){});
take(^(int x, int y){});
- take(^(int x, int x){}); // expected-error {{redefinition of parameter 'x'}}
+ take(^(int x, // expected-note {{previous declaration is here}}
+ int x){}); // expected-error {{redefinition of parameter 'x'}}
take(^(int x) { return x+1; });
diff --git a/clang/test/SemaCXX/default2.cpp b/clang/test/SemaCXX/default2.cpp
index d2c44bd998a..e674260680f 100644
--- a/clang/test/SemaCXX/default2.cpp
+++ b/clang/test/SemaCXX/default2.cpp
@@ -16,7 +16,8 @@ void i()
}
-int f1(int i, int i, int j) { // expected-error {{redefinition of parameter 'i'}}
+int f1(int i, // expected-note {{previous declaration is here}}
+ int i, int j) { // expected-error {{redefinition of parameter 'i'}}
i = 17;
return j;
}
OpenPOWER on IntegriCloud