]> granicus.if.org Git - clang/commitdiff
Make wording for certain invalid unary expressions more consistent.
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 9 Oct 2013 00:22:23 +0000 (00:22 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 9 Oct 2013 00:22:23 +0000 (00:22 +0000)
An invalid decltype expression like 'decltype int' gives:
error: expected '(' after 'decltype'

This makes it so 'sizeof int' gives a similar one:
error: expected parentheses around type name in sizeof expression

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

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseExpr.cpp
test/CXX/dcl.dcl/dcl.attr/dcl.align/p7.cpp
test/CXX/expr/expr.unary/expr.sizeof/p1.cpp
test/Parser/expressions.c

index 1ffcd9213e3d27d1c8a70fe30fd4926f807ecc58..61b871d37684b482924114dfef0991fce77fe047 100644 (file)
@@ -310,8 +310,8 @@ def err_unspecified_vla_size_with_static : Error<
 def warn_deprecated_register : Warning<
   "'register' storage class specifier is deprecated">,
   InGroup<DeprecatedRegister>;
-def err_missed_parentheses_around_typename : Error<
-  "missed parentheses around type name in %0">;
+def err_expected_parentheses_around_typename : Error<
+  "expected parentheses around type name in %0 expression">;
 
 def err_expected_case_before_expression: Error<
   "expected 'case' keyword before expression">;
index 35c2aeffc28602216d4b6f33388524abe3f336cd..c9a718b5278735c4060a460693f0fa0f2f00a1eb 100644 (file)
@@ -1602,7 +1602,7 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok,
 
         SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.getLocation());
         SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
-        Diag(LParenLoc, diag::err_missed_parentheses_around_typename)
+        Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
           << OpTok.getName()
           << FixItHint::CreateInsertion(LParenLoc, "(")
           << FixItHint::CreateInsertion(RParenLoc, ")");
index 0f8f5f5e75d4088b73042a3ca601a5cbacb5be75..81e2ca5f1e4d6726e936d41f98ba7ab8c7e1386e 100644 (file)
@@ -16,5 +16,5 @@ static_assert(alignof(Y<char, int, sizeof(int)>) == alignof(int), "");
 static_assert(alignof(Y<int, char, 1>) == alignof(int), ""); // expected-note {{in instantiation of}}
 
 void pr16992 () {
-  int x = alignof int;  // expected-error{{missed parentheses around type name in alignof}}
+  int x = alignof int;  // expected-error {{expected parentheses around type name in alignof expression}}
 }
index c8a91892a93086fb19b12023660843ba7aecc1ce..aa76b3a73462458056b020496a06eb5ece322c7b 100644 (file)
@@ -31,7 +31,7 @@ namespace pr16992 {
 
 template<typename T> struct ABC {
   int func () {
-    return sizeof T;  //expected-error{{missed parentheses around type name in sizeof}}
+    return sizeof T;  // expected-error {{expected parentheses around type name in sizeof expression}}
   }
 };
 
index dfc8f6c712b0be82a9d52a21a9c063a6f23083f2..95d6fb354f3ff17f852dd0abf60c58094fefeda5 100644 (file)
@@ -62,8 +62,8 @@ void test7() {
 struct pr16992 { int x; };
 
 void func_16992 () {
-  int x1 = sizeof int;  // expected-error{{missed parentheses around type name in sizeof}}
-  int x2 = sizeof struct pr16992;  // expected-error{{missed parentheses around type name in sizeof}}
-  int x3 = __alignof int;  // expected-error{{missed parentheses around type name in __alignof}}
-  int x4 = _Alignof int;  // expected-error{{missed parentheses around type name in _Alignof}}
+  int x1 = sizeof int;            // expected-error {{expected parentheses around type name in sizeof expression}}
+  int x2 = sizeof struct pr16992; // expected-error {{expected parentheses around type name in sizeof expression}}
+  int x3 = __alignof int;         // expected-error {{expected parentheses around type name in __alignof expression}}
+  int x4 = _Alignof int;          // expected-error {{expected parentheses around type name in _Alignof expression}}
 }