[cfe-commits] r136780 - /cfe/trunk/www/diagnostics.html

Chris Lattner sabre at nondot.org
Wed Aug 3 08:54:40 PDT 2011


Author: lattner
Date: Wed Aug  3 10:54:40 2011
New Revision: 136780

URL: http://llvm.org/viewvc/llvm-project?rev=136780&view=rev
Log:
give an example of a 'lowered vtable reference'

Modified:
    cfe/trunk/www/diagnostics.html

Modified: cfe/trunk/www/diagnostics.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/diagnostics.html?rev=136780&r1=136779&r2=136780&view=diff
==============================================================================
--- cfe/trunk/www/diagnostics.html (original)
+++ cfe/trunk/www/diagnostics.html Wed Aug  3 10:54:40 2011
@@ -104,10 +104,8 @@
 <h2>No Pretty Printing of Expressions in Diagnostics</h2>
 
 <p>Since Clang has range highlighting, it never needs to pretty print your code
-back out to you.  This is particularly bad in G++ (which often emits errors
-containing lowered vtable references), but even GCC can produce
-inscrutible error messages in some cases when it tries to do this.  In this
-example P and Q have type "int*":</p>
+back out to you.  GCC can produce inscrutible error messages in some cases when
+it tries to do this.  In this example P and Q have type "int*":</p>
 
 <pre>
   $ <b>gcc-4.2 -fsyntax-only t.c</b>
@@ -118,6 +116,31 @@
   <font color="blue">  ~~~~~^</font>
 </pre>
 
+<p>This can be particularly bad in G++, which often emits errors
+   containing lowered vtable references.  For example:</p>
+  
+<pre>
+  $ <b>cat t.cc</b>
+  struct a {
+    virtual int bar();
+  };
+  
+  struct foo : public virtual a {
+  };
+  
+  void test(foo *P) {
+    return P->bar() + *P;
+  }
+  $ <b>gcc-4.2 t.cc</b>
+  t.cc: In function 'void test(foo*)':
+  t.cc:9: error: no match for 'operator+' in '(((a*)P) + (*(long int*)(P->foo::<anonymous>.a::_vptr$a + -0x00000000000000020)))->a::bar() + * P'
+  t.cc:9: error: return-statement with a value, in function returning 'void'
+  $ <b>clang t.cc</b>
+  t.cc:9:18: <font color="red">error:</font> invalid operands to binary expression ('int' and 'foo')
+  <font color="darkgreen">  return P->bar() + *P;</font>
+  <font color="blue">         ~~~~~~~~ ^ ~~</font>
+</pre>
+  
 
 <h2>Typedef Preservation and Selective Unwrapping</h2>
 
@@ -169,7 +192,7 @@
 }
 
 using namespace myapp;
-void addHTTPService(servers::Server const &server, ::services::WebService const *http) {
+void addHTTPService(servers::Server const &;amp;server, ::services::WebService const *http) {
   server += http;
 }
 </pre>





More information about the cfe-commits mailing list