[cfe-commits] r51424 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/void_arg.c
Eli Friedman
eli.friedman at gmail.com
Thu May 22 01:54:04 PDT 2008
Author: efriedma
Date: Thu May 22 03:54:03 2008
New Revision: 51424
URL: http://llvm.org/viewvc/llvm-project?rev=51424&view=rev
Log:
Patch for PR2350; the issue was tnat we were allowing (with an error)
void f(const void) in one place and rejecting it in another.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/void_arg.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=51424&r1=51423&r2=51424&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu May 22 03:54:03 2008
@@ -878,9 +878,10 @@
// Check for C99 6.7.5.3p10 - foo(void) is a non-varargs
// function that takes no arguments, not a function that takes a
// single void argument.
+ // We let through "const void" here because Sema::GetTypeForDeclarator
+ // already checks for that case.
if (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 &&
FTI.ArgInfo[0].Param &&
- !((ParmVarDecl*)FTI.ArgInfo[0].Param)->getType().getCVRQualifiers() &&
((ParmVarDecl*)FTI.ArgInfo[0].Param)->getType()->isVoidType()) {
// empty arg list, don't push any params.
ParmVarDecl *Param = (ParmVarDecl*)FTI.ArgInfo[0].Param;
@@ -888,7 +889,7 @@
// In C++, the empty parameter-type-list must be spelled "void"; a
// typedef of void is not permitted.
if (getLangOptions().CPlusPlus &&
- Param->getType() != Context.VoidTy) {
+ Param->getType().getUnqualifiedType() != Context.VoidTy) {
Diag(Param->getLocation(), diag::ext_param_typedef_of_void);
}
Modified: cfe/trunk/test/Sema/void_arg.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/void_arg.c?rev=51424&r1=51423&r2=51424&view=diff
==============================================================================
--- cfe/trunk/test/Sema/void_arg.c (original)
+++ cfe/trunk/test/Sema/void_arg.c Thu May 22 03:54:03 2008
@@ -1,4 +1,4 @@
-/* RUN: clang -fsyntax-only %s 2>&1 | grep '6 diagnostics'
+/* RUN: clang -fsyntax-only %s -verify
*/
typedef void Void;
@@ -6,13 +6,13 @@
void foo() {
int X;
- X = sizeof(int (void a));
- X = sizeof(int (int, void));
- X = sizeof(int (void, ...));
-
- X = sizeof(int (Void a));
- X = sizeof(int (int, Void));
- X = sizeof(int (Void, ...));
+ X = sizeof(int (void a)); // expected-error {{argument may not have 'void' type}}
+ X = sizeof(int (int, void)); // expected-error {{must be the first and only parameter}}
+ X = sizeof(int (void, ...)); // expected-error {{must be the first and only parameter}}
+
+ X = sizeof(int (Void a)); // expected-error {{argument may not have 'void' type}}
+ X = sizeof(int (int, Void)); // expected-error {{must be the first and only parameter}}
+ X = sizeof(int (Void, ...)); // expected-error {{must be the first and only parameter}}
// Accept these.
X = sizeof(int (void));
@@ -23,3 +23,4 @@
void bar(Void) {
}
+void f(const void); // expected-error {{parameter must not have type qualifiers}}
More information about the cfe-commits
mailing list