From: Douglas Gregor Date: Tue, 14 May 2013 23:22:32 +0000 (+0000) Subject: Don't mark a type specifier as "owned" if there is no declaration to own. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=86a87308f11e7ee7c71ff608aec0cde11aa7df58;p=clang Don't mark a type specifier as "owned" if there is no declaration to own. This simplifies error recovery elsewhere, eliminating the crash in . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181846 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index 3b3ab2c27b..dfce324b70 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -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; } diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp index 7239646d8d..228bc0ecbd 100644 --- a/test/SemaCXX/nested-name-spec.cpp +++ b/test/SemaCXX/nested-name-spec.cpp @@ -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'?}} } + +// +namespace N { + struct X { }; + namespace N { + struct Foo { + struct N::X *foo(); // expected-error{{no struct named 'X' in namespace 'N::N'}} + }; + } +}