summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Lex/ModuleMap.cpp11
-rw-r--r--clang/test/Modules/parse-attributes.modulemap12
2 files changed, 20 insertions, 3 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 1c5b4e2f1ad..301892c3b1b 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1402,7 +1402,9 @@ void ModuleMapParser::parseModuleDecl() {
// Parse the optional attribute list.
Attributes Attrs;
- parseOptionalAttributes(Attrs);
+ if (parseOptionalAttributes(Attrs))
+ return;
+
// Parse the opening brace.
if (!Tok.is(MMToken::LBrace)) {
@@ -2067,7 +2069,9 @@ void ModuleMapParser::parseConfigMacros() {
// Parse the optional attributes.
Attributes Attrs;
- parseOptionalAttributes(Attrs);
+ if (parseOptionalAttributes(Attrs))
+ return;
+
if (Attrs.IsExhaustive && !ActiveModule->Parent) {
ActiveModule->ConfigMacrosExhaustive = true;
}
@@ -2215,7 +2219,8 @@ void ModuleMapParser::parseInferredModuleDecl(bool Framework, bool Explicit) {
// Parse optional attributes.
Attributes Attrs;
- parseOptionalAttributes(Attrs);
+ if (parseOptionalAttributes(Attrs))
+ return;
if (ActiveModule) {
// Note that we have an inferred submodule.
diff --git a/clang/test/Modules/parse-attributes.modulemap b/clang/test/Modules/parse-attributes.modulemap
new file mode 100644
index 00000000000..0d18325580a
--- /dev/null
+++ b/clang/test/Modules/parse-attributes.modulemap
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t.modules
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t.modules \
+// RUN: -fmodule-map-file=%s -I%S -include "Inputs/empty.h" \
+// RUN: -fsyntax-only -x c++ /dev/null 2>&1 | FileCheck %s
+
+// CHECK: error: expected ']' to close attribute
+// CHECK-NOT: error: expected '{' to start module 'A'
+
+module A [system {
+ header "Inputs/empty.h"
+ private header "Inputs/empty.h"
+}
OpenPOWER on IntegriCloud