From: John McCall Date: Thu, 3 Feb 2011 11:29:18 +0000 (+0000) Subject: More tweaks to the compatibility page. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6966c6736e9c49e235c22aea5870e519f4bc2741;p=clang More tweaks to the compatibility page. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124792 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/www/compatibility.html b/www/compatibility.html index ca1553150b..aa6a39dda1 100644 --- a/www/compatibility.html +++ b/www/compatibility.html @@ -65,7 +65,7 @@
  • Implicit downcasts
  • @@ -418,8 +418,8 @@ compatibility with GNU C and C99 programs:

    @@ -428,12 +428,9 @@ template parameter.
    1. replace the variable length array with a fixed-size array if you can - determine a - reasonable upper bound at compile time; sometimes this is as + determine a reasonable upper bound at compile time; sometimes this is as simple as changing int size = ...; to const int size - = ...; (if the definition of size is a compile-time - integral constant);
    2. -
    3. use std::string instead of a char [];
    4. + = ...; (if the initializer is a compile-time constant);
    5. use std::vector or some other suitable container type; or
    6. allocate the array on the heap instead using new Type[] - @@ -762,18 +759,18 @@ void f(int a, int a);

      Due to a bug in its implementation, GCC allows implicit downcasts -(from base class to a derived class) when calling functions. Such code is -inherently unsafe, since the object might not actually be an instance -of the derived class, and is rejected by Clang. For example, given -this code:

      +of Objective-C pointers (from a base class to a derived class) when +calling functions. Such code is inherently unsafe, since the object +might not actually be an instance of the derived class, and is +rejected by Clang. For example, given this code:

       @interface Base @end
       @interface Derived : Base @end
       
      -void f(Derived *);
      -void g(Base *base) {
      -  f(base);
      +void f(Derived *p);
      +void g(Base *p) {
      +  f(p);
       }
       
      @@ -781,11 +778,11 @@ void g(Base *base) {
       downcast.mm:6:3: error: no matching function for call to 'f'
      -  f(base);
      +  f(p);
         ^
       downcast.mm:4:6: note: candidate function not viable: cannot convert from
             superclass 'Base *' to subclass 'Derived *' for 1st argument
      -void f(Derived *);
      +void f(Derived *p);
            ^
       
      @@ -798,13 +795,17 @@ explicit cast:

      -

      Use of class as method name

      +

      Using class as a property name

      -

      Use of 'class' name to declare a method is allowed in objective-c++ mode to -be compatible with GCC. However, use of property dot syntax notation to call -this method is not allowed in clang++, as [I class] is a suitable syntax that -will work. So, this test will fail in clang++. +

      In C and Objective-C, class is a normal identifier and +can be used to name fields, ivars, methods, and so on. In +C++, class is a keyword. For compatibility with existing +code, Clang permits class to be used as part of a method +selector in Objective-C++, but this does not extend to any other part +of the language. In particular, it is impossible to use property dot +syntax in Objective-C++ with the property name class, so +the following code will fail to parse:

       @interface I {
      @@ -818,6 +819,7 @@ int cls;
       @end
       
       
      +

      Use explicit message-send syntax instead, i.e. [I class].