llvm-project/clang/test/PCH/modulemaps-nomodules.cpp
Kadir Cetinkaya 4d0cfa6d09
[clang] Don't create import decls without -fmodules
When modules are disabled, there's no loaded module for these import
decls to point at. This results in crashes when there are modulemap
files but no -fmodules flag (this configuration is used for layering
check violations).

This patch makes sure import declarations are introduced only when
modules are enabled, which makes this case similar to textual headers
(no import decls are created for #include of textual headers from a
modulemap).

Differential Revision: https://reviews.llvm.org/D152274
2023-06-16 09:26:45 +02:00

7 lines
355 B
C++

// Make sure we don't crash when serializing a PCH with an include from a
// modulemap file in nomodules mode.
// No need to pass -fno-modules explicitly, absence implies negation for cc1.
// RUN: %clang_cc1 -I %S/Inputs/modulemaps-nomodules -fmodule-map-file=%S/Inputs/modulemaps-nomodules/module.modulemap %s -emit-pch -o /dev/null
#include "header.h"