r226633 - Revert "Sema: err_after_alias is unreachable, remove it"

David Majnemer david.majnemer at gmail.com
Tue Jan 20 17:30:41 PST 2015


Author: majnemer
Date: Tue Jan 20 19:30:40 2015
New Revision: 226633

URL: http://llvm.org/viewvc/llvm-project?rev=226633&view=rev
Log:
Revert "Sema: err_after_alias is unreachable, remove it"

This reverts commit r226626.  err_after_alias is, in fact, reachable.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/alias-redefinition.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=226633&r1=226632&r2=226633&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jan 20 19:30:40 2015
@@ -3902,6 +3902,8 @@ def warn_missing_variable_declarations :
 def err_static_data_member_reinitialization :
   Error<"static data member %0 already has an initializer">;
 def err_redefinition : Error<"redefinition of %0">;
+def err_alias_after_tentative :
+  Error<"alias definition of %0 after tentative definition">;
 def err_alias_is_definition :
   Error<"definition %0 cannot also be an alias">;
 def err_definition_of_implicitly_declared_member : Error<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=226633&r1=226632&r2=226633&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan 20 19:30:40 2015
@@ -2223,7 +2223,11 @@ static void checkNewAttributesAfterDef(S
         S.CheckForFunctionRedefinition(FD, cast<FunctionDecl>(Def));
       else {
         VarDecl *VD = cast<VarDecl>(New);
-        S.Diag(VD->getLocation(), diag::err_redefinition) << VD->getDeclName();
+        unsigned Diag = cast<VarDecl>(Def)->isThisDeclarationADefinition() ==
+                                VarDecl::TentativeDefinition
+                            ? diag::err_alias_after_tentative
+                            : diag::err_redefinition;
+        S.Diag(VD->getLocation(), Diag) << VD->getDeclName();
         S.Diag(Def->getLocation(), diag::note_previous_definition);
         VD->setInvalidDecl();
       }

Modified: cfe/trunk/test/Sema/alias-redefinition.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/alias-redefinition.c?rev=226633&r1=226632&r2=226633&view=diff
==============================================================================
--- cfe/trunk/test/Sema/alias-redefinition.c (original)
+++ cfe/trunk/test/Sema/alias-redefinition.c Tue Jan 20 19:30:40 2015
@@ -29,6 +29,5 @@ static int var2 __attribute((alias("v2")
 extern int var3 __attribute__((alias("C"))); // expected-note{{previous definition is here}}
 int var3 = 3; // expected-error{{redefinition of 'var3'}}
 
-int v4;
-int var4;
-int var4 __attribute((alias("v4"))); // expected-error {{definition 'var4' cannot also be an alias}}
+int var4; // expected-note{{previous definition is here}}
+extern int var4 __attribute__((alias("v4"))); // expected-error{{alias definition of 'var4' after tentative definition}}





More information about the cfe-commits mailing list