summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2016-09-13 01:20:40 +0000
committerRichard Trieu <rtrieu@google.com>2016-09-13 01:20:40 +0000
commitffa532d7a1d964230ee7e4eaeb91678c47484325 (patch)
treef6661d5a53442c638b9a5a35d2bc7320e9e8f334
parenteeb56abe643929f570006917c088e53bc7c896a4 (diff)
downloadbcm5719-llvm-ffa532d7a1d964230ee7e4eaeb91678c47484325.tar.gz
bcm5719-llvm-ffa532d7a1d964230ee7e4eaeb91678c47484325.zip
Fix interaction between serialization and c++1z feature.
In c++1z, static_assert is not required to have a StringLiteral message, where previously it was required. Update the AST Reader to be able to handle a null StringLiteral. llvm-svn: 281286
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp2
-rw-r--r--clang/test/Modules/Inputs/static_assert/a.h3
-rw-r--r--clang/test/Modules/Inputs/static_assert/module.modulemap1
-rw-r--r--clang/test/Modules/static_assert.cpp8
4 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index d68d6d308a7..686c7f2e347 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2239,7 +2239,7 @@ void ASTDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) {
VisitDecl(D);
D->AssertExprAndFailed.setPointer(Reader.ReadExpr(F));
D->AssertExprAndFailed.setInt(Record[Idx++]);
- D->Message = cast<StringLiteral>(Reader.ReadExpr(F));
+ D->Message = cast_or_null<StringLiteral>(Reader.ReadExpr(F));
D->RParenLoc = ReadSourceLocation(Record, Idx);
}
diff --git a/clang/test/Modules/Inputs/static_assert/a.h b/clang/test/Modules/Inputs/static_assert/a.h
new file mode 100644
index 00000000000..e876df06d06
--- /dev/null
+++ b/clang/test/Modules/Inputs/static_assert/a.h
@@ -0,0 +1,3 @@
+class S {
+ static_assert(4 == 4);
+};
diff --git a/clang/test/Modules/Inputs/static_assert/module.modulemap b/clang/test/Modules/Inputs/static_assert/module.modulemap
new file mode 100644
index 00000000000..bb00c840ce3
--- /dev/null
+++ b/clang/test/Modules/Inputs/static_assert/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" }
diff --git a/clang/test/Modules/static_assert.cpp b/clang/test/Modules/static_assert.cpp
new file mode 100644
index 00000000000..d1b759073cd
--- /dev/null
+++ b/clang/test/Modules/static_assert.cpp
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps \
+// RUN: -I%S/Inputs/static_assert -std=c++1z -verify %s
+// expected-no-diagnostics
+
+#include "a.h"
+
+S s;
OpenPOWER on IntegriCloud