Files
clang-p2996/clang/test/Modules/predefined.cpp
Arthur Eubanks 878e590503 Reland [clang] Make predefined expressions string literals under -fms-extensions
MSVC makes these string literals [1][2].

[1] https://godbolt.org/z/6vnTzbExx
[2] https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170

Fixes #114

Initial commit didn't check if there was a function name when stepping through expressions ignoring parens.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D146764
2023-05-10 10:54:58 -07:00

28 lines
644 B
C++

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: cd %t
// RUN: %clang_cc1 -x c++ -std=c++20 -emit-module-interface a.h -o a.pcm -fms-extensions -verify
// RUN: %clang_cc1 -std=c++20 a.cpp -fmodule-file=A=a.pcm -fms-extensions -fsyntax-only -verify
//--- a.h
// expected-no-diagnostics
export module A;
export template <typename T>
void f() {
char a[] = __func__;
}
//--- a.cpp
// expected-warning@a.h:8 {{initializing an array from a '__func__' predefined identifier is a Microsoft extension}}
import A;
void g() {
f<int>(); // expected-note {{in instantiation of function template specialization 'f<int>' requested here}}
}