[cfe-commits] r72747 - in /cfe/trunk: lib/AST/Type.cpp lib/Sema/Sema.cpp test/Parser/cxx-ambig-paren-expr.cpp test/SemaCXX/const-cast.cpp test/SemaCXX/decl-expr-ambiguity.cpp test/SemaCXX/member-expr.cpp test/SemaCXX/reinterpret-cast.cpp test/SemaCXX/static-cast.cpp test/SemaObjCXX/blocks.mm test/SemaTemplate/temp_arg_nontype.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Tue Jun 2 19:06:51 PDT 2009


Author: akirtzidis
Date: Tue Jun  2 21:06:50 2009
New Revision: 72747

URL: http://llvm.org/viewvc/llvm-project?rev=72747&view=rev
Log:
Use "()" instead of "(void)" when pretty-printing a parameter-less function type for C++.

Modified:
    cfe/trunk/lib/AST/Type.cpp
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/test/Parser/cxx-ambig-paren-expr.cpp
    cfe/trunk/test/SemaCXX/const-cast.cpp
    cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp
    cfe/trunk/test/SemaCXX/member-expr.cpp
    cfe/trunk/test/SemaCXX/reinterpret-cast.cpp
    cfe/trunk/test/SemaCXX/static-cast.cpp
    cfe/trunk/test/SemaObjCXX/blocks.mm
    cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=72747&r1=72746&r2=72747&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Jun  2 21:06:50 2009
@@ -1410,7 +1410,7 @@
     if (getNumArgs())
       S += ", ";
     S += "...";
-  } else if (getNumArgs() == 0) {
+  } else if (getNumArgs() == 0 && !Policy.CPlusPlus) {
     // Do not emit int() if we have a proto, emit 'int(void)'.
     S += "void";
   }

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=72747&r1=72746&r2=72747&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Jun  2 21:06:50 2009
@@ -60,7 +60,7 @@
         // Not va_list.
         Ty.getUnqualifiedType() != Context.getBuiltinVaListType()) {
       S = "'"+S+"' (aka '";
-      S += DesugaredTy.getAsString();
+      S += DesugaredTy.getAsString(Context.PrintingPolicy);
       S += "')";
       Output.append(S.begin(), S.end());
       return;

Modified: cfe/trunk/test/Parser/cxx-ambig-paren-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-ambig-paren-expr.cpp?rev=72747&r1=72746&r2=72747&view=diff

==============================================================================
--- cfe/trunk/test/Parser/cxx-ambig-paren-expr.cpp (original)
+++ cfe/trunk/test/Parser/cxx-ambig-paren-expr.cpp Tue Jun  2 21:06:50 2009
@@ -5,9 +5,9 @@
   int x, *px;
   
   // Type id.
-  (T())x;    // expected-error {{used type 'T (void)'}}
-  (T())+x;   // expected-error {{used type 'T (void)'}}
-  (T())*px;  // expected-error {{used type 'T (void)'}}
+  (T())x;    // expected-error {{used type 'T ()'}}
+  (T())+x;   // expected-error {{used type 'T ()'}}
+  (T())*px;  // expected-error {{used type 'T ()'}}
   
   // Expression.
   x = (T());

Modified: cfe/trunk/test/SemaCXX/const-cast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/const-cast.cpp?rev=72747&r1=72746&r2=72747&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/const-cast.cpp (original)
+++ cfe/trunk/test/SemaCXX/const-cast.cpp Tue Jun  2 21:06:50 2009
@@ -58,6 +58,6 @@
   // Function pointers.
   f fp2 = const_cast<f>(fp1); // expected-error {{const_cast to 'f' (aka 'int (*)(int)'), which is not a reference, pointer-to-object, or pointer-to-data-member}}
   void (A::*mfn)() = 0;
-  (void)const_cast<void (A::*)()>(mfn); // expected-error {{const_cast to 'void (struct A::*)(void)', which is not a reference, pointer-to-object, or pointer-to-data-member}}
+  (void)const_cast<void (A::*)()>(mfn); // expected-error {{const_cast to 'void (struct A::*)()', which is not a reference, pointer-to-object, or pointer-to-data-member}}
   return **var3;
 }

Modified: cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp?rev=72747&r1=72746&r2=72747&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp (original)
+++ cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp Tue Jun  2 21:06:50 2009
@@ -19,7 +19,7 @@
   (int(1)); // expected-warning {{expression result unused}}
 
   // type-id
-  (int())1; // expected-error {{used type 'int (void)' where arithmetic or pointer type is required}}
+  (int())1; // expected-error {{used type 'int ()' where arithmetic or pointer type is required}}
 
   // Declarations.
   int fd(T(a)); // expected-warning {{parentheses were disambiguated as a function declarator}}

Modified: cfe/trunk/test/SemaCXX/member-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-expr.cpp?rev=72747&r1=72746&r2=72747&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/member-expr.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-expr.cpp Tue Jun  2 21:06:50 2009
@@ -28,6 +28,6 @@
  A *f0();
 };
 int f0(B *b) {
-  return b->f0->f0; // expected-error{{member reference base type 'struct A *(void)' is not a structure or union}} \
+  return b->f0->f0; // expected-error{{member reference base type 'struct A *()' is not a structure or union}} \
   // expected-note{{perhaps you meant to call this function}}
 }

Modified: cfe/trunk/test/SemaCXX/reinterpret-cast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/reinterpret-cast.cpp?rev=72747&r1=72746&r2=72747&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/reinterpret-cast.cpp (original)
+++ cfe/trunk/test/SemaCXX/reinterpret-cast.cpp Tue Jun  2 21:06:50 2009
@@ -80,11 +80,11 @@
   void (structure::*psf)() = 0;
   (void)reinterpret_cast<int (structure::*)()>(psf);
 
-  (void)reinterpret_cast<void (structure::*)()>(psi); // expected-error {{reinterpret_cast from 'int const struct structure::*' to 'void (struct structure::*)(void)' is not allowed}}
-  (void)reinterpret_cast<int structure::*>(psf); // expected-error {{reinterpret_cast from 'void (struct structure::*)(void)' to 'int struct structure::*' is not allowed}}
+  (void)reinterpret_cast<void (structure::*)()>(psi); // expected-error {{reinterpret_cast from 'int const struct structure::*' to 'void (struct structure::*)()' is not allowed}}
+  (void)reinterpret_cast<int structure::*>(psf); // expected-error {{reinterpret_cast from 'void (struct structure::*)()' to 'int struct structure::*' is not allowed}}
 
   // Cannot cast from integers to member pointers, not even the null pointer
   // literal.
-  (void)reinterpret_cast<void (structure::*)()>(0); // expected-error {{reinterpret_cast from 'int' to 'void (struct structure::*)(void)' is not allowed}}
+  (void)reinterpret_cast<void (structure::*)()>(0); // expected-error {{reinterpret_cast from 'int' to 'void (struct structure::*)()' is not allowed}}
   (void)reinterpret_cast<int structure::*>(0); // expected-error {{reinterpret_cast from 'int' to 'int struct structure::*' is not allowed}}
 }

Modified: cfe/trunk/test/SemaCXX/static-cast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/static-cast.cpp?rev=72747&r1=72746&r2=72747&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/static-cast.cpp (original)
+++ cfe/trunk/test/SemaCXX/static-cast.cpp Tue Jun  2 21:06:50 2009
@@ -115,7 +115,7 @@
   // Bad code below
 
   (void)static_cast<int*>((const void*)0); // expected-error {{static_cast from 'void const *' to 'int *' casts away constness}}
-  (void)static_cast<void (*)()>((void*)0); // expected-error {{static_cast from 'void *' to 'void (*)(void)' is not allowed}}
+  (void)static_cast<void (*)()>((void*)0); // expected-error {{static_cast from 'void *' to 'void (*)()' is not allowed}}
 }
 
 // Member pointer upcast.

Modified: cfe/trunk/test/SemaObjCXX/blocks.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/blocks.mm?rev=72747&r1=72746&r2=72747&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjCXX/blocks.mm (original)
+++ cfe/trunk/test/SemaObjCXX/blocks.mm Tue Jun  2 21:06:50 2009
@@ -3,12 +3,12 @@
 
 void bar(id(^)(void));
 void foo(id <NSObject>(^objectCreationBlock)(void)) {
-    return bar(objectCreationBlock); // expected-warning{{incompatible pointer types passing 'id (^)(void)', expected 'id<NSObject> (^)(void)'}}
+    return bar(objectCreationBlock); // expected-warning{{incompatible pointer types passing 'id (^)()', expected 'id<NSObject> (^)()'}}
 }
 
 void bar2(id(*)(void));
 void foo2(id <NSObject>(*objectCreationBlock)(void)) {
-    return bar2(objectCreationBlock); // expected-warning{{incompatible pointer types passing 'id (*)(void)', expected 'id<NSObject> (*)(void)'}}
+    return bar2(objectCreationBlock); // expected-warning{{incompatible pointer types passing 'id (*)()', expected 'id<NSObject> (*)()'}}
 }
 
 void bar3(id(*)()); // expected-note{{candidate function}}

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=72747&r1=72746&r2=72747&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Tue Jun  2 21:06:50 2009
@@ -3,7 +3,7 @@
 
 A<0> *a0;
 
-A<int()> *a1; // expected-error{{template argument for non-type template parameter is treated as type 'int (void)'}}
+A<int()> *a1; // expected-error{{template argument for non-type template parameter is treated as type 'int ()'}}
 
 A<int> *a2; // expected-error{{template argument for non-type template parameter must be an expression}}
 





More information about the cfe-commits mailing list