]> granicus.if.org Git - clang/commitdiff
Use "()" instead of "(void)" when pretty-printing a parameter-less function type...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 3 Jun 2009 02:06:50 +0000 (02:06 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 3 Jun 2009 02:06:50 +0000 (02:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72747 91177308-0d34-0410-b5e6-96231b3b80d8

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

index b2ee58f3f355821038d14b83c395bac38aad8f31..f573744083a40c19f0d92830c3da0153e69228a0 100644 (file)
@@ -1410,7 +1410,7 @@ void FunctionProtoType::getAsStringInternal(std::string &S, const PrintingPolicy
     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";
   }
index 1212d070f6993d797283cb8f4df425e121263343..e3cea5be42833a144535edd71f3e5fef1ac67e0e 100644 (file)
@@ -60,7 +60,7 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
         // 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;
index 6f23b35d3e6bde2e8719d4472034cfb80db843d6..1712d849d516430f6823d05cf68c5ca429fcb096 100644 (file)
@@ -5,9 +5,9 @@ void f() {
   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());
index 39d61db0dc9499173d40ffee18db5a8daa6d9cf4..ee0048bd73bee238c10b7c1d49d405fd658f2793 100644 (file)
@@ -58,6 +58,6 @@ short *bad_const_cast_test(char const *volatile *const volatile *var)
   // 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;
 }
index bff333464b913b8ea868db2050d4f7fc3b4e7314..05e25e9bb86843bcac8bc34daaea9ee70e39e510 100644 (file)
@@ -19,7 +19,7 @@ void f() {
   (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}}
index 60ee10df7f6a65c489232501004ef7623a68cd2e..28b1224d8d8fbfef78d658bcbab501e49a501367 100644 (file)
@@ -28,6 +28,6 @@ struct B {
  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}}
 }
index fd5ca8cf39d4bb8ef0499481f3674e6250c2bb05..91b72cc02207c2b84d7ad894d015a0df622e6cf4 100644 (file)
@@ -80,11 +80,11 @@ void memptrs()
   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}}
 }
index 8399e77085b3f784c92a9036ac45f858f1b9ab45..b5c515d5e161fbf091be853c071b11c52972caef 100644 (file)
@@ -115,7 +115,7 @@ void t_529_10()
   // 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.
index 3d421a878e59168866d62f83ad31ea776ee7836e..e3304a41b7308c448e6b55c20bc5e0785b00e3bc 100644 (file)
@@ -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}}
index fe18fe657c160f3a96ad67c1eca3b81f556bbec9..534030dba0ea26f72ff39fdd4f5339c6541d94d6 100644 (file)
@@ -3,7 +3,7 @@ template<int N> struct A; // expected-note 5{{template parameter is declared her
 
 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}}