[cfe-commits] r38839 - in /cfe/cfe/trunk: Parse/ParseDecl.cpp Parse/Parser.cpp include/clang/Parse/DeclSpec.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:25:05 PDT 2007
Author: sabre
Date: Wed Jul 11 11:25:04 2007
New Revision: 38839
URL: http://llvm.org/viewvc/llvm-project?rev=38839&view=rev
Log:
better comments, infrastructure for parsing function bodies.
Modified:
cfe/cfe/trunk/Parse/ParseDecl.cpp
cfe/cfe/trunk/Parse/Parser.cpp
cfe/cfe/trunk/include/clang/Parse/DeclSpec.h
Modified: cfe/cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseDecl.cpp?rev=38839&r1=38838&r2=38839&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:25:04 2007
@@ -295,8 +295,7 @@
ParseDeclaratorInternal(D);
// FIXME: validate D.
-
-
+
}
/// ParseDeclaratorInternal
Modified: cfe/cfe/trunk/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/Parser.cpp?rev=38839&r1=38838&r2=38839&view=diff
==============================================================================
--- cfe/cfe/trunk/Parse/Parser.cpp (original)
+++ cfe/cfe/trunk/Parse/Parser.cpp Wed Jul 11 11:25:04 2007
@@ -201,7 +201,16 @@
Declarator DeclaratorInfo(DS, Declarator::FileContext);
ParseDeclarator(DeclaratorInfo);
- // If the declarator was a function type... handle it.
+ // If the declarator was the start of a function definition, handle it.
+ if (Tok.getKind() != tok::equal && // int X()= -> not a function def
+ Tok.getKind() != tok::comma && // int X(), -> not a function def
+ Tok.getKind() != tok::semi && // int X(); -> not a function def
+ DS.StorageClassSpec != DeclSpec::SCS_typedef && // typedef int X()
+ DeclaratorInfo.isInnermostFunctionType()) { // int *X -> not a fn def.
+ assert(0 && "unimp");
+
+
+ }
// must be: decl-spec[opt] declarator init-declarator-list
// Parse declarator '=' initializer.
Modified: cfe/cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=38839&r1=38838&r2=38839&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/DeclSpec.h Wed Jul 11 11:25:04 2007
@@ -163,7 +163,13 @@
void *NumElts;
};
struct FunctionTypeInfo {
+ /// hasPrototype - This is true if the function had at least one typed
+ /// argument. If the function is () or (a,b,c), then it has no prototype,
+ /// and is treated as a K&R-style function.
bool hasPrototype : 1;
+
+ /// isVariadic - If this function has a prototype, and if that proto ends
+ /// with ',...)', this is true.
bool isVariadic : 1;
// TODO: capture argument info.
};
@@ -244,8 +250,10 @@
///
TheContext Context;
- /// DeclTypeInfo - The final pieces of information is information about each
- /// type parsed as we parse it.
+ /// DeclTypeInfo - This holds each type that the declarator includes as it is
+ /// parsed. This is pushed from the identifier out, which means that element
+ /// #0 will be the most closely bound to the identifier, and
+ /// DeclTypeInfo.back() will be the least closely bound.
SmallVector<DeclaratorTypeInfo, 8> DeclTypeInfo;
public:
@@ -281,6 +289,13 @@
void AddTypeInfo(const DeclaratorTypeInfo &TI) {
DeclTypeInfo.push_back(TI);
}
+
+ /// isInnermostFunctionType - Once this declarator is fully parsed and formed,
+ /// this method returns true if the identifier is a function declarator.
+ bool isInnermostFunctionType() const {
+ return !DeclTypeInfo.empty() &&
+ DeclTypeInfo[0].Kind == DeclaratorTypeInfo::Function;
+ }
};
More information about the cfe-commits
mailing list