]> granicus.if.org Git - clang/commitdiff
Fix serialization of uninstantiated exception specifications. Patch by Li Kan,
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 21 Apr 2012 17:47:47 +0000 (17:47 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 21 Apr 2012 17:47:47 +0000 (17:47 +0000)
test by me.

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

lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp
test/PCH/cxx11-exception-spec.cpp [new file with mode: 0644]

index 06b42f3ab1309896aa7fb881d1dc9f3a0fc5c1f4..fd0c17139468bda4c2bf4aeecef8a8707746e7f4 100644 (file)
@@ -3866,6 +3866,9 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
       EPI.Exceptions = Exceptions.data();
     } else if (EST == EST_ComputedNoexcept) {
       EPI.NoexceptExpr = ReadExpr(*Loc.F);
+    } else if (EST == EST_Uninstantiated) {
+      EPI.ExceptionSpecDecl = ReadDeclAs<FunctionDecl>(*Loc.F, Record, Idx);
+      EPI.ExceptionSpecTemplate = ReadDeclAs<FunctionDecl>(*Loc.F, Record, Idx);
     }
     return Context.getFunctionType(ResultType, ParamTypes.data(), NumParams,
                                     EPI);
index e9c0596becb8789460f54bf41b9f3a0cc92a73a8..29ea01b9145754d0732d7412177c3c12f4ded93e 100644 (file)
@@ -195,6 +195,9 @@ void ASTTypeWriter::VisitFunctionProtoType(const FunctionProtoType *T) {
       Writer.AddTypeRef(T->getExceptionType(I), Record);
   } else if (T->getExceptionSpecType() == EST_ComputedNoexcept) {
     Writer.AddStmt(T->getNoexceptExpr());
+  } else if (T->getExceptionSpecType() == EST_Uninstantiated) {
+    Writer.AddDeclRef(T->getExceptionSpecDecl(), Record);
+    Writer.AddDeclRef(T->getExceptionSpecTemplate(), Record);
   }
   Code = TYPE_FUNCTION_PROTO;
 }
diff --git a/test/PCH/cxx11-exception-spec.cpp b/test/PCH/cxx11-exception-spec.cpp
new file mode 100644 (file)
index 0000000..3fca4e4
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+template<bool b> int f() noexcept(b) {}
+decltype(f<false>()) a;
+decltype(f<true>()) b;
+
+#else
+
+static_assert(!noexcept(f<false>()), "");
+static_assert(noexcept(f<true>()), "");
+
+#endif