[cfe-commits] r39365 - in /cfe/cfe/trunk: AST/SemaType.cpp Sema/SemaType.cpp include/clang/Basic/DiagnosticKinds.def
Steve Naroff
snaroff at apple.com
Wed Jul 11 09:43:39 PDT 2007
Author: snaroff
Date: Wed Jul 11 11:43:39 2007
New Revision: 39365
URL: http://llvm.org/viewvc/llvm-project?rev=39365&view=rev
Log:
Bug #:
Submitted by:
Reviewed by:
Fix a couple bugs in Sema::GetTypeForDeclarator(). Need to disallow:
- void arrayOfFunctions[3]()
- void arrayOfVoids[3]
Need to talk to Chris about the return value...
Modified:
cfe/cfe/trunk/AST/SemaType.cpp
cfe/cfe/trunk/Sema/SemaType.cpp
cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def
Modified: cfe/cfe/trunk/AST/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaType.cpp?rev=39365&r1=39364&r2=39365&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/SemaType.cpp (original)
+++ cfe/cfe/trunk/AST/SemaType.cpp Wed Jul 11 11:43:39 2007
@@ -15,6 +15,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/Parse/DeclSpec.h"
+#include "clang/Lex/IdentifierTable.h"
using namespace llvm;
using namespace clang;
@@ -130,15 +131,23 @@
else
ASM = ArrayType::Normal;
+ Type *CanonicalT = T->getCanonicalType();
+
// If the element type is a struct or union that contains a variadic
// array, reject it: C99 6.7.2.1p2.
- if (RecordType *EltTy = dyn_cast<RecordType>(T->getCanonicalType())) {
+ if (RecordType *EltTy = dyn_cast<RecordType>(CanonicalT)) {
if (EltTy->getDecl()->hasFlexibleArrayMember()) {
std::string Name;
T->getAsString(Name);
Diag(DeclType.Loc, diag::err_flexible_array_in_array, Name);
return TypeRef();
}
+ } else if (isa<FunctionType>(CanonicalT)) {// reject "void aryOfFunc[3]()"
+ Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_functions,
+ D.getIdentifier()->getName());
+ } else if (CanonicalT->isVoidType()) { // reject "void aryOfVoids[3]"
+ Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_voids,
+ D.getIdentifier()->getName());
}
T = Context.getArrayType(T, ASM, ATI.TypeQuals,
Modified: cfe/cfe/trunk/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaType.cpp?rev=39365&r1=39364&r2=39365&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaType.cpp Wed Jul 11 11:43:39 2007
@@ -15,6 +15,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/Parse/DeclSpec.h"
+#include "clang/Lex/IdentifierTable.h"
using namespace llvm;
using namespace clang;
@@ -130,15 +131,23 @@
else
ASM = ArrayType::Normal;
+ Type *CanonicalT = T->getCanonicalType();
+
// If the element type is a struct or union that contains a variadic
// array, reject it: C99 6.7.2.1p2.
- if (RecordType *EltTy = dyn_cast<RecordType>(T->getCanonicalType())) {
+ if (RecordType *EltTy = dyn_cast<RecordType>(CanonicalT)) {
if (EltTy->getDecl()->hasFlexibleArrayMember()) {
std::string Name;
T->getAsString(Name);
Diag(DeclType.Loc, diag::err_flexible_array_in_array, Name);
return TypeRef();
}
+ } else if (isa<FunctionType>(CanonicalT)) {// reject "void aryOfFunc[3]()"
+ Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_functions,
+ D.getIdentifier()->getName());
+ } else if (CanonicalT->isVoidType()) { // reject "void aryOfVoids[3]"
+ Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_voids,
+ D.getIdentifier()->getName());
}
T = Context.getArrayType(T, ASM, ATI.TypeQuals,
Modified: cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=39365&r1=39364&r2=39365&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Jul 11 11:43:39 2007
@@ -462,7 +462,11 @@
"'%s' may not be nested in a struct due to flexible array member")
DIAG(err_flexible_array_in_array, ERROR,
"'%s' may not be used as an array element due to flexible array member")
-
+DIAG(err_illegal_decl_array_of_functions, ERROR,
+ "'%s' declared as array of functions")
+DIAG(err_illegal_decl_array_of_voids, ERROR,
+ "'%s' declared as array of voids")
+
// Expressions.
DIAG(ext_sizeof_function_type, EXTENSION,
"invalid application of 'sizeof' to a function type")
More information about the cfe-commits
mailing list