From: Richard Smith Date: Fri, 1 Feb 2013 00:45:12 +0000 (+0000) Subject: Consistently format sample diagnostics on this page. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a55e3ff9cbb5ccf338abd15d60970d9655e46d55;p=clang Consistently format sample diagnostics on this page. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174126 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/www/compatibility.html b/www/compatibility.html index 725c52ff4b..de864eda4f 100644 --- a/www/compatibility.html +++ b/www/compatibility.html @@ -188,10 +188,9 @@ use the API calls instead of calls like __builtin_ia32_paddw128.

different type. Clang produces an error on similar code, e.g.,

-lvalue.c:2:3: error: assignment to cast is illegal, lvalue casts are not
-      supported
+lvalue.c:2:3: error: assignment to cast is illegal, lvalue casts are not supported
   (int*)addr = val;
-  ^~~~~~~~~~ ~
+  ^~~~~~~~~~ ~
 

To fix this problem, move the cast to the right-hand side. In this @@ -232,12 +231,12 @@ the stack is fresh, i.e. still zeroed.) Therefore, Clang rejects this code with a hard error:

-t.c:3:5: error: goto into protected scope
+t.c:3:5: error: goto into protected scope
     goto error;
-    ^
-t.c:5:15: note: jump bypasses setup of __block variable
+    ^
+t.c:5:15: note: jump bypasses setup of __block variable
   __block int result;
-              ^
+              ^
 

The fix is to rewrite the code to not require jumping into a @@ -308,10 +307,9 @@ rejects the instruction with this error message:

-<inline asm>:3:1: error: ambiguous instructions require an explicit suffix (could be 'addb', 'addw', 'addl', or 'addq')
+<inline asm>:3:1: error: ambiguous instructions require an explicit suffix (could be 'addb', 'addw', 'addl', or 'addq')
 add $4, (%rax)
-^
-1 error generated.
+^
 

To fix this compatibility issue, add an explicit suffix to the instruction: @@ -331,9 +329,9 @@ can, among other things, be cast to a different type. Clang treats type-cast of super:

-super.m:11:12: error: cannot cast 'super' (it isn't an expression)
+super.m:11:12: error: cannot cast 'super' (it isn't an expression)
   [(Super*)super add:4];
-   ~~~~~~~~^
+   ~~~~~~~~^
 

To fix this problem, remove the type cast, e.g.

@@ -352,10 +350,9 @@ Objective-C class may change over time as instance variables are added ABI:

-sizeof.m:4:14: error: invalid application of 'sizeof' to interface 'NSArray' in
-      non-fragile ABI
+sizeof.m:4:14: error: invalid application of 'sizeof' to interface 'NSArray' in non-fragile ABI
   int size = sizeof(NSArray);
-             ^     ~~~~~~~~~
+             ^     ~~~~~~~~~
 

Code that relies on the size of an Objective-C class is likely to @@ -377,12 +374,12 @@ this problem, use the Objective-C runtime API function internal Objective-C structures as implementation detail and won't do implicit conversions:

-t.mm:11:2: error: no matching function for call to 'f'
+t.mm:11:2: error: no matching function for call to 'f'
         f((struct objc_object *)p);
-        ^
-t.mm:5:6: note: candidate function not viable: no known conversion from 'struct objc_object *' to 'id' for 1st argument
+        ^
+t.mm:5:6: note: candidate function not viable: no known conversion from 'struct objc_object *' to 'id' for 1st argument
 void f(id x);
-     ^
+     ^
 

Code should use types id, SEL, and Class @@ -465,15 +462,16 @@ int main() {

Clang complains: -

  my_file.cpp:2:10: error: call to function 'Multiply' that is neither visible in the template definition nor found by argument-dependent lookup
-    return Multiply(x, x);
-           ^
-  my_file.cpp:10:3: note: in instantiation of function template specialization 'Squared<int>' requested here
-    Squared(5);
-    ^
-  my_file.cpp:5:5: note: 'Multiply' should be declared prior to the call site
-  int Multiply(int x, int y) {
-      ^
+
+my_file.cpp:2:10: error: call to function 'Multiply' that is neither visible in the template definition nor found by argument-dependent lookup
+  return Multiply(x, x);
+         ^
+my_file.cpp:10:3: note: in instantiation of function template specialization 'Squared<int>' requested here
+  Squared(5);
+  ^
+my_file.cpp:5:5: note: 'Multiply' should be declared prior to the call site
+int Multiply(int x, int y) {
+    ^
 

The C++ standard says that unqualified names like Multiply @@ -526,15 +524,16 @@ void Use() {

Again, Clang complains:

-
  my_file2.cpp:5:13: error: call to function 'operator<<' that is neither visible in the template definition nor found by argument-dependent lookup
-    std::cout << value << "\n";
-              ^
-  my_file2.cpp:17:3: note: in instantiation of function template specialization 'Dump<ns::Data>' requested here
-    Dump(ns::Data());
-    ^
-  my_file2.cpp:12:15: note: 'operator<<' should be declared prior to the call site or in namespace 'ns'
-  std::ostream& operator<<(std::ostream& out, ns::Data data) {
-                ^
+
+my_file2.cpp:5:13: error: call to function 'operator<<' that is neither visible in the template definition nor found by argument-dependent lookup
+  std::cout << value << "\n";
+            ^
+my_file2.cpp:17:3: note: in instantiation of function template specialization 'Dump<ns::Data>' requested here
+  Dump(ns::Data());
+  ^
+my_file2.cpp:12:15: note: 'operator<<' should be declared prior to the call site or in namespace 'ns'
+std::ostream& operator<<(std::ostream& out, ns::Data data) {
+              ^
 

Just like before, unqualified lookup didn't find any declarations @@ -587,18 +586,18 @@ Clang correctly rejects it with the following errors (when Derived is eventually instantiated):

-my_file.cpp:8:5: error: use of undeclared identifier 'DoThis'
+my_file.cpp:8:5: error: use of undeclared identifier 'DoThis'
     DoThis(x);
-    ^
+    ^
     this->
-my_file.cpp:2:8: note: must qualify identifier to find this declaration in dependent base class
+my_file.cpp:2:8: note: must qualify identifier to find this declaration in dependent base class
   void DoThis(T x) {}
-       ^
-my_file.cpp:9:5: error: use of undeclared identifier 'DoThat'
+       ^
+my_file.cpp:9:5: error: use of undeclared identifier 'DoThat'
     DoThat(x);
-    ^
+    ^
     this->
-my_file.cpp:3:15: note: must qualify identifier to find this declaration in dependent base class
+my_file.cpp:3:15: note: must qualify identifier to find this declaration in dependent base class
   static void DoThat(T x) {}
 
@@ -820,13 +819,13 @@ void g(Base *p) {

Clang produces the following error:

-downcast.mm:6:3: error: no matching function for call to 'f'
+downcast.mm:6:3: error: no matching function for call to 'f'
   f(p);
-  ^
-downcast.mm:4:6: note: candidate function not viable: cannot convert from
+  ^
+downcast.mm:4:6: note: candidate function not viable: cannot convert from
       superclass 'Base *' to subclass 'Derived *' for 1st argument
 void f(Derived *p);
-     ^
+     ^
 

If the downcast is actually correct (e.g., because the code has