]> granicus.if.org Git - clang/commit
Implement more thoughful error recovery when dealing with bogus declarator types.
authorSteve Naroff <snaroff@apple.com>
Tue, 28 Aug 2007 03:03:08 +0000 (03:03 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 28 Aug 2007 03:03:08 +0000 (03:03 +0000)
commite1223f7246c2c297f7b62816fd8c6a0a14151977
tree97daf64133f6e36fe3e32999ae6a53e902963f4c
parent0b1d9b7557437176f9cea1283bfac2510812bece
Implement more thoughful error recovery when dealing with bogus declarator types.

For example, the following code was resulting in spurious warnings. This was the result of
Sema::GetTypeForDeclarator() synthesizing a type to hand back to the caller (in this case,
"int []", instead of "struct s[]", which is invalid).

struct s;
struct s* t (struct s z[]) {   // expected-error {{array has incomplete element type}}
  return z;
}

Strategy: Flag the error in Declarator/DeclaratorChunk. This info is later stored in
the ParmVarDecl. If the decl is referenced, Sema::ParseIdentifierExpr() will check if
the type is invalid. If so, it quietly returns "true", without instantiating a DeclRefExpr.

This seems to work nicely. If Chris is happy with the approach, I will generalize this to
all VarDecls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41521 91177308-0d34-0410-b5e6-96231b3b80d8
Parse/ParseDecl.cpp
Sema/SemaDecl.cpp
Sema/SemaExpr.cpp
Sema/SemaType.cpp
include/clang/AST/Decl.h
include/clang/Parse/DeclSpec.h