aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorSean Hunt <scshunt@csclub.uwaterloo.ca>2010-11-03 01:07:06 +0000
committerSean Hunt <scshunt@csclub.uwaterloo.ca>2010-11-03 01:07:06 +0000
commit7533a5b65f81a4eed1e0f0afeb859e26bc0c056b (patch)
treec9bca3e7c8d3d3aa94dcc3d3c8aaaa7f5e33b2c4 /lib/Sema/SemaDecl.cpp
parent40749ee585abc84fbb3c8fdbd8aaac062f153062 (diff)
Provide an error when a non-identifier name (such as an operator) is used as a
parameter name. Fixes PR8012. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118138 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 285173628c..10a23ec43e 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -4757,8 +4757,18 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
<< Context.getTypeDeclType(OwnedDecl);
}
+ // Ensure we have a valid name
+ IdentifierInfo *II = 0;
+ if (D.hasName()) {
+ II = D.getIdentifier();
+ if (!II) {
+ Diag(D.getIdentifierLoc(), diag::err_bad_parameter_name)
+ << GetNameForDeclarator(D).getName().getAsString();
+ D.setInvalidType(true);
+ }
+ }
+
// Check for redeclaration of parameters, e.g. int foo(int x, int x);
- IdentifierInfo *II = D.getIdentifier();
if (II) {
LookupResult R(*this, II, D.getIdentifierLoc(), LookupOrdinaryName,
ForRedeclaration);