From: wolf Date: Mon, 24 Jun 2002 11:46:04 +0000 (+0000) Subject: Detect a violation of DR 45. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31c7df8b0be9b5a59fe2e7be4c170a555bae531c;p=dealii-svn.git Detect a violation of DR 45. git-svn-id: https://svn.dealii.org/trunk@6179 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index 13f9cc630c..44bde186e7 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -1999,6 +1999,59 @@ AC_DEFUN(DEAL_II_CHECK_TEMPLATE_TEMPLATE_TYPEDEF_BUG, dnl +dnl ------------------------------------------------------------- +dnl gcc 2.95 does not correctly implement the resolution of +dnl defect report #45 to the C++ standard (see +dnl http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#45). +dnl try to detect this, and set a flag correspondingly. in short, +dnl the DR says that this is allowed, since member classes are +dnl implicitly also friends: +dnl ----------------------------- +dnl class X { +dnl static int i; +dnl +dnl struct Y { +dnl int f() { return i; }; +dnl }; +dnl }; +dnl ----------------------------- +dnl +dnl We work around this problem, if we encounter it. +dnl +dnl Usage: DEAL_II_CHECK_NESTED_CLASS_FRIEND_BUG +dnl +dnl ------------------------------------------------------------- +AC_DEFUN(DEAL_II_CHECK_NESTED_CLASS_FRIEND_BUG, dnl +[ + AC_MSG_CHECKING(for nested classes are implicit friends bug) + AC_LANG(C++) + CXXFLAGS="$CXXFLAGSG" + AC_TRY_COMPILE( + [ + class X { + static int i; + + struct Y { + int f() { return i; }; + }; + }; + ], + [], + [ + AC_MSG_RESULT(no) + ], + [ + AC_MSG_RESULT(yes. using workaround) + AC_DEFINE(DEAL_II_NESTED_CLASS_FRIEND_BUG, 1, + [Defined if the compiler does not properly implement + the resolution of defect report #45 to the C++ + standard, which makes nested types implicit friends + of the enclosing class.]) + ]) +]) + + + dnl ------------------------------------------------------------- dnl Many compilers get this wrong (see Section 14.7.3.1, number (4)): dnl ---------------------------------