]> granicus.if.org Git - clang/commitdiff
Don't mark a type specifier as "owned" if there is no declaration to own.
authorDouglas Gregor <dgregor@apple.com>
Tue, 14 May 2013 23:22:32 +0000 (23:22 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 14 May 2013 23:22:32 +0000 (23:22 +0000)
This simplifies error recovery elsewhere, eliminating the crash in
<rdar://problem/13853540>.

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

lib/Sema/DeclSpec.cpp
test/SemaCXX/nested-name-spec.cpp

index 3b3ab2c27b4ab6afec4b7188ef8aa51628bd6d46..dfce324b702ab5670b58828aacefee759c6dec6e 100644 (file)
@@ -651,7 +651,7 @@ bool DeclSpec::SetTypeSpecType(TST T, SourceLocation TagKwLoc,
   DeclRep = Rep;
   TSTLoc = TagKwLoc;
   TSTNameLoc = TagNameLoc;
-  TypeSpecOwned = Owned;
+  TypeSpecOwned = Owned && Rep != 0;
   return false;
 }
 
index 7239646d8d7e890618dc261849c2d244ce9ebb26..228bc0ecbdb4b0c0b66a8bf33664cb0646281de5 100644 (file)
@@ -297,3 +297,13 @@ namespace NS {
 int foobar = a + longer_b; // expected-error {{use of undeclared identifier 'a'; did you mean 'NS::a'?}} \
                            // expected-error {{use of undeclared identifier 'longer_b'; did you mean 'NS::longer_b'?}}
 }
+
+// <rdar://problem/13853540>
+namespace N {
+  struct X { };
+  namespace N {
+    struct Foo {
+      struct N::X *foo(); // expected-error{{no struct named 'X' in namespace 'N::N'}}
+    };
+  }
+}