[cfe-commits] r80129 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprCXX.cpp test/SemaCXX/pseudo-destructors.cpp
Anders Carlsson
andersca at mac.com
Wed Aug 26 12:22:42 PDT 2009
Author: andersca
Date: Wed Aug 26 14:22:42 2009
New Revision: 80129
URL: http://llvm.org/viewvc/llvm-project?rev=80129&view=rev
Log:
More support for pseudo dtors.
Added:
cfe/trunk/test/SemaCXX/pseudo-destructors.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=80129&r1=80128&r2=80129&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Aug 26 14:22:42 2009
@@ -1554,6 +1554,11 @@
def err_return_in_constructor_handler : Error<
"return in the catch of a function try block of a constructor is illegal">;
+def err_ident_in_pseudo_dtor_not_a_type : Error<
+ "identifier %0 in pseudo-destructor expression does not name a type">;
+def err_type_in_pseudo_dtor_not_a_class_type : Error<
+ "type %0 in pseudo-destructor expression is not a class type">;
+
def err_invalid_use_of_function_type : Error<
"a function type is not allowed here">;
def err_invalid_use_of_array_type : Error<"an array type is not allowed here">;
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=80129&r1=80128&r2=80129&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Aug 26 14:22:42 2009
@@ -1694,18 +1694,35 @@
const CXXScopeSpec *SS) {
if (SS && SS->isInvalid())
return ExprError();
+
+ Expr *BaseExpr = (Expr *)Base.get();
- // Since this might be a postfix expression, get rid of ParenListExprs.
- Base = MaybeConvertParenListExprToParenExpr(S, move(Base));
-
- Expr *BaseExpr = Base.takeAs<Expr>();
- assert(BaseExpr && "no record expression");
+ if (BaseExpr->isTypeDependent() ||
+ (SS && isDependentScopeSpecifier(*SS))) {
+ // FIXME: Return an unresolved ref expr.
+ return ExprError();
+ }
+
+ TypeTy *BaseTy = getTypeName(*ClassName, ClassNameLoc, S, SS);
+ if (!BaseTy) {
+ Diag(ClassNameLoc, diag::err_ident_in_pseudo_dtor_not_a_type)
+ << ClassName;
+ return ExprError();
+ }
- // Perform default conversions.
- DefaultFunctionArrayConversion(BaseExpr);
+ QualType BaseType = GetTypeFromParser(BaseTy);
+ if (!BaseType->isRecordType()) {
+ Diag(ClassNameLoc, diag::err_type_in_pseudo_dtor_not_a_class_type)
+ << BaseType;
+ return ExprError();
+ }
- QualType BaseType = BaseExpr->getType();
- return ExprError();
+ CanQualType CanBaseType = Context.getCanonicalType(BaseType);
+ DeclarationName DtorName =
+ Context.DeclarationNames.getCXXDestructorName(CanBaseType);
+
+ return BuildMemberReferenceExpr(S, move(Base), OpLoc, OpKind, ClassNameLoc,
+ DtorName, DeclPtrTy(), SS);
}
Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) {
Added: cfe/trunk/test/SemaCXX/pseudo-destructors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pseudo-destructors.cpp?rev=80129&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/pseudo-destructors.cpp (added)
+++ cfe/trunk/test/SemaCXX/pseudo-destructors.cpp Wed Aug 26 14:22:42 2009
@@ -0,0 +1,13 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+struct A {};
+
+enum Foo { F };
+typedef Foo Bar;
+
+void f(A* a) {
+ a->~A();
+ a->A::~A();
+
+ a->~foo(); // expected-error{{identifier 'foo' in pseudo-destructor expression does not name a type}}
+ a->~Bar(); // expected-error{{type 'Bar' (aka 'enum Foo') in pseudo-destructor expression is not a class type}}
+}
More information about the cfe-commits
mailing list