[cfe-commits] r83124 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprCXX.cpp test/SemaCXX/overloaded-operator.cpp
Fariborz Jahanian
fjahanian at apple.com
Tue Sep 29 17:19:41 PDT 2009
Author: fjahanian
Date: Tue Sep 29 19:19:41 2009
New Revision: 83124
URL: http://llvm.org/viewvc/llvm-project?rev=83124&view=rev
Log:
self-referecing operator '->' member function was causing
infinit recursion. This patch fixes it. [13.3.1.2]-p2
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/overloaded-operator.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=83124&r1=83123&r2=83124&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep 29 19:19:41 2009
@@ -1646,6 +1646,8 @@
def err_ident_in_pseudo_dtor_not_a_type : Error<
"identifier %0 in pseudo-destructor expression does not name a type">;
+def err_operator_arrow_circular : Error<
+ "circular pointer delegation detected">;
def err_pseudo_dtor_base_not_scalar : Error<
"object expression of non-scalar type %0 cannot be used in a "
"pseudo-destructor expression">;
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=83124&r1=83123&r2=83124&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Sep 29 19:19:41 2009
@@ -1982,6 +1982,11 @@
BaseExpr = (Expr*)Base.get();
if (BaseExpr == NULL)
return ExprError();
+ if (Context.getCanonicalType(BaseExpr->getType()) ==
+ Context.getCanonicalType(BaseType)) {
+ Diag(OpLoc, diag::err_operator_arrow_circular);
+ return ExprError();
+ }
BaseType = BaseExpr->getType();
}
}
Modified: cfe/trunk/test/SemaCXX/overloaded-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-operator.cpp?rev=83124&r1=83123&r2=83124&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/overloaded-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/overloaded-operator.cpp Tue Sep 29 19:19:41 2009
@@ -213,3 +213,14 @@
struct AA { bool operator!=(AA&); };
struct BB : AA {};
bool x(BB y, BB z) { return y != z; }
+
+
+struct AX {
+ AX& operator ->();
+ int b;
+};
+
+void m() {
+ AX a;
+ a->b = 0; // expected-error {{circular pointer delegation detected}}
+}
More information about the cfe-commits
mailing list