[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 2 11:57:50 PDT 2023


aaron.ballman added inline comments.


================
Comment at: clang/test/Modules/predefined.cpp:6
+// RUN: %clang_cc1 -x c++ -std=c++20 -emit-module-interface a.h -o a.pcm -fms-extensions
+// RUN: %clang_cc1 -std=c++20 a.cpp -fmodule-file=A=a.pcm -fms-extensions -fsyntax-only
+
----------------
Er, should we have a `-verify` on this as well as `// expected-no-diagnostics`?


================
Comment at: clang/test/Sema/ms_predefined_expr.cpp:5-9
+ const char a[] = __FUNCTION__;
+ const char b[] = __FUNCDNAME__;
+ const char c[] = __FUNCSIG__;
+ const char d[] = __func__;
+ const char e[] = __PRETTY_FUNCTION__;
----------------
Apologies for not noticing this earlier, but because this code isn't portable (for the standard predefined identifiers), I think we should also have a `-pedantic` test that ensures we get a diagnostic about accepting this code being a Microsoft extension.

I would recommend something along the lines of: `initializing an array from a '%0' predefined identifier is a Microsoft extension` put into a new warning group named `-Wmicrosoft-init-from-predefined` which is added to the `-Wmicrosoft` warning group.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146764/new/

https://reviews.llvm.org/D146764



More information about the cfe-commits mailing list