]> granicus.if.org Git - clang/commitdiff
Module: Improve diagnostic message when cxx modules are disabled and @import is used...
authorManman Ren <manman.ren@gmail.com>
Thu, 19 Jan 2017 19:05:55 +0000 (19:05 +0000)
committerManman Ren <manman.ren@gmail.com>
Thu, 19 Jan 2017 19:05:55 +0000 (19:05 +0000)
rdar://problem/19399671

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

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseObjc.cpp
test/Modules/check-syntax.mm [new file with mode: 0644]

index 0943feae950eb8ae4f27e2e6c6d4788ee30994b6..a7d2116f1a705f98573eb0895f2b3b43a5533efe 100644 (file)
@@ -243,7 +243,10 @@ def err_expected_property_name : Error<"expected property name">;
 
 def err_unexpected_at : Error<"unexpected '@' in program">;
 def err_atimport : Error<
-"use of '@import' when modules are disabled">;
+  "use of '@import' when modules are disabled">;
+def err_atimport_cxx : Error<
+  "use of '@import' when C++ modules are disabled, consider using fmodules "
+  "and fcxx-modules">;
 
 def err_invalid_reference_qualifier_application : Error<
   "'%0' qualifier may not be applied to a reference">;
index 81761bf8d2d89535399793a61527db34d750e5c5..68768e1835544d899441e6cd867b5c8ba0aabec7 100644 (file)
@@ -83,7 +83,10 @@ Parser::DeclGroupPtrTy Parser::ParseObjCAtDirectives() {
   case tok::objc_import:
     if (getLangOpts().Modules || getLangOpts().DebuggerSupport)
       return ParseModuleImport(AtLoc);
-    Diag(AtLoc, diag::err_atimport);
+    if (getLangOpts().CPlusPlus)
+      Diag(AtLoc, diag::err_atimport_cxx);
+    else
+      Diag(AtLoc, diag::err_atimport);
     SkipUntil(tok::semi);
     return Actions.ConvertDeclToDeclGroup(nullptr);
   default:
diff --git a/test/Modules/check-syntax.mm b/test/Modules/check-syntax.mm
new file mode 100644 (file)
index 0000000..ebb4bd3
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: not %clang -fmodules -fno-cxx-modules -fsyntax-only %s 2>&1 | FileCheck %s
+// rdar://19399671
+
+// CHECK: use of '@import' when C++ modules are disabled
+@import Foundation;