[cfe-commits] r41362 - in /cfe/trunk: Sema/SemaExpr.cpp include/clang/Basic/DiagnosticKinds.def
Steve Naroff
snaroff at apple.com
Fri Aug 24 10:20:07 PDT 2007
Author: snaroff
Date: Fri Aug 24 12:20:07 2007
New Revision: 41362
URL: http://llvm.org/viewvc/llvm-project?rev=41362&view=rev
Log:
Make sure we get extension diagnostics for GCC's complex extensions.
Now we emit the following when -pedantic-errors is enabled...
[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang complex.c -pedantic-errors
complex.c:4:3: error: ISO C does not support '++'/'--' on complex integer types
++x;
^ ~
complex.c:9:7: error: ISO C does not support '~' for complex conjugation
X = ~Y;
^
complex.c:10:7: error: ISO C does not support '~' for complex conjugation
x = ~y;
^
Modified:
cfe/trunk/Sema/SemaExpr.cpp
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=41362&r1=41361&r2=41362&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Fri Aug 24 12:20:07 2007
@@ -1256,18 +1256,23 @@
QualType resType = op->getType();
assert(!resType.isNull() && "no type for increment/decrement expression");
- // C99 6.5.2.4p1: C99 does not support ++/-- on complex types.
- // We allow complex as a GCC extension.
+ // C99 6.5.2.4p1: We allow complex as a GCC extension.
if (const PointerType *pt = dyn_cast<PointerType>(resType)) {
if (!pt->getPointeeType()->isObjectType()) { // C99 6.5.2.4p2, 6.5.6p2
Diag(OpLoc, diag::err_typecheck_arithmetic_incomplete_type,
resType.getAsString(), op->getSourceRange());
return QualType();
}
- } else if (!resType->isRealType() && !resType->isComplexType()) {
- Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement,
- resType.getAsString(), op->getSourceRange());
- return QualType();
+ } else if (!resType->isRealType()) {
+ if (resType->isComplexType())
+ // C99 does not support ++/-- on complex types.
+ Diag(OpLoc, diag::ext_integer_increment_complex,
+ resType.getAsString(), op->getSourceRange());
+ else {
+ Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement,
+ resType.getAsString(), op->getSourceRange());
+ return QualType();
+ }
}
// At this point, we know we have a real, complex or pointer type.
// Now make sure the operand is a modifiable lvalue.
@@ -1555,11 +1560,16 @@
case UnaryOperator::Not: // bitwise complement
UsualUnaryConversions(Input);
resultType = Input->getType();
- // C99 6.5.3.3p1. C99 does not support '~' for complex conjugation.
- // We allow complex as a GCC extension.
- if (!resultType->isIntegerType() && !resultType->isComplexType())
- return Diag(OpLoc, diag::err_typecheck_unary_expr,
- resultType.getAsString());
+ // C99 6.5.3.3p1. We allow complex as a GCC extension.
+ if (!resultType->isIntegerType()) {
+ if (resultType->isComplexType())
+ // C99 does not support '~' for complex conjugation.
+ Diag(OpLoc, diag::ext_integer_complement_complex,
+ resultType.getAsString());
+ else
+ return Diag(OpLoc, diag::err_typecheck_unary_expr,
+ resultType.getAsString());
+ }
break;
case UnaryOperator::LNot: // logical negation
// Unlike +/-/~, integer promotions aren't done here (C99 6.5.3.3p5).
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=41362&r1=41361&r2=41362&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Fri Aug 24 12:20:07 2007
@@ -275,6 +275,10 @@
"ISO C does not support complex integer types")
DIAG(ext_thread_before, EXTENSION,
"'__thread' before 'static'")
+DIAG(ext_integer_increment_complex, EXTENSION,
+ "ISO C does not support '++'/'--' on complex integer types")
+DIAG(ext_integer_complement_complex, EXTENSION,
+ "ISO C does not support '~' for complex conjugation")
DIAG(ext_empty_struct_union_enum, EXTENSION,
"use of empty %0 extension")
More information about the cfe-commits
mailing list