[cfe-commits] r39512 - in /cfe/cfe/trunk: Sema/SemaExpr.cpp include/clang/AST/Decl.h include/clang/Basic/DiagnosticKinds.def
Steve Naroff
snaroff at apple.com
Wed Jul 11 09:45:09 PDT 2007
Author: snaroff
Date: Wed Jul 11 11:45:09 2007
New Revision: 39512
URL: http://llvm.org/viewvc/llvm-project?rev=39512&view=rev
Log:
Bug #:
Submitted by:
Reviewed by:
- Implement FIXME in Sema::CheckIndirectionOperand().
- Added "const" to FunctionDecl::getResultType().
Modified:
cfe/cfe/trunk/Sema/SemaExpr.cpp
cfe/cfe/trunk/include/clang/AST/Decl.h
cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def
Modified: cfe/cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaExpr.cpp?rev=39512&r1=39511&r2=39512&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaExpr.cpp Wed Jul 11 11:45:09 2007
@@ -1000,11 +1000,24 @@
assert(!qType.isNull() && "no type for * expression");
- // FIXME: need to check if the pointee is an incomplete type. Find spec ref.
- if (PointerType *PT = dyn_cast<PointerType>(qType.getCanonicalType()))
- return PT->getPointeeType();
- Diag(OpLoc, diag::err_typecheck_indirection_expr, qType.getAsString(),
- op->getSourceRange());
+ if (PointerType *PT = dyn_cast<PointerType>(qType.getCanonicalType())) {
+ QualType ptype = PT->getPointeeType();
+ // C99 6.5.3.2p4. "if it points to an object,...".
+ if (ptype->isIncompleteType()) { // An incomplete type is not an object
+ // GCC compat: special case 'void *' (treat as warning).
+ if (ptype->isVoidType()) {
+ Diag(OpLoc, diag::ext_typecheck_deref_ptr_to_void,
+ qType.getAsString(), op->getSourceRange());
+ } else {
+ Diag(OpLoc, diag::err_typecheck_deref_incomplete_type,
+ ptype.getAsString(), op->getSourceRange());
+ return QualType();
+ }
+ }
+ return ptype;
+ }
+ Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer,
+ qType.getAsString(), op->getSourceRange());
return QualType();
}
Modified: cfe/cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Decl.h?rev=39512&r1=39511&r2=39512&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Decl.h Wed Jul 11 11:45:09 2007
@@ -210,7 +210,7 @@
}
void setParams(VarDecl **NewParamInfo, unsigned NumParams);
- QualType getResultType() {
+ QualType getResultType() const {
return cast<FunctionType>(getType())->getResultType();
}
StorageClass getStorageClass() const { return SClass; }
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=39512&r1=39511&r2=39512&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Jul 11 11:45:09 2007
@@ -550,8 +550,12 @@
"invalid lvalue in address expression")
DIAG(err_typecheck_unary_expr, ERROR,
"invalid argument type to unary expression '%0'")
-DIAG(err_typecheck_indirection_expr, ERROR,
+DIAG(err_typecheck_indirection_requires_pointer, ERROR,
"indirection requires a pointer operand ('%0' invalid)")
+DIAG(err_typecheck_deref_incomplete_type, ERROR,
+ "dereferencing pointer to incomplete type '%0'")
+DIAG(ext_typecheck_deref_ptr_to_void, EXTENSION,
+ "dereferencing '%0' pointer")
DIAG(err_typecheck_invalid_operands, ERROR,
"invalid operands to binary expression ('%0' and '%1')")
DIAG(ext_typecheck_comparison_of_pointer_integer, EXTENSION,
More information about the cfe-commits
mailing list