]> granicus.if.org Git - clang/commitdiff
[Sema] A tag decl that is marked as invalid and is used in a decl-spec,
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 10 Mar 2012 03:20:58 +0000 (03:20 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 10 Mar 2012 03:20:58 +0000 (03:20 +0000)
should not impede creating a proper TypeLoc info for the decl-spec.

This improves our semantic error recovery.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152481 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/TypeLoc.h
lib/Sema/SemaType.cpp
test/Index/index-invalid-code.m [new file with mode: 0644]

index 1c750965ae3799f452f0972013e7f7db4d72441b..aab87be7c48f2117f929f8293e2a990f7a8f08c4 100644 (file)
@@ -572,8 +572,9 @@ public:
 
   /// \brief True if the tag was defined in this type specifier.
   bool isDefinition() const {
-    return getDecl()->isCompleteDefinition() &&
-         (getNameLoc().isInvalid() || getNameLoc() == getDecl()->getLocation());
+    TagDecl *D = getDecl();
+    return D->isCompleteDefinition() &&
+         (D->getIdentifier() == 0 || D->getLocation() == getNameLoc());
   }
 };
 
index 505cc8f769c8d3b11d0d7de1a928df3f0efe2d0d..919faa0a3cb71492974cac929a8cbc1f796d984a 100644 (file)
@@ -766,9 +766,6 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
     ElaboratedTypeKeyword Keyword
       = ElaboratedType::getKeywordForTypeSpec(DS.getTypeSpecType());
     Result = S.getElaboratedType(Keyword, DS.getTypeSpecScope(), Result);
-
-    if (D->isInvalidDecl())
-      declarator.setInvalidType(true);
     break;
   }
   case DeclSpec::TST_typename: {
diff --git a/test/Index/index-invalid-code.m b/test/Index/index-invalid-code.m
new file mode 100644 (file)
index 0000000..9084533
--- /dev/null
@@ -0,0 +1,8 @@
+struct S {
+  int {
+};
+typedef struct S S;
+
+// RUN: c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: struct | name: S |
+// CHECK-NOT: [indexDeclaration]: kind: struct | name: S |