[cfe-commits] r62944 - in /cfe/trunk: lib/AST/ASTContext.cpp lib/AST/Type.cpp lib/Parse/ParseTentative.cpp test/SemaCXX/member-pointer.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Sat Jan 24 15:29:36 PST 2009
Author: cornedbee
Date: Sat Jan 24 17:29:36 2009
New Revision: 62944
URL: http://llvm.org/viewvc/llvm-project?rev=62944&view=rev
Log:
Make tentative parsing of pointer-to-member decls work, and fix other stuff pointed out by Doug.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/test/SemaCXX/member-pointer.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=62944&r1=62943&r2=62944&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Jan 24 17:29:36 2009
@@ -400,10 +400,11 @@
// pointer size.
return getTypeInfo(cast<ReferenceType>(T)->getPointeeType());
case Type::MemberPointer: {
- // Note that this is not only platform- but also ABI-dependent. We follow
+ // FIXME: This is not only platform- but also ABI-dependent. We follow
// the GCC ABI, where pointers to data are one pointer large, pointers to
// functions two pointers. But if we want to support ABI compatibility with
- // other compilers too, we need to delegate this completely to TargetInfo.
+ // other compilers too, we need to delegate this completely to TargetInfo
+ // or some ABI abstraction layer.
QualType Pointee = cast<MemberPointerType>(T)->getPointeeType();
unsigned AS = Pointee.getAddressSpace();
Width = Target.getPointerWidth(AS);
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=62944&r1=62943&r2=62944&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sat Jan 24 17:29:36 2009
@@ -324,6 +324,8 @@
// correctly.
if (const PointerLikeType *PT = getAsPointerLikeType())
return PT->getPointeeType()->isVariablyModifiedType();
+ if (const MemberPointerType *PT = getAsMemberPointerType())
+ return PT->getPointeeType()->isVariablyModifiedType();
// A function can return a variably modified type
// This one isn't completely obvious, but it follows from the
Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=62944&r1=62943&r2=62944&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Sat Jan 24 17:29:36 2009
@@ -357,7 +357,7 @@
/// '*' cv-qualifier-seq[opt]
/// '&'
/// [C++0x] '&&' [TODO]
-/// '::'[opt] nested-name-specifier '*' cv-qualifier-seq[opt] [TODO]
+/// '::'[opt] nested-name-specifier '*' cv-qualifier-seq[opt]
///
/// cv-qualifier-seq:
/// cv-qualifier cv-qualifier-seq[opt]
@@ -387,8 +387,12 @@
// ptr-operator declarator
while (1) {
- if (Tok.is(tok::star) || Tok.is(tok::amp) ||
- (Tok.is(tok::caret) && getLang().Blocks)) {
+ if (Tok.is(tok::coloncolon) || Tok.is(tok::identifier))
+ TryAnnotateCXXScopeToken();
+
+ if (Tok.is(tok::star) || Tok.is(tok::amp) ||
+ (Tok.is(tok::caret) && getLang().Blocks) ||
+ (Tok.is(tok::annot_cxxscope) && NextToken().is(tok::star))) {
// ptr-operator
ConsumeToken();
while (Tok.is(tok::kw_const) ||
Modified: cfe/trunk/test/SemaCXX/member-pointer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-pointer.cpp?rev=62944&r1=62943&r2=62944&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-pointer.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-pointer.cpp Sat Jan 24 17:29:36 2009
@@ -12,3 +12,8 @@
int C::*pci; // expected-error {{'pci' does not point into a class}}
void A::*pdv; // expected-error {{'pdv' declared as a member pointer to void}}
int& A::*pdr; // expected-error {{'pdr' declared as a pointer to a reference}}
+
+void f() {
+ // This requires tentative parsing.
+ int (A::*pf)(int, int);
+}
More information about the cfe-commits
mailing list