[cfe-commits] r41521 - in /cfe/trunk: Parse/ParseDecl.cpp Sema/SemaDecl.cpp Sema/SemaExpr.cpp Sema/SemaType.cpp include/clang/AST/Decl.h include/clang/Parse/DeclSpec.h

Steve Naroff snaroff at apple.com
Mon Aug 27 21:12:08 PDT 2007

On Aug 27, 2007, at 8:23 PM, Chris Lattner wrote:

>> This seems to work nicely. If Chris is happy with the approach, I  
>> will generalize this to
>> all VarDecls.
> Cool, this is very nice.  Some little comments:
>> @@ -221,11 +221,14 @@
>>  /// ParmVarDecl - Represent a parameter to a function.
>>  class ParmVarDecl : public VarDecl {
>> +  bool InvalidType;
> I think this should move all the way up to Decl (even past VarDecl)  
> and be generalized to just be "InvalidDecl". This will allow it to  
> be set for a decl that has any erroneous aspect: for example, on a  
> "void foo" parm decl (void is a valid type, but not a valid type  
> for a parmdecl, f.e.).

Agreed. This was only temporary (to prove the approach for ParmDecls).

>> ===================================================================== 
>> =========
>> --- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
>> +++ cfe/trunk/include/clang/Parse/DeclSpec.h Mon Aug 27 22:03:08 2007
>> @@ -315,10 +315,12 @@
>>      IdentifierInfo *Ident;
>>      SourceLocation IdentLoc;
>>      Action::TypeTy *TypeInfo;
>> +    bool InvalidType;
> Why does this need invalidtype here?

It is needed for ParmVarDecls (see Sema::ParseParmDeclarator() for  
more details).

> Isn't it sufficient to mark the whole Declarator object?

This would be nice (and was my first thought, until I bumped into  
problems with ParmVarDecls).

That said, if you think it is still superfluous, I am happy to change  
it (if you can tell me how to get ParmVarDecls to work:-)

> Thanks Steve, I think this is a very nice solution!

Great. This will also enable us to fix the following "undeclared  
identifier" diags:-)

[dylan:~/llvm/tools/clang] admin% cat x.c
struct s;
void proto(struct s);

void f () {
   struct s v, *p;

   p = &v; // v is currently undeclared.

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang x.c
x.c:5:12: error: variable has incomplete type 'struct s'
   struct s v, *p;
x.c:7:8: error: use of undeclared identifier 'v'
   p = &v; // v is currently undeclared.
2 diagnostics generated.

> -Chris

More information about the cfe-commits mailing list