[cfe-commits] r58649 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/default2.cpp
Douglas Gregor
doug.gregor at gmail.com
Mon Nov 3 14:47:57 PST 2008
Author: dgregor
Date: Mon Nov 3 16:47:57 2008
New Revision: 58649
URL: http://llvm.org/viewvc/llvm-project?rev=58649&view=rev
Log:
Check that this cannot be used in a default argument. Happily, it was already implemented
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/default2.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=58649&r1=58648&r2=58649&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Nov 3 16:47:57 2008
@@ -84,8 +84,13 @@
VDecl->getName(), DefaultArg->getSourceRange());
}
- // FIXME: when Clang has support for member functions, "this"
- // will also need to be diagnosed.
+ // C++ [dcl.fct.default]p8:
+ // The keyword this shall not be used in a default argument of a
+ // member function.
+ // Note: this requirement is already diagnosed by
+ // Sema::ActOnCXXThis, because the use of "this" inside a default
+ // argument doesn't occur inside the body of a non-static member
+ // function.
return false;
}
Modified: cfe/trunk/test/SemaCXX/default2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default2.cpp?rev=58649&r1=58648&r2=58649&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/default2.cpp (original)
+++ cfe/trunk/test/SemaCXX/default2.cpp Mon Nov 3 16:47:57 2008
@@ -36,3 +36,7 @@
void (*f2)(int = 17) // {expected-error {{default arguments can only be specified}}}
= (void (*)(int = 42))f; // {expected-error {{default arguments can only be specified}}}
}
+
+class X {
+ void f(X* x = this); // expected-error{{invalid use of 'this' outside of a nonstatic member function}}
+};
More information about the cfe-commits
mailing list