[cfe-commits] r61127 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaDecl.cpp test/CodeGen/rdr-6140807-alias-references-forward.c test/Parser/recovery.c test/Sema/c89.c test/Sema/function.c test/Sema/redefinition.c
Chris Lattner
sabre at nondot.org
Tue Dec 16 23:33:08 PST 2008
Author: lattner
Date: Wed Dec 17 01:32:46 2008
New Revision: 61127
URL: http://llvm.org/viewvc/llvm-project?rev=61127&view=rev
Log:
diagnose C99 6.9.1p5, C arguments in definitions that are lacking
a name. This implements PR3208.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGen/rdr-6140807-alias-references-forward.c
cfe/trunk/test/Parser/recovery.c
cfe/trunk/test/Sema/c89.c
cfe/trunk/test/Sema/function.c
cfe/trunk/test/Sema/redefinition.c
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=61127&r1=61126&r2=61127&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Dec 17 01:32:46 2008
@@ -484,8 +484,9 @@
ObjCDeclQualifier getObjCDeclQualifier() const {
return ObjCDeclQualifier(objcDeclQualifier);
}
- void setObjCDeclQualifier(ObjCDeclQualifier QTVal)
- { objcDeclQualifier = QTVal; }
+ void setObjCDeclQualifier(ObjCDeclQualifier QTVal) {
+ objcDeclQualifier = QTVal;
+ }
const Expr *getDefaultArg() const { return DefaultArg; }
Expr *getDefaultArg() { return DefaultArg; }
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=61127&r1=61126&r2=61127&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Dec 17 01:32:46 2008
@@ -720,6 +720,8 @@
"expected parameter declarator")
DIAG(err_bad_variable_name, ERROR,
"'%0' cannot be the name of a variable or data member")
+DIAG(err_parameter_name_omitted, ERROR,
+ "parameter name omitted")
DIAG(err_declarator_need_ident, ERROR,
"declarator requires an identifier")
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=61127&r1=61126&r2=61127&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Dec 17 01:32:46 2008
@@ -720,6 +720,11 @@
Param->setInvalidDecl();
HasInvalidParm = true;
}
+
+ // C99 6.9.1p5: If the declarator includes a parameter type list, the
+ // declaration of each parameter shall include an identifier.
+ if (Param->getIdentifier() == 0 && !getLangOptions().CPlusPlus)
+ Diag(Param->getLocation(), diag::err_parameter_name_omitted);
}
return HasInvalidParm;
Modified: cfe/trunk/test/CodeGen/rdr-6140807-alias-references-forward.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rdr-6140807-alias-references-forward.c?rev=61127&r1=61126&r2=61127&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/rdr-6140807-alias-references-forward.c (original)
+++ cfe/trunk/test/CodeGen/rdr-6140807-alias-references-forward.c Wed Dec 17 01:32:46 2008
@@ -10,5 +10,5 @@
return f(1.);
}
-int x(int) {
+int x(int a) {
}
Modified: cfe/trunk/test/Parser/recovery.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/recovery.c?rev=61127&r1=61126&r2=61127&view=diff
==============================================================================
--- cfe/trunk/test/Parser/recovery.c (original)
+++ cfe/trunk/test/Parser/recovery.c Wed Dec 17 01:32:46 2008
@@ -20,7 +20,7 @@
// rdar://6094870
-int test(int) {
+int test(int a) {
struct { int i; } x;
if (x.hello) // expected-error {{no member named 'hello'}}
Modified: cfe/trunk/test/Sema/c89.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/c89.c?rev=61127&r1=61126&r2=61127&view=diff
==============================================================================
--- cfe/trunk/test/Sema/c89.c (original)
+++ cfe/trunk/test/Sema/c89.c Wed Dec 17 01:32:46 2008
@@ -44,7 +44,8 @@
void test8(int, x); /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
typedef int sometype;
-int a(sometype, y) {return 0;} /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
+int a(sometype, y) {return 0;} /* expected-warning {{declaration specifier missing, defaulting to 'int'}} \
+ expected-error {{parameter name omitted}}*/
Modified: cfe/trunk/test/Sema/function.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/function.c?rev=61127&r1=61126&r2=61127&view=diff
==============================================================================
--- cfe/trunk/test/Sema/function.c (original)
+++ cfe/trunk/test/Sema/function.c Wed Dec 17 01:32:46 2008
@@ -29,3 +29,6 @@
void t10(){}
void t11(){t10(1);}
+// PR3208
+void t12(int) {} // expected-error{{parameter name omitted}}
+
Modified: cfe/trunk/test/Sema/redefinition.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/redefinition.c?rev=61127&r1=61126&r2=61127&view=diff
==============================================================================
--- cfe/trunk/test/Sema/redefinition.c (original)
+++ cfe/trunk/test/Sema/redefinition.c Wed Dec 17 01:32:46 2008
@@ -1,5 +1,5 @@
// RUN: clang %s -fsyntax-only -verify
-int f(int) { } // expected-note {{previous definition is here}}
+int f(int a) { } // expected-note {{previous definition is here}}
int f(int);
-int f(int) { } // expected-error {{redefinition of 'f'}}
+int f(int a) { } // expected-error {{redefinition of 'f'}}
More information about the cfe-commits
mailing list