While working on getting Boost & its friends work under Clang,
I've stumbled upon the code that looks like the following:

   decltype(x, y) z = w;

The "x, y" is a perfectly valid expression, and should work.
But it's not, because decltype is actually defined as a macros
in libcxx:

#if !__is_identifier(__decltype) || _GNUC_VER >= 406
#  define decltype(__x) __decltype(__x)
#else
#  define decltype(__x) __typeof__(__x)
#endif

This is easily being fixed by variadic macros, which are supported
by GCC 3.0+ and all Clang versions. So I'm proposing the following
change, which likely worths getting upstream as well.

--
WBR,
  Vadim Zhukov


Index: __config
===================================================================
RCS file: /cvs/src/lib/libcxx/include/__config,v
retrieving revision 1.3
diff -u -p -r1.3 __config
--- __config    19 Sep 2016 22:17:22 -0000      1.3
+++ __config    28 May 2017 14:57:43 -0000
@@ -669,10 +669,11 @@ template <unsigned> struct __static_asse
 
 #ifdef _LIBCPP_HAS_NO_DECLTYPE
 // GCC 4.6 provides __decltype in all standard modes.
+// variadic macros are required since decltype(x, y) is valid
 #if !__is_identifier(__decltype) || _GNUC_VER >= 406
-#  define decltype(__x) __decltype(__x)
+#  define decltype(...) __decltype(__VA_ARGS__)
 #else
-#  define decltype(__x) __typeof__(__x)
+#  define decltype(...) __typeof__(__VA_ARGS__)
 #endif
 #endif
 

Reply via email to