diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp
index 569352e..e1ea33f 100644
--- a/lib/Sema/DeclSpec.cpp
+++ b/lib/Sema/DeclSpec.cpp
@@ -632,7 +632,7 @@ bool DeclSpec::SetTypeSpecType(TST T, SourceLocation TagKwLoc,
   DeclRep = Rep;
   TSTLoc = TagKwLoc;
   TSTNameLoc = TagNameLoc;
-  TypeSpecOwned = Owned;
+  TypeSpecOwned = Owned && Rep;
   return false;
 }
 
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp
index ec1ccbf..11a08d9 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp
@@ -6,3 +6,6 @@ void A::f(enum { e2 }) {} // expected-error{{can not be defined in a parameter}}
 
 enum { e3 } A::g() { } // expected-error{{can not be defined in the result type}} \
 // expected-error{{out-of-line definition}}
+
+struct B {}; // expected-note{{previous definition is here}}
+struct B {} f(); // expected-error{{redefinition of 'B'}}
