r226442 - Add back a check removed in r226436
David Majnemer
david.majnemer at gmail.com
Mon Jan 19 02:21:23 PST 2015
Author: majnemer
Date: Mon Jan 19 04:21:22 2015
New Revision: 226442
URL: http://llvm.org/viewvc/llvm-project?rev=226442&view=rev
Log:
Add back a check removed in r226436
It shouldn't have been removed, the code which replaced it didn't cover
this case.
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=226442&r1=226441&r2=226442&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jan 19 04:21:22 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=226442&r1=226441&r2=226442&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jan 19 04:21:22 2015
@@ -2219,8 +2219,18 @@ static void checkNewAttributesAfterDef(S
const Attr *NewAttribute = NewAttributes[I];
if (isa<AliasAttr>(NewAttribute)) {
- FunctionDecl *FD = cast<FunctionDecl>(New);
- S.CheckForFunctionRedefinition(FD, cast<FunctionDecl>(Def));
+ if (FunctionDecl *FD = dyn_cast<FunctionDecl>(New))
+ S.CheckForFunctionRedefinition(FD, cast<FunctionDecl>(Def));
+ else {
+ VarDecl *VD = cast<VarDecl>(New);
+ 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();
+ }
++I;
continue;
}
Modified: cfe/trunk/test/Sema/alias-redefinition.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/alias-redefinition.c?rev=226442&r1=226441&r2=226442&view=diff
==============================================================================
--- cfe/trunk/test/Sema/alias-redefinition.c (original)
+++ cfe/trunk/test/Sema/alias-redefinition.c Mon Jan 19 04:21:22 2015
@@ -25,3 +25,6 @@ void __attribute((alias("f5"))) fun5(voi
int var1 __attribute((alias("v1"))); // expected-error {{definition 'var1' cannot also be an alias}}
static int var2 __attribute((alias("v2"))) = 2; // expected-error {{definition 'var2' cannot also be an alias}}
+
+extern int var3 __attribute__((alias("C"))); // expected-note{{previous definition is here}}
+int var3 = 3; // expected-error{{redefinition of 'var3'}}
More information about the cfe-commits
mailing list