[clang] [clang] Don't crash in invalid #module directive (PR #208695)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 10 09:12:15 PDT 2026


================
@@ -1455,10 +1455,11 @@ void Preprocessor::HandleDirective(Token &Result) {
       return HandlePragmaDirective({PIK_HashPragma, Introducer.getLocation()});
     case tok::pp_module:
     case tok::pp___preprocessed_module:
-      return HandleCXXModuleDirective(Result);
+      if (Introducer.isModuleContextualKeyword())
+        return HandleCXXModuleDirective(Result);
+      break;
     case tok::pp___preprocessed_import:
       return HandleCXXImportDirective(Result);
-    // GNU Extensions.
----------------
shafik wrote:

I guess the comment was incorrect in the current spot?

https://github.com/llvm/llvm-project/pull/208695


More information about the cfe-commits mailing list