]> granicus.if.org Git - clang/commitdiff
Removed the warning
authorDouglas Gregor <dgregor@apple.com>
Wed, 17 Dec 2008 16:19:15 +0000 (16:19 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 17 Dec 2008 16:19:15 +0000 (16:19 +0000)
  warning: statement was disambiguated as declaration

because it is currently firing in cases where the declaration would
not actually parse as a statement. We'd love to bring this warning
back if we can make it more accurate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61137 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Parse/ParseTentative.cpp
test/SemaCXX/const-cast.cpp
test/SemaCXX/decl-expr-ambiguity.cpp
test/SemaCXX/direct-initializer.cpp
test/SemaCXX/references.cpp

index 42ce6c7a9f129500b3b7ea3b80247f3e53b1639e..7beac265f7c7b1df08178c38de9c1dc59ed45699 100644 (file)
@@ -597,8 +597,6 @@ DIAG(err_expected_lparen_after_type, ERROR,
      "expected '(' for function-style cast or type construction")
 DIAG(err_expected_equal_after_declarator, ERROR,
      "expected '=' after declarator")
-DIAG(warn_statement_disambiguation, WARNING,
-     "statement was disambiguated as %0")
 DIAG(warn_parens_disambiguated_as_function_decl, WARNING,
      "parentheses were disambiguated as a function declarator")
 DIAG(err_expected_member_or_base_name, ERROR,
index 3c50884c9ce4622ff7f6d5eaf35caca4c40ea552..f352efa87262ed600a43c54d221ea8ddc68d24bf 100644 (file)
@@ -126,18 +126,6 @@ bool Parser::isCXXSimpleDeclaration() {
     TPR = TPResult::True();
 
   assert(TPR == TPResult::True() || TPR == TPResult::False());
-  if (TPR == TPResult::True() && Tok.isNot(tok::kw_void)) {
-    // We have a declaration that looks like a functional cast; there's a high
-    // chance that the author intended the statement to be an expression.
-    // Emit a warning.
-    Diag(Tok, diag::warn_statement_disambiguation)
-      << "declaration" << SourceRange(Tok.getLocation(), TentativeParseLoc);
-  } else if (TPR == TPResult::False() && Tok.is(tok::kw_void)) {
-    // A functional cast to 'void' expression ? Warning..
-    Diag(Tok, diag::warn_statement_disambiguation)
-      << "expression" << SourceRange(Tok.getLocation(), TentativeParseLoc);
-  }
-
   return TPR == TPResult::True();
 }
 
index bc3908fd5d0230fabe078bb5beef787b7240cdbd..03a0e908ebbff4954e52a4b67d6ad769a7989689 100644 (file)
@@ -27,7 +27,7 @@ char ***good_const_cast_test(ccvpcvpp var)
   // Drop reference. Intentionally without qualifier change.
   char *** var5 = const_cast<cppp>(var4);
   const int ar[100] = {0};
-  int (&rar)[100] = const_cast<iarr>(ar); // expected-warning {{statement was disambiguated as declaration}} expected-error {{const_cast from 'int const [100]' to 'iarr' is not allowed}}
+  int (&rar)[100] = const_cast<iarr>(ar); // expected-error {{const_cast from 'int const [100]' to 'iarr' is not allowed}}
   // Array decay. Intentionally without qualifier change.
   int *pi = const_cast<int*>(ar);
   f fp = 0;
index 7d12e22329d3fee4137da182f79abc520c44c897..db845393cd01196c73c22649cb689662b0bb0a63 100644 (file)
@@ -10,7 +10,7 @@ void f() {
   int(a)++; // expected-error {{expression is not assignable}}
   __extension__ int(a)++; // expected-error {{expression is not assignable}}
   typeof(int)(a,5)<<a; // expected-error {{function-style cast to a builtin type can only take one argument}}
-  void(a), ++a; // expected-warning {{statement was disambiguated as expression}} expected-warning {{expression result unused}}
+  void(a), ++a; // expected-warning {{expression result unused}}
   if (int(a)+1) {}
   for (int(a)+1;;) {}
   a = sizeof(int()+1);
@@ -23,13 +23,13 @@ void f() {
 
   // Declarations.
   int fd(T(a)); // expected-warning {{parentheses were disambiguated as a function declarator}}
-  T(*d)(int(p)); // expected-warning {{parentheses were disambiguated as a function declarator}} expected-warning {{statement was disambiguated as declaration}} expected-note {{previous definition is here}}
-  T(d)[5]; // expected-warning {{statement was disambiguated as declaration}} expected-error {{redefinition of 'd'}}
-  typeof(int[])(f) = { 1, 2 }; // expected-warning {{statement was disambiguated as declaration}}
+  T(*d)(int(p)); // expected-warning {{parentheses were disambiguated as a function declarator}} expected-note {{previous definition is here}}
+  T(d)[5]; // expected-error {{redefinition of 'd'}}
+  typeof(int[])(f) = { 1, 2 }; 
   void(b)(int);
-  int(d2) __attribute__(()); // expected-warning {{statement was disambiguated as declaration}}
+  int(d2) __attribute__(()); 
   if (int(a)=1) {}
-  int(d3(int())); // expected-warning {{statement was disambiguated as declaration}}
+  int(d3(int()));
 }
 
 class C { };
index d5b91bb2b713a4c7ceacf5cad868e36291b16de0..8f4fbb2db6ffc2df773570aaea35e183749004c9 100644 (file)
@@ -5,7 +5,7 @@ int (x2)(1);
 
 void f() {
   int x(1);
-  int (x2)(1); // expected-warning {{statement was disambiguated as declaration}}
+  int (x2)(1);
   for (int x(1);;) {}
 }
 
index f1c82db27c55b469be5199858241215ee29a9a4d..61e30b584dfcc082ddc99a20289a5f85fe80869b 100644 (file)
@@ -7,10 +7,10 @@ void f() {
   r = 1;
   int *p = &r;
   int &rr = r;
-  int (&rg)(int) = g; // expected-warning{{statement was disambiguated as declaration}}
+  int (&rg)(int) = g;
   rg(i);
   int a[3];
-  int (&ra)[3] = a;  // expected-warning{{statement was disambiguated as declaration}}
+  int (&ra)[3] = a;
   ra[1] = i;
   int *Q;
   int *& P = Q;
@@ -24,7 +24,7 @@ void test2() {
 
 
     int c[3];
-    int (&rc)[3] = c; // expected-warning{{statement was disambiguated as declaration}}
+    int (&rc)[3] = c;
 }
 
 // C++ [dcl.init.ref]p5b1