llvm-project/clang/test/Headers/stdarg-cxx-modules.cpp
Dmitry Polukhin f3761a4bd3
[C++20][Modules] Allow using stdarg.h with header units (#100739)
Summary:
Macro like `va_start`/`va_end` marked as builtin functions that makes
these identifiers special and it results in redefinition of the
identifiers as builtins and it hides macro definitions during preloading
C++ modules. In case of modules Clang ignores special identifiers but
`PP.getCurrentModule()` was not set. This diff fixes IsModule detection
logic for this particular case.

Test Plan: check-clang

---------

Co-authored-by: Chuanqi Xu <yedeng.yd@linux.alibaba.com>
2024-08-01 12:33:20 +03:00

26 lines
571 B
C++

// RUN: rm -fR %t
// RUN: split-file %s %t
// RUN: cd %t
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header h1.h
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header h2.h -fmodule-file=h1.pcm
// RUN: %clang_cc1 -std=c++20 -fsyntax-only main.cpp -fmodule-file=h1.pcm -fmodule-file=h2.pcm
//--- h1.h
#include <stdarg.h>
// expected-no-diagnostics
//--- h2.h
import "h1.h";
// expected-no-diagnostics
//--- main.cpp
import "h1.h";
import "h2.h";
void foo(int x, ...) {
va_list v;
va_start(v, x);
va_end(v);
}
// expected-no-diagnostics