errors, e.g.:
t.c:1:21: error: redefinition of parameter 'x'
int test(int x, int x);
^
t.c:1:14: note: previous declaration is here
int test(int x, int x);
^
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96769
91177308-0d34-0410-b5e6-
96231b3b80d8
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">;
<< 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)) {
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;
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;
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; });
}
-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;
}